: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(funnels): hide baseline from chart when toggled off with compare enabled (#69614)
Thomas Obermüller80607057d943
diff --git a/frontend/src/scenes/funnels/funnelDataLogic.test.ts b/frontend/src/scenes/funnels/funnelDataLogic.test.tsindex 50abcb1f9e65..ac51ec0affa4 100644--- a/frontend/src/scenes/funnels/funnelDataLogic.test.ts+++ b/frontend/src/scenes/funnels/funnelDataLogic.test.ts@@ -1786,5 +1786,38 @@ describe('funnelDataLogic', () => {.map((b) => getVisibilityKey(b.breakdown_value))expect(breakdownValues).toEqual(['Chrome', 'Chrome', 'Safari', 'Safari'])})++ it('hides both periods of the baseline when its legend entry is hidden', async () => {+ const insight: Partial<InsightModel> = {+ filters: { insight: InsightType.FUNNELS },+ result: funnelResultStepsBreakdownCompare.result as InsightModel['result'],+ }+ await expectLogic(logic, () => {+ const query: FunnelsQuery = {+ ...stepsQuery,+ funnelsFilter: { ...stepsQuery.funnelsFilter, hiddenLegendBreakdowns: ['Baseline'] },+ }+ logic.actions.updateQuerySource(query)+ builtDataNodeLogic.actions.loadDataSuccess(insight)+ }).toFinishAllListeners()++ // The synthesized baseline pair takes a separate path than the value bars, so it must be+ // hidden too; the values keep their baseline-shifted orders (hence colors) while the+ // baseline is merely hidden.+ const visibleValues = logic.values.visibleStepsWithConversionMetrics[0].nested_breakdown?.map((b) => [+ getVisibilityKey(b.breakdown_value),+ b.compare_label,+ b.order,+ ])+ expect(visibleValues).toEqual([+ ['Chrome', 'current', 1],+ ['Chrome', 'previous', 1],+ ['Safari', 'current', 2],+ ['Safari', 'previous', 2],+ ])++ // The table still lists both baseline rows (just unchecked), so they can be toggled back on.+ expect(logic.values.flattenedBreakdowns.filter((b) => b.isBaseline)).toHaveLength(2)+ })})})diff --git a/frontend/src/scenes/funnels/funnelDataLogic.ts b/frontend/src/scenes/funnels/funnelDataLogic.tsindex 5842bbd440ea..2c2553ab0c41 100644--- a/frontend/src/scenes/funnels/funnelDataLogic.ts+++ b/frontend/src/scenes/funnels/funnelDataLogic.ts@@ -537,13 +537,20 @@ export const funnelDataLogic = kea<funnelDataLogicType>([// and per-value orders (both periods of a value share one order, hence one color).if (isBreakdownCompareFunnel) {const baselineRows = flattenedBreakdowns.filter((b) => b.isBaseline)+ // Offset stays 1 while the baseline is merely hidden, so the remaining values keep+ // their color positions when the baseline is toggled — same as the plain-breakdown+ // path, which assigns orders before filtering.const baselineOffset = baselineRows.length > 0 ? 1 : 0// Size each baseline bar by its period's share of the larger period (the larger fills,// the smaller is proportionally shorter) — matching how the value and pure-compare bars// are scaled, so the previous baseline isn't drawn at full height.const compareBasis = Math.max(0, ...baselineRows.map((row) => row.steps?.[0]?.count ?? 0))+ const visibleBaselineRows = baselineRows.filter(+ (row) =>+ isOnlySeries || !hiddenLegendBreakdowns?.includes(getVisibilityKey(row.breakdown_value))+ )return steps.map((step, stepIndex) => {- const baselineEntries = baselineRows+ const baselineEntries = visibleBaselineRows.map((row) => row.steps?.[stepIndex]).filter((s): s is FunnelStepWithConversionMetrics => s != null).map((s) => ({