: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 null metric fields (#64231)
Juraj Majerik89e5cb922793
diff --git a/frontend/src/scenes/experiments/utils.ts b/frontend/src/scenes/experiments/utils.tsindex b0fff55ac5d5..54dbb266ef26 100644--- a/frontend/src/scenes/experiments/utils.ts+++ b/frontend/src/scenes/experiments/utils.ts@@ -711,10 +711,10 @@ export const isLegacyExperimentQuery = (query: unknown): query is ExperimentTren*/export const isLegacyExperiment = ({ metrics, metrics_secondary, saved_metrics }: Experiment): boolean => {// saved_metrics has a different structure and so we need to check for it separately- if (saved_metrics.some(isLegacySharedMetric)) {+ if ((saved_metrics ?? []).some(isLegacySharedMetric)) {return true}- return [...metrics, ...metrics_secondary].some(isLegacyExperimentQuery)+ return [...(metrics ?? []), ...(metrics_secondary ?? [])].some(isLegacyExperimentQuery)}export const isLegacySharedMetric = ({ query }: SharedMetric): boolean => isLegacyExperimentQuery(query)