: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): match compare colors on hog-charts funnel trends (#63589)
Thomas Obermüllere01ea2a5ef3d
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.tsx b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.tsxindex a9674b071964..df0eb3c048b3 100644--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.tsx+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.tsx@@ -91,7 +91,7 @@ export function FunnelLineChart({getColor: (step) =>getFunnelsColor({...step,- breakdownIndex: step.seriesIndex,+ breakdownIndex: step.colorIndex,} as unknown as FlattenedFunnelStepByBreakdown),}),[steps, incompletenessOffsetFromEnd, getFunnelsColor]diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.ts b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.tsindex a26ff20a1e47..a3e308fcaada 100644--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.ts+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.test.ts@@ -73,6 +73,37 @@ describe('funnelChartTransforms', () => {})})+ describe('compare against previous period', () => {+ const compareSteps: IndexedFunnelStep[] = [+ makeStep({ id: 0, seriesIndex: 0, colorIndex: 0, compare: true, compare_label: 'current' }),+ makeStep({ id: 1, seriesIndex: 1, colorIndex: 0, compare: true, compare_label: 'previous' }),+ ]++ it('builds a comparisonOf map keyed on the previous-period series so it gets dimmed', () => {+ const config = buildFunnelLineTimeSeriesConfig({+ indexedSteps: compareSteps,+ interval: 'day',+ timezone: 'UTC',+ allDays: ['2024-06-10'],+ showTrendLines: false,+ })++ expect(config.comparisonOf).toEqual({ '1': '1' })+ })++ it('omits comparisonOf when no series is a previous-period comparison', () => {+ const config = buildFunnelLineTimeSeriesConfig({+ indexedSteps: [makeStep()],+ interval: 'day',+ timezone: 'UTC',+ allDays: ['2024-06-10'],+ showTrendLines: false,+ })++ expect(config.comparisonOf).toBeUndefined()+ })+ })+describe('buildFunnelLineTimeSeriesConfig', () => {it('produces a percentage y-axis tick formatter', () => {const config = buildFunnelLineTimeSeriesConfig({@@ -132,7 +163,7 @@ describe('funnelChartTransforms', () => {describe('type contracts', () => {it('IndexedFunnelStep is assignable from FunnelStepWithNestedBreakdown', () => {const step: FunnelStepWithNestedBreakdown = makeStep()- const indexed: IndexedFunnelStep = { ...step, id: 0, seriesIndex: 0 }+ const indexed: IndexedFunnelStep = { ...step, id: 0, seriesIndex: 0, colorIndex: 0 }expect(indexed.id).toBe(0)})})diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.ts b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.tsindex 9532949bb1f3..d156cc2a91da 100644--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.ts+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/funnelChartTransforms.ts@@ -8,7 +8,15 @@ import type { FunnelStepWithNestedBreakdown, IntervalType } from '~/types'import { buildTrendsLineTimeSeriesConfig, buildTrendsSeries } from '../../trends/TrendsLineChart/trendsChartTransforms'import type { FunnelSeriesMeta } from '../shared/funnelSeriesMeta'-export type IndexedFunnelStep = FunnelStepWithNestedBreakdown & { id: number; seriesIndex: number }+// `colorIndex`, `compare`, and `compare_label` are added at runtime by `funnelDataLogic.indexedSteps`+// (the base FunnelStep types don't declare them).+export type IndexedFunnelStep = FunnelStepWithNestedBreakdown & {+ id: number+ seriesIndex: number+ colorIndex: number+ compare?: boolean+ compare_label?: string | null+}// The API populates `data`/`days`, but the base FunnelStep type marks them optional —// normalize so the trends transform never receives undefined.@@ -19,6 +27,8 @@ interface NormalizedFunnelStep {days?: string[]breakdown_value?: SeriesDatum['breakdown_value']order: number+ compare?: boolean+ compare_label?: string | null}function normalizeStep(step: IndexedFunnelStep): NormalizedFunnelStep {@@ -29,6 +39,8 @@ function normalizeStep(step: IndexedFunnelStep): NormalizedFunnelStep {days: step.days,breakdown_value: step.breakdown_value as SeriesDatum['breakdown_value'],order: step.order,+ compare: step.compare,+ compare_label: step.compare_label,}}