: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): show date in historical trends tooltip header (#59208)
Georgis Andonisc7d3627b982e
diff --git a/frontend/src/scenes/funnels/FunnelLineGraph.tsx b/frontend/src/scenes/funnels/FunnelLineGraph.tsxindex bb47cdbf6322..77ddd33f33f4 100644--- a/frontend/src/scenes/funnels/FunnelLineGraph.tsx+++ b/frontend/src/scenes/funnels/FunnelLineGraph.tsx@@ -2,9 +2,9 @@ import { useValues } from 'kea'import { DateDisplay } from 'lib/components/DateDisplay'import { dayjs } from 'lib/dayjs'-import { capitalizeFirstLetter, shortTimeZone } from 'lib/utils'+import { capitalizeFirstLetter } from 'lib/utils'import { insightLogic } from 'scenes/insights/insightLogic'-import { getFormattedDate } from 'scenes/insights/InsightTooltip/insightTooltipUtils'+import { getDatumTitle } from 'scenes/insights/InsightTooltip/insightTooltipUtils'import { formatBreakdownLabel } from 'scenes/insights/utils'import { LineGraph } from 'scenes/insights/views/LineGraph/LineGraph'import { teamLogic } from 'scenes/teamLogic'@@ -18,6 +18,7 @@ import { BreakdownKeyType, ChartParams, GraphDataset, GraphType } from '~/types'import { funnelDataLogic } from './funnelDataLogic'import { funnelPersonsModalLogic } from './funnelPersonsModalLogic'+import { hasBreakdown } from './funnelUtils'const LineGraphWrapper = ({ inCardView, children }: { inCardView?: boolean; children: JSX.Element }): JSX.Element => {if (inCardView) {@@ -71,22 +72,11 @@ export function FunnelLineGraph({showTrendLines={funnelsFilter?.showTrendLines ?? false}goalLines={goalLines ?? []}tooltip={{- showHeader: false,- hideColorCol: true,renderSeries: (_, datum) => {- if (!indexedSteps?.[0]?.days) {- return 'Trend'+ if (hasBreakdown(datum.breakdown_value)) {+ return <div className="datum-label-column">{getDatumTitle(datum, breakdownFilter)}</div>}- return (- getFormattedDate(indexedSteps[0].days?.[datum.dataIndex], {- interval,- dateRange: insightData?.resolved_date_range,- timezone: insightData?.timezone,- weekStartDay,- }) +- ' ' +- (insightData?.timezone ? shortTimeZone(insightData.timezone) : 'UTC')- )+ return <div className="datum-label-column">Conversion</div>},renderCount: (count) => {return `${count}%`@@ -106,11 +96,7 @@ export function FunnelLineGraph({const day = dataset?.days?.[index] ?? ''const breakdownValue = (dataset as { breakdown_value?: BreakdownKeyType })?.breakdown_value- const hasBreakdown =- breakdownValue !== undefined &&- breakdownValue !== 'Baseline' &&- !(Array.isArray(breakdownValue) && breakdownValue[0] === 'Baseline')- const breakdownLabel = hasBreakdown+ const breakdownLabel = hasBreakdown(breakdownValue)? formatBreakdownLabel(breakdownValue,breakdownFilter,@@ -139,7 +125,7 @@ export function FunnelLineGraph({funnelTrendsDropOff: false,includeRecordings: true,funnelTrendsEntrancePeriodStart: dayjs(day).format('YYYY-MM-DD HH:mm:ss'),- ...(hasBreakdown ? { funnelStepBreakdown: breakdownValue } : {}),+ ...(hasBreakdown(breakdownValue) ? { funnelStepBreakdown: breakdownValue } : {}),}openPersonsModal({title,diff --git a/frontend/src/scenes/funnels/funnelUtils.test.ts b/frontend/src/scenes/funnels/funnelUtils.test.tsindex b676a062021a..b14d13200c9c 100644--- a/frontend/src/scenes/funnels/funnelUtils.test.ts+++ b/frontend/src/scenes/funnels/funnelUtils.test.ts@@ -22,6 +22,7 @@ import {getReferenceStep,getStepBreakdownSeries,getVisibilityKey,+ hasBreakdown,isFunnelWithEnoughSteps,isFunnelWithIncompleteDataWarehouseStep,parseDisplayNameForCorrelation,@@ -834,3 +835,28 @@ describe('isFunnelWithIncompleteDataWarehouseStep', () => {expect(isFunnelWithIncompleteDataWarehouseStep(series as FunnelsQuery['series'])).toBe(expected)})})++describe('hasBreakdown', () => {+ it.each([+ { scenario: 'undefined value', breakdownValue: undefined, expected: false },+ { scenario: '"Baseline" string', breakdownValue: 'Baseline', expected: false },+ { scenario: '["Baseline"] array', breakdownValue: ['Baseline'], expected: false },+ {+ scenario: '["Baseline", "mobile"] multi-breakdown array',+ breakdownValue: ['Baseline', 'mobile'],+ expected: false,+ },+ { scenario: 'numeric zero (regression: 0 must count as a real breakdown)', breakdownValue: 0, expected: true },+ {+ scenario: 'empty string (regression: "" must count as a real breakdown)',+ breakdownValue: '',+ expected: true,+ },+ { scenario: 'non-baseline string', breakdownValue: 'Chrome', expected: true },+ { scenario: 'non-baseline number', breakdownValue: 42, expected: true },+ { scenario: 'non-baseline array', breakdownValue: ['Chrome', 'mobile'], expected: true },+ { scenario: 'null', breakdownValue: null, expected: true },+ ])('returns $expected for $scenario', ({ breakdownValue, expected }) => {+ expect(hasBreakdown(breakdownValue as Parameters<typeof hasBreakdown>[0])).toBe(expected)+ })+})diff --git a/frontend/src/scenes/funnels/funnelUtils.tsx b/frontend/src/scenes/funnels/funnelUtils.tsxindex 4e96f68b9535..5babc75d7584 100644--- a/frontend/src/scenes/funnels/funnelUtils.tsx+++ b/frontend/src/scenes/funnels/funnelUtils.tsx@@ -192,6 +192,19 @@ export function hasBreakdownFilterParameter()}+/**+ * Whether a series's `breakdown_value` represents an actual user-picked breakdown.+ * The funnel backend uses the literal "Baseline" (or `['Baseline', ...]` for+ * multi-breakdowns) to mark the overall, non-broken-down series.+ */+export function hasBreakdown(breakdownValue: BreakdownKeyType | undefined): boolean {+ return (+ breakdownValue !== undefined &&+ breakdownValue !== 'Baseline' &&+ !(Array.isArray(breakdownValue) && breakdownValue[0] === 'Baseline')+ )+}+/** String identifier for breakdowns used when determining visibility. */export function getVisibilityKey(breakdownValue?: BreakdownKeyType): string {const breakdownValues = getBreakdownStepValues(