From ed0ba355b70718ed8b6c121eb7f0a8f9161a4500 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Mon, 16 Dec 2024 09:07:24 -0800 Subject: [PATCH] fix(experiments): Fix minimum detectable effect calculator (#26935) --- .../ExperimentView/DataCollectionCalculator.tsx | 13 +++++++++++-- frontend/src/scenes/funnels/funnelDataLogic.ts | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/scenes/experiments/ExperimentView/DataCollectionCalculator.tsx b/frontend/src/scenes/experiments/ExperimentView/DataCollectionCalculator.tsx index 95938242c143d..e7797f03de7ba 100644 --- a/frontend/src/scenes/experiments/ExperimentView/DataCollectionCalculator.tsx +++ b/frontend/src/scenes/experiments/ExperimentView/DataCollectionCalculator.tsx @@ -3,10 +3,10 @@ import { LemonBanner, LemonInput, Link, Tooltip } from '@posthog/lemon-ui' import { BindLogic, useActions, useValues } from 'kea' import { LemonSlider } from 'lib/lemon-ui/LemonSlider' import { humanFriendlyNumber } from 'lib/utils' -import { insightDataLogic } from 'scenes/insights/insightDataLogic' import { insightLogic } from 'scenes/insights/insightLogic' import { Query } from '~/queries/Query/Query' +import { ExperimentFunnelsQuery, ExperimentTrendsQuery, NodeKind } from '~/queries/schema' import { ExperimentIdType, InsightType } from '~/types' import { MetricInsightId } from '../constants' @@ -120,7 +120,16 @@ export function DataCollectionCalculator({ experimentId }: ExperimentCalculatorP syncWithUrl: false, }) const { insightProps } = useValues(insightLogicInstance) - const { query } = useValues(insightDataLogic(insightProps)) + let query = null + if (experiment.metrics.length > 0) { + query = { + kind: NodeKind.InsightVizNode, + source: + metricType === InsightType.FUNNELS + ? (experiment.metrics[0] as ExperimentFunnelsQuery).funnels_query + : (experiment.metrics[0] as ExperimentTrendsQuery).count_query, + } + } const funnelConversionRate = conversionMetrics?.totalRate * 100 || 0 diff --git a/frontend/src/scenes/funnels/funnelDataLogic.ts b/frontend/src/scenes/funnels/funnelDataLogic.ts index 0a48c272e929b..54ed637e4d2bd 100644 --- a/frontend/src/scenes/funnels/funnelDataLogic.ts +++ b/frontend/src/scenes/funnels/funnelDataLogic.ts @@ -169,6 +169,7 @@ export const funnelDataLogic = kea([ if ( // TODO: Ideally we don't check filters anymore, but tests are still using this insightData?.filters?.insight !== InsightType.FUNNELS && + querySource && querySource?.kind !== NodeKind.FunnelsQuery ) { return [] @@ -275,6 +276,7 @@ export const funnelDataLogic = kea([ if ( // TODO: Ideally we don't check filters anymore, but tests are still using this insightData?.filters?.insight !== InsightType.FUNNELS && + querySource && querySource?.kind !== NodeKind.FunnelsQuery ) { return false