: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
feat(insights): wire trends/retention/stickiness charts to InsightSeriesTooltip (#67095)
Sam Penningtonfcc0ce167147
diff --git a/products/product_analytics/frontend/insights/retention/RetentionBarChart/RetentionBarChart.tsx b/products/product_analytics/frontend/insights/retention/RetentionBarChart/RetentionBarChart.tsxindex 74399853021b..ffd8f67a8021 100644--- a/products/product_analytics/frontend/insights/retention/RetentionBarChart/RetentionBarChart.tsx+++ b/products/product_analytics/frontend/insights/retention/RetentionBarChart/RetentionBarChart.tsx@@ -3,9 +3,12 @@ import posthog from 'posthog-js'import { useCallback, useMemo, type ErrorInfo } from 'react'import { TimeSeriesBarChart } from '@posthog/quill-charts'-import type { PointClickData, TooltipConfig, TooltipContext } from '@posthog/quill-charts'+import type { PointClickData, TooltipContext } from '@posthog/quill-charts'import { buildTheme } from 'lib/charts/utils/theme'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { roundToDecimal } from 'lib/utils/numbers'import { insightLogic } from 'scenes/insights/insightLogic'import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'import { retentionGraphLogic } from 'scenes/retention/retentionGraphLogic'@@ -16,6 +19,8 @@ import { groupsModel } from '~/models/groupsModel'import type { GoalLine } from '~/queries/schema/schema-general'import type { GroupTypeIndex, LabelGroupType } from '~/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'+import { INSIGHT_TOOLTIP_CONFIG, INSIGHT_TOOLTIP_CONFIG_LEGACY } from '../../shared/tooltipConfig'import {buildRetentionBarChartConfig,buildRetentionSeries,@@ -27,8 +32,6 @@ import { RetentionTooltip } from '../shared/RetentionTooltip'interface RetentionBarChartProps {inSharedMode?: boolean}--const TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }const EMPTY_GOAL_LINES: GoalLine[] = []const handleChartError = (error: Error, info: ErrorInfo): void => {@@ -54,6 +57,9 @@ function resolveGroupTypeLabel(export function RetentionBarChart({ inSharedMode = false }: RetentionBarChartProps): JSX.Element | null {const { insightProps } = useValues(insightLogic)const { isDarkModeOn } = useValues(themeLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]+ const TOOLTIP_CONFIG = quillTooltipEnabled ? INSIGHT_TOOLTIP_CONFIG : INSIGHT_TOOLTIP_CONFIG_LEGACYconst theme = useMemo(() => buildTheme(), [isDarkModeOn])const {@@ -101,19 +107,43 @@ export function RetentionBarChart({ inSharedMode = false }: RetentionBarChartPro)const renderTooltip = useCallback(- (ctx: TooltipContext<RetentionSeriesMeta>) => (- <RetentionTooltip- context={ctx}- xAxisLabels={xAxisLabels}- period={period}- selectedInterval={selectedInterval}- shouldShowMeanPerBreakdown={shouldShowMeanPerBreakdown}- isPercentage={isPercentage}- groupTypeLabel={groupTypeLabel}- onRowClick={canClick ? onRowClick : undefined}- />- ),+ (ctx: TooltipContext<RetentionSeriesMeta>) => {+ if (quillTooltipEnabled) {+ const altTitle =+ selectedInterval !== null+ ? `${period ?? ''} ${selectedInterval}`+ : (xAxisLabels[ctx.dataIndex] ?? ctx.label)+ return (+ <InsightSeriesTooltip+ context={ctx}+ altTitle={altTitle}+ renderCount={(value) =>+ isPercentage ? `${roundToDecimal(value)}%` : `${roundToDecimal(value)}`+ }+ renderSeriesOverride={(datum) => {+ const showCohortPrefix = selectedInterval !== null || !shouldShowMeanPerBreakdown+ return showCohortPrefix ? `Cohort ${datum.label ?? ''}` : (datum.label ?? '')+ }}+ groupTypeLabel={groupTypeLabel}+ onRowClick={canClick ? onRowClick : undefined}+ />+ )+ }+ return (+ <RetentionTooltip+ context={ctx}+ xAxisLabels={xAxisLabels}+ period={period}+ selectedInterval={selectedInterval}+ shouldShowMeanPerBreakdown={shouldShowMeanPerBreakdown}+ isPercentage={isPercentage}+ groupTypeLabel={groupTypeLabel}+ onRowClick={canClick ? onRowClick : undefined}+ />+ )+ },[+ quillTooltipEnabled,xAxisLabels,period,selectedInterval,@@ -144,7 +174,7 @@ export function RetentionBarChart({ inSharedMode = false }: RetentionBarChartProconst barConfig = useMemo(() => buildRetentionBarChartConfig({ isPercentage, goalLines, series, tooltip: TOOLTIP_CONFIG }),- [isPercentage, goalLines, series]+ [isPercentage, goalLines, series, TOOLTIP_CONFIG])if (filteredTrendSeries.length === 0 && hasValidBreakdown) {diff --git a/products/product_analytics/frontend/insights/retention/RetentionLineChart/RetentionLineChart.tsx b/products/product_analytics/frontend/insights/retention/RetentionLineChart/RetentionLineChart.tsxindex e6abe9459e89..5216b9802e96 100644--- a/products/product_analytics/frontend/insights/retention/RetentionLineChart/RetentionLineChart.tsx+++ b/products/product_analytics/frontend/insights/retention/RetentionLineChart/RetentionLineChart.tsx@@ -3,9 +3,12 @@ import posthog from 'posthog-js'import { useCallback, useMemo, type ErrorInfo } from 'react'import { TimeSeriesLineChart } from '@posthog/quill-charts'-import type { PointClickData, TooltipConfig, TooltipContext } from '@posthog/quill-charts'+import type { PointClickData, TooltipContext } from '@posthog/quill-charts'import { buildTheme } from 'lib/charts/utils/theme'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { roundToDecimal } from 'lib/utils/numbers'import { insightLogic } from 'scenes/insights/insightLogic'import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'import { retentionGraphLogic } from 'scenes/retention/retentionGraphLogic'@@ -16,6 +19,8 @@ import { groupsModel } from '~/models/groupsModel'import type { GoalLine } from '~/queries/schema/schema-general'import type { GroupTypeIndex, LabelGroupType } from '~/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'+import { INSIGHT_TOOLTIP_CONFIG, INSIGHT_TOOLTIP_CONFIG_LEGACY } from '../../shared/tooltipConfig'import {buildRetentionLineChartConfig,buildRetentionSeries,@@ -27,8 +32,6 @@ import { RetentionTooltip } from '../shared/RetentionTooltip'interface RetentionLineChartProps {inSharedMode?: boolean}--const TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }const EMPTY_GOAL_LINES: GoalLine[] = []const handleChartError = (error: Error, info: ErrorInfo): void => {@@ -54,6 +57,9 @@ function resolveGroupTypeLabel(export function RetentionLineChart({ inSharedMode = false }: RetentionLineChartProps): JSX.Element | null {const { insightProps } = useValues(insightLogic)const { isDarkModeOn } = useValues(themeLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]+ const TOOLTIP_CONFIG = quillTooltipEnabled ? INSIGHT_TOOLTIP_CONFIG : INSIGHT_TOOLTIP_CONFIG_LEGACYconst theme = useMemo(() => buildTheme(), [isDarkModeOn])const {@@ -104,19 +110,43 @@ export function RetentionLineChart({ inSharedMode = false }: RetentionLineChartP)const renderTooltip = useCallback(- (ctx: TooltipContext<RetentionSeriesMeta>) => (- <RetentionTooltip- context={ctx}- xAxisLabels={xAxisLabels}- period={period}- selectedInterval={selectedInterval}- shouldShowMeanPerBreakdown={shouldShowMeanPerBreakdown}- isPercentage={isPercentage}- groupTypeLabel={groupTypeLabel}- onRowClick={canClick ? onRowClick : undefined}- />- ),+ (ctx: TooltipContext<RetentionSeriesMeta>) => {+ if (quillTooltipEnabled) {+ const altTitle =+ selectedInterval !== null+ ? `${period ?? ''} ${selectedInterval}`+ : (xAxisLabels[ctx.dataIndex] ?? ctx.label)+ return (+ <InsightSeriesTooltip+ context={ctx}+ altTitle={altTitle}+ renderCount={(value) =>+ isPercentage ? `${roundToDecimal(value)}%` : `${roundToDecimal(value)}`+ }+ renderSeriesOverride={(datum) => {+ const showCohortPrefix = selectedInterval !== null || !shouldShowMeanPerBreakdown+ return showCohortPrefix ? `Cohort ${datum.label ?? ''}` : (datum.label ?? '')+ }}+ groupTypeLabel={groupTypeLabel}+ onRowClick={canClick ? onRowClick : undefined}+ />+ )+ }+ return (+ <RetentionTooltip+ context={ctx}+ xAxisLabels={xAxisLabels}+ period={period}+ selectedInterval={selectedInterval}+ shouldShowMeanPerBreakdown={shouldShowMeanPerBreakdown}+ isPercentage={isPercentage}+ groupTypeLabel={groupTypeLabel}+ onRowClick={canClick ? onRowClick : undefined}+ />+ )+ },[+ quillTooltipEnabled,xAxisLabels,period,selectedInterval,@@ -148,7 +178,7 @@ export function RetentionLineChart({ inSharedMode = false }: RetentionLineChartPconst lineConfig = useMemo(() =>buildRetentionLineChartConfig({ isPercentage, goalLines, showTrendLines, series, tooltip: TOOLTIP_CONFIG }),- [isPercentage, goalLines, showTrendLines, series]+ [isPercentage, goalLines, showTrendLines, series, TOOLTIP_CONFIG])if (filteredTrendSeries.length === 0 && hasValidBreakdown) {diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsxindex 133088043450..c273a94c56e3 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsx@@ -5,6 +5,8 @@ import { TimeSeriesBarChart } from '@posthog/quill-charts'import type { PointClickData, Series, TimeSeriesBarChartConfig, TooltipContext } from '@posthog/quill-charts'import { buildTheme } from 'lib/charts/utils/theme'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { InsightEmptyState } from 'scenes/insights/EmptyStates'import { insightLogic } from 'scenes/insights/insightLogic'import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'@@ -20,6 +22,8 @@ import { InsightVizNode } from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'import { ChartDisplayType } from '~/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'+import { INSIGHT_TOOLTIP_CONFIG_LEGACY } from '../../shared/tooltipConfig'import { makeChartErrorHandler } from '../../trends/shared/chartErrorHandler'import { getTrendsSeriesDisplayLabel } from '../../trends/shared/getTrendsSeriesDisplayLabel'import {@@ -47,6 +51,9 @@ const handleChartError = makeChartErrorHandler('stickiness-bar-chart')export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.Element | null {const theme = useMemo(() => buildTheme(), [])const { insightProps } = useValues(insightLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]+ const tooltipConfig = quillTooltipEnabled ? STICKINESS_TOOLTIP_CONFIG : INSIGHT_TOOLTIP_CONFIG_LEGACYconst legendConfig = useInsightsLegendConfig({ insightProps })const quillLegendEnabled = !!legendConfig@@ -112,12 +119,12 @@ export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.ElyAxisScaleType,isGrouped,valueLabels: showValuesOnSeries ? { formatter: stickinessPercentFormatter } : false,- tooltip: STICKINESS_TOOLTIP_CONFIG,+ tooltip: tooltipConfig,}),// Interactive legend is a component concern, kept out of the pure transform.legend: legendConfig,}),- [yAxisScaleType, isGrouped, showValuesOnSeries, legendConfig]+ [yAxisScaleType, isGrouped, showValuesOnSeries, legendConfig, tooltipConfig])// Close over the primitives so the click memos don't invalidate when unrelated@@ -155,23 +162,21 @@ export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.ElhandleStickinessChartClick(seriesKey, datum.dataIndex, clickDeps)}: undefined- return (- <TrendsTooltip- context={ctx}- timezone={timezone}- interval={interval ?? undefined}- breakdownFilter={breakdownFilter ?? undefined}- trendsFilter={trendsFilter}- formula={formula}- showPercentView={true}- isPercentStackView={false}- baseCurrency={baseCurrency}- groupTypeLabel={resolvedGroupTypeLabel}- formatCompareLabel={formatCompareLabel}- onRowClick={onRowClick}- altTitle={altTitle}- />- )+ const sharedProps = {+ context: ctx,+ timezone,+ interval: interval ?? undefined,+ breakdownFilter: breakdownFilter ?? undefined,+ trendsFilter,+ showPercentView: true as const,+ isPercentStackView: false as const,+ baseCurrency,+ groupTypeLabel: resolvedGroupTypeLabel,+ formatCompareLabel,+ onRowClick,+ altTitle,+ }+ return quillTooltipEnabled ? <InsightSeriesTooltip {...sharedProps} /> : <TrendsTooltip {...sharedProps} />},[timezone,@@ -185,6 +190,7 @@ export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.ElhasClickHandler,clickDeps,altTitle,+ quillTooltipEnabled,])diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsxindex 296e4c0c104f..22697b501835 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsx@@ -5,6 +5,8 @@ import { TimeSeriesLineChart } from '@posthog/quill-charts'import type { PointClickData, Series, TimeSeriesLineChartConfig, TooltipContext } from '@posthog/quill-charts'import { buildTheme } from 'lib/charts/utils/theme'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { InsightEmptyState } from 'scenes/insights/EmptyStates'import { insightLogic } from 'scenes/insights/insightLogic'import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUtils'@@ -19,6 +21,8 @@ import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'import { InsightVizNode } from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'+import { INSIGHT_TOOLTIP_CONFIG_LEGACY } from '../../shared/tooltipConfig'import { makeChartErrorHandler } from '../../trends/shared/chartErrorHandler'import { getTrendsSeriesDisplayLabel } from '../../trends/shared/getTrendsSeriesDisplayLabel'import {@@ -47,6 +51,9 @@ const handleChartError = makeChartErrorHandler('stickiness-line-chart')export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.Element | null {const theme = useMemo(() => buildTheme(), [])const { insightProps } = useValues(insightLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]+ const tooltipConfig = quillTooltipEnabled ? STICKINESS_TOOLTIP_CONFIG : INSIGHT_TOOLTIP_CONFIG_LEGACYconst legendConfig = useInsightsLegendConfig({ insightProps })const quillLegendEnabled = !!legendConfig@@ -114,12 +121,12 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.yAxisScaleType,valueLabels: showValuesOnSeries ? { formatter: stickinessPercentFormatter } : false,showCrosshair: true,- tooltip: STICKINESS_TOOLTIP_CONFIG,+ tooltip: tooltipConfig,}),// Interactive legend is a component concern, kept out of the pure transform.legend: legendConfig,}),- [yAxisScaleType, showValuesOnSeries, legendConfig]+ [yAxisScaleType, showValuesOnSeries, legendConfig, tooltipConfig])const canHandleClick = !!context?.onDataPointClick || !!hasPersonsModal@@ -153,23 +160,21 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.handleStickinessChartClick(seriesKey, datum.dataIndex, clickDeps)}: undefined- return (- <TrendsTooltip- context={ctx}- timezone={timezone}- interval={interval ?? undefined}- breakdownFilter={breakdownFilter ?? undefined}- trendsFilter={trendsFilter}- formula={formula}- showPercentView={true}- isPercentStackView={false}- baseCurrency={baseCurrency}- groupTypeLabel={resolvedGroupTypeLabel}- formatCompareLabel={context?.formatCompareLabel}- onRowClick={onRowClick}- altTitle={altTitle}- />- )+ const sharedProps = {+ context: ctx,+ timezone,+ interval: interval ?? undefined,+ breakdownFilter: breakdownFilter ?? undefined,+ trendsFilter,+ showPercentView: true as const,+ isPercentStackView: false as const,+ baseCurrency,+ groupTypeLabel: resolvedGroupTypeLabel,+ formatCompareLabel: context?.formatCompareLabel,+ onRowClick,+ altTitle,+ }+ return quillTooltipEnabled ? <InsightSeriesTooltip {...sharedProps} /> : <TrendsTooltip {...sharedProps} />},[timezone,@@ -183,6 +188,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.canHandleClick,clickDeps,altTitle,+ quillTooltipEnabled,])diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.ts b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.tsindex b42bf5cfd2c1..167cd53edff6 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.ts+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/stickinessChartTransforms.ts@@ -6,6 +6,7 @@ import type { SeriesDatum } from 'scenes/insights/InsightTooltip/insightTooltipUimport { ChartDisplayType } from '~/types'+import { INSIGHT_TOOLTIP_CONFIG } from '../../shared/tooltipConfig'import { COMPARE_PREVIOUS_DIM_OPACITY, dimHexColor } from '../../trends/shared/compareDimming'import { humanizeSeriesLabel } from '../../trends/shared/humanizeSeriesLabel'@@ -90,9 +91,7 @@ export function stickinessPercentFormatter(value: number): string {return `${value.toFixed(1)}%`}-/** Stickiness adapters pin their tooltip to the top with pinnable rows. Shared so the- * line and bar ports stay consistent. */-export const STICKINESS_TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }+export const STICKINESS_TOOLTIP_CONFIG = INSIGHT_TOOLTIP_CONFIG/** Stickiness `date` is an interval-count integer (1, 2, …), not a date.* Render "Stickiness on {interval} {day}" so InsightTooltip doesn't try todiff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsxindex 3d1d6e83edaa..31ad70a8e04f 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx@@ -529,6 +529,9 @@ describe('TrendsBarChart (ActionsBarValue)', () => {}renderInsight({query: aggregatedBar({ compareFilter: { compare: true } }),+ // Pin to the legacy InsightTooltip path — the glyph/ribbon assertions are specific+ // to that rendering and will get a quill-flavoured equivalent when the flag ships.+ featureFlags: { [FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]: false },mocks: {additionalMockResponses: [{ match: (q) => q.kind === NodeKind.TrendsQuery, response: compareResults }],},diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsxindex 75357d3a0d70..0ebe881eca18 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx@@ -13,6 +13,8 @@ import {import type { BarChartConfig, PointClickData, TimeSeriesBarChartConfig, TooltipContext } from '@posthog/quill-charts'import { buildTheme } from 'lib/charts/utils/theme'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { percentage } from 'lib/utils/numbers'import { formatAggregationAxisValue } from 'scenes/insights/aggregationAxisFormat'import { InsightEmptyState } from 'scenes/insights/EmptyStates'@@ -31,6 +33,8 @@ import { QueryContext } from '~/queries/types'import { getStackBreakdownValues } from '~/queries/utils'import { ChartDisplayType } from '~/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'+import { INSIGHT_TOOLTIP_CONFIG, INSIGHT_TOOLTIP_CONFIG_LEGACY } from '../../shared/tooltipConfig'import { AnnotationsLayer } from '../shared/AnnotationsLayer'import { makeChartErrorHandler } from '../shared/chartErrorHandler'import { getTrendsSeriesDisplayLabel } from '../shared/getTrendsSeriesDisplayLabel'@@ -57,7 +61,6 @@ interface TrendsBarChartProps {}const EMPTY_LABELS: string[] = []-const TIME_SERIES_TOOLTIP_CONFIG = { pinnable: true, placement: 'top' as const }const AGGREGATED_TOOLTIP_CONFIG = { pinnable: false }type AggregationLabelFn = (groupTypeIndex: number | null | undefined) => { plural: string }@@ -87,6 +90,9 @@ export function TrendsBarChart({embedded = false,}: TrendsBarChartProps): JSX.Element | null {const theme = useMemo(() => buildTheme(), [])+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]+ const TIME_SERIES_TOOLTIP_CONFIG = quillTooltipEnabled ? INSIGHT_TOOLTIP_CONFIG : INSIGHT_TOOLTIP_CONFIG_LEGACYconst { insightProps, insight } = useValues(insightLogic)// Time-series bars (vertical) render the in-chart legend; the aggregated bar-value layout has@@ -246,6 +252,7 @@ export function TrendsBarChart({showValuesOnSeries,valueLabelFormatter,legendConfig,+ quillTooltipEnabled,])@@ -374,23 +381,25 @@ export function TrendsBarChart({}}: undefined- return (- <TrendsTooltip- context={tooltipCtx}- timezone={timezone}- interval={interval ?? undefined}- breakdownFilter={breakdownFilter ?? undefined}- dateRange={insightData?.resolved_date_range ?? undefined}- trendsFilter={trendsFilter}- formula={formula}- showPercentView={isStickiness}- isPercentStackView={isPercentStackView}- baseCurrency={baseCurrency}- groupTypeLabel={resolvedGroupTypeLabel}- formatCompareLabel={context?.formatCompareLabel}- onRowClick={onRowClick}- showHeader={isAggregated ? false : undefined}- />+ const sharedProps = {+ context: tooltipCtx,+ timezone,+ interval: interval ?? undefined,+ breakdownFilter: breakdownFilter ?? undefined,+ dateRange: insightData?.resolved_date_range ?? undefined,+ trendsFilter,+ showPercentView: isStickiness,+ isPercentStackView,+ baseCurrency,+ groupTypeLabel: resolvedGroupTypeLabel,+ formatCompareLabel: context?.formatCompareLabel,+ onRowClick,+ showHeader: isAggregated ? (false as const) : undefined,+ }+ return quillTooltipEnabled ? (+ <InsightSeriesTooltip {...sharedProps} />+ ) : (+ <TrendsTooltip {...sharedProps} formula={formula} />)},[@@ -408,6 +417,7 @@ export function TrendsBarChart({canHandleClick,clickDeps,isAggregated,+ quillTooltipEnabled,])diff --git a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsxindex 2119457d9457..825c684f8b47 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsx@@ -6,6 +6,8 @@ import type { ChartLegendConfig, PointClickData, TooltipContext } from '@posthogimport { buildTheme } from 'lib/charts/utils/theme'import { getBarColorFromStatus } from 'lib/colors'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { formatAggregationAxisValue } from 'scenes/insights/aggregationAxisFormat'import { InsightEmptyState } from 'scenes/insights/EmptyStates'import { insightLogic } from 'scenes/insights/insightLogic'@@ -19,6 +21,7 @@ import { InsightVizNode } from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'import type { LifecycleToggle } from '~/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'import { AnnotationsLayer } from '../shared/AnnotationsLayer'import { buildBaseLegendConfig } from '../shared/buildBaseLegendConfig'import { makeChartErrorHandler } from '../shared/chartErrorHandler'@@ -37,7 +40,8 @@ interface TrendsLifecycleChartProps {}const EMPTY_LABELS: string[] = []-const LIFECYCLE_TOOLTIP_CONFIG = { pinnable: true, placement: 'top' as const }+const LIFECYCLE_TOOLTIP_CONFIG = { placement: 'cursor' as const }+const LIFECYCLE_TOOLTIP_CONFIG_LEGACY = { pinnable: true, placement: 'top' as const }const handleChartError = makeChartErrorHandler('trends-lifecycle-chart')@@ -49,6 +53,8 @@ const renderLifecycleSeriesLabel = (datum: SeriesDatum): React.ReactNode => datuexport function TrendsLifecycleChart({ context, inSharedMode = false }: TrendsLifecycleChartProps): JSX.Element | null {const theme = useMemo(() => buildTheme(), [])+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]const { insightProps, insight, canEditInsight } = useValues(insightLogic)const {@@ -113,7 +119,7 @@ export function TrendsLifecycleChart({ context, inSharedMode = false }: TrendsLitimezone,allDays: currentPeriodResult?.days ?? [],valueLabels: showValuesOnSeries || showPercentagesOnSeries ? { formatter: valueLabelFormatter } : false,- tooltip: LIFECYCLE_TOOLTIP_CONFIG,+ tooltip: quillTooltipEnabled ? LIFECYCLE_TOOLTIP_CONFIG : LIFECYCLE_TOOLTIP_CONFIG_LEGACY,legend: legendConfig,}),[@@ -130,6 +136,7 @@ export function TrendsLifecycleChart({ context, inSharedMode = false }: TrendsLishowPercentagesOnSeries,valueLabelFormatter,legendConfig,+ quillTooltipEnabled,])@@ -173,26 +180,28 @@ export function TrendsLifecycleChart({ context, inSharedMode = false }: TrendsLiconst renderTooltip = useCallback((ctx: TooltipContext<TrendsSeriesMeta>) => {+ const sharedProps = {+ context: ctx,+ timezone,+ interval: interval ?? undefined,+ breakdownFilter: breakdownFilter ?? undefined,+ dateRange: insightData?.resolved_date_range ?? undefined,+ trendsFilter,+ formula,+ baseCurrency,+ groupTypeLabel: 'Users' as const,+ renderSeriesOverride: renderLifecycleSeriesLabel,+ }const onRowClick = canHandleClick? (datum: SeriesDatum) => {const seriesKey = ctx.seriesData[datum.datasetIndex].series.keyhandleTrendsChartClick(seriesKey, datum.dataIndex, clickDeps, LIFECYCLE_PERSONS_MODAL_OPTIONS)}: undefined- return (- <TrendsTooltip- context={ctx}- timezone={timezone}- interval={interval ?? undefined}- breakdownFilter={breakdownFilter ?? undefined}- dateRange={insightData?.resolved_date_range ?? undefined}- trendsFilter={trendsFilter}- formula={formula}- baseCurrency={baseCurrency}- groupTypeLabel="Users"- onRowClick={onRowClick}- renderSeriesOverride={renderLifecycleSeriesLabel}- />+ return quillTooltipEnabled ? (+ <InsightSeriesTooltip {...sharedProps} sortedByValue={false} hideZeroRows onRowClick={onRowClick} />+ ) : (+ <TrendsTooltip {...sharedProps} onRowClick={onRowClick} />)},[@@ -203,6 +212,7 @@ export function TrendsLifecycleChart({ context, inSharedMode = false }: TrendsLitrendsFilter,formula,baseCurrency,+ quillTooltipEnabled,canHandleClick,clickDeps,]diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsxindex a0d3ff3de391..97f9a37a3023 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx@@ -43,13 +43,12 @@ afterEach(() => {describe('TrendsLineChart', () => {describe('tooltips', () => {- it('shows the series value and glyph for a single series', async () => {+ it('shows the series value for a single series', async () => {renderInsight({ query: buildTrendsQuery() })const tooltip = await chart.hoverTooltip(2)expect(tooltip.row('Pageview')).toContain('134')- expect(tooltip.element.querySelector('.graph-series-glyph')).toBeInTheDocument()})it('shows each series with its own value for multiple series', async () => {@@ -66,9 +65,6 @@ describe('TrendsLineChart', () => {expect(tooltip.row('Pageview')).toContain('134')expect(tooltip.row('Napped')).toContain('5')-- const glyphs = tooltip.element.querySelectorAll('.graph-series-glyph')- expect(glyphs.length).toBe(2)})it('sorts tooltip rows by descending value regardless of series order', async () => {@@ -188,22 +184,6 @@ describe('TrendsLineChart', () => {expect(tooltip.row('Pageview')).toMatch(/%/)})- it('hides series glyph for formula insights', async () => {- renderInsight({- query: buildTrendsQuery({- trendsFilter: { formula: 'A + B' },- series: [- { kind: NodeKind.EventsNode, event: '$pageview', name: '$pageview' },- { kind: NodeKind.EventsNode, event: 'Napped', name: 'Napped' },- ],- }),- })-- const tooltip = await chart.hoverTooltip(2)-- expect(tooltip.element.querySelector('.graph-series-glyph')).not.toBeInTheDocument()- })-it('shows zero-count series alongside active ones', async () => {renderInsight({query: buildTrendsQuery({@@ -681,10 +661,8 @@ describe('TrendsLineChart', () => {expect(tooltip.row('Pageview')).toContain('134')// The trend-line carries the same series label; only the main// row should appear, so there must be exactly one row matching.- const rows = Array.from(tooltip.element.querySelectorAll('tr')).filter((r) =>- r.textContent?.includes('Pageview')- )- expect(rows).toHaveLength(1)+ const matching = tooltip.rows().filter((label) => label.includes('Pageview'))+ expect(matching).toHaveLength(1)})})diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsxindex c8edafc0dd1d..3c7cc9727931 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx@@ -2,9 +2,11 @@ import { useValues } from 'kea'import { useCallback, useMemo } from 'react'import { DEFAULT_Y_AXIS_ID, TimeSeriesLineChart } from '@posthog/quill-charts'-import type { PointClickData, TooltipConfig, TooltipContext } from '@posthog/quill-charts'+import type { PointClickData, TooltipContext } from '@posthog/quill-charts'import { buildTheme } from 'lib/charts/utils/theme'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { ciRanges } from 'lib/statistics'import { percentage } from 'lib/utils/numbers'import { formatAggregationAxisValue } from 'scenes/insights/aggregationAxisFormat'@@ -24,13 +26,15 @@ import { InsightVizNode } from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'import { ChartDisplayType } from '~/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'+import { INSIGHT_TOOLTIP_CONFIG, INSIGHT_TOOLTIP_CONFIG_LEGACY } from '../../shared/tooltipConfig'import { AnnotationsLayer } from '../shared/AnnotationsLayer'import { makeChartErrorHandler } from '../shared/chartErrorHandler'import { getTrendsSeriesDisplayLabel } from '../shared/getTrendsSeriesDisplayLabel'import { handleTrendsChartClick } from '../shared/handleTrendsChartClick'import { TrendsAlertOverlays } from '../shared/TrendsAlertOverlays'import { buildTrendsSeriesMeta, resolveGroupTypeLabel, type TrendsSeriesMeta } from '../shared/trendsSeriesMeta'-import { TrendsTooltip } from '../shared/TrendsTooltip'+import { TrendsTooltip as TrendsTooltipLegacy } from '../shared/TrendsTooltip'import { useInsightsLegendConfig } from '../shared/useInsightsLegendConfig'import { buildTrendsLineTimeSeriesConfig, buildTrendsSeries } from './trendsChartTransforms'@@ -39,12 +43,13 @@ interface TrendsLineChartProps {inSharedMode?: boolean}-const TOOLTIP_CONFIG: TooltipConfig = { pinnable: true, placement: 'top' }-const handleChartError = makeChartErrorHandler('trends-line-chart')export function TrendsLineChart({ context, inSharedMode = false }: TrendsLineChartProps): JSX.Element | null {const { isDarkModeOn } = useValues(themeLogic)+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]+ const TOOLTIP_CONFIG = quillTooltipEnabled ? INSIGHT_TOOLTIP_CONFIG : INSIGHT_TOOLTIP_CONFIG_LEGACYconst theme = useMemo(() => buildTheme(), [isDarkModeOn])const { insightProps, insight } = useValues(insightLogic)@@ -171,22 +176,25 @@ export function TrendsLineChart({ context, inSharedMode = false }: TrendsLineChahandleTrendsChartClick(seriesKey, datum.dataIndex, clickDeps)}: undefined- return (- <TrendsTooltip- context={ctx}- timezone={timezone}- interval={interval ?? undefined}- breakdownFilter={breakdownFilter ?? undefined}- dateRange={insightData?.resolved_date_range ?? undefined}- trendsFilter={trendsFilter}- formula={formula}- showPercentView={isStickiness}- isPercentStackView={isPercentStackView}- baseCurrency={baseCurrency}- groupTypeLabel={resolvedGroupTypeLabel}- formatCompareLabel={context?.formatCompareLabel}- onRowClick={onRowClick}- />+ const tooltipProps = {+ context: ctx,+ timezone,+ interval: interval ?? undefined,+ breakdownFilter: breakdownFilter ?? undefined,+ dateRange: insightData?.resolved_date_range ?? undefined,+ trendsFilter,+ formula,+ showPercentView: isStickiness,+ isPercentStackView,+ baseCurrency,+ groupTypeLabel: resolvedGroupTypeLabel,+ formatCompareLabel: context?.formatCompareLabel,+ onRowClick,+ }+ return quillTooltipEnabled ? (+ <InsightSeriesTooltip {...tooltipProps} />+ ) : (+ <TrendsTooltipLegacy {...tooltipProps} />)},[@@ -203,6 +211,7 @@ export function TrendsLineChart({ context, inSharedMode = false }: TrendsLineChacontext?.formatCompareLabel,canHandleClick,clickDeps,+ quillTooltipEnabled,])@@ -284,6 +293,7 @@ export function TrendsLineChart({ context, inSharedMode = false }: TrendsLineChashowValuesOnSeries,valueLabelFormatter,legendConfig,+ TOOLTIP_CONFIG,])diff --git a/products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart.tsxindex 71aef3555bc0..53380798691c 100644--- a/products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsPieChart/TrendsPieChart.tsx@@ -6,6 +6,8 @@ import { PieChart } from '@posthog/quill-charts'import type { PieChartConfig, RadialSlicePayload, Series, TooltipContext } from '@posthog/quill-charts'import { buildTheme } from 'lib/charts/utils/theme'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import {formatAggregationAxisValue,formatAggregationAxisValueWithShareOfTotal,@@ -27,6 +29,7 @@ import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'import { InsightVizNode } from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'+import { InsightSeriesTooltip } from '../../shared/InsightSeriesTooltip'import type { TrendsSeriesMeta } from '../shared/trendsSeriesMeta'import { TrendsTooltip } from '../shared/TrendsTooltip'import { buildTrendsPieSeries } from './trendsPieTransforms'@@ -45,6 +48,8 @@ const handleChartError = (error: Error, info: ErrorInfo): void => {}export function TrendsPieChart({ context, showPersonsModal = true }: TrendsPieChartProps): JSX.Element | null {+ const { featureFlags } = useValues(featureFlagLogic)+ const quillTooltipEnabled = !!featureFlags[FEATURE_FLAGS.PRODUCT_ANALYTICS_INSIGHTS_TOOLTIPS]const { isDarkModeOn } = useValues(themeLogic)// isDarkModeOn invalidates the memo so buildTheme() re-reads CSS vars on dark-mode toggle.const theme = useMemo(() => buildTheme(), [isDarkModeOn])@@ -204,20 +209,24 @@ export function TrendsPieChart({ context, showPersonsModal = true }: TrendsPieCh)const renderTooltip = useCallback(- (ctx: TooltipContext<TrendsSeriesMeta>) => (- <TrendsTooltip- context={ctx}- breakdownFilter={breakdownFilter ?? undefined}- trendsFilter={trendsFilter}- formula={formula}- baseCurrency={baseCurrency}- groupTypeLabel={resolvedGroupTypeLabel}- formatCompareLabel={context?.formatCompareLabel}- onRowClick={onRowClick}- showHeader={false}- renderCount={renderCount}- />- ),+ (ctx: TooltipContext<TrendsSeriesMeta>) => {+ const sharedProps = {+ context: ctx,+ breakdownFilter: breakdownFilter ?? undefined,+ trendsFilter,+ baseCurrency,+ groupTypeLabel: resolvedGroupTypeLabel,+ formatCompareLabel: context?.formatCompareLabel,+ onRowClick,+ showHeader: false as const,+ renderCount,+ }+ return quillTooltipEnabled ? (+ <InsightSeriesTooltip {...sharedProps} />+ ) : (+ <TrendsTooltip {...sharedProps} formula={formula} />+ )+ },[breakdownFilter,trendsFilter,@@ -227,6 +236,7 @@ export function TrendsPieChart({ context, showPersonsModal = true }: TrendsPieChcontext?.formatCompareLabel,onRowClick,renderCount,+ quillTooltipEnabled,])