Skip to content

Commit

Permalink
fix(experiments): Fix minimum detectable effect calculator (#26935)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber authored Dec 16, 2024
1 parent 0c0087f commit ed0ba35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions frontend/src/scenes/funnels/funnelDataLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
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 []
Expand Down Expand Up @@ -275,6 +276,7 @@ export const funnelDataLogic = kea<funnelDataLogicType>([
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
Expand Down

0 comments on commit ed0ba35

Please sign in to comment.