:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(experiments): skip the health request for a missing experiment (#120123)
Marcel Poelkered9b9f5d4a3f
diff --git a/frontend/src/scenes/experiments/experimentLogic.test.ts b/frontend/src/scenes/experiments/experimentLogic.test.tsindex 8528d5599529..b30e054e8b8d 100644--- a/frontend/src/scenes/experiments/experimentLogic.test.ts+++ b/frontend/src/scenes/experiments/experimentLogic.test.ts@@ -2671,6 +2671,28 @@ describe('experimentLogic', () => {expect(checkedEvents).toHaveLength(1)})+ it('sends no health request for an experiment the server cannot find', async () => {+ const healthRequest = jest.fn(() => [200, { findings: [] }])+ useMocks({+ get: {+ '/api/projects/:team/experiments/:id': () => [404, { detail: 'Not found.' }],+ [healthUrl]: healthRequest,+ },+ })+ const keyedLogic = mountKeyedLogic()+ const captureSpy = jest.spyOn(posthog, 'capture').mockReturnValue(undefined as any)++ await expectLogic(keyedLogic, () => {+ keyedLogic.actions.loadExperiment()+ })+ .toDispatchActions(['setExperimentMissing', 'loadExperimentSuccess', 'loadExperimentHealthSuccess'])+ .toMatchValues({ experimentHealth: null })++ expect(healthRequest).not.toHaveBeenCalled()+ const checkedEvents = captureSpy.mock.calls.filter(([event]) => event === 'experiment health checked')+ expect(checkedEvents).toHaveLength(0)+ })+it('shows a reader with the flag neither warnings nor findings until the health answers', async () => {setHealthFindingsFlag(true)let release: () => void = () => {}diff --git a/frontend/src/scenes/experiments/experimentLogic.tsx b/frontend/src/scenes/experiments/experimentLogic.tsxindex 175495d4cbd2..1dbeba8bfa47 100644--- a/frontend/src/scenes/experiments/experimentLogic.tsx+++ b/frontend/src/scenes/experiments/experimentLogic.tsx@@ -2454,7 +2454,11 @@ export const experimentLogic = kea<experimentLogicType>([null as ExperimentHealthApi | null,{loadExperimentHealth: async (trigger: ExperimentHealthLoadTrigger, breakpoint) => {- if (typeof values.experimentId !== 'number' || values.currentProjectId === null) {+ if (+ typeof values.experimentId !== 'number' ||+ values.experimentMissing ||+ values.currentProjectId === null+ ) {return null}if (trigger === 'experiment_update') {