: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): guard isLegacyExperiment against missing experiment (#65702)
Juraj Majerika0b6c9cf75f8
diff --git a/frontend/src/scenes/experiments/utils.ts b/frontend/src/scenes/experiments/utils.tsindex 7638e01e0e4e..49614f7c008b 100644--- a/frontend/src/scenes/experiments/utils.ts+++ b/frontend/src/scenes/experiments/utils.ts@@ -720,7 +720,11 @@ export const isLegacyExperimentQuery = (query: unknown): query is ExperimentTren** We should remove these legacy metrics once we've migrated all experiments to the new query runner.*/-export const isLegacyExperiment = ({ metrics, metrics_secondary, saved_metrics }: Experiment): boolean => {+export const isLegacyExperiment = (experiment?: Experiment | null): boolean => {+ if (!experiment) {+ return false+ }+ const { metrics, metrics_secondary, saved_metrics } = experiment// saved_metrics has a different structure and so we need to check for it separatelyif ((saved_metrics ?? []).some(isLegacySharedMetric)) {return true