Skip to content

: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.

fix(funnels): show conversion value for every breakdown series in trends tooltip (#63627)

Steven Shultsc92fa24bb93b
diff --git a/frontend/src/test/insight-testing/mocks.ts b/frontend/src/test/insight-testing/mocks.ts
index 64c8ee9380ec..95dbb5434811 100644
--- a/frontend/src/test/insight-testing/mocks.ts
+++ b/frontend/src/test/insight-testing/mocks.ts
@@ -156,6 +156,10 @@ function resolveActors(query: QueryBody): Array<{ email: string }> {
/** Funnels in trends-viz mode return a flat `FunnelStep[]` — one entry per series, or per breakdown value. */
function buildFunnelsResponse(query: QueryBody): FunnelsQueryResponseLike {
const breakdownProp = query.breakdownFilter?.breakdowns?.[0]?.property ?? query.breakdownFilter?.breakdown
+ const isCompare = !!(query as { compareFilter?: { compare?: boolean } }).compareFilter?.compare
+ if (isCompare && breakdownProp && funnelTrendsSteps.compareByBreakdown[breakdownProp]) {
+ return { results: funnelTrendsSteps.compareByBreakdown[breakdownProp] }
+ }
if (breakdownProp && funnelTrendsSteps.byBreakdown[breakdownProp]) {
return { results: funnelTrendsSteps.byBreakdown[breakdownProp] }
}
diff --git a/frontend/src/test/insight-testing/test-data.ts b/frontend/src/test/insight-testing/test-data.ts
index cb33ffb087ca..c57ead1df0a2 100644
--- a/frontend/src/test/insight-testing/test-data.ts
+++ b/frontend/src/test/insight-testing/test-data.ts
@@ -263,6 +263,8 @@ export interface FunnelStepData {
labels: string[]
name?: string
breakdown_value?: string | number
+ // The funnels runner tags compare rows with `compare_label` (it doesn't set `compare`).
+ compare_label?: 'current' | 'previous'
}
export const funnelTrendsSteps = {
@@ -293,6 +295,48 @@ export const funnelTrendsSteps = {
},
] satisfies FunnelStepData[],
} as Record<string, FunnelStepData[]>,
+ // Compare-to-previous + breakdown: current and previous rows per breakdown value, each
+ // tagged with `compare_label` so the tooltip can split them into their own rows.
+ compareByBreakdown: {
+ hedgehog: [
+ {
+ count: 30,
+ data: [20, 35, 50, 70, 45],
+ days,
+ labels,
+ name: '$pageview → Napped',
+ breakdown_value: 'Spike',
+ compare_label: 'current',
+ },
+ {
+ count: 28,
+ data: [18, 30, 45, 65, 40],
+ days,
+ labels,
+ name: '$pageview → Napped',
+ breakdown_value: 'Spike',
+ compare_label: 'previous',
+ },
+ {
+ count: 20,
+ data: [5, 15, 30, 50, 25],
+ days,
+ labels,
+ name: '$pageview → Napped',
+ breakdown_value: 'Bramble',
+ compare_label: 'current',
+ },
+ {
+ count: 18,
+ data: [3, 10, 25, 45, 20],
+ days,
+ labels,
+ name: '$pageview → Napped',
+ breakdown_value: 'Bramble',
+ compare_label: 'previous',
+ },
+ ] satisfies FunnelStepData[],
+ } as Record<string, FunnelStepData[]>,
}
// Keyed by breakdown value (or '__none__'), then by calendar date.
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx
index 8eba7d59dd4c..8babdcd7664c 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx
@@ -61,6 +61,45 @@ describe('FunnelLineChart', () => {
expect(tooltip.textContent).toContain('Spike')
expect(tooltip.textContent).toContain('Bramble')
})
+
+ it('shows each breakdown series conversion value, not a placeholder dash', async () => {
+ renderInsight({
+ query: buildFunnelsQuery({
+ breakdownFilter: { breakdown: 'hedgehog', breakdown_type: 'event' },
+ }),
+ featureFlags: HOG_CHARTS_FUNNEL_FLAG,
+ })
+
+ const tooltip = await chart.hoverTooltip(2)
+
+ // Every breakdown series is its own tooltip row and must render its own
+ // conversion value. Regression guard: distinct series orders previously
+ // split the rows across columns the inverted layout never rendered, so
+ // only the first series showed a value and the rest showed "–".
+ expect(tooltip.row('Spike')).toContain('50%')
+ expect(tooltip.row('Bramble')).toContain('30%')
+ })
+
+ it('shows a distinct conversion value for each breakdown × compare series', async () => {
+ renderInsight({
+ query: buildFunnelsQuery({
+ breakdownFilter: { breakdown: 'hedgehog', breakdown_type: 'event' },
+ compareFilter: { compare: true },
+ }),
+ featureFlags: HOG_CHARTS_FUNNEL_FLAG,
+ })
+
+ const tooltip = await chart.hoverTooltip(2)
+
+ // Current and previous of the same breakdown are separate tooltip rows, keyed by
+ // breakdown_value/compare_label. Regression guard: without compare_label threaded into
+ // the tooltip datum, both rows collapsed into one shared column and only the current
+ // value rendered, leaving the previous row showing "–".
+ expect(tooltip.row('Spike · Current')).toContain('50%')
+ expect(tooltip.row('Spike · Previous')).toContain('45%')
+ expect(tooltip.row('Bramble · Current')).toContain('30%')
+ expect(tooltip.row('Bramble · Previous')).toContain('25%')
+ })
})
describe('click → persons modal', () => {
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineTooltip.tsx b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineTooltip.tsx
index 7adf12069946..3ee1d6656c91 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineTooltip.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineTooltip.tsx
@@ -40,11 +40,16 @@ export function FunnelLineTooltip({
id: idx,
dataIndex: context.dataIndex,
datasetIndex: idx,
- order: meta.order ?? idx,
+ // Each conversion-rate line is a single value, so every series shares one tooltip
+ // value column. The inverted layout instead separates them into rows keyed by
+ // breakdown_value/compare_label. Distinct orders would split them across columns
+ // the layout never renders, leaving every series but the first showing "–".
+ order: 0,
label: entry.series.label,
color: entry.color,
count: entry.value,
breakdown_value: meta.breakdown_value,
+ compare_label: meta.compare_label,
date_label: meta.days?.[context.dataIndex],
}
}),
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.ts b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.ts
index a3e308fcaada..267692f32c0e 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.ts
+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.ts
@@ -47,6 +47,17 @@ describe('funnelChartTransforms', () => {
})
})
+ it('carries compare_label into series meta when comparing to a previous period', () => {
+ const steps: IndexedFunnelStep[] = [
+ makeStep({ id: 0, order: 0, breakdown_value: 'Spike', compare_label: 'current' }),
+ makeStep({ id: 1, order: 1, breakdown_value: 'Spike', compare_label: 'previous' }),
+ ]
+ const series = buildFunnelLineSeries(steps, { getColor: () => RED })
+
+ expect(series[0].meta).toMatchObject({ breakdown_value: 'Spike', compare_label: 'current' })
+ expect(series[1].meta).toMatchObject({ breakdown_value: 'Spike', compare_label: 'previous' })
+ })
+
it('normalises missing data to an empty array so the trends transform accepts it', () => {
const step = makeStep({ data: undefined as unknown as number[] })
const [series] = buildFunnelLineSeries([step], { getColor: () => RED })
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.ts b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.ts
index d156cc2a91da..50c9d9704122 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.ts
+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.ts
@@ -60,6 +60,7 @@ export function buildFunnelLineSeries(
buildMeta: (step) => ({
days: step.days,
breakdown_value: step.breakdown_value,
+ compare_label: (step.compare_label ?? undefined) as SeriesDatum['compare_label'],
order: step.order,
label: step.label,
}),
diff --git a/products/product_analytics/frontend/insights/funnels/shared/funnelSeriesMeta.ts b/products/product_analytics/frontend/insights/funnels/shared/funnelSeriesMeta.ts
index 8d1625949589..978e4e7cccd2 100644
--- a/products/product_analytics/frontend/insights/funnels/shared/funnelSeriesMeta.ts
+++ b/products/product_analytics/frontend/insights/funnels/shared/funnelSeriesMeta.ts
@@ -6,6 +6,8 @@ export type FunnelSeriesMeta = {
days?: string[]
// Narrower than BreakdownKeyType — matches SeriesDatum so the tooltip adapter needs no cast.
breakdown_value?: SeriesDatum['breakdown_value']
+ // Present in compare-to-previous mode; lets the tooltip split current/previous into separate rows.
+ compare_label?: SeriesDatum['compare_label']
order: number
label?: string | null
}