: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
refactor(insights): stop frontend and mcp reads of results action (#124134)
Thomas Obermüller29d04a9a3ee4
diff --git a/frontend/src/lib/components/InsightLegend/InsightLegendRow.tsx b/frontend/src/lib/components/InsightLegend/InsightLegendRow.tsxindex 097feb7de49f..fb027ff357bb 100644--- a/frontend/src/lib/components/InsightLegend/InsightLegendRow.tsx+++ b/frontend/src/lib/components/InsightLegend/InsightLegendRow.tsx@@ -44,6 +44,7 @@ export function InsightLegendRow({ item, readOnly = false }: InsightLegendRowProlegendSeriesIsolationMenuEligible,getIsOnlyVisibleSeriesInLegend,querySource,+ actionNames,} = useValues(trendsDataLogic(insightProps))const { toggleResultHidden, toggleOtherSeriesHidden, toggleAllResultsHidden } = useActions(trendsDataLogic(insightProps)@@ -100,7 +101,7 @@ export function InsightLegendRow({ item, readOnly = false }: InsightLegendRowPro<InsightLabelkey={item.id}seriesColor={mainColor}- series={getResultSeries(querySource, item)}+ series={getResultSeries(querySource, item, actionNames)}fallbackName={item.breakdown_value === '' ? 'None' : item.label}hasMultipleSeries={!isSingleSeriesDefinition}breakdownValue={formattedBreakdownValue}diff --git a/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsx b/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsxindex 3a4c0a648643..5d00e497c079 100644--- a/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsx+++ b/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsx@@ -16,6 +16,7 @@ import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'import { ResultCustomizationBy } from '~/queries/schema/schema-general'import { FlattenedFunnelStepByBreakdown } from '~/types'+import { trendsDataLogic } from 'products/product_analytics/frontend/insights/trends/trendsDataLogic'import { IndexedTrendResult } from 'products/product_analytics/frontend/insights/trends/types'import { resultCustomizationsModalLogic } from './resultCustomizationsModalLogic'@@ -87,9 +88,11 @@ function TrendsInfo({ dataset, resultCustomizationBy }: TrendsInfoProps): JSX.Elconst { allCohorts } = useValues(cohortsModel)const { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)const { breakdownFilter, querySource } = useValues(insightVizDataLogic)+ const { insightProps } = useValues(insightLogic)+ const { actionNames } = useValues(trendsDataLogic(insightProps))// A formula row has no series node, so fall back to the row label.- const seriesNode = getResultSeries(querySource, dataset).node+ const seriesNode = getResultSeries(querySource, dataset, actionNames).nodeconst seriesName = seriesNode ? (<EntityFilterInfo filter={seriesNode} allowWrap={true} showSingleName={true} />) : (diff --git a/frontend/src/queries/nodes/WebVitals/definitions.ts b/frontend/src/queries/nodes/WebVitals/definitions.tsindex 4bb8d89cfb90..bc792220faf3 100644--- a/frontend/src/queries/nodes/WebVitals/definitions.ts+++ b/frontend/src/queries/nodes/WebVitals/definitions.ts@@ -4,10 +4,6 @@ import { IconExclamation } from 'lib/lemon-ui/icons'import { WebVitalsPercentile } from 'scenes/web-analytics/common'import { InsightQueryNode, WebVitalsItem, WebVitalsMetric, WebVitalsMetricBand } from '~/queries/schema/schema-general'-import type { TrendResult } from '~/types'--/** A web vitals result row. The trends runner gives every row an `order`, which `WebVitalsItem` does not declare. */-export type WebVitalsRow = WebVitalsItem & Pick<TrendResult, 'order'>const PERCENTILE_NAME: Record<WebVitalsPercentile, string> = {p75: '75%',@@ -67,7 +63,7 @@ export const EXPERIENCE_PER_BAND: Record<WebVitalsMetricBand, string> = {}export const getMetric = (- results: WebVitalsRow[] | undefined,+ results: WebVitalsItem[] | undefined,querySource: InsightQueryNode | undefined,metric: WebVitalsMetric,percentile: WebVitalsPercentile@@ -76,7 +72,7 @@ export const getMetric = (// `getResultSeries` from `scenes/`. A web vitals query has no formulas, so `order` is always a series index.const series = querySource && 'series' in querySource ? querySource.series : []const data = results?.find((result) => {- const node = result.order != null ? series[result.order] : undefined+ const node = series[result.order]return node?.custom_name === metric && node.math === percentile})?.datadiff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 3ffb3df17f63..b011a9fff70b 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -10230,6 +10230,13 @@"CachedLifecycleQueryResponse": {"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"cache_key": {"type": "string"},@@ -14720,6 +14727,13 @@"CachedStickinessQueryResponse": {"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"cache_key": {"type": "string"},@@ -15863,6 +15877,13 @@"CachedTrendsQueryResponse": {"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"boxplot_data": {"deprecated": "Box plot data is now returned in results. This field is no longer populated.","items": {@@ -31551,6 +31572,13 @@"LifecycleQueryResponse": {"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"error": {"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.","type": "string"@@ -46802,6 +46830,13 @@{"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"boxplot_data": {"deprecated": "Box plot data is now returned in results. This field is no longer populated.","items": {@@ -47134,6 +47169,13 @@{"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"error": {"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.","type": "string"@@ -47199,6 +47241,13 @@{"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"error": {"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.","type": "string"@@ -53744,6 +53793,13 @@"StickinessQueryResponse": {"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"error": {"description": "Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise.","type": "string"@@ -56398,6 +56454,13 @@"TrendsQueryResponse": {"additionalProperties": false,"properties": {+ "action_names": {+ "additionalProperties": {+ "type": "string"+ },+ "description": "The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.",+ "type": "object"+ },"boxplot_data": {"deprecated": "Box plot data is now returned in results. This field is no longer populated.","items": {@@ -59275,9 +59338,13 @@"type": "string"},"type": "array"+ },+ "order": {+ "$ref": "#/definitions/integer",+ "description": "The index of the row's series in the query."}},- "required": ["data", "days", "action"],+ "required": ["data", "days", "order", "action"],"type": "object"},"WebVitalsItemAction": {diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 01ab5cece4d3..387661231a79 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -2005,6 +2005,11 @@ export interface BoxPlotDatum {export interface TrendsQueryResponse extends AnalyticsQueryResponseBase {results: Record<string, any>[]+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name`+ * displays this name, because the query holds only the action's id.+ */+ action_names?: Record<string, string>/** Wether more breakdown values are available. */hasMore?: boolean/** @deprecated Box plot data is now returned in results. This field is no longer populated. */@@ -2616,6 +2621,11 @@ export const STICKINESS_FILTER_PROPERTIES = new Set<keyof StickinessFilter>([export interface StickinessQueryResponse extends AnalyticsQueryResponseBase {results: Record<string, any>[]+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name`+ * displays this name, because the query holds only the action's id.+ */+ action_names?: Record<string, string>}export type CachedStickinessQueryResponse = CachedQueryResponse<StickinessQueryResponse>@@ -2971,6 +2981,11 @@ export type QueryStatus = {export interface LifecycleQueryResponse extends AnalyticsQueryResponseBase {results: Record<string, any>[]+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name`+ * displays this name, because the query holds only the action's id.+ */+ action_names?: Record<string, string>}export type CachedLifecycleQueryResponse = CachedQueryResponse<LifecycleQueryResponse>@@ -4363,6 +4378,8 @@ export interface WebVitalsItemAction {export interface WebVitalsItem {data: number[]days: string[]+ /** The index of the row's series in the query. */+ order: integeraction: WebVitalsItemAction}diff --git a/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts b/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.tsindex 632ffc931ec4..a0771a9ba7fb 100644--- a/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts+++ b/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts@@ -152,10 +152,10 @@ describe('dashboardBreakdownColors', () => {it('handles trends insights', () => {const tiles = [trendsTile([- { action: { order: 0 }, breakdown_value: ['Chrome'], compare_label: 'previous' },- { action: { order: 0 }, breakdown_value: ['Firefox'], compare_label: 'previous' },+ { order: 0, breakdown_value: ['Chrome'], compare_label: 'previous' },+ { order: 0, breakdown_value: ['Firefox'], compare_label: 'previous' },]),- trendsTile([{ action: { order: 0 }, breakdown_value: 'Safari' }]),+ trendsTile([{ order: 0, breakdown_value: 'Safari' }]),]expect(extractBreakdownValues(tiles)).toEqual([@@ -168,10 +168,10 @@ describe('dashboardBreakdownColors', () => {it('orders values by assignment rank, most re-used first', () => {const tiles = [trendsTile([- { action: { order: 0 }, breakdown_value: ['Apple'] },- { action: { order: 0 }, breakdown_value: ['Zebra'] },+ { order: 0, breakdown_value: ['Apple'] },+ { order: 0, breakdown_value: ['Zebra'] },]),- trendsTile([{ action: { order: 0 }, breakdown_value: ['Zebra'] }]),+ trendsTile([{ order: 0, breakdown_value: ['Zebra'] }]),]// Zebra is on two charts vs Apple's one, so the modal lists it first even@@ -185,12 +185,12 @@ describe('dashboardBreakdownColors', () => {it('deduplicates repeated breakdown values across tiles', () => {const tiles = [trendsTile([- { action: { order: 0 }, breakdown_value: ['Chrome'] },- { action: { order: 1 }, breakdown_value: ['Firefox'] },+ { order: 0, breakdown_value: ['Chrome'] },+ { order: 1, breakdown_value: ['Firefox'] },]),trendsTile([- { action: { order: 0 }, breakdown_value: ['Chrome'] },- { action: { order: 1 }, breakdown_value: ['Safari'] },+ { order: 0, breakdown_value: ['Chrome'] },+ { order: 1, breakdown_value: ['Safari'] },]),]@@ -204,7 +204,7 @@ describe('dashboardBreakdownColors', () => {it('stringifies numeric values so trends and funnels tiles share one entry', () => {const tiles = [// trends keys wrap scalars in an array; funnels keep them bare- trendsTile([{ action: { order: 0 }, breakdown_value: [123] }]),+ trendsTile([{ order: 0, breakdown_value: [123] }]),createTestTile({result: [{ breakdown_value: 123 }],query: {@@ -317,7 +317,7 @@ describe('dashboardBreakdownColors', () => {it('handles cohort breakdowns, keying them all to the shared cohort property', () => {const cohortTile = (values: number[][]): DashboardTile =>createTestTile({- result: values.map((breakdown_value) => ({ action: { order: 0 }, breakdown_value })),+ result: values.map((breakdown_value) => ({ order: 0, breakdown_value })),query: {kind: NodeKind.InsightVizNode,source: {@@ -340,14 +340,14 @@ describe('dashboardBreakdownColors', () => {it('unifies single and multi form of one property into one scoped entry', () => {const tiles = [- trendsTile([{ action: { order: 0 }, breakdown_value: ['Chrome'] }], {+ trendsTile([{ order: 0, breakdown_value: ['Chrome'] }], {breakdown: '$browser',breakdown_type: 'event',}),trendsTile([- { action: { order: 0 }, breakdown_value: ['Chrome'] },- { action: { order: 0 }, breakdown_value: ['Firefox'] },+ { order: 0, breakdown_value: ['Chrome'] },+ { order: 0, breakdown_value: ['Firefox'] },],{ breakdowns: [{ property: '$browser' }] }),@@ -361,11 +361,11 @@ describe('dashboardBreakdownColors', () => {it('clusters values by property in tile order before ranking within each property', () => {const tiles = [- trendsTile([{ action: { order: 0 }, breakdown_value: ['Mac OS X'] }], { breakdown: '$os' }),- trendsTile([{ action: { order: 0 }, breakdown_value: ['Mac OS X'] }], { breakdown: '$os' }),- trendsTile([{ action: { order: 0 }, breakdown_value: ['Chrome'] }], { breakdown: '$browser' }),- trendsTile([{ action: { order: 0 }, breakdown_value: ['Chrome'] }], { breakdown: '$browser' }),- trendsTile([{ action: { order: 0 }, breakdown_value: ['Chrome'] }], { breakdown: '$browser' }),+ trendsTile([{ order: 0, breakdown_value: ['Mac OS X'] }], { breakdown: '$os' }),+ trendsTile([{ order: 0, breakdown_value: ['Mac OS X'] }], { breakdown: '$os' }),+ trendsTile([{ order: 0, breakdown_value: ['Chrome'] }], { breakdown: '$browser' }),+ trendsTile([{ order: 0, breakdown_value: ['Chrome'] }], { breakdown: '$browser' }),+ trendsTile([{ order: 0, breakdown_value: ['Chrome'] }], { breakdown: '$browser' }),]// Chrome is on more tiles, but $os tiles come first on the dashboard@@ -380,12 +380,12 @@ describe('dashboardBreakdownColors', () => {it('keeps values grouped by tile and deduplicates within a tile', () => {const tiles = [trendsTile([- { action: { order: 0 }, breakdown_value: ['Chrome'] },+ { order: 0, breakdown_value: ['Chrome'] },// second series over the same breakdown repeats the value within the tile- { action: { order: 1 }, breakdown_value: ['Chrome'] },- { action: { order: 0 }, breakdown_value: ['Firefox'] },+ { order: 1, breakdown_value: ['Chrome'] },+ { order: 0, breakdown_value: ['Firefox'] },]),- trendsTile([{ action: { order: 0 }, breakdown_value: 'Chrome' }]),+ trendsTile([{ order: 0, breakdown_value: 'Chrome' }]),trendsTile([]),]diff --git a/frontend/src/scenes/dashboard/dashboardLogic.test.ts b/frontend/src/scenes/dashboard/dashboardLogic.test.tsindex 55b9cd3ae083..e2baec4150e9 100644--- a/frontend/src/scenes/dashboard/dashboardLogic.test.ts+++ b/frontend/src/scenes/dashboard/dashboardLogic.test.ts@@ -2594,7 +2594,7 @@ describe('dashboardLogic', () => {...insight,dashboard_tiles: [{ id: 1, dashboard_id: 5 }],result: breakdownValues.map((breakdown_value) => ({- action: { order: 0 },+ order: 0,breakdown_value: [breakdown_value],})),query: {@@ -2635,9 +2635,9 @@ describe('dashboardLogic', () => {...tileInsight,dashboard_tiles: [{ id: 1, dashboard_id: 5 }],result: [- { action: { order: 0 }, breakdown_value: ['Chrome'] },- { action: { order: 0 }, breakdown_value: ['Firefox'] },- { action: { order: 0 }, breakdown_value: ['Safari'] },+ { order: 0, breakdown_value: ['Chrome'] },+ { order: 0, breakdown_value: ['Firefox'] },+ { order: 0, breakdown_value: ['Safari'] },],query: {kind: NodeKind.InsightVizNode,@@ -2668,7 +2668,7 @@ describe('dashboardLogic', () => {dashboardsModel.actions.updateDashboardInsight({...tileInsight,dashboard_tiles: [{ id: 1, dashboard_id: 5 }],- result: [{ action: { order: 0 }, breakdown_value: ['Chrome'] }],+ result: [{ order: 0, breakdown_value: ['Chrome'] }],query: {kind: NodeKind.InsightVizNode,source: { kind: NodeKind.TrendsQuery, series: [] },@@ -2717,7 +2717,7 @@ describe('dashboardLogic', () => {...insight,dashboard_tiles: [{ id: 1, dashboard_id: 5 }],result: breakdownValues- ? breakdownValues.map((breakdown_value) => ({ action: { order: 0 }, breakdown_value }))+ ? breakdownValues.map((breakdown_value) => ({ order: 0, breakdown_value })): null,query: {kind: NodeKind.InsightVizNode,diff --git a/frontend/src/scenes/insights/utils/resultSeries.test.ts b/frontend/src/scenes/insights/utils/resultSeries.test.tsindex 9896735b4720..f84d55069963 100644--- a/frontend/src/scenes/insights/utils/resultSeries.test.ts+++ b/frontend/src/scenes/insights/utils/resultSeries.test.ts@@ -1,13 +1,21 @@import { InsightQueryNode, NodeKind } from '~/queries/schema/schema-general'import { BaseMathType, ChartDisplayType, FilterLogicalOperator } from '~/types'-import { ResultSeries, ResultSeriesRow, getResultSeries } from './resultSeries'+import { ActionNames, ResultSeries, ResultSeriesRow, getResultSeries } from './resultSeries'describe('getResultSeries()', () => {const pageviews = { kind: NodeKind.EventsNode as const, event: '$pageview', name: '$pageview' }const signups = { kind: NodeKind.ActionsNode as const, id: 7, name: 'Signed up' }- it.each<{ case: string; query: InsightQueryNode; row: ResultSeriesRow; expected: ResultSeries }>([+ const signedUpNames: ActionNames = { '7': 'Signed up' }++ it.each<{+ case: string+ query: InsightQueryNode+ row: ResultSeriesRow+ actionNames?: ActionNames+ expected: ResultSeries+ }>([{case: 'a formula row to no series, although its order is a valid series index',query: {@@ -15,7 +23,7 @@ describe('getResultSeries()', () => {series: [pageviews, signups],trendsFilter: { formulaNodes: [{ formula: 'A+B' }, { formula: 'A/B' }] },},- row: { order: 1, action: null },+ row: { order: 1 },expected: { order: 1, node: null, math: null },},{@@ -25,13 +33,13 @@ describe('getResultSeries()', () => {series: [pageviews, signups],trendsFilter: { display: ChartDisplayType.CalendarHeatmap, formulaNodes: [{ formula: 'A+B' }] },},- row: { action: { order: 0, name: '$pageview' } },+ row: { order: 0 },expected: { order: 0, node: pageviews, math: {} },},{- case: 'a stickiness row by the order it carries only on action',+ case: 'a stickiness row by its order',query: { kind: NodeKind.StickinessQuery, series: [pageviews, signups] },- row: { action: { order: 1, name: 'Signed up' } },+ row: { order: 1 },expected: { order: 1, node: signups, math: {} },},{@@ -59,11 +67,37 @@ describe('getResultSeries()', () => {},},{- case: 'an action series saved without a name to the name the runner resolved',+ case: 'an action series saved without a name to its name in action_names',query: { kind: NodeKind.TrendsQuery, series: [{ kind: NodeKind.ActionsNode, id: 7 }] },- row: { order: 0, action: { order: 0, name: 'Signed up' } },+ row: { order: 0 },+ actionNames: signedUpNames,expected: { order: 0, node: { kind: NodeKind.ActionsNode, id: 7, name: 'Signed up' }, math: {} },},+ {+ case: 'a group series with an action saved without a name to its members, by their names in action_names',+ query: {+ kind: NodeKind.TrendsQuery,+ series: [+ {+ kind: NodeKind.GroupNode,+ operator: FilterLogicalOperator.Or,+ nodes: [pageviews, { kind: NodeKind.ActionsNode, id: 7 }],+ },+ ],+ },+ row: { order: 0 },+ actionNames: signedUpNames,+ expected: {+ order: 0,+ node: {+ kind: NodeKind.GroupNode,+ operator: FilterLogicalOperator.Or,+ nodes: [pageviews, { kind: NodeKind.ActionsNode, id: 7 }],+ name: '$pageview, Signed up',+ },+ math: {},+ },+ },{case: 'a group series saved without a name to its members, as the runner labels it',query: {@@ -88,7 +122,7 @@ describe('getResultSeries()', () => {math: {},},},- ])('resolves $case', ({ query, row, expected }) => {- expect(getResultSeries(query, row)).toEqual(expected)+ ])('resolves $case', ({ query, row, actionNames, expected }) => {+ expect(getResultSeries(query, row, actionNames)).toEqual(expected)})})diff --git a/frontend/src/scenes/insights/utils/resultSeries.ts b/frontend/src/scenes/insights/utils/resultSeries.tsindex b7a45259b44f..0cbc790e8388 100644--- a/frontend/src/scenes/insights/utils/resultSeries.ts+++ b/frontend/src/scenes/insights/utils/resultSeries.ts@@ -9,7 +9,7 @@ import {import { InsightQueryNode } from '~/queries/schema/schema-general'import { isInsightQueryWithSeries, isLifecycleQuery, isTrendsQuery } from '~/queries/utils'-import { ActionFilter, BaseMathType, ChartDisplayType, IntervalType } from '~/types'+import { BaseMathType, ChartDisplayType, IntervalType } from '~/types'export type ResultSeriesMath = Pick<SeriesNode, 'math' | 'math_property' | 'math_hogql' | 'math_group_type_index'>@@ -26,18 +26,16 @@ export interface ResultSeries {export interface ResultSeriesRow {order?: number | null- action?: Pick<ActionFilter, 'order' | 'name'> | null}+/** A response's `action_names`: the name of each action the query's series reference, keyed by action id. */+export type ActionNames = Partial<Record<string, string>>+const WEEK_OR_LONGER_INTERVALS = new Set<IntervalType>(['week', 'month', 'quarter', 'year'])const MONTH_OR_LONGER_INTERVALS = new Set<IntervalType>(['month', 'quarter', 'year'])-/**- * The row's series or formula index. Stickiness, lifecycle and calendar heatmap rows carry it only on the legacy- * `action`, so this reads `action.order` for them until those runners emit `order` at the top level.- */export function getResultOrder(result: ResultSeriesRow): number {- return result.order ?? result.action?.order ?? 0+ return result.order ?? 0}/**@@ -65,9 +63,14 @@ export function getResultSeriesIndex(return hasFormulaResults(querySource) ? undefined : getResultOrder(result)}+/**+ * Pass the response's `action_names` wherever the series name is displayed, so that an action series saved without a+ * name displays the action's name.+ */export function getResultSeries(querySource: InsightQueryNode | null | undefined,- result: ResultSeriesRow+ result: ResultSeriesRow,+ actionNames?: ActionNames): ResultSeries {const order = getResultOrder(result)const node =@@ -77,14 +80,15 @@ export function getResultSeries(if (!node) {return { order, node: null, math: null }}- return { order, node: withDisplayName(node, result), math: getRunnerMath(querySource, node) }+ return { order, node: withDisplayName(node, actionNames), math: getRunnerMath(querySource, node) }}/*** The key the runner labels a series with: its event, its table, or a group's member keys joined by commas. Null for- * an all-events series, an action, and a group that holds an action saved without a name.+ * an all-events series, an action, and a group that holds an action saved without a name that `actionNames` does+ * not name.*/-function getSeriesKey(node: SeriesNode): string | null {+function getSeriesKey(node: SeriesNode, actionNames?: ActionNames): string | null {if (isEventsSeriesNode(node)) {return node.event ?? null}@@ -98,8 +102,8 @@ function getSeriesKey(node: SeriesNode): string | null {isEventsSeriesNode(member)? (member.event ?? 'All events'): isActionsSeriesNode(member)- ? ensureStringIsNotBlank(member.name)- : getSeriesKey(member)+ ? (ensureStringIsNotBlank(member.name) ?? getActionName(member.id, actionNames))+ : getSeriesKey(member, actionNames))return memberKeys.every((key) => key !== null) ? memberKeys.join(', ') : null}@@ -120,24 +124,27 @@ export function getResultSeriesCustomName(node: SeriesNode): string | null {/*** A series saved without a `name` displays the raw key it queries, as the runner's label does. A nameless action- * has no key worth showing, so it takes the name the runner resolved from the database while responses still- * carry `action`. So does a group that holds a nameless action.+ * has no key in the query, so it takes the action's name from `actionNames`, as the runner takes it from the+ * database. So does a nameless action in a group.*/-function withDisplayName(node: SeriesNode, result: ResultSeriesRow): SeriesNode {+function withDisplayName(node: SeriesNode, actionNames: ActionNames | undefined): SeriesNode {if (ensureStringIsNotBlank(node.name)) {return node}- const runnerName = ensureStringIsNotBlank(result.action?.name)const name = isEventsSeriesNode(node)? node.event: isGroupSeriesNode(node)- ? (getSeriesKey(node) ?? runnerName)+ ? getSeriesKey(node, actionNames): isActionsSeriesNode(node)- ? runnerName+ ? getActionName(node.id, actionNames): nullreturn name ? { ...node, name } : node}+function getActionName(id: number, actionNames: ActionNames | undefined): string | null {+ return ensureStringIsNotBlank(actionNames?.[id])+}+function getRunnerMath(querySource: InsightQueryNode | null | undefined, node: SeriesNode): ResultSeriesMath {if (isLifecycleQuery(querySource)) {return { math: BaseMathType.TotalCount }diff --git a/frontend/src/scenes/max/__mocks__/quillComparison.mocks.ts b/frontend/src/scenes/max/__mocks__/quillComparison.mocks.tsindex 0c93d847d6d5..894eb4bd1737 100644--- a/frontend/src/scenes/max/__mocks__/quillComparison.mocks.ts+++ b/frontend/src/scenes/max/__mocks__/quillComparison.mocks.ts@@ -550,7 +550,7 @@ function dayLabel(day: string): string {function trendSeries(label: string, data: number[], breakdownValue?: string): Record<string, unknown> {return {- action: { id: 'account created', type: 'events', order: 0, name: 'account created', properties: {} },+ order: 0,label,count: data.reduce((sum, value) => sum + value, 0),data,diff --git a/frontend/src/scenes/web-analytics/PagePerformance.stories.tsx b/frontend/src/scenes/web-analytics/PagePerformance.stories.tsxindex d473408de46d..eed8226fc5b7 100644--- a/frontend/src/scenes/web-analytics/PagePerformance.stories.tsx+++ b/frontend/src/scenes/web-analytics/PagePerformance.stories.tsx@@ -91,7 +91,7 @@ const CANDIDATES = {const trend = (label: string, values: number[]): Record<string, unknown> => ({results: [{- action: { id: label, name: label, type: 'events', order: 0 },+ order: 0,label,data: values,days: BUCKETS,diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsxindex b3d17e75c297..67304a957a7a 100644--- a/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsx+++ b/frontend/src/scenes/web-analytics/WebAnalyticsExport.test.tsx@@ -1,6 +1,5 @@import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/insightVizKeys'-import type { WebVitalsRow } from '~/queries/nodes/WebVitals/definitions'import {DataTableNode,NodeKind,@@ -8,6 +7,7 @@ import {WebStatsTableQueryResponse,WebVitalsPathBreakdownQuery,WebVitalsPathBreakdownQueryResponse,+ WebVitalsItem,WebVitalsQuery,WebVitalsQueryResponse,} from '~/queries/schema/schema-general'@@ -37,7 +37,7 @@ const webVitalsQuery: WebVitalsQuery = {},}-const webVitalsRows: WebVitalsRow[] = [+const webVitalsRows: WebVitalsItem[] = [{action: { custom_name: 'LCP', math: PropertyMathType.P90 },order: 0,diff --git a/frontend/src/scenes/web-analytics/webAnalyticsExportUtils.ts b/frontend/src/scenes/web-analytics/webAnalyticsExportUtils.tsindex 1cd1519b307c..6487473bff03 100644--- a/frontend/src/scenes/web-analytics/webAnalyticsExportUtils.ts+++ b/frontend/src/scenes/web-analytics/webAnalyticsExportUtils.ts@@ -14,7 +14,7 @@ import {getInsightExportAdapter,} from '~/queries/nodes/InsightViz/exportAdapters'import { insightVizDataNodeKey } from '~/queries/nodes/InsightViz/insightVizKeys'-import { GRADE_PER_BAND, WebVitalsRow } from '~/queries/nodes/WebVitals/definitions'+import { GRADE_PER_BAND } from '~/queries/nodes/WebVitals/definitions'import {DataTableNode,NodeKind,@@ -289,8 +289,8 @@ function webVitalsColumnName(metric: WebVitalsMetric, percentile: string): strinfunction webVitalsTrendsAdapter(response: WebVitalsQueryResponse, query: WebVitalsQuery): TrendsAdapter {return new TrendsAdapter({...response,- results: ((response.results ?? []) as WebVitalsRow[]).map((item) => {- const node = getResultSeries(query.source, { order: item.order }).node+ results: (response.results ?? []).map((item) => {+ const node = getResultSeries(query.source, item).nodereturn node?.custom_name && node.math? { ...item, label: webVitalsColumnName(node.custom_name as WebVitalsMetric, node.math) }: itemdiff --git a/frontend/src/test/insight-testing/mocks.ts b/frontend/src/test/insight-testing/mocks.tsindex cb38dcd17d0e..a327aef1ed95 100644--- a/frontend/src/test/insight-testing/mocks.ts+++ b/frontend/src/test/insight-testing/mocks.ts@@ -95,7 +95,6 @@ function buildTrendsResponse(series: SeriesData[], opts: { formulaLabels?: strintemplateRows.map((s) => {const data = s.data.map((v) => v * (formulaIdx + 1))return {- action: null,order: formulaIdx,label,count: data.reduce((a, b) => a + b, 0),@@ -113,20 +112,10 @@ function buildTrendsResponse(series: SeriesData[], opts: { formulaLabels?: strin}return {results: series.map((s, i) => {- // Breakdown/compare rows carry their parent series' identity (event name and- // order), like the real runner.+ // Breakdown/compare rows carry their parent series' order, like the real runner.const isChildRow = s.compare || s.breakdown_value != nullconst seriesOrder = isChildRow ? (s.seriesIndex ?? 0) : i- const entityName = (isChildRow ? s.eventName : undefined) ?? s.labelreturn {- action: isFormula- ? null- : {- id: `$${entityName.toLowerCase().replace(/\s+/g, '_')}`,- type: 'events',- name: entityName,- order: seriesOrder,- },order: isFormula ? 0 : seriesOrder,label: s.label,count: s.data.reduce((a, b) => a + b, 0),@@ -149,17 +138,11 @@ function buildStickinessResponse(series: SeriesData[]): TrendsQueryResponse {return {results: series.map((s, i) => {const buckets = s.data.length- // Compare current/previous and breakdown rows share their series' identity, mirroring the real runner.+ // Compare current/previous and breakdown rows share their series' order, mirroring the real runner.const isChildRow = s.compare || s.breakdown_value != nullconst seriesOrder = isChildRow ? (s.seriesIndex ?? 0) : i- const entityName = (isChildRow ? s.eventName : undefined) ?? s.labelreturn {- action: {- id: `$${entityName.toLowerCase().replace(/\s+/g, '_')}`,- type: 'events',- name: entityName,- order: seriesOrder,- },+ order: seriesOrder,label: s.label,count: s.data.reduce((a, b) => a + b, 0),aggregated_value: s.data.reduce((a, b) => a + b, 0),@@ -235,10 +218,10 @@ function resolveSeriesData(query: QueryBody): SeriesData[] {if (isCompare) {const compareSeries = lookupCompareSeries(eventName)if (compareSeries) {- return compareSeries.map((row) => ({ ...row, seriesIndex, eventName }))+ return compareSeries.map((row) => ({ ...row, seriesIndex }))}}- return lookupSeries(eventName, breakdownProp ?? undefined).map((row) => ({ ...row, seriesIndex, eventName }))+ return lookupSeries(eventName, breakdownProp ?? undefined).map((row) => ({ ...row, seriesIndex }))})}diff --git a/frontend/src/test/insight-testing/test-data.ts b/frontend/src/test/insight-testing/test-data.tsindex 604d118d4bae..2a5792a231e3 100644--- a/frontend/src/test/insight-testing/test-data.ts+++ b/frontend/src/test/insight-testing/test-data.ts@@ -91,8 +91,6 @@ export interface SeriesData {compare_label?: string/** Index of the query series this row belongs to — stamped by the mock resolver. */seriesIndex?: number- /** Event name of the query series this row belongs to — stamped by the mock resolver. */- eventName?: string}type CannedSeries = SeriesData & { labels: string[]; days: string[] }diff --git a/frontend/src/toolbar/floating/components/__mocks__/list-web-vitals-response.ts b/frontend/src/toolbar/floating/components/__mocks__/list-web-vitals-response.tsindex 946e32626eab..1f59873255f1 100644--- a/frontend/src/toolbar/floating/components/__mocks__/list-web-vitals-response.ts+++ b/frontend/src/toolbar/floating/components/__mocks__/list-web-vitals-response.ts@@ -33,45 +33,7 @@ export const listWebVitalsAPIResponse = {days: ['2025-01-19', '2025-01-26'],count: 112,label: '$web_vitals',- filter: {- insight: 'TRENDS',- properties: [- {- key: '$pathname',- label: null,- operator: 'exact',- type: 'event',- value: ['/project/1/web/web-vitals'],- },- ],- filter_test_accounts: false,- date_to: '2025-02-01T23:59:59.999999Z',- date_from: '2025-01-25T00:00:00Z',- entity_type: 'events',- interval: 'week',- aggregationAxisFormat: 'numeric',- display: 'ActionsLineGraph',- resultCustomizationBy: 'value',- showAlertThresholdLines: false,- showLegend: false,- showPercentStackView: false,- showValuesOnSeries: false,- smoothingIntervals: 1,- yAxisScaleType: 'linear',- },- action: {- days: ['2025-01-19T00:00:00Z', '2025-01-26T00:00:00Z'],- id: '$web_vitals',- type: 'events',- order: 0,- name: '$web_vitals',- custom_name: 'INP',- math: 'p90',- math_property: '$web_vitals_INP_value',- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 0,},{data: [1108.456, 1412.345],@@ -79,45 +41,7 @@ export const listWebVitalsAPIResponse = {days: ['2025-01-19', '2025-01-26'],count: 1108.456,label: '$web_vitals',- filter: {- insight: 'TRENDS',- properties: [- {- key: '$pathname',- label: null,- operator: 'exact',- type: 'event',- value: ['/project/1/web/web-vitals'],- },- ],- filter_test_accounts: false,- date_to: '2025-02-01T23:59:59.999999Z',- date_from: '2025-01-25T00:00:00Z',- entity_type: 'events',- interval: 'week',- aggregationAxisFormat: 'numeric',- display: 'ActionsLineGraph',- resultCustomizationBy: 'value',- showAlertThresholdLines: false,- showLegend: false,- showPercentStackView: false,- showValuesOnSeries: false,- smoothingIntervals: 1,- yAxisScaleType: 'linear',- },- action: {- days: ['2025-01-19T00:00:00Z', '2025-01-26T00:00:00Z'],- id: '$web_vitals',- type: 'events',- order: 1,- name: '$web_vitals',- custom_name: 'LCP',- math: 'p90',- math_property: '$web_vitals_LCP_value',- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 1,},{data: [0.45, 0.45],@@ -125,45 +49,7 @@ export const listWebVitalsAPIResponse = {days: ['2025-01-19', '2025-01-26'],count: 0.45,label: '$web_vitals',- filter: {- insight: 'TRENDS',- properties: [- {- key: '$pathname',- label: null,- operator: 'exact',- type: 'event',- value: ['/project/1/web/web-vitals'],- },- ],- filter_test_accounts: false,- date_to: '2025-02-01T23:59:59.999999Z',- date_from: '2025-01-25T00:00:00Z',- entity_type: 'events',- interval: 'week',- aggregationAxisFormat: 'numeric',- display: 'ActionsLineGraph',- resultCustomizationBy: 'value',- showAlertThresholdLines: false,- showLegend: false,- showPercentStackView: false,- showValuesOnSeries: false,- smoothingIntervals: 1,- yAxisScaleType: 'linear',- },- action: {- days: ['2025-01-19T00:00:00Z', '2025-01-26T00:00:00Z'],- id: '$web_vitals',- type: 'events',- order: 2,- name: '$web_vitals',- custom_name: 'CLS',- math: 'p90',- math_property: '$web_vitals_CLS_value',- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 2,},{data: [1808.1, 1808.1],@@ -171,45 +57,7 @@ export const listWebVitalsAPIResponse = {days: ['2025-01-19', '2025-01-26'],count: 1808.1,label: '$web_vitals',- filter: {- insight: 'TRENDS',- properties: [- {- key: '$pathname',- label: null,- operator: 'exact',- type: 'event',- value: ['/project/1/web/web-vitals'],- },- ],- filter_test_accounts: false,- date_to: '2025-02-01T23:59:59.999999Z',- date_from: '2025-01-25T00:00:00Z',- entity_type: 'events',- interval: 'week',- aggregationAxisFormat: 'numeric',- display: 'ActionsLineGraph',- resultCustomizationBy: 'value',- showAlertThresholdLines: false,- showLegend: false,- showPercentStackView: false,- showValuesOnSeries: false,- smoothingIntervals: 1,- yAxisScaleType: 'linear',- },- action: {- days: ['2025-01-19T00:00:00Z', '2025-01-26T00:00:00Z'],- id: '$web_vitals',- type: 'events',- order: 3,- name: '$web_vitals',- custom_name: 'FCP',- math: 'p90',- math_property: '$web_vitals_FCP_value',- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 3,},],timezone: 'UTC',diff --git a/frontend/src/toolbar/shared/web-vitals/webVitalsToolbarLogic.ts b/frontend/src/toolbar/shared/web-vitals/webVitalsToolbarLogic.tsindex cfd1724f7459..6fed1047367c 100644--- a/frontend/src/toolbar/shared/web-vitals/webVitalsToolbarLogic.ts+++ b/frontend/src/toolbar/shared/web-vitals/webVitalsToolbarLogic.ts@@ -17,11 +17,14 @@ export type WebVitalsMetrics = Record<WebVitalsMetric, number | null | undefined// It returns this and much more, but we only care about the metricsexport type WebVitalsMetricsResponse = {results: {- action: { custom_name: WebVitalsMetric }+ order: numberdata: [number, number] // We care about the second value, last one from the week}[]}+// The series order of the `/web_vitals` query in `posthog/api/web_vitals.py`. Each row's `order` indexes it.+const WEB_VITALS_SERIES_ORDER: WebVitalsMetric[] = ['INP', 'LCP', 'CLS', 'FCP']+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface webVitalsToolbarLogicValues {posthog: PostHog | null // toolbarConfigLogic@@ -129,11 +132,14 @@ export const webVitalsToolbarLogic = kea<webVitalsToolbarLogicType>([}const json = result.data+ const metricValue = (metric: WebVitalsMetric): number | null =>+ json.results.find((row) => row.order === WEB_VITALS_SERIES_ORDER.indexOf(metric))?.data[1] ??+ nullreturn {- LCP: json.results.find((result) => result.action.custom_name === 'LCP')?.data[1] ?? null,- FCP: json.results.find((result) => result.action.custom_name === 'FCP')?.data[1] ?? null,- CLS: json.results.find((result) => result.action.custom_name === 'CLS')?.data[1] ?? null,- INP: json.results.find((result) => result.action.custom_name === 'INP')?.data[1] ?? null,+ LCP: metricValue('LCP'),+ FCP: metricValue('FCP'),+ CLS: metricValue('CLS'),+ INP: metricValue('INP'),}},},diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 6f42f5484a12..7be14374226b 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -3581,9 +3581,6 @@ export interface TrendAPIResponse<ResultType = TrendResult[]> {}export interface TrendResult {- /** Series entity. `null` for formula results, which aren't backed by a single entity. */- action: ActionFilter | null- actions?: ActionFilter[]count: numberdata: number[]days: string[]@@ -3597,10 +3594,8 @@ export interface TrendResult {compare?: booleanpersons_urls?: { url: string }[]persons?: Person- filter?: TrendsFilterType- /** Series order set by the query runner: the action order for plain series, or the- * formula index for formula results (uniform across a formula's breakdown rows).- * Unlike `action.order`, this is always populated — formula results carry `action: null`. */+ /** Series order set by the query runner: the series index for plain series, or the+ * formula index for formula results (uniform across a formula's breakdown rows). */order?: number/** Slope graph only: whether the last bucket is the current, still-accumulating period. Set by* SlopeGraphTrendsQueryRunner so the insight and MCP dash the provisional end identically. */@@ -5480,7 +5475,6 @@ export type GraphDataset = Partial<| 'breakdown_value'| 'persons_urls'| 'persons'- | 'filter'>> & {/** Used in filtering out visibility of datasets. Set internally by chart.js */diff --git a/posthog/api/test/dashboards/test_dashboard.py b/posthog/api/test/dashboards/test_dashboard.pyindex 2b3979607de1..9d179770f743 100644--- a/posthog/api/test/dashboards/test_dashboard.py+++ b/posthog/api/test/dashboards/test_dashboard.py@@ -4045,6 +4045,7 @@ class TestDashboard(APIBaseTest, QueryMatchingTest):},},"resolved_date_range": ANY,+ "action_names": None,"query_status": None,"query_scan": None,"warnings": None,diff --git a/posthog/api/web_vitals.py b/posthog/api/web_vitals.pyindex 31d8c552dd86..9c0d06da3e30 100644--- a/posthog/api/web_vitals.py+++ b/posthog/api/web_vitals.py@@ -43,6 +43,7 @@ class WebVitalsViewSet(TeamAndOrgViewSetMixin, viewsets.GenericViewSet):"properties": [{"type": "event", "key": "$pathname", "operator": "is_cleaned_path_exact", "value": [pathname]}],+ # The toolbar's webVitalsToolbarLogic.ts finds each metric by its row's `order`, so keep this order"series": [{"kind": "EventsNode",diff --git a/posthog/caching/calculate_results.py b/posthog/caching/calculate_results.pyindex acec9e39ccdf..d36311df39bd 100644--- a/posthog/caching/calculate_results.py+++ b/posthog/caching/calculate_results.py@@ -173,6 +173,7 @@ def calculate_for_query_based_insight(types=getattr(process_response, "types", None),resolved_date_range=_model_field_as_dict(process_response, "resolved_date_range"),resolved_compare_date_range=_model_field_as_dict(process_response, "resolved_compare_date_range"),+ action_names=getattr(process_response, "action_names", None),query_scan=_model_field_as_dict(process_response, "query_scan"),warnings=_model_list_field_as_dicts(process_response, "warnings"),)@@ -198,6 +199,7 @@ def calculate_for_query_based_insight(types=response.get("types"),resolved_date_range=response.get("resolved_date_range"),resolved_compare_date_range=response.get("resolved_compare_date_range"),+ action_names=response.get("action_names"),query_scan=response.get("query_scan"),warnings=response.get("warnings"),)diff --git a/posthog/caching/insight_result.py b/posthog/caching/insight_result.pyindex 24b2ed219a0b..d7b6f73bf52e 100644--- a/posthog/caching/insight_result.py+++ b/posthog/caching/insight_result.py@@ -23,6 +23,7 @@ class InsightResult:# ResolvedDateRangeResponse-shaped dicts — the fields carry model_dump outputresolved_date_range: Optional[dict] = Noneresolved_compare_date_range: Optional[dict] = None+ action_names: Optional[dict[str, str]] = None# A QueryScanSummary dict. The insight serializer puts the stored analysis on it.query_scan: Optional[dict] = Nonewarnings: Optional[list] = Nonediff --git a/posthog/hogql_queries/query_runner.py b/posthog/hogql_queries/query_runner.pyindex f1a20468a6e7..ea089421bd13 100644--- a/posthog/hogql_queries/query_runner.py+++ b/posthog/hogql_queries/query_runner.py@@ -43,6 +43,9 @@ from posthog.schema import (ActorsPropertyTaxonomyQuery,ActorsQuery,BreakdownType,+ CachedLifecycleQueryResponse,+ CachedStickinessQueryResponse,+ CachedTrendsQueryResponse,CacheMissResponse,CalendarHeatmapQuery,ChartDisplayType,@@ -66,6 +69,7 @@ from posthog.schema import (InsightActorsQuery,InsightActorsQueryOptions,LifecycleQuery,+ LifecycleQueryResponse,MarketingAnalyticsAggregatedQuery,MarketingAnalyticsSearchQuery,MarketingAnalyticsTableQuery,@@ -105,12 +109,14 @@ from posthog.schema import (SessionsQuery,SessionsTimelineQuery,StickinessQuery,+ StickinessQueryResponse,SuggestedQuestionsQuery,TeamTaxonomyQuery,TraceNeighborsQuery,TraceQuery,TracesQuery,TrendsQuery,+ TrendsQueryResponse,UsageMetricsQuery,VectorSearchQuery,WebAgentAnalyticsQuery,@@ -185,6 +191,7 @@ from posthog.hogql_queries.utils.breakdowns import has_multi_breakdown, has_singfrom posthog.hogql_queries.utils.entities import every_warehouse_series_reads_flag_calls, has_data_warehouse_nodefrom posthog.hogql_queries.utils.event_usage import log_event_usage_from_query_metadatafrom posthog.hogql_queries.utils.properties import has_any_property_filters+from posthog.hogql_queries.utils.result_series import get_response_action_namesfrom posthog.hogql_queries.validation.validation import (QueryValidationContext,QueryValidationRule,@@ -2141,7 +2148,9 @@ class QueryRunner(ABC, Generic[Q, R, CR]):def calculate(self) -> R:self.validate()- return self._calculate()+ response = self._calculate()+ self._fill_action_names(response)+ return responsedef validate(self) -> None:run_validation_rules(self.validators(), self.validation_context)@@ -2294,6 +2303,7 @@ class QueryRunner(ABC, Generic[Q, R, CR]):if isinstance(cached_response, CachedResponse):self._fill_cached_result_order(cached_response)+ self._fill_action_names(cached_response)# Apply current query's custom_name values to cached response# (custom_name is excluded from cache key, so cached values may be stale)cached_response, custom_names_modified = self.apply_series_custom_names(cached_response)@@ -3336,6 +3346,25 @@ class QueryRunner(ABC, Generic[Q, R, CR]):if isinstance(action, dict) and isinstance(action.get("order"), int):result["order"] = action["order"]+ def _fill_action_names(self, response: object) -> None:+ """Set `action_names` on a trends, stickiness or lifecycle response that lacks it.++ This runs on a fresh calculation and on a cache hit. A response cached before the runners returned+ `action_names` carries the names only on each row's `action`, which readers no longer use.+ """+ if not isinstance(+ response,+ TrendsQueryResponse+ | StickinessQueryResponse+ | LifecycleQueryResponse+ | CachedTrendsQueryResponse+ | CachedStickinessQueryResponse+ | CachedLifecycleQueryResponse,+ ):+ return+ if response.action_names is None:+ response.action_names = get_response_action_names(self.team, self.query.model_dump(mode="json"))+def _apply_trends_custom_names(self, cached_response: CR) -> tuple[CR, bool]:"""Apply custom_name values to TrendsQuery results (nested under action)."""series = getattr(self.query, "series", None)diff --git a/posthog/hogql_queries/utils/result_series.py b/posthog/hogql_queries/utils/result_series.pyindex 9181acd91e0d..b19d5a6a69da 100644--- a/posthog/hogql_queries/utils/result_series.py+++ b/posthog/hogql_queries/utils/result_series.py@@ -14,6 +14,7 @@ if TYPE_CHECKING:from posthog.models import TeamWAREHOUSE_NODE_KINDS = frozenset({"DataWarehouseNode", "LifecycleDataWarehouseNode"})+ACTION_NAMES_QUERY_KINDS = frozenset({"TrendsQuery", "StickinessQuery", "LifecycleQuery"})def get_result_order(result: Mapping[str, Any]) -> int:@@ -60,6 +61,18 @@ def get_action_names(team: "Team", query: Mapping[str, Any]) -> dict[int, str |return dict(Action.objects.filter(pk__in=action_ids, team__project_id=team.project_id).values_list("pk", "name"))+def get_response_action_names(team: "Team", query: Mapping[str, Any]) -> dict[str, str] | None:+ """The `action_names` a trends, stickiness or lifecycle response carries, keyed by action id.++ None for any other query. Pass an insight's stored query through `upgrade` first, because it stamps `kind` on+ legacy series nodes. An action without a name is absent, because the field only supplies names to display.+ """+ source = query.get("source") if query.get("kind") == "InsightVizNode" else query+ if not isinstance(source, Mapping) or source.get("kind") not in ACTION_NAMES_QUERY_KINDS:+ return None+ return {str(action_id): name for action_id, name in get_action_names(team, source).items() if name}++def get_series_key(node: Mapping[str, Any], action_names: Mapping[int, str | None] | None = None) -> str | None:"""The key the runners label a series with: its event, its table, its action's name, or a group's member keys.diff --git a/posthog/schema.py b/posthog/schema.pyindex 3616bf101bae..bc003124bd11 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -8354,6 +8354,14 @@ class StickinessQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )error: str | None = Field(default=None,description=(@@ -9313,6 +9321,14 @@ class TrendsQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )boxplot_data: list[BoxPlotDatum] | None = Noneerror: str | None = Field(default=None,@@ -12935,6 +12951,14 @@ class CachedLifecycleQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )cache_key: strcache_target_age: AwareDatetime | None = Nonecalculation_trigger: str | None = Field(@@ -15456,6 +15480,14 @@ class CachedStickinessQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )cache_key: strcache_target_age: AwareDatetime | None = Nonecalculation_trigger: str | None = Field(@@ -16118,6 +16150,14 @@ class CachedTrendsQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )boxplot_data: list[BoxPlotDatum] | None = Nonecache_key: strcache_target_age: AwareDatetime | None = None@@ -19353,6 +19393,14 @@ class LifecycleQueryResponse(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )error: str | None = Field(default=None,description=(@@ -23907,6 +23955,14 @@ class QueryResponseAlternative60(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )boxplot_data: list[BoxPlotDatum] | None = Noneerror: str | None = Field(default=None,@@ -24151,6 +24207,14 @@ class QueryResponseAlternative65(BaseModel):model_config = ConfigDict(extra="forbid",)+ action_names: dict[str, str] | None = Field(+ default=None,+ description=(+ "The name of each action the query's series reference, keyed by action id."+ " A series saved without a `name` displays this name, because the query"+ " holds only the action's id."+ ),+ )error: str | None = Field(default=None,description=(@@ -26917,6 +26981,7 @@ class WebVitalsItem(BaseModel):action: WebVitalsItemActiondata: list[float]days: list[str]+ order: int = Field(..., description="The index of the row's series in the query.")class WebVitalsPathBreakdownQueryResponse(BaseModel):diff --git a/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.ts b/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.tsindex e22b29e30159..63074d12e4c6 100644--- a/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.ts+++ b/products/ai_observability/frontend/evaluations/overview/evaluationDetailResultsLogic.ts@@ -68,7 +68,7 @@ function breakdownCounts(response: TrendsQueryResponse): Map<string, BreakdownCoconst raw = Array.isArray(entry.breakdown_value) ? entry.breakdown_value[0] : entry.breakdown_valueconst key = String(raw ?? BREAKDOWN_NULL)const current: BreakdownCounts = byValue.get(key) ?? { days: entry.days ?? [] }- current[entry.action?.order === 1 ? 'graded' : 'result'] = entry.data ?? []+ current[entry.order === 1 ? 'graded' : 'result'] = entry.data ?? []byValue.set(key, current)}return byValuediff --git a/products/canvas/frontend/editing/blockLibrary/componentSources.ts b/products/canvas/frontend/editing/blockLibrary/componentSources.tsindex b3294108a6b1..6c1ab08b0890 100644--- a/products/canvas/frontend/editing/blockLibrary/componentSources.ts+++ b/products/canvas/frontend/editing/blockLibrary/componentSources.ts@@ -144,7 +144,7 @@ export function Trend(props: TrendProps) {const names = sql? sqlColumns: series.map((row, index) => {- const base = breakdown ? breakdownLabel(row.breakdown_value) : eventName(row.action?.id ?? events[index % events.length] ?? row.label ?? "Series");+ const base = breakdown ? breakdownLabel(row.breakdown_value) : eventName(events[row.order ?? index % events.length] ?? row.label ?? "Series");return row.compare_label === "previous" ? base + " (previous)" : base;});const previousAt = (index: number) => (sql ? comparing && index >= baseColumns.length : series[index]?.compare_label === "previous");@@ -1050,7 +1050,7 @@ const BAR_DISPLAYS = new Set(["ActionsBar", "ActionsStackedBar", "ActionsUnstackfunction seriesName(row: any, index: number): string {if (row.breakdown_value !== undefined && row.breakdown_value !== null && row.breakdown_value !== "") return breakdownLabel(row.breakdown_value);- return eventName(String(row.label ?? row.action?.name ?? "Series " + (index + 1)));+ return eventName(String(row.label ?? "Series " + (index + 1)));}function TrendsBody({ rows, display }: { rows: any[]; display: string }) {diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex e8b693471eee..2dea1d52e17a 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -2677,9 +2677,16 @@ export interface AccessControlFilterWarningApi {type?: 'access_control'}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type TrendsQueryResponseApiActionNames = { [key: string]: string } | null+export type TrendsQueryResponseApiResultsItem = { [key: string]: unknown }export interface TrendsQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: TrendsQueryResponseApiActionNamesboxplot_data?: BoxPlotDatumApi[] | null/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null@@ -4351,9 +4358,16 @@ export interface PathsV2QueryApi {version?: number | null}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type StickinessQueryResponseApiActionNames = { [key: string]: string } | null+export type StickinessQueryResponseApiResultsItem = { [key: string]: unknown }export interface StickinessQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: StickinessQueryResponseApiActionNames/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null/** Generated HogQL query. */@@ -4505,9 +4519,16 @@ export interface LifecycleFilterApi {toggledLifecycles?: LifecycleToggleApi[] | null}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type LifecycleQueryResponseApiActionNames = { [key: string]: string } | null+export type LifecycleQueryResponseApiResultsItem = { [key: string]: unknown }export interface LifecycleQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: LifecycleQueryResponseApiActionNames/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null/** Generated HogQL query. */@@ -9914,6 +9935,12 @@ export type InsightApiResolvedDateRange = {readonly date_to?: string} | null+/**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+export type InsightApiActionNames = { [key: string]: string } | null+/*** Simplified serializer to speed response times when loading large amounts of objects.*/@@ -10013,6 +10040,11 @@ export interface InsightApi {readonly types: readonly unknown[] | null/** @nullable */readonly resolved_date_range: InsightApiResolvedDateRange+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+ readonly action_names: InsightApiActionNames/** What ClickHouse read for this insight's last slow run, with the findings of its query scan. */readonly query_scan: unknown/** Warnings from the run that produced these results. A `warehouse_sync` warning means the query read a data warehouse table whose sync failed, is paused, or is overdue, so the results can be out of date. Reflects the sync state when the results were computed. Null for shared insights. */diff --git a/products/desktop/packages/api-client/src/generated.ts b/products/desktop/packages/api-client/src/generated.tsindex fb60fcdbd537..744b137660ca 100644--- a/products/desktop/packages/api-client/src/generated.ts+++ b/products/desktop/packages/api-client/src/generated.ts@@ -1967,6 +1967,7 @@ export namespace Schemas {series_label?: (string | null) | undefined;};export type TrendsQueryResponse = {+ action_names?: (Record<string, string> | null) | undefined;boxplot_data?: (Array<BoxPlotDatum> | null) | undefined;error?: (string | null) | undefined;hasMore?: (boolean | null) | undefined;@@ -3189,6 +3190,7 @@ export namespace Schemas {version: number | null;}>;export type StickinessQueryResponse = {+ action_names?: (Record<string, string> | null) | undefined;error?: (string | null) | undefined;hogql?: (string | null) | undefined;modifiers?: (HogQLQueryModifiers | null) | undefined;@@ -3295,6 +3297,7 @@ export namespace Schemas {toggledLifecycles: Array<LifecycleToggle> | null;}>;export type LifecycleQueryResponse = {+ action_names?: (Record<string, string> | null) | undefined;error?: (string | null) | undefined;hogql?: (string | null) | undefined;modifiers?: (HogQLQueryModifiers | null) | undefined;@@ -16363,6 +16366,10 @@ export namespace Schemas {date_from: string;date_to: string;}> | null;+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ */+ action_names: Record<string, string> | null;/*** What ClickHouse read for this insight's last slow run, with the findings of its query scan.*/@@ -19592,6 +19599,7 @@ export namespace Schemas {date_from: string;date_to: string;}> | null;+ action_names: Record<string, string> | null;query_scan: unknown;warnings: _InsightResultWarnings | null;_create_in_folder: string;diff --git a/products/desktop/packages/core/src/canvas/blockLibrary/componentSources.ts b/products/desktop/packages/core/src/canvas/blockLibrary/componentSources.tsindex 7783d721c174..c77616204403 100644--- a/products/desktop/packages/core/src/canvas/blockLibrary/componentSources.ts+++ b/products/desktop/packages/core/src/canvas/blockLibrary/componentSources.ts@@ -144,7 +144,7 @@ export function Trend(props: TrendProps) {const names = sql? sqlColumns: series.map((row, index) => {- const base = breakdown ? breakdownLabel(row.breakdown_value) : eventName(row.action?.id ?? events[index % events.length] ?? row.label ?? "Series");+ const base = breakdown ? breakdownLabel(row.breakdown_value) : eventName(events[row.order ?? index % events.length] ?? row.label ?? "Series");return row.compare_label === "previous" ? base + " (previous)" : base;});const previousAt = (index: number) => (sql ? comparing && index >= baseColumns.length : series[index]?.compare_label === "previous");@@ -1050,7 +1050,7 @@ const BAR_DISPLAYS = new Set(["ActionsBar", "ActionsStackedBar", "ActionsUnstackfunction seriesName(row: any, index: number): string {if (row.breakdown_value !== undefined && row.breakdown_value !== null && row.breakdown_value !== "") return breakdownLabel(row.breakdown_value);- return eventName(String(row.label ?? row.action?.name ?? "Series " + (index + 1)));+ return eventName(String(row.label ?? "Series " + (index + 1)));}function TrendsBody({ rows, display }: { rows: any[]; display: string }) {diff --git a/products/marketing_analytics/frontend/AdPerformanceOverview.stories.tsx b/products/marketing_analytics/frontend/AdPerformanceOverview.stories.tsxindex 789d8a3a0903..004f12fef46f 100644--- a/products/marketing_analytics/frontend/AdPerformanceOverview.stories.tsx+++ b/products/marketing_analytics/frontend/AdPerformanceOverview.stories.tsx@@ -173,7 +173,6 @@ export const WithTrends: Story = {? series.custom_name: marketingAnalyticsLogic.values.tileColumnSelectionreturn {- action: { ...series, type: 'data_warehouse', order: index },order: index,label: series.custom_name ?? metric,days,diff --git a/products/marketing_analytics/frontend/adPerformanceMetrics.test.ts b/products/marketing_analytics/frontend/adPerformanceMetrics.test.tsindex 06fc01ffd275..d90e825e05d5 100644--- a/products/marketing_analytics/frontend/adPerformanceMetrics.test.ts+++ b/products/marketing_analytics/frontend/adPerformanceMetrics.test.ts@@ -1,21 +1,43 @@import type { ExternalTable } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingAnalyticsLogic'import { externalAdsCostTile } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingCostTile'-import { MarketingAnalyticsColumnsSchemaNames, NodeKind, SourceMap } from '~/queries/schema/schema-general'+import { MarketingAnalyticsColumnsSchemaNames, NodeKind, SourceMap, TrendsQuery } from '~/queries/schema/schema-general'import { DataWarehouseSettingsTab, PropertyFilterType, PropertyOperator, TrendResult } from '~/types'import { adPerformanceSparklines, buildAdPerformanceTrendsQuery } from './adPerformanceMetrics'-const row = (metric: string, data: number[], days = ['2026-01-01', '2026-01-02']): TrendResult =>- ({- action: { custom_name: metric },- data,- days,- labels: days,- label: metric,- count: 0,- aggregated_value: 0,- }) as TrendResult+const SERIES_METRICS = [+ 'cost',+ 'clicks',+ 'impressions',+ 'reported_conversion',+ 'reported_conversion_value',+ 'trial started',+]++const sparklineQuery: TrendsQuery = {+ kind: NodeKind.TrendsQuery,+ series: SERIES_METRICS.map((metric) => ({+ kind: NodeKind.DataWarehouseNode,+ id: 'example_ad_stats',+ table_name: 'example_ad_stats',+ id_field: 'id',+ distinct_id_field: 'id',+ timestamp_field: 'day',+ custom_name: metric,+ })),+}++// The runner labels a warehouse series with its table, so only the series at `order` names the metric+const row = (metric: string, data: number[], days = ['2026-01-01', '2026-01-02']): TrendResult => ({+ order: SERIES_METRICS.indexOf(metric),+ data,+ days,+ labels: days,+ label: 'example_ad_stats',+ count: 0,+ aggregated_value: 0,+})const table: ExternalTable = {id: 'table-one',@@ -45,7 +67,7 @@ const table: ExternalTable = {describe('Ad performance sparklines', () => {it('sums sources by date before calculating ratios and leaves zero denominators as gaps', () => {- const metrics = adPerformanceSparklines([+ const metrics = adPerformanceSparklines(sparklineQuery, [row('cost', [10, 20]),row('cost', [90, 30]),row('clicks', [5, 0]),@@ -62,7 +84,7 @@ describe('Ad performance sparklines', () => {})it('aligns dates, preserves unknown values, and excludes attributed goals and comparison periods', () => {- const metrics = adPerformanceSparklines([+ const metrics = adPerformanceSparklines(sparklineQuery, [row('cost', [20, 10], ['2026-01-02', '2026-01-01']),row('clicks', [5, NaN]),row('trial started', [100, 200]),diff --git a/products/marketing_analytics/frontend/adPerformanceMetrics.ts b/products/marketing_analytics/frontend/adPerformanceMetrics.tsindex c857cb9ca6f0..8afda8b94809 100644--- a/products/marketing_analytics/frontend/adPerformanceMetrics.ts+++ b/products/marketing_analytics/frontend/adPerformanceMetrics.ts@@ -1,3 +1,4 @@+import { getResultSeries } from 'scenes/insights/utils/resultSeries'import type {ExternalTable,NativeSource,@@ -120,11 +121,13 @@ export function buildAdPerformanceTrendsQuery(}export function adPerformanceSparklines(+ query: TrendsQuery,results: TrendResult[]): Partial<Record<validColumnsForTiles, AdPerformanceSparkline>> {const buckets = new Map<string, Map<string, number>>()for (const row of results) {- const metric = row.action?.custom_name+ // `buildAdPerformanceTrendsQuery` names each series after the metric it reads+ const metric = getResultSeries(query, row).node?.custom_nameif (row.compare || !metric || !RAW_METRICS.some((key) => key === metric)) {continue}diff --git a/products/marketing_analytics/frontend/adPerformanceTrendsLogic.ts b/products/marketing_analytics/frontend/adPerformanceTrendsLogic.tsindex c6bb4223ec1a..047895237011 100644--- a/products/marketing_analytics/frontend/adPerformanceTrendsLogic.ts+++ b/products/marketing_analytics/frontend/adPerformanceTrendsLogic.ts@@ -45,11 +45,17 @@ export const adPerformanceTrendsLogic: LogicWrapper<adPerformanceTrendsLogicType})),selectors({sparklines: [- (s) => [s.response, s.responseLoading, s.responseError],- (response, loading, error): Partial<Record<validColumnsForTiles, AdPerformanceSparkline>> =>+ (s, p) => [s.response, s.responseLoading, s.responseError, p.query],+ (+ response,+ loading,+ error,+ query: TrendsQuery+ ): Partial<Record<validColumnsForTiles, AdPerformanceSparkline>> =>loading || error? {}: adPerformanceSparklines(+ query,((response as TrendsQueryResponse | null)?.results ?? []) as TrendResult[]),],diff --git a/products/persons/frontend/generated/api.schemas.ts b/products/persons/frontend/generated/api.schemas.tsindex e20398eb3c82..3dbce55d5f7b 100644--- a/products/persons/frontend/generated/api.schemas.ts+++ b/products/persons/frontend/generated/api.schemas.ts@@ -1607,9 +1607,16 @@ export interface BoxPlotDatumApi {series_label?: string | null}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type TrendsQueryResponseApiActionNames = { [key: string]: string } | null+export type TrendsQueryResponseApiResultsItem = { [key: string]: unknown }export interface TrendsQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: TrendsQueryResponseApiActionNamesboxplot_data?: BoxPlotDatumApi[] | null/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null@@ -3281,9 +3288,16 @@ export interface PathsV2QueryApi {version?: number | null}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type StickinessQueryResponseApiActionNames = { [key: string]: string } | null+export type StickinessQueryResponseApiResultsItem = { [key: string]: unknown }export interface StickinessQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: StickinessQueryResponseApiActionNames/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null/** Generated HogQL query. */@@ -3435,9 +3449,16 @@ export interface LifecycleFilterApi {toggledLifecycles?: LifecycleToggleApi[] | null}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type LifecycleQueryResponseApiActionNames = { [key: string]: string } | null+export type LifecycleQueryResponseApiResultsItem = { [key: string]: unknown }export interface LifecycleQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: LifecycleQueryResponseApiActionNames/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null/** Generated HogQL query. */diff --git a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.py b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.pyindex 7cc6c3e5b0bb..d266a4c8c1d6 100644--- a/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/lifecycle/test/test_lifecycle_query_runner.py@@ -1762,21 +1762,17 @@ class TestLifecycleQueryRunner(ClickhouseTestMixin, APIBaseTest):pageview_action = create_action(team=self.team, name="$pageview", event_name="$pageview")- result = (- LifecycleQueryRunner(- team=self.team,- query=LifecycleQuery(- dateRange=DateRange(date_from="2020-01-12T00:00:00Z", date_to="2020-01-19T00:00:00Z"),- interval=IntervalType.DAY,- series=[ActionsNode(id=pageview_action.pk)],- ),- )- .calculate()- .results- )+ response = LifecycleQueryRunner(+ team=self.team,+ query=LifecycleQuery(+ dateRange=DateRange(date_from="2020-01-12T00:00:00Z", date_to="2020-01-19T00:00:00Z"),+ interval=IntervalType.DAY,+ series=[ActionsNode(id=pageview_action.pk)],+ ),+ ).calculate()assertLifecycleResults(- result,+ response.results,[{"status": "dormant", "data": [0, -2, -1, 0, -2, 0, -1, 0]},{"status": "new", "data": [1, 0, 0, 1, 0, 0, 0, 0]},@@ -1784,6 +1780,7 @@ class TestLifecycleQueryRunner(ClickhouseTestMixin, APIBaseTest):{"status": "returning", "data": [1, 1, 0, 0, 0, 0, 0, 0]},],)+ assert response.action_names == {str(pageview_action.pk): "$pageview"}def test_lifecycle_trend_all_time(self):self._create_events(diff --git a/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.py b/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.pyindex 2c29c2dbe1a3..e3437f6bb548 100644--- a/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/stickiness/test/test_stickiness_query_runner.py@@ -1642,14 +1642,16 @@ class TestStickinessSeriesCustomNames(BaseTest):assert patched_response.results == expected_resultsassert was_modified is expect_modified- def test_a_cached_row_without_a_top_level_order_takes_it_from_action(self) -> None:- query = StickinessQuery(series=[EventsNode(event="$pageview"), EventsNode(event="sign up")])+ def test_a_response_cached_by_an_older_runner_reads_like_a_fresh_one(self) -> None:+ action = Action.objects.create(team=self.team, name="Signed up")+ query = StickinessQuery(series=[EventsNode(event="$pageview"), ActionsNode(id=action.id)])cached_rows = [{"label": "$pageview", "data": [3], "action": {"order": 0, "name": "$pageview"}},- {"label": "sign up", "data": [1], "action": {"order": 1, "name": "sign up"}},+ {"label": "Signed up", "data": [1], "action": {"order": 1, "name": "Signed up"}},]+ # An older runner cached rows without a top-level `order` and a response without `action_names`.with patch.object(- StickinessQueryRunner, "_calculate", return_value=StickinessQueryResponse(results=cached_rows)+ StickinessQueryRunner, "calculate", return_value=StickinessQueryResponse(results=cached_rows)):StickinessQueryRunner(query=query, team=self.team).run(execution_mode=ExecutionMode.CALCULATE_BLOCKING_ALWAYS@@ -1661,6 +1663,7 @@ class TestStickinessSeriesCustomNames(BaseTest):assert isinstance(response, CachedStickinessQueryResponse)assert [row["order"] for row in response.results] == [0, 1]+ assert response.action_names == {str(action.id): "Signed up"}class TestStickinessSeriesFanOut(BaseTest):diff --git a/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.py b/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.pyindex 67c5b0acdf1c..a8e46c46fb42 100644--- a/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.py+++ b/products/product_analytics/backend/hogql_queries/trends/test/test_trends_query_runner.py@@ -8061,6 +8061,11 @@ class TestTrendsQueryRunner(ClickhouseTestMixin, APIBaseTest):self.assertEqual(11, len(result["data"]), "Should have 11 days of data")self.assertEqual(result["count"], sum(result["data"]), "Count should equal sum of data points")+ # A series saved without a name displays the action's name from here, also inside a group.+ self.assertEqual(+ {str(page_action.id): "Page Action", str(pageview_action.id): "Pageview Action"}, response.action_names+ )+@parameterized.expand([(diff --git a/products/product_analytics/backend/presentation/insight.py b/products/product_analytics/backend/presentation/insight.pyindex 6ac90342edce..cae24ded6ed2 100644--- a/products/product_analytics/backend/presentation/insight.py+++ b/products/product_analytics/backend/presentation/insight.py@@ -2,6 +2,7 @@ import jsonimport builtinsfrom collections import defaultdictfrom collections.abc import Sequence+from copy import deepcopyfrom datetime import datetime, timedeltafrom functools import lru_cachefrom typing import Any, Union, cast@@ -83,6 +84,7 @@ from posthog.hogql_queries.apply_dashboard_filters import ()from posthog.hogql_queries.query_runner import ExecutionMode, enforce_api_queries_budgetfrom posthog.hogql_queries.refresh_policy import ComputeSurface, resolve_execution_mode+from posthog.hogql_queries.utils.result_series import get_response_action_namesfrom posthog.kafka_client.topics import KAFKA_METRICS_TIME_TO_SEE_DATAfrom posthog.models import Userfrom posthog.models.activity_logging.activity_log import (@@ -605,6 +607,11 @@ class InsightSerializer(InsightBasicSerializer):hogql = serializers.SerializerMethodField()types = serializers.SerializerMethodField()resolved_date_range = serializers.SerializerMethodField(read_only=True)+ action_names = serializers.SerializerMethodField(+ read_only=True,+ help_text="The name of each action the insight's series reference, keyed by action id. A series saved without "+ "a name displays this name.",+ )query_scan = serializers.SerializerMethodField(read_only=True,help_text="What ClickHouse read for this insight's last slow run, with the findings of its query scan.",@@ -661,6 +668,7 @@ class InsightSerializer(InsightBasicSerializer):"hogql","types","resolved_date_range",+ "action_names","query_scan","warnings","_create_in_folder",@@ -1122,6 +1130,10 @@ class InsightSerializer(InsightBasicSerializer):def get_resolved_date_range(self, insight: Insight):return self.insight_result(insight).resolved_date_range+ @extend_schema_field(serializers.DictField(child=serializers.CharField(), allow_null=True))+ def get_action_names(self, insight: Insight):+ return self.insight_result(insight).action_names+@extend_schema_field(OpenApiTypes.ANY)def get_query_scan(self, insight: Insight):# A shared insight is read from outside the project, and the scan describes the@@ -1306,6 +1318,11 @@ class InsightSerializer(InsightBasicSerializer):entry = QueryCache(team_id=insight.team_id, cache_key=expected_cache_key).lookup().entrycached_response = entry.as_full_response() if entry else Noneif cached_response:+ action_names = cached_response.get("action_names")+ if action_names is None and isinstance(insight.query, dict):+ # An entry cached before responses carried `action_names` lacks the field, and this shortcut+ # skips the runner that fills it on a cache hit.+ action_names = get_response_action_names(insight.team, upgrade(deepcopy(insight.query)))return InsightResult(result=cached_response.get("results"),has_more=cached_response.get("hasMore"),@@ -1320,6 +1337,7 @@ class InsightSerializer(InsightBasicSerializer):query_status=cached_response.get("query_status"),hogql=cached_response.get("hogql"),types=cached_response.get("types"),+ action_names=action_names,query_scan=cached_response.get("query_scan"),warnings=cached_response.get("warnings"),)diff --git a/products/product_analytics/backend/tests/api/test_insight.py b/products/product_analytics/backend/tests/api/test_insight.pyindex 86afceeefd05..b623149cd8dd 100644--- a/products/product_analytics/backend/tests/api/test_insight.py+++ b/products/product_analytics/backend/tests/api/test_insight.py@@ -69,13 +69,14 @@ from posthog.test.db_context_capturing import capture_db_queriesfrom posthog.test.insight_queries import browser_filtered_pageview_query, default_pageview_query, insight_queryfrom products.access_control.backend.models.access_control import AccessControl+from products.actions.backend.models.action import Actionfrom products.alerts.backend.models.alert import AlertConfiguration, AlertSubscription, Thresholdfrom products.dashboards.backend.facade.access import DashboardAccessMethodfrom products.dashboards.backend.models.dashboard import Dashboardfrom products.dashboards.backend.models.dashboard_tile import DashboardTile, Textfrom products.product_analytics.backend.facade.models import Insight, InsightVariablefrom products.product_analytics.backend.models.insight import InsightViewed-from products.product_analytics.backend.presentation.insight import chart_display_filter+from products.product_analytics.backend.presentation.insight import InsightSerializer, chart_display_filterfrom products.subscriptions.backend.facade.testing import (create_subscription,create_subscription_delivery,@@ -649,7 +650,10 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):# never execute the body of. A 200 alone doesn't prove this: insight_result's# broad except Exception swallows calculation crashes into a query_status error# and still renders 200, so assert the embedded result actually computed.- insight_id, _ = self.dashboard_api.create_insight({"name": "insight"})+ action = Action.objects.create(team=self.team, name="Viewed a page", steps_json=[{"event": "$pageview"}])+ query = default_pageview_query()+ query["source"]["series"] = [{"kind": "ActionsNode", "id": action.id}]+ insight_id, _ = self.dashboard_api.create_insight({"name": "insight", "query": query})sharing_config = SharingConfiguration.objects.create(team=self.team, insight_id=insight_id, enabled=True)# .json suffix returns exported_data directly, skipping exporter.html rendering@@ -662,6 +666,8 @@ class TestInsight(ClickhouseTestMixin, APIBaseTest, QueryMatchingTest):query_status = exported["insight"]["query_status"] or {}self.assertFalse(query_status.get("error"), query_status)self.assertIsNotNone(exported["insight"]["result"])+ # A shared view cannot read actions, so an action series saved without a name takes its name from here.+ self.assertEqual(exported["insight"]["action_names"], {str(action.id): "Viewed a page"})def test_shared_force_refresh_ignores_client_filter_overrides(self) -> None:# Regression: the /shared/<token> page load runs without an authenticator, so the serializer@@ -4425,6 +4431,24 @@ class TestInsightQueryScan(APIBaseTest):self.assertNotIn("query_scan", body["query_status"])+class TestInsightExportCacheShortcut(APIBaseTest):+ @patch("products.product_analytics.backend.presentation.insight.QueryCache")+ def test_an_entry_cached_without_action_names_takes_them_from_the_query(+ self, mock_query_cache: mock.MagicMock+ ) -> None:+ action = Action.objects.create(team=self.team, name="Completed checkout")+ query = default_pageview_query()+ query["source"]["series"] = [{"kind": "ActionsNode", "id": action.id}]+ insight = Insight.objects.create(team=self.team, query=query)+ # The image exporter hands over the key of an entry cached before responses carried `action_names`.+ mock_query_cache.return_value.lookup.return_value.entry.as_full_response.return_value = {"results": []}+ serializer = InsightSerializer(context={"export_cache_keys": {insight.id: f"cache_{self.team.pk}_abc123"}})++ result = serializer.insight_result(insight)++ self.assertEqual(result.action_names, {str(action.id): "Completed checkout"})++class TestInsightWarnings(APIBaseTest):WARNING = {"type": "warehouse_sync",diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex af696328e166..906649249cce 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -1493,9 +1493,16 @@ export interface AccessControlFilterWarningApi {type?: 'access_control'}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type TrendsQueryResponseApiActionNames = { [key: string]: string } | null+export type TrendsQueryResponseApiResultsItem = { [key: string]: unknown }export interface TrendsQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: TrendsQueryResponseApiActionNamesboxplot_data?: BoxPlotDatumApi[] | null/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null@@ -3167,9 +3174,16 @@ export interface PathsV2QueryApi {version?: number | null}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type StickinessQueryResponseApiActionNames = { [key: string]: string } | null+export type StickinessQueryResponseApiResultsItem = { [key: string]: unknown }export interface StickinessQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: StickinessQueryResponseApiActionNames/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null/** Generated HogQL query. */@@ -3321,9 +3335,16 @@ export interface LifecycleFilterApi {toggledLifecycles?: LifecycleToggleApi[] | null}+/**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+export type LifecycleQueryResponseApiActionNames = { [key: string]: string } | null+export type LifecycleQueryResponseApiResultsItem = { [key: string]: unknown }export interface LifecycleQueryResponseApi {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: LifecycleQueryResponseApiActionNames/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null/** Generated HogQL query. */@@ -8805,6 +8826,12 @@ export type InsightApiResolvedDateRange = {readonly date_to?: string} | null+/**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+export type InsightApiActionNames = { [key: string]: string } | null+/*** Simplified serializer to speed response times when loading large amounts of objects.*/@@ -8904,6 +8931,11 @@ export interface InsightApi {readonly types: readonly unknown[] | null/** @nullable */readonly resolved_date_range: InsightApiResolvedDateRange+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+ readonly action_names: InsightApiActionNames/** What ClickHouse read for this insight's last slow run, with the findings of its query scan. */readonly query_scan: unknown/** Warnings from the run that produced these results. A `warehouse_sync` warning means the query read a data warehouse table whose sync failed, is paused, or is overdue, so the results can be out of date. Reflects the sync state when the results were computed. Null for shared insights. */@@ -8935,6 +8967,12 @@ export type PatchedInsightApiResolvedDateRange = {readonly date_to?: string} | null+/**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+export type PatchedInsightApiActionNames = { [key: string]: string } | null+/*** Simplified serializer to speed response times when loading large amounts of objects.*/@@ -9034,6 +9072,11 @@ export interface PatchedInsightApi {readonly types?: readonly unknown[] | null/** @nullable */readonly resolved_date_range?: PatchedInsightApiResolvedDateRange+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+ readonly action_names?: PatchedInsightApiActionNames/** What ClickHouse read for this insight's last slow run, with the findings of its query scan. */readonly query_scan?: unknown/** Warnings from the run that produced these results. A `warehouse_sync` warning means the query read a data warehouse table whose sync failed, is paused, or is overdue, so the results can be out of date. Reflects the sync state when the results were computed. Null for shared insights. */diff --git a/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewData.test.ts b/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewData.test.tsindex 10a46517151c..2ba8a736528f 100644--- a/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewData.test.ts+++ b/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewData.test.ts@@ -6,18 +6,17 @@ import type { TrendResult } from '~/types'import { PREVIEW_SERIES_LIMIT, deriveChartPreview } from './chartPreviewData'import type { ChartPreviewData } from './chartPreviewData'-function series(overrides: Partial<TrendResult> & { math?: string }): TrendResult {- const { math = 'total', ...rest } = overrides+function series(overrides: Partial<TrendResult>): TrendResult {return {- action: { id: '$pageview', type: 'events', order: 0, math } as TrendResult['action'],+ order: 0,label: '$pageview',data: [1, 2, 3, 4],days: ['2026-01-01', '2026-01-02', '2026-01-03', '2026-01-04'],labels: ['1-Jan', '2-Jan', '3-Jan', '4-Jan'],count: 10,aggregated_value: 0,- ...rest,- } as TrendResult+ ...overrides,+ }}function query(display: ChartDisplayType, overrides: Partial<TrendsQuery> = {}): TrendsQuery {@@ -53,8 +52,10 @@ describe('deriveChartPreview', () => {it.each(['total', 'sum'])('derives a %s total from raw buckets', (math) => {const preview = deriveChartPreview(ChartDisplayType.BoldNumber,- query(ChartDisplayType.ActionsLineGraph),- response([series({ math })])+ query(ChartDisplayType.ActionsLineGraph, {+ series: [{ kind: NodeKind.EventsNode, event: '$pageview', math: math as MathType }],+ }),+ response([series({})]))expect(results(preview)[0]).toMatchObject({ data: [], aggregated_value: 10 })})@@ -74,7 +75,7 @@ describe('deriveChartPreview', () => {series: [{ kind: NodeKind.EventsNode, event: '$pageview', math: math as MathType }],...queryOverrides,}),- response([series({ math })])+ response([series({})]))).toBeNull()})@@ -152,9 +153,7 @@ describe('deriveChartPreview', () => {breakdownFilter: { breakdown: '$browser', breakdown_type: 'event' },})const browsers = Array.from({ length: PREVIEW_SERIES_LIMIT - 2 }, (_, index) => `browser ${index}`)- const rows = [0, 1].flatMap((order) =>- browsers.map((browser) => series({ action: null, order, breakdown_value: browser } as Partial<TrendResult>))- )+ const rows = [0, 1].flatMap((order) => browsers.map((browser) => series({ order, breakdown_value: browser })))expect(results(deriveChartPreview(ChartDisplayType.ActionsLineGraph, source, response(rows)))).toHaveLength(PREVIEW_SERIES_LIMIT@@ -221,7 +220,7 @@ describe('deriveChartPreview', () => {})it('derives time series tiles from the remembered time series when only a total value is loaded', () => {- const loaded = response([series({ math: 'dau', data: [], aggregated_value: 42 })])+ const loaded = response([series({ data: [], aggregated_value: 42 })])const remembered = response([series({ compare_label: CompareLabelType.Current }),series({ compare_label: CompareLabelType.Previous }),diff --git a/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.ts b/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.tsindex 335f5deed112..90f50b613dfd 100644--- a/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.ts+++ b/products/product_analytics/frontend/insights/chartAlternatives/chartPreviewsLogic.test.ts@@ -23,7 +23,7 @@ const FIRST_REFRESH = '2026-01-01T00:00:00.000Z'const SECOND_REFRESH = '2026-01-01T00:01:00.000Z'const timeSeriesRow = {- action: { id: '$pageview', type: 'events', order: 0, math: 'total' },+ order: 0,label: '$pageview',data: [1, 2, 3],days: ['2026-01-01', '2026-01-02', '2026-01-03'],@@ -92,7 +92,7 @@ describe('chartPreviewsLogic', () => {breakdownFilter: { breakdowns: [{ property: '$browser', type: 'event' }] },})insightDataLogic(insightProps).actions.setInsightData({- results: [{ ...timeSeriesRow, action: { ...timeSeriesRow.action, math: BaseMathType.UniqueUsers } }],+ results: [timeSeriesRow],hasMore: true,last_refresh: FIRST_REFRESH,})diff --git a/products/product_analytics/frontend/insights/home/homeTabSampleData.ts b/products/product_analytics/frontend/insights/home/homeTabSampleData.tsindex a5d475546d4f..263653341cd2 100644--- a/products/product_analytics/frontend/insights/home/homeTabSampleData.ts+++ b/products/product_analytics/frontend/insights/home/homeTabSampleData.ts@@ -22,7 +22,6 @@ export function getHomeTabSampleStatData(metric: HomeTabMetricKey, query: Trendsconst step = interval === 'quarter' ? 3 : 1const end = (dateStringToDayJs(query.dateRange?.date_to ?? null) ?? dayjs()).startOf(unit)const days = values.map((_, index) => end.subtract((values.length - index) * step, unit).toISOString())- const series = query.series[0]return {results: Array.from({ length: query.compareFilter?.compare ? 2 : 1 }, (_, index): TrendResult => {@@ -30,13 +29,7 @@ export function getHomeTabSampleStatData(metric: HomeTabMetricKey, query: Trendsconst total = data.reduce((sum, value) => sum + value, 0)const count = metric === 'session_duration' || metric === 'daily_active_users' ? total / data.length : totalreturn {- action: {- id: series.kind === NodeKind.EventsNode ? (series.event ?? null) : null,- type: 'events',- order: 0,- name: 'Sample',- math: series.math,- },+ order: 0,label: 'Sample',count,aggregated_value: count,@@ -119,13 +112,7 @@ export function getHomeTabSampleData(}const results: TrendResult[] = breakdowns.map(([label, count]) => ({- action: {- id: source.series[0].kind === NodeKind.EventsNode ? (source.series[0].event ?? null) : null,- type: 'events',- order: 0,- name: 'Sample',- math: source.series[0].math,- },+ order: 0,label,breakdown_value: label,count,diff --git a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsxindex ef557da34902..64cb407c601c 100644--- a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx+++ b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx@@ -38,7 +38,6 @@ type InsightSeriesMetaBase = {compare_label?: SeriesDatum['compare_label']days?: string[]order?: number- filter?: SeriesDatum['filter']}type InsightSeriesTooltipEntry<Meta extends InsightSeriesMetaBase> = TooltipContext<Meta>['seriesData'][number]@@ -263,7 +262,6 @@ export function InsightSeriesTooltip<Meta extends InsightSeriesMetaBase>({breakdown_value: meta.breakdown_value ?? undefined,compare_label: meta.compare_label,date_label: meta.days?.[context.dataIndex],- filter: meta.filter,})})return mdiff --git a/products/product_analytics/frontend/insights/shared/InsightTooltip/InsightTooltip.stories.tsx b/products/product_analytics/frontend/insights/shared/InsightTooltip/InsightTooltip.stories.tsxindex 092a0dc22c88..f85873a7f900 100644--- a/products/product_analytics/frontend/insights/shared/InsightTooltip/InsightTooltip.stories.tsx+++ b/products/product_analytics/frontend/insights/shared/InsightTooltip/InsightTooltip.stories.tsx@@ -6,7 +6,7 @@ import { humanFriendlyNumber } from 'lib/utils/numbers'import { cohortsModel } from '~/models/cohortsModel'import { NodeKind } from '~/queries/schema/schema-general'-import { BaseMathType, InsightType } from '~/types'+import { BaseMathType } from '~/types'import { InsightTooltip } from './InsightTooltip'import { InsightTooltipProps } from './insightTooltipUtils'@@ -106,17 +106,6 @@ export const Columns: Story = {label: '$autocapture - Safari',color: '#42827e',count: 0,- filter: {- insight: InsightType.TRENDS,- properties: [],- filter_test_accounts: true,- date_to: '2025-06-05T23:59:59.999999Z',- date_from: '2025-05-29T00:00:00Z',- entity_type: 'events',- interval: 'day',- breakdown: '$browser',- breakdown_type: 'event',- },},{id: 1,@@ -140,17 +129,6 @@ export const Columns: Story = {label: '$pageview - Chrome',color: '#1d4aff',count: 0,- filter: {- insight: InsightType.TRENDS,- properties: [],- filter_test_accounts: true,- date_to: '2025-06-05T23:59:59.999999Z',- date_from: '2025-05-29T00:00:00Z',- entity_type: 'events',- interval: 'day',- breakdown: '$browser',- breakdown_type: 'event',- },},{id: 2,@@ -174,17 +152,6 @@ export const Columns: Story = {label: '$pageview - Safari',color: '#621da6',count: 0,- filter: {- insight: InsightType.TRENDS,- properties: [],- filter_test_accounts: true,- date_to: '2025-06-05T23:59:59.999999Z',- date_from: '2025-05-29T00:00:00Z',- entity_type: 'events',- interval: 'day',- breakdown: '$browser',- breakdown_type: 'event',- },},],},diff --git a/products/product_analytics/frontend/insights/shared/InsightTooltip/insightTooltipUtils.tsx b/products/product_analytics/frontend/insights/shared/InsightTooltip/insightTooltipUtils.tsxindex 6ed89eab9161..c892aa399bcb 100644--- a/products/product_analytics/frontend/insights/shared/InsightTooltip/insightTooltipUtils.tsx+++ b/products/product_analytics/frontend/insights/shared/InsightTooltip/insightTooltipUtils.tsx@@ -10,7 +10,7 @@ import type { ResultSeries } from 'scenes/insights/utils/resultSeries'import { cohortsModel } from '~/models/cohortsModel'import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'import { BreakdownFilter, DateRange } from '~/queries/schema/schema-general'-import { CompareLabelType, FilterType, IntervalType } from '~/types'+import { CompareLabelType, IntervalType } from '~/types'export interface SeriesDatum {id: number // determines order that series will be displayed in@@ -25,7 +25,6 @@ export interface SeriesDatum {dotted?: booleancolor?: stringcount: number- filter?: FilterTypehideTooltip?: booleananomalyScore?: number | null}diff --git a/products/product_analytics/frontend/insights/shared/InsightsTable/InsightsTable.tsx b/products/product_analytics/frontend/insights/shared/InsightsTable/InsightsTable.tsxindex 0be5e5976361..b429b7df0249 100644--- a/products/product_analytics/frontend/insights/shared/InsightsTable/InsightsTable.tsx+++ b/products/product_analytics/frontend/insights/shared/InsightsTable/InsightsTable.tsx@@ -98,6 +98,7 @@ export function InsightsTable({getTrendsHidden,insightData,querySource,+ actionNames,} = useValues(trendsDataLogic(insightProps))const { toggleResultHidden, toggleAllResultsHidden } = useActions(trendsDataLogic(insightProps))const {@@ -213,7 +214,7 @@ export function InsightsTable({) : (<SeriesColumnItemitem={item}- series={getResultSeries(querySource, item)}+ series={getResultSeries(querySource, item, actionNames)}showCountedByTag={showCountedByTag}canEditSeriesNameInline={canEditSeriesNameInline}seriesNameTooltip={seriesNameTooltip}@@ -248,8 +249,8 @@ export function InsightsTable({return compareFn()(formatItemBreakdownLabel!(a), formatItemBreakdownLabel!(b))}- const labelA = getResultSeriesName(getResultSeries(querySource, a)) || a.label || ''- const labelB = getResultSeriesName(getResultSeries(querySource, b)) || b.label || ''+ const labelA = getResultSeriesName(getResultSeries(querySource, a, actionNames)) || a.label || ''+ const labelB = getResultSeriesName(getResultSeries(querySource, b, actionNames)) || b.label || ''return labelA.localeCompare(labelB)},})diff --git a/products/product_analytics/frontend/insights/shared/InsightsTable/insightsTableDataLogic.test.ts b/products/product_analytics/frontend/insights/shared/InsightsTable/insightsTableDataLogic.test.tsindex d6e6f573ab0f..d9a14a3764e5 100644--- a/products/product_analytics/frontend/insights/shared/InsightsTable/insightsTableDataLogic.test.ts+++ b/products/product_analytics/frontend/insights/shared/InsightsTable/insightsTableDataLogic.test.ts@@ -300,17 +300,6 @@ describe('insightsTableDataLogic', () => {let builtDataNodeLogic: ReturnType<typeof dataNodeLogic.build>const makeCompareResult = (overrides: Partial<IndexedTrendResult>): Partial<IndexedTrendResult> => ({- action: {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: null,- math_property: null,- math_group_type_index: null,- properties: {},- } as any,order: 0,label: '$pageview',count: 100,@@ -399,14 +388,12 @@ describe('insightsTableDataLogic', () => {makeCompareResult({compare_label: CompareLabelType.Current,compare: true,- action: { order: 1, id: '$autocapture', name: '$autocapture' } as any,order: 1,label: '$autocapture',}),makeCompareResult({compare_label: CompareLabelType.Previous,compare: true,- action: { order: 1, id: '$autocapture', name: '$autocapture' } as any,order: 1,label: '$autocapture',count: 60,@@ -561,7 +548,6 @@ describe('insightsTableDataLogic', () => {data: number[]): Partial<IndexedTrendResult> =>makeCompareResult({- action: { order, id: '$pageview', name: '$pageview' } as any,order,compare: true,compare_label,diff --git a/products/product_analytics/frontend/insights/shared/hasTrendsChartData.test.ts b/products/product_analytics/frontend/insights/shared/hasTrendsChartData.test.tsindex f9eaf9691e1f..267a4177171d 100644--- a/products/product_analytics/frontend/insights/shared/hasTrendsChartData.test.ts+++ b/products/product_analytics/frontend/insights/shared/hasTrendsChartData.test.ts@@ -4,7 +4,7 @@ import { hasTrendsChartData } from './hasTrendsChartData'function makeResult(overrides: Partial<IndexedTrendResult> = {}): IndexedTrendResult {return {- action: null,+ order: 0,count: 0,data: [],days: [],diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.stories.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.stories.tsxindex 19eda9e9d6a2..60695f541176 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.stories.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.stories.tsx@@ -73,18 +73,6 @@ function StickinessBarChartStory({ insightFixture }: { insightFixture: any }): Jconst STICKINESS_DAYS = [1, 2, 3, 4, 5, 6, 7, 8]const STICKINESS_LABELS = STICKINESS_DAYS.map((d) => (d === 1 ? '1 day' : `${d} days`))-const ACTION = {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: null,- math_property: null,- math_group_type_index: null,- properties: {},-}-function buildStickinessInsight({display,id,@@ -120,19 +108,13 @@ function buildStickinessInsight({dashboards: [],dashboard_tiles: [],result: results.map((r) => ({- action: ACTION,+ order: 0,label: r.label,count: r.count,data: r.data,labels: STICKINESS_LABELS,days: STICKINESS_DAYS,breakdown_value: r.breakdown_value,- filter: {- date_from: '2022-03-08T00:00:00Z',- insight: 'STICKINESS',- interval: 'day',- shown_as: 'Stickiness',- },})),query: {kind: 'InsightVizNode',diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsxindex dbf027d8cde5..b051d4bca8a0 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.tsx@@ -64,6 +64,7 @@ export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.EltrendsFilter,labelGroupType,hasPersonsModal,+ actionNames,querySource,showValuesOnSeries,isSingleSeriesDefinition,@@ -74,8 +75,8 @@ export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.Elconst { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)const buildMeta = useCallback(- (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource),- [querySource]+ (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource, actionNames),+ [querySource, actionNames])const seriesIdentification = useMemo(@@ -87,6 +88,7 @@ export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.El(r: IndexedTrendResult): string =>getTrendsSeriesDisplayLabel(r, {querySource,+ actionNames,breakdownFilter,cohorts: allCohorts?.results,formatPropertyValueForDisplay,@@ -95,6 +97,7 @@ export function StickinessBarChart({ context }: StickinessBarChartProps): JSX.El}),[querySource,+ actionNames,breakdownFilter,allCohorts?.results,formatPropertyValueForDisplay,diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsxindex c89be9ff25de..b3366b30de22 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.tsx@@ -67,6 +67,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.stickinessFilter,labelGroupType,hasPersonsModal,+ actionNames,querySource,showValuesOnSeries,isSingleSeriesDefinition,@@ -77,8 +78,8 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.const { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)const buildMeta = useCallback(- (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource),- [querySource]+ (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource, actionNames),+ [querySource, actionNames])const seriesIdentification = useMemo(@@ -91,6 +92,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.(r: IndexedTrendResult): string =>getTrendsSeriesDisplayLabel(r, {querySource,+ actionNames,breakdownFilter,cohorts: allCohorts?.results,formatPropertyValueForDisplay,@@ -99,6 +101,7 @@ export function StickinessLineChart({ context }: StickinessLineChartProps): JSX.}),[querySource,+ actionNames,breakdownFilter,allCohorts?.results,formatPropertyValueForDisplay,diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsxindex 804f4ec8f15d..89f28916c023 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/handleStickinessChartClick.test.tsx@@ -1,7 +1,7 @@import { render } from '@testing-library/react'import { NodeKind } from '~/queries/schema/schema-general'-import { CompareLabelType, EntityTypes } from '~/types'+import { CompareLabelType } from '~/types'import type { IndexedTrendResult } from 'products/product_analytics/frontend/insights/trends/types'@@ -16,13 +16,7 @@ function makeTrendResult(overrides: Partial<IndexedTrendResult> = {}): IndexedTrid: 0,seriesIndex: 0,colorIndex: 0,- action: {- id: '$pageview',- type: EntityTypes.EVENTS,- order: 0,- name: '$pageview',- days: daysAsType([1, 2, 3]),- },+ order: 0,label: '$pageview',count: 10,aggregated_value: 10,@@ -172,10 +166,9 @@ describe('handleStickinessChartClick', () => {expect(openPersonsModal).not.toHaveBeenCalled()})- it('uses trendResult.days[index] as fallback when action.days is missing', () => {+ it('reads the day from trendResult.days[index]', () => {const openPersonsModal = jest.fn()const trendResult = makeTrendResult({- action: { id: '$pageview', type: EntityTypes.EVENTS, order: 0, name: '$pageview' },days: daysAsType([10, 20, 30]),})const deps = makeDeps({ openPersonsModal, indexedResults: [trendResult] })@@ -185,11 +178,10 @@ describe('handleStickinessChartClick', () => {expect(openPersonsModal.mock.calls[0][0].query).toMatchObject({ day: 30 })})- it('no-ops when neither action.days nor trendResult.days can supply a day', () => {+ it('no-ops when trendResult.days cannot supply a day', () => {const openPersonsModal = jest.fn()const onDataPointClick = jest.fn()const trendResult = makeTrendResult({- action: { id: '$pageview', type: EntityTypes.EVENTS, order: 0, name: '$pageview' },days: [],})const deps = makeDeps({diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsxindex bd5c6348bdbb..6c546a8e1ce6 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.stories.tsx@@ -173,19 +173,6 @@ const PREVIOUS_LABELS = ['3-Jul-2023',]-const ACTION = {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},-}-// Compare-against-previous in unstacked-bar mode renders two bars per band (previous, current).// Pre-fix, annotations anchored to the band center landed on the previous-period bar.// The numbers below are intentionally distinct so the snapshot diffs the tall current bars@@ -210,7 +197,7 @@ const COMPARE_BAR_INSIGHT = {dashboard_tiles: [],result: [{- action: ACTION,+ order: 0,label: '$pageview',count: 700,data: [120, 95, 110, 130, 140, 80, 125],@@ -218,16 +205,9 @@ const COMPARE_BAR_INSIGHT = {days: CURRENT_DAYS,compare: true,compare_label: 'current',- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsUnstackedBar',- insight: 'TRENDS',- interval: 'day',- },},{- action: ACTION,+ order: 0,label: '$pageview',count: 420,data: [70, 60, 65, 75, 80, 50, 70],@@ -235,13 +215,6 @@ const COMPARE_BAR_INSIGHT = {days: PREVIOUS_DAYS,compare: true,compare_label: 'previous',- filter: {- date_from: '2023-06-27T00:00:00Z',- date_to: '2023-07-03T23:59:59Z',- display: 'ActionsUnstackedBar',- insight: 'TRENDS',- interval: 'day',- },},],query: {@@ -284,7 +257,7 @@ const AGGREGATED_COMPARE_BREAKDOWN_INSIGHT = {dashboard_tiles: [],result: [{- action: ACTION,+ order: 0,label: 'Chrome',count: 0,aggregated_value: 900,@@ -294,16 +267,9 @@ const AGGREGATED_COMPARE_BREAKDOWN_INSIGHT = {breakdown_value: 'Chrome',compare: true,compare_label: 'current',- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsBarValue',- insight: 'TRENDS',- interval: 'day',- },},{- action: ACTION,+ order: 0,label: 'Chrome',count: 0,aggregated_value: 600,@@ -313,16 +279,9 @@ const AGGREGATED_COMPARE_BREAKDOWN_INSIGHT = {breakdown_value: 'Chrome',compare: true,compare_label: 'previous',- filter: {- date_from: '2023-06-27T00:00:00Z',- date_to: '2023-07-03T23:59:59Z',- display: 'ActionsBarValue',- insight: 'TRENDS',- interval: 'day',- },},{- action: ACTION,+ order: 0,label: 'Safari',count: 0,aggregated_value: 500,@@ -332,16 +291,9 @@ const AGGREGATED_COMPARE_BREAKDOWN_INSIGHT = {breakdown_value: 'Safari',compare: true,compare_label: 'current',- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsBarValue',- insight: 'TRENDS',- interval: 'day',- },},{- action: ACTION,+ order: 0,label: 'Safari',count: 0,aggregated_value: 350,@@ -351,13 +303,6 @@ const AGGREGATED_COMPARE_BREAKDOWN_INSIGHT = {breakdown_value: 'Safari',compare: true,compare_label: 'previous',- filter: {- date_from: '2023-06-27T00:00:00Z',- date_to: '2023-07-03T23:59:59Z',- display: 'ActionsBarValue',- insight: 'TRENDS',- interval: 'day',- },},],query: {@@ -405,68 +350,40 @@ const PERCENT_STACK_BREAKDOWN_INSIGHT = {dashboard_tiles: [],result: [{- action: ACTION,+ order: 0,label: 'Chrome',count: 14000,data: [4000, 3500, 3000, 1500, 1200, 600, 200],labels: CURRENT_LABELS,days: CURRENT_DAYS,breakdown_value: 'Chrome',- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsBar',- insight: 'TRENDS',- interval: 'day',- },},{- action: ACTION,+ order: 0,label: 'Safari',count: 6500,data: [400, 800, 1500, 1800, 1500, 400, 100],labels: CURRENT_LABELS,days: CURRENT_DAYS,breakdown_value: 'Safari',- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsBar',- insight: 'TRENDS',- interval: 'day',- },},{- action: ACTION,+ order: 0,label: 'Firefox',count: 2200,data: [200, 250, 300, 500, 500, 350, 100],labels: CURRENT_LABELS,days: CURRENT_DAYS,breakdown_value: 'Firefox',- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsBar',- insight: 'TRENDS',- interval: 'day',- },},{- action: ACTION,+ order: 0,label: 'Edge',count: 900,data: [80, 120, 150, 200, 200, 100, 50],labels: CURRENT_LABELS,days: CURRENT_DAYS,breakdown_value: 'Edge',- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsBar',- insight: 'TRENDS',- interval: 'day',- },},],query: {@@ -496,7 +413,7 @@ export const PercentStackBreakdown: Story = {// 50 breakdown rows — verifies all bars are visible and the container grows rather than clipping.// If TrendsInsight--ActionsBarValue loses its max-height:none override, only ~20 rows show up.const BAR_VALUE_50_BREAKDOWNS = Array.from({ length: 50 }, (_, i) => ({- action: ACTION,+ order: 0,label: `/blog/post-${String(i + 1).padStart(2, '0')}`,count: 0,aggregated_value: Math.max(5, Math.round(9000 / (i + 1))),@@ -504,13 +421,6 @@ const BAR_VALUE_50_BREAKDOWNS = Array.from({ length: 50 }, (_, i) => ({labels: [],days: [],breakdown_value: `/blog/post-${String(i + 1).padStart(2, '0')}`,- filter: {- date_from: '2023-07-04T00:00:00Z',- date_to: '2023-07-10T23:59:59Z',- display: 'ActionsBarValue',- insight: 'TRENDS',- interval: 'day',- },}))const BAR_VALUE_50_BREAKDOWNS_INSIGHT = {diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsxindex 89c10da894c5..cc91eb989600 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx@@ -349,7 +349,7 @@ describe('TrendsBarChart (ActionsBarValue)', () => {const totalRows = 20const manyBreakdowns = {results: Array.from({ length: totalRows }, (_, i) => ({- action: { id: '$napped', type: 'events', name: 'Napped', order: 0 },+ order: 0,label: `value ${i}`,count: totalRows - i,aggregated_value: totalRows - i,diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsxindex 488503d4993f..adbd3109dbb8 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.tsx@@ -116,6 +116,7 @@ export function TrendsBarChart({isStickiness,labelGroupType,hasPersonsModal,+ actionNames,querySource,getTrendsColor,getTrendsHidden,@@ -131,8 +132,8 @@ export function TrendsBarChart({const { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)const buildMeta = useCallback(- (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource),- [querySource]+ (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource, actionNames),+ [querySource, actionNames])const seriesIdentification = useMemo(@@ -165,18 +166,20 @@ export function TrendsBarChart({(r: IndexedTrendResult): string =>getAggregatedDisplayLabelFn(r, {querySource,+ actionNames,stackBreakdowns,breakdownFilter,cohorts: allCohorts?.results,formatPropertyValueForDisplay,}),- [querySource, stackBreakdowns, breakdownFilter, allCohorts?.results, formatPropertyValueForDisplay]+ [querySource, actionNames, stackBreakdowns, breakdownFilter, allCohorts?.results, formatPropertyValueForDisplay])const getLabel = useCallback((r: IndexedTrendResult): string =>getTrendsSeriesDisplayLabel(r, {querySource,+ actionNames,breakdownFilter,cohorts: allCohorts?.results,formatPropertyValueForDisplay,@@ -185,6 +188,7 @@ export function TrendsBarChart({}),[querySource,+ actionNames,breakdownFilter,allCohorts?.results,formatPropertyValueForDisplay,diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/getAggregatedDisplayLabel.ts b/products/product_analytics/frontend/insights/trends/TrendsBarChart/getAggregatedDisplayLabel.tsindex 7fcca5474924..9052c591957c 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/getAggregatedDisplayLabel.ts+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/getAggregatedDisplayLabel.ts@@ -1,5 +1,5 @@import { formatBreakdownLabel } from 'scenes/insights/utils'-import { getResultSeries } from 'scenes/insights/utils/resultSeries'+import { ActionNames, getResultSeries } from 'scenes/insights/utils/resultSeries'import { FormatPropertyValueForDisplayFunction } from '~/models/propertyDefinitionsModel'import { BreakdownFilter, InsightQueryNode } from '~/queries/schema/schema-general'@@ -12,6 +12,7 @@ import { humanizeSeriesLabel } from '../shared/humanizeSeriesLabel'export interface AggregatedDisplayLabelDeps {querySource: InsightQueryNode | null | undefined+ actionNames?: ActionNamesstackBreakdowns: booleanbreakdownFilter: BreakdownFilter | null | undefinedcohorts: CohortType[] | undefined@@ -20,7 +21,7 @@ export interface AggregatedDisplayLabelDeps {/** Category-axis label for a single band of the aggregated (Bar chart - Total value) chart. */export function getAggregatedDisplayLabel(r: IndexedTrendResult, deps: AggregatedDisplayLabelDeps): string {- const seriesName = getResultSeriesName(getResultSeries(deps.querySource, r))+ const seriesName = getResultSeriesName(getResultSeries(deps.querySource, r, deps.actionNames))if (deps.stackBreakdowns) {// Breakdown values within the band are distinguished by color and the tooltip.return seriesName ?? humanizeSeriesLabel(r.label)diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/handleTrendsBarAggregatedChartClick.test.ts b/products/product_analytics/frontend/insights/trends/TrendsBarChart/handleTrendsBarAggregatedChartClick.test.tsindex ec5fb8f777b9..071b0f823977 100644--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/handleTrendsBarAggregatedChartClick.test.ts+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/handleTrendsBarAggregatedChartClick.test.ts@@ -1,5 +1,4 @@import { NodeKind } from '~/queries/schema/schema-general'-import { EntityTypes } from '~/types'import type { IndexedTrendResult } from 'products/product_analytics/frontend/insights/trends/types'@@ -11,13 +10,7 @@ function makeTrendResult(overrides: Partial<IndexedTrendResult> = {}): IndexedTrid: 0,seriesIndex: 0,colorIndex: 0,- action: {- id: '$pageview',- type: EntityTypes.EVENTS,- order: 0,- name: '$pageview',- days: ['2024-06-10', '2024-06-11', '2024-06-12'],- },+ order: 0,label: '$pageview',count: 10,aggregated_value: 10,diff --git a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.stories.tsx b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.stories.tsxindex f0605bdd9f21..24513e722d14 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.stories.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.stories.tsx@@ -89,21 +89,8 @@ const LIFECYCLE_LABELS = ['10-Jul-2023',]-const ACTION = {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},-}-const lifecycleSeries = (status: 'new' | 'returning' | 'resurrecting' | 'dormant', data: number[]): object => ({- action: ACTION,+ order: 0,label: `$pageview - ${status}`,count: data.reduce((a, b) => a + b, 0),aggregated_value: data.reduce((a, b) => a + b, 0),diff --git a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsxindex d1f7ea953085..8885c53ca241 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsx@@ -35,7 +35,7 @@ const LIFECYCLE_DAYS = ['2024-06-10', '2024-06-11', '2024-06-12', '2024-06-13',const LIFECYCLE_LABELS = ['10-Jun', '11-Jun', '12-Jun', '13-Jun', '14-Jun']const buildLifecycleSeries = (status: 'new' | 'returning' | 'resurrecting' | 'dormant', data: number[]): object => ({- action: { id: '$pageview', type: 'events', name: '$pageview', order: 0 },+ order: 0,label: `$pageview - ${status}`,count: data.reduce((a, b) => a + b, 0),aggregated_value: data.reduce((a, b) => a + b, 0),diff --git a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsxindex b3690f6d94ab..24b0b0c5ff3c 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.tsx@@ -66,6 +66,7 @@ export function TrendsLifecycleChart({ context, inSharedMode = false }: TrendsLilifecycleFilter,formula,hasPersonsModal,+ actionNames,querySource,showValuesOnSeries,showPercentagesOnSeries,@@ -113,8 +114,8 @@ export function TrendsLifecycleChart({ context, inSharedMode = false }: TrendsLi)const buildMeta = useCallback(- (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource),- [querySource]+ (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource, actionNames),+ [querySource, actionNames])const {diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsxindex 0ecebb45c334..492be6739d96 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.tsx@@ -105,6 +105,7 @@ export function TrendsLineChart({isStickiness,labelGroupType,hasPersonsModal,+ actionNames,querySource,incompletenessOffsetFromEnd,showMovingAverage,@@ -121,8 +122,8 @@ export function TrendsLineChart({const { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)const buildMeta = useCallback(- (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource),- [querySource]+ (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource, actionNames),+ [querySource, actionNames])const seriesIdentification = useMemo(@@ -134,6 +135,7 @@ export function TrendsLineChart({(r: IndexedTrendResult): string =>getTrendsSeriesDisplayLabel(r, {querySource,+ actionNames,breakdownFilter,cohorts: allCohorts?.results,formatPropertyValueForDisplay,@@ -142,6 +144,7 @@ export function TrendsLineChart({}),[querySource,+ actionNames,breakdownFilter,allCohorts?.results,formatPropertyValueForDisplay,diff --git a/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.ts b/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.tsindex a66494f33205..a460254be00f 100644--- a/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.ts+++ b/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.ts@@ -1,6 +1,6 @@import type { Series } from '@posthog/quill-charts'-import { getResultSeries, getResultSeriesIndex } from 'scenes/insights/utils/resultSeries'+import { ActionNames, getResultSeries, getResultSeriesIndex } from 'scenes/insights/utils/resultSeries'import type { InsightQueryNode } from '~/queries/schema/schema-general'@@ -11,6 +11,7 @@ import type { TrendsSeriesMeta } from '../shared/trendsSeriesMeta'export interface BuildTrendsPieSeriesOpts<R> {querySource: InsightQueryNode | null | undefined+ actionNames?: ActionNames/** Resolved color per result (typically `getTrendsColor`). */getColor: (r: R, index: number) => string/** True when the result should be excluded from rendering. */@@ -41,12 +42,11 @@ export function buildTrendsPieSeries<R extends IndexedTrendResult>(data: [r.aggregated_value ?? 0],color: opts.getColor(r, index),meta: {- series: getResultSeries(opts.querySource, r),+ series: getResultSeries(opts.querySource, r, opts.actionNames),breakdown_value: r.breakdown_value,compare_label: r.compare_label,days: r.days,order: getResultSeriesIndex(opts.querySource, r) ?? r.id,- filter: r.filter,},visibility: excluded ? { excluded: true } : undefined,}diff --git a/products/product_analytics/frontend/insights/trends/__mocks__/trendsDataLogicMocks.ts b/products/product_analytics/frontend/insights/trends/__mocks__/trendsDataLogicMocks.tsindex 637b1396851a..cb6ae50c5ecd 100644--- a/products/product_analytics/frontend/insights/trends/__mocks__/trendsDataLogicMocks.ts+++ b/products/product_analytics/frontend/insights/trends/__mocks__/trendsDataLogicMocks.ts@@ -3,17 +3,7 @@ import { TrendAPIResponse } from '~/types'export const trendResult: TrendAPIResponse = {result: [{- action: {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: null,- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 0,label: '$pageview',count: 538545.0,data: [87830.0, 91561.0, 104892.0, 74522.0, 26535.0, 35259.0, 91718.0, 26228.0],@@ -127,79 +117,6 @@ export const trendResult: TrendAPIResponse = {url: 'api/projects/2/persons/trends/?breakdown_attribution_type=first_touch&breakdown_normalize_url=False&date_from=2023-03-07T00%3A00%3A00-08%3A00&display=ActionsLineGraph&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&properties=%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22key%22%3A+%22email%22%2C+%22operator%22%3A+%22not_icontains%22%2C+%22type%22%3A+%22person%22%2C+%22value%22%3A+%22posthog.com%22%7D%5D%7D%2C+%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22key%22%3A+%22%24host%22%2C+%22operator%22%3A+%22is_not%22%2C+%22type%22%3A+%22event%22%2C+%22value%22%3A+%5B%22127.0.0.1%3A3000%22%2C+%22127.0.0.1%3A5000%22%2C+%22localhost%3A5000%22%2C+%22localhost%3A8000%22%2C+%22localhost%3A8001%22%2C+%22localhost%22%5D%7D%5D%7D%2C+%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22key%22%3A+%22distinct_id%22%2C+%22operator%22%3A+%22not_icontains%22%2C+%22type%22%3A+%22event%22%2C+%22value%22%3A+%22posthog.com%22%7D%5D%7D%2C+%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22key%22%3A+%22email%22%2C+%22operator%22%3A+%22is_not%22%2C+%22type%22%3A+%22person%22%2C+%22value%22%3A+%5B%22capturi%40capturi.com%22%5D%7D%5D%7D%2C+%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22key%22%3A+%22email%22%2C+%22operator%22%3A+%22is_not%22%2C+%22type%22%3A+%22person%22%2C+%22value%22%3A+%5B%22fuziontech%40gmail.com%22%5D%7D%5D%7D%2C+%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22key%22%3A+%22realm%22%2C+%22operator%22%3A+%22is_not%22%2C+%22type%22%3A+%22event%22%2C+%22value%22%3A+%5B%22demo%22%5D%7D%5D%7D%2C+%7B%22type%22%3A+%22AND%22%2C+%22values%22%3A+%5B%7B%22key%22%3A+%22%24ip%22%2C+%22operator%22%3A+%22is_not%22%2C+%22type%22%3A+%22event%22%2C+%22value%22%3A+%5B%2271.84.26.175%22%5D%7D%5D%7D%5D%7D&sampling_factor=&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&date_to=2023-03-07T23%3A59%3A59.999999-08%3A00&entity_order=0',},],- filter: {- breakdown_attribution_type: 'first_touch',- breakdown_normalize_url: false,- date_from: '-7d',- display: 'ActionsLineGraph',- events: [- {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: null,- math_property: null,- math_group_type_index: null,- properties: {},- },- ],- insight: 'TRENDS',- interval: 'day',- properties: {- type: 'AND',- values: [- {- type: 'AND',- values: [{ key: 'email', operator: 'not_icontains', type: 'person', value: 'posthog.com' }],- },- {- type: 'AND',- values: [- {- key: '$host',- operator: 'is_not',- type: 'event',- value: [- '127.0.0.1:3000',- '127.0.0.1:5000',- 'localhost:5000',- 'localhost:8000',- 'localhost:8001',- 'localhost',- ],- },- ],- },- {- type: 'AND',- values: [- { key: 'distinct_id', operator: 'not_icontains', type: 'event', value: 'posthog.com' },- ],- },- {- type: 'AND',- values: [- { key: 'email', operator: 'is_not', type: 'person', value: ['[email protected]'] },- ],- },- {- type: 'AND',- values: [- { key: 'email', operator: 'is_not', type: 'person', value: ['[email protected]'] },- ],- },- { type: 'AND', values: [{ key: 'realm', operator: 'is_not', type: 'event', value: ['demo'] }] },- {- type: 'AND',- values: [{ key: '$ip', operator: 'is_not', type: 'event', value: ['71.84.26.175'] }],- },- ],- },- sampling_factor: '',- smoothing_intervals: 1,- },},],type: 'Trends',@@ -214,17 +131,7 @@ export const trendResult: TrendAPIResponse = {export const trendPieResult: TrendAPIResponse = {result: [{- action: {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: null,- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 0,label: '$pageview',count: 0,data: [],@@ -240,34 +147,13 @@ export const trendPieResult: TrendAPIResponse = {'2023-03-07',],aggregated_value: 553348,- filter: {- breakdown_attribution_type: 'first_touch',- breakdown_normalize_url: false,- date_from: '-7d',- display: 'ActionsPie',- events: '[{"id": "$pageview", "type": "events", "order": 0, "name": "$pageview", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}, {"id": "$autocapture", "type": "events", "order": 1, "name": "$autocapture", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}, {"id": "$feature_flag_called", "type": "events", "order": 2, "name": "$feature_flag_called", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}]',- insight: 'TRENDS',- interval: 'day',- sampling_factor: '',- smoothing_intervals: 1,- },persons: {filter: { entity_id: '$pageview', entity_type: 'events', entity_math: null, entity_order: 0 },url: 'api/projects/2/persons/trends/?breakdown_attribution_type=first_touch&breakdown_normalize_url=False&date_from=-7d&display=ActionsPie&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24autocapture%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+1%2C+%22name%22%3A+%22%24autocapture%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24feature_flag_called%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+2%2C+%22name%22%3A+%22%24feature_flag_called%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&sampling_factor=&smoothing_intervals=1&entity_id=%24pageview&entity_type=events&entity_order=0',},},{- action: {- id: '$autocapture',- type: 'events',- order: 1,- name: '$autocapture',- custom_name: null,- math: null,- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 1,label: '$autocapture',count: 0,data: [],@@ -283,34 +169,13 @@ export const trendPieResult: TrendAPIResponse = {'2023-03-07',],aggregated_value: 874570,- filter: {- breakdown_attribution_type: 'first_touch',- breakdown_normalize_url: false,- date_from: '-7d',- display: 'ActionsPie',- events: '[{"id": "$pageview", "type": "events", "order": 0, "name": "$pageview", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}, {"id": "$autocapture", "type": "events", "order": 1, "name": "$autocapture", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}, {"id": "$feature_flag_called", "type": "events", "order": 2, "name": "$feature_flag_called", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}]',- insight: 'TRENDS',- interval: 'day',- sampling_factor: '',- smoothing_intervals: 1,- },persons: {filter: { entity_id: '$autocapture', entity_type: 'events', entity_math: null, entity_order: 1 },url: 'api/projects/2/persons/trends/?breakdown_attribution_type=first_touch&breakdown_normalize_url=False&date_from=-7d&display=ActionsPie&events=%5B%7B%22id%22%3A+%22%24pageview%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+0%2C+%22name%22%3A+%22%24pageview%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24autocapture%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+1%2C+%22name%22%3A+%22%24autocapture%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%2C+%7B%22id%22%3A+%22%24feature_flag_called%22%2C+%22type%22%3A+%22events%22%2C+%22order%22%3A+2%2C+%22name%22%3A+%22%24feature_flag_called%22%2C+%22custom_name%22%3A+null%2C+%22math%22%3A+null%2C+%22math_property%22%3A+null%2C+%22math_group_type_index%22%3A+null%2C+%22properties%22%3A+%7B%7D%7D%5D&insight=TRENDS&interval=day&sampling_factor=&smoothing_intervals=1&entity_id=%24autocapture&entity_type=events&entity_order=1',},},{- action: {- id: '$feature_flag_called',- type: 'events',- order: 2,- name: '$feature_flag_called',- custom_name: null,- math: null,- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 2,label: '$feature_flag_called',count: 0,data: [],@@ -326,17 +191,6 @@ export const trendPieResult: TrendAPIResponse = {'2023-03-07',],aggregated_value: 3377681,- filter: {- breakdown_attribution_type: 'first_touch',- breakdown_normalize_url: false,- date_from: '-7d',- display: 'ActionsPie',- events: '[{"id": "$pageview", "type": "events", "order": 0, "name": "$pageview", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}, {"id": "$autocapture", "type": "events", "order": 1, "name": "$autocapture", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}, {"id": "$feature_flag_called", "type": "events", "order": 2, "name": "$feature_flag_called", "custom_name": null, "math": null, "math_property": null, "math_group_type_index": null, "properties": {}}]',- insight: 'TRENDS',- interval: 'day',- sampling_factor: '',- smoothing_intervals: 1,- },persons: {filter: {entity_id: '$feature_flag_called',@@ -362,39 +216,7 @@ export const breakdownPieResult: TrendAPIResponse = {count: 0,aggregated_value: 27,label: '["signup-page-4.0","billing-limit","kafka-inspector","person-on-events-enabled","auto-rollback-feature-flags","onboarding-v2-demo","query_running_time","query-timings","hedgehog-mode","web-analytics","web-analytics-sampling","high-frequency-batch-exports","exception-autocapture","data-warehouse","data-warehouse-postgres-import","ff-dashboard-templates","show-product-intro-existing-products","cs-dashboards","redirect-signups-to-instance","apps-and-exports-ui","hogql-insights-preview","hogql-insights-lifecycle","hogql-insights-paths","hogql-insights-retention","hogql-insights-trends","hogql-insights-stickiness","hogql-insights-funnels","hogql-insight-live-compare","hogql-in-insight-serialization","bi_viz","webhooks-denylist","pipeline-ui","session-recording-sampling","person-feed-canvas","feature-flag-cohort-creation","insight-horizontal-controls","surveys-widgets","invite-team-member-onboarding","year-in-hog","session-replay-export-mobile-data","discussions","ai-session-summary","ai-session-permissions","product-intro-pages","session-replay-doctor","session-replay-similar-recordings","saved-not-pinned","billing-upgrade-language","new-experiments-ui","session-replay-filter-ordering","session-replay-linked-variants","session-replay-error-clustering","audit-logs-access","reverse-proxy-onboarding","session-replay-mobile-onboarding","ip-allowlist-setting","email-verification-ticket-submission","theme"]',- filter: {- insight: 'TRENDS',- filter_test_accounts: true,- date_to: '2024-05-09T23:59:59.999999Z',- date_from: '2024-05-02T00:00:00Z',- entity_type: 'events',- interval: 'day',- display: 'ActionsPie',- breakdown: '$active_feature_flags',- breakdown_type: 'event',- },- action: {- days: [- '2024-05-02T00:00:00Z',- '2024-05-03T00:00:00Z',- '2024-05-04T00:00:00Z',- '2024-05-05T00:00:00Z',- '2024-05-06T00:00:00Z',- '2024-05-07T00:00:00Z',- '2024-05-08T00:00:00Z',- '2024-05-09T00:00:00Z',- ],- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 0,breakdown_value:'["signup-page-4.0","billing-limit","kafka-inspector","person-on-events-enabled","auto-rollback-feature-flags","onboarding-v2-demo","query_running_time","query-timings","hedgehog-mode","web-analytics","web-analytics-sampling","high-frequency-batch-exports","exception-autocapture","data-warehouse","data-warehouse-postgres-import","ff-dashboard-templates","show-product-intro-existing-products","cs-dashboards","redirect-signups-to-instance","apps-and-exports-ui","hogql-insights-preview","hogql-insights-lifecycle","hogql-insights-paths","hogql-insights-retention","hogql-insights-trends","hogql-insights-stickiness","hogql-insights-funnels","hogql-insight-live-compare","hogql-in-insight-serialization","bi_viz","webhooks-denylist","pipeline-ui","session-recording-sampling","person-feed-canvas","feature-flag-cohort-creation","insight-horizontal-controls","surveys-widgets","invite-team-member-onboarding","year-in-hog","session-replay-export-mobile-data","discussions","ai-session-summary","ai-session-permissions","product-intro-pages","session-replay-doctor","session-replay-similar-recordings","saved-not-pinned","billing-upgrade-language","new-experiments-ui","session-replay-filter-ordering","session-replay-linked-variants","session-replay-error-clustering","audit-logs-access","reverse-proxy-onboarding","session-replay-mobile-onboarding","ip-allowlist-setting","email-verification-ticket-submission","theme"]',},@@ -404,39 +226,7 @@ export const breakdownPieResult: TrendAPIResponse = {count: 0,aggregated_value: 322,label: '$$_posthog_breakdown_other_$$',- filter: {- insight: 'TRENDS',- filter_test_accounts: true,- date_to: '2024-05-09T23:59:59.999999Z',- date_from: '2024-05-02T00:00:00Z',- entity_type: 'events',- interval: 'day',- display: 'ActionsPie',- breakdown: '$active_feature_flags',- breakdown_type: 'event',- },- action: {- days: [- '2024-05-02T00:00:00Z',- '2024-05-03T00:00:00Z',- '2024-05-04T00:00:00Z',- '2024-05-05T00:00:00Z',- '2024-05-06T00:00:00Z',- '2024-05-07T00:00:00Z',- '2024-05-08T00:00:00Z',- '2024-05-09T00:00:00Z',- ],- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 0,breakdown_value: '$$_posthog_breakdown_other_$$',},{@@ -445,39 +235,7 @@ export const breakdownPieResult: TrendAPIResponse = {count: 0,aggregated_value: 801,label: '["signup-page-4.0","billing-limit","kafka-inspector","person-on-events-enabled","auto-rollback-feature-flags","onboarding-v2-demo","query_running_time","query-timings","hedgehog-mode","web-analytics","web-analytics-sampling","high-frequency-batch-exports","exception-autocapture","data-warehouse","data-warehouse-postgres-import","ff-dashboard-templates","show-product-intro-existing-products","cs-dashboards","redirect-signups-to-instance","apps-and-exports-ui","hogql-insights-preview","hogql-insights-lifecycle","hogql-insights-paths","hogql-insights-retention","hogql-insights-trends","hogql-insights-stickiness","hogql-insights-funnels","hogql-in-insight-serialization","bi_viz","webhooks-denylist","pipeline-ui","session-recording-sampling","person-feed-canvas","feature-flag-cohort-creation","insight-horizontal-controls","surveys-widgets","invite-team-member-onboarding","year-in-hog","session-replay-export-mobile-data","discussions","ai-session-summary","ai-session-permissions","product-intro-pages","session-replay-doctor","session-replay-similar-recordings","saved-not-pinned","billing-upgrade-language","new-experiments-ui","session-replay-filter-ordering","session-replay-linked-variants","session-replay-error-clustering","audit-logs-access","reverse-proxy-onboarding","session-replay-mobile-onboarding","ip-allowlist-setting","email-verification-ticket-submission","theme"]',- filter: {- insight: 'TRENDS',- filter_test_accounts: true,- date_to: '2024-05-09T23:59:59.999999Z',- date_from: '2024-05-02T00:00:00Z',- entity_type: 'events',- interval: 'day',- display: 'ActionsPie',- breakdown: '$active_feature_flags',- breakdown_type: 'event',- },- action: {- days: [- '2024-05-02T00:00:00Z',- '2024-05-03T00:00:00Z',- '2024-05-04T00:00:00Z',- '2024-05-05T00:00:00Z',- '2024-05-06T00:00:00Z',- '2024-05-07T00:00:00Z',- '2024-05-08T00:00:00Z',- '2024-05-09T00:00:00Z',- ],- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 0,breakdown_value:'["signup-page-4.0","billing-limit","kafka-inspector","person-on-events-enabled","auto-rollback-feature-flags","onboarding-v2-demo","query_running_time","query-timings","hedgehog-mode","web-analytics","web-analytics-sampling","high-frequency-batch-exports","exception-autocapture","data-warehouse","data-warehouse-postgres-import","ff-dashboard-templates","show-product-intro-existing-products","cs-dashboards","redirect-signups-to-instance","apps-and-exports-ui","hogql-insights-preview","hogql-insights-lifecycle","hogql-insights-paths","hogql-insights-retention","hogql-insights-trends","hogql-insights-stickiness","hogql-insights-funnels","hogql-in-insight-serialization","bi_viz","webhooks-denylist","pipeline-ui","session-recording-sampling","person-feed-canvas","feature-flag-cohort-creation","insight-horizontal-controls","surveys-widgets","invite-team-member-onboarding","year-in-hog","session-replay-export-mobile-data","discussions","ai-session-summary","ai-session-permissions","product-intro-pages","session-replay-doctor","session-replay-similar-recordings","saved-not-pinned","billing-upgrade-language","new-experiments-ui","session-replay-filter-ordering","session-replay-linked-variants","session-replay-error-clustering","audit-logs-access","reverse-proxy-onboarding","session-replay-mobile-onboarding","ip-allowlist-setting","email-verification-ticket-submission","theme"]',},@@ -487,39 +245,7 @@ export const breakdownPieResult: TrendAPIResponse = {count: 0,aggregated_value: 25567,label: '$$_posthog_breakdown_null_$$',- filter: {- insight: 'TRENDS',- filter_test_accounts: true,- date_to: '2024-05-09T23:59:59.999999Z',- date_from: '2024-05-02T00:00:00Z',- entity_type: 'events',- interval: 'day',- display: 'ActionsPie',- breakdown: '$active_feature_flags',- breakdown_type: 'event',- },- action: {- days: [- '2024-05-02T00:00:00Z',- '2024-05-03T00:00:00Z',- '2024-05-04T00:00:00Z',- '2024-05-05T00:00:00Z',- '2024-05-06T00:00:00Z',- '2024-05-07T00:00:00Z',- '2024-05-08T00:00:00Z',- '2024-05-09T00:00:00Z',- ],- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 0,breakdown_value: '$$_posthog_breakdown_null_$$',},{@@ -528,39 +254,7 @@ export const breakdownPieResult: TrendAPIResponse = {count: 0,aggregated_value: 2,label: '[]',- filter: {- insight: 'TRENDS',- filter_test_accounts: true,- date_to: '2024-05-09T23:59:59.999999Z',- date_from: '2024-05-02T00:00:00Z',- entity_type: 'events',- interval: 'day',- display: 'ActionsPie',- breakdown: '$active_feature_flags',- breakdown_type: 'event',- },- action: {- days: [- '2024-05-02T00:00:00Z',- '2024-05-03T00:00:00Z',- '2024-05-04T00:00:00Z',- '2024-05-05T00:00:00Z',- '2024-05-06T00:00:00Z',- '2024-05-07T00:00:00Z',- '2024-05-08T00:00:00Z',- '2024-05-09T00:00:00Z',- ],- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 0,breakdown_value: '[]',},{@@ -569,39 +263,7 @@ export const breakdownPieResult: TrendAPIResponse = {count: 0,aggregated_value: 9,label: '["signup-page-4.0","billing-limit","kafka-inspector","person-on-events-enabled","auto-rollback-feature-flags","onboarding-v2-demo","query_running_time","query-timings","hedgehog-mode","web-analytics","web-analytics-sampling","high-frequency-batch-exports","exception-autocapture","data-warehouse","data-warehouse-postgres-import","ff-dashboard-templates","show-product-intro-existing-products","cs-dashboards","redirect-signups-to-instance","apps-and-exports-ui","hogql-insights-preview","hogql-insights-lifecycle","hogql-insights-paths","hogql-insights-retention","hogql-insights-trends","hogql-insights-stickiness","hogql-insights-funnels","hogql-insight-live-compare","hogql-in-insight-serialization","bi_viz","webhooks-denylist","pipeline-ui","session-recording-sampling","person-feed-canvas","feature-flag-cohort-creation","insight-horizontal-controls","surveys-widgets","invite-team-member-onboarding","year-in-hog","session-replay-export-mobile-data","discussions","ai-session-summary","ai-session-permissions","product-intro-pages","session-replay-doctor","session-replay-similar-recordings","saved-not-pinned","billing-upgrade-language","new-experiments-ui","session-replay-filter-ordering","session-replay-linked-variants","session-replay-error-clustering","audit-logs-access","reverse-proxy-onboarding","session-replay-mobile-onboarding","ip-allowlist-setting","email-verification-ticket-submission","theme"]',- filter: {- insight: 'TRENDS',- filter_test_accounts: true,- date_to: '2024-05-09T23:59:59.999999Z',- date_from: '2024-05-02T00:00:00Z',- entity_type: 'events',- interval: 'day',- display: 'ActionsPie',- breakdown: '$active_feature_flags',- breakdown_type: 'event',- },- action: {- days: [- '2024-05-02T00:00:00Z',- '2024-05-03T00:00:00Z',- '2024-05-04T00:00:00Z',- '2024-05-05T00:00:00Z',- '2024-05-06T00:00:00Z',- '2024-05-07T00:00:00Z',- '2024-05-08T00:00:00Z',- '2024-05-09T00:00:00Z',- ],- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_hogql: null,- math_group_type_index: null,- properties: {},- },+ order: 0,breakdown_value:'["signup-page-4.0","billing-limit","kafka-inspector","person-on-events-enabled","auto-rollback-feature-flags","onboarding-v2-demo","query_running_time","query-timings","hedgehog-mode","web-analytics","web-analytics-sampling","high-frequency-batch-exports","exception-autocapture","data-warehouse","data-warehouse-postgres-import","ff-dashboard-templates","show-product-intro-existing-products","cs-dashboards","redirect-signups-to-instance","apps-and-exports-ui","hogql-insights-preview","hogql-insights-lifecycle","hogql-insights-paths","hogql-insights-retention","hogql-insights-trends","hogql-insights-stickiness","hogql-insights-funnels","hogql-insight-live-compare","hogql-in-insight-serialization","bi_viz","webhooks-denylist","pipeline-ui","session-recording-sampling","person-feed-canvas","feature-flag-cohort-creation","insight-horizontal-controls","surveys-widgets","invite-team-member-onboarding","year-in-hog","session-replay-export-mobile-data","discussions","ai-session-summary","ai-session-permissions","product-intro-pages","session-replay-doctor","session-replay-similar-recordings","saved-not-pinned","billing-upgrade-language","new-experiments-ui","session-replay-filter-ordering","session-replay-linked-variants","session-replay-error-clustering","audit-logs-access","reverse-proxy-onboarding","session-replay-mobile-onboarding","ip-allowlist-setting","email-verification-ticket-submission","theme"]',},@@ -613,17 +275,7 @@ export const breakdownPieResult: TrendAPIResponse = {export const lifecycleResult: TrendAPIResponse = {result: [{- action: {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 0,label: '$pageview - new',count: 35346.0,data: [2757.0, 3021.0, 15176.0, 4456.0, 2172.0, 3038.0, 3244.0, 1482.0],@@ -740,17 +392,7 @@ export const lifecycleResult: TrendAPIResponse = {],},{- action: {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 0,label: '$pageview - dormant',count: -50255.0,data: [-4906.0, -4421.0, -4609.0, -17127.0, -7016.0, -2762.0, -3740.0, -5674.0],@@ -867,17 +509,7 @@ export const lifecycleResult: TrendAPIResponse = {],},{- action: {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 0,label: '$pageview - returning',count: 9814.0,data: [1714.0, 1617.0, 1677.0, 1805.0, 578.0, 457.0, 879.0, 1087.0],@@ -994,17 +626,7 @@ export const lifecycleResult: TrendAPIResponse = {],},{- action: {- id: '$pageview',- type: 'events',- order: 0,- name: '$pageview',- custom_name: null,- math: 'total',- math_property: null,- math_group_type_index: null,- properties: {},- },+ order: 0,label: '$pageview - resurrecting',count: 11612.0,data: [1567.0, 1648.0, 2079.0, 1333.0, 469.0, 1124.0, 2638.0, 754.0],diff --git a/products/product_analytics/frontend/insights/trends/shared/TrendsTooltip.tsx b/products/product_analytics/frontend/insights/trends/shared/TrendsTooltip.tsxindex 0f3033ba20a3..009502e27b14 100644--- a/products/product_analytics/frontend/insights/trends/shared/TrendsTooltip.tsx+++ b/products/product_analytics/frontend/insights/trends/shared/TrendsTooltip.tsx@@ -86,7 +86,6 @@ export function TrendsTooltip({breakdown_value: meta.breakdown_value,compare_label: meta.compare_label,date_label: meta.days?.[context.dataIndex],- filter: meta.filter,}})data.sort(diff --git a/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.ts b/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.tsindex 5905dbc8f78c..793a8bdd9ca3 100644--- a/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.ts+++ b/products/product_analytics/frontend/insights/trends/shared/anomalyPointsAdapter.test.ts@@ -1,5 +1,3 @@-import { EntityTypes } from '~/types'-import type { AnomalyPoint } from 'products/alerts/frontend/types'import type { IndexedTrendResult } from 'products/product_analytics/frontend/insights/trends/types'@@ -10,14 +8,6 @@ function makeResult(overrides: Partial<IndexedTrendResult> = {}): IndexedTrendReid: 0,seriesIndex: 0,colorIndex: 0,- // The trends runner sends `action.days` as datetimes, which never match an alert's dates.- action: {- id: '$pageview',- type: EntityTypes.EVENTS,- order: 0,- name: '$pageview',- days: ['2024-06-10T00:00:00Z', '2024-06-11T00:00:00Z', '2024-06-12T00:00:00Z'],- },order: 0,label: '$pageview',count: 10,diff --git a/products/product_analytics/frontend/insights/trends/shared/getTrendsSeriesDisplayLabel.ts b/products/product_analytics/frontend/insights/trends/shared/getTrendsSeriesDisplayLabel.tsindex ab9b63480103..4f4c7b7c50bc 100644--- a/products/product_analytics/frontend/insights/trends/shared/getTrendsSeriesDisplayLabel.ts+++ b/products/product_analytics/frontend/insights/trends/shared/getTrendsSeriesDisplayLabel.ts@@ -1,6 +1,6 @@import { alphabet } from 'lib/utils/strings'import { formatBreakdownLabel } from 'scenes/insights/utils'-import { getResultSeries } from 'scenes/insights/utils/resultSeries'+import { ActionNames, getResultSeries } from 'scenes/insights/utils/resultSeries'import type { FormatPropertyValueForDisplayFunction } from '~/models/propertyDefinitionsModel'import type { BreakdownFilter, InsightQueryNode } from '~/queries/schema/schema-general'@@ -14,6 +14,7 @@ import { humanizeSeriesLabel } from './humanizeSeriesLabel'export interface TrendsSeriesLabelDeps {querySource: InsightQueryNode | null | undefined+ actionNames?: ActionNamesbreakdownFilter: BreakdownFilter | null | undefinedcohorts: CohortType[] | undefinedformatPropertyValueForDisplay: FormatPropertyValueForDisplayFunction | undefined@@ -22,7 +23,7 @@ export interface TrendsSeriesLabelDeps {}export function getTrendsSeriesDisplayLabel(r: IndexedTrendResult, deps: TrendsSeriesLabelDeps): string {- const series = getResultSeries(deps.querySource, r)+ const series = getResultSeries(deps.querySource, r, deps.actionNames)const seriesName = getResultSeriesName(series) ?? humanizeSeriesLabel(r.label)if (r.breakdown_value != null) {const breakdownLabel = formatBreakdownLabel(diff --git a/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsx b/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsxindex 417fbfc9c553..b06f3f59a142 100644--- a/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsx+++ b/products/product_analytics/frontend/insights/trends/shared/handleTrendsChartClick.test.tsx@@ -1,5 +1,5 @@import { NodeKind } from '~/queries/schema/schema-general'-import { CompareLabelType, EntityTypes } from '~/types'+import { CompareLabelType } from '~/types'import type { IndexedTrendResult } from 'products/product_analytics/frontend/insights/trends/types'@@ -10,7 +10,6 @@ function makeTrendResult(overrides: Partial<IndexedTrendResult> = {}): IndexedTrid: 0,seriesIndex: 0,colorIndex: 0,- action: { id: '$pageview', type: EntityTypes.EVENTS, order: 0, name: '$pageview' },order: 0,label: '$pageview',count: 10,@@ -103,14 +102,13 @@ describe('handleTrendsChartClick', () => {})- it('forwards a formula-series click (action: null) to context.onDataPointClick instead of the modal', () => {- // Formula results carry no `action`, so the generic drill-down can't attribute them to a series- // (it silently falls back to series 0). Products embedding formula charts rely on their- // onDataPointClick handler winning here, with the day read from the top-level `days`.+ it('forwards a formula-series click to context.onDataPointClick instead of the modal', () => {+ // The generic drill-down can't attribute a formula row to one series (it silently falls back+ // to series 0). Products embedding formula charts rely on their onDataPointClick handler+ // winning here, with the day read from the top-level `days`.const openPersonsModal = jest.fn()const onDataPointClick = jest.fn()const trendResult = makeTrendResult({- action: null,label: 'Yes rate',days: ['2024-06-10', '2024-06-11', '2024-06-12'],})diff --git a/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.ts b/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.tsindex 05a7d09c3847..b5b0a36c46da 100644--- a/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.ts+++ b/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.ts@@ -1,4 +1,4 @@-import { ResultSeries, getResultSeries } from 'scenes/insights/utils/resultSeries'+import { ActionNames, ResultSeries, getResultSeries } from 'scenes/insights/utils/resultSeries'import type { Noun } from '~/models/groupsModel'import type { InsightQueryNode } from '~/queries/schema/schema-general'@@ -14,14 +14,14 @@ export type TrendsSeriesMeta = {compare_label?: SeriesDatum['compare_label']days?: string[]order?: number- filter?: SeriesDatum['filter']}export const buildTrendsSeriesMeta = (r: IndexedTrendResult,- querySource: InsightQueryNode | null | undefined+ querySource: InsightQueryNode | null | undefined,+ actionNames?: ActionNames): TrendsSeriesMeta => {- const series = getResultSeries(querySource, r)+ const series = getResultSeries(querySource, r, actionNames)return {series,// Formula results have no series node; their raw label (custom name or "Formula (…)") is the@@ -31,7 +31,6 @@ export const buildTrendsSeriesMeta = (compare_label: r.compare_label,days: r.days,order: series.order,- filter: r.filter,}}diff --git a/products/product_analytics/frontend/insights/trends/shared/useInsightsLegendConfig.test.tsx b/products/product_analytics/frontend/insights/trends/shared/useInsightsLegendConfig.test.tsxindex 4565756c4008..328aa3d6828a 100644--- a/products/product_analytics/frontend/insights/trends/shared/useInsightsLegendConfig.test.tsx+++ b/products/product_analytics/frontend/insights/trends/shared/useInsightsLegendConfig.test.tsx@@ -53,13 +53,13 @@ function setup({const SERIES: InsightModel['result'] = [{- action: { id: '$pageview', type: 'events', order: 0, name: '$pageview' },+ order: 0,label: '$pageview',data: [1],days: [],},{- action: { id: '$autocapture', type: 'events', order: 1, name: '$autocapture' },+ order: 1,label: '$autocapture',data: [2],days: [],diff --git a/products/product_analytics/frontend/insights/trends/shared/useTrendsPartOfWholeChart.tsx b/products/product_analytics/frontend/insights/trends/shared/useTrendsPartOfWholeChart.tsxindex 3fc0e60fc9ba..e0f6c959190f 100644--- a/products/product_analytics/frontend/insights/trends/shared/useTrendsPartOfWholeChart.tsx+++ b/products/product_analytics/frontend/insights/trends/shared/useTrendsPartOfWholeChart.tsx@@ -69,6 +69,7 @@ export function useTrendsPartOfWholeChart({formula,pieChartVizOptions,hasDataWarehouseSeries,+ actionNames,querySource,breakdownFilter,labelGroupType,@@ -78,8 +79,8 @@ export function useTrendsPartOfWholeChart({} = useValues(trendsDataLogic(insightProps))const buildMeta = useCallback(- (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource),- [querySource]+ (r: IndexedTrendResult): TrendsSeriesMeta => buildTrendsSeriesMeta(r, querySource, actionNames),+ [querySource, actionNames])const seriesIdentification = useMemo(@@ -103,6 +104,7 @@ export function useTrendsPartOfWholeChart({(r: IndexedTrendResult): string =>getTrendsSeriesDisplayLabel(r, {querySource,+ actionNames,breakdownFilter,cohorts: allCohorts.results,formatPropertyValueForDisplay,@@ -111,6 +113,7 @@ export function useTrendsPartOfWholeChart({}),[querySource,+ actionNames,breakdownFilter,allCohorts.results,formatPropertyValueForDisplay,@@ -123,13 +126,14 @@ export function useTrendsPartOfWholeChart({() =>buildTrendsPieSeries(indexedResults ?? [], {querySource,+ actionNames,getColor: getTrendsColor,// Hidden series are listed (dimmed) and excluded via config.legend.hiddenKeys instead// of being dropped here, so the legend can restore them.getHidden: undefined,getLabel,}),- [indexedResults, querySource, getTrendsColor, getLabel]+ [indexedResults, querySource, actionNames, getTrendsColor, getLabel])const visibleResults = useMemo(diff --git a/products/product_analytics/frontend/insights/trends/trendsDataLogic.test.ts b/products/product_analytics/frontend/insights/trends/trendsDataLogic.test.tsindex 63222addbea4..ae3aefe77c97 100644--- a/products/product_analytics/frontend/insights/trends/trendsDataLogic.test.ts+++ b/products/product_analytics/frontend/insights/trends/trendsDataLogic.test.ts@@ -7,7 +7,14 @@ import { getTrendResultCustomizationKey } from 'scenes/insights/utils'import { ExportType } from '~/exporter/types'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'-import { DataNode, LifecycleQuery, NodeKind, ResultCustomizationBy, TrendsQuery } from '~/queries/schema/schema-general'+import {+ DataNode,+ LifecycleQuery,+ NodeKind,+ ResultCustomizationBy,+ TrendsQuery,+ TrendsQueryResponse,+} from '~/queries/schema/schema-general'import { initKeaTests } from '~/test/init'import { ChartDisplayType, InsightLogicProps, InsightModel } from '~/types'@@ -93,6 +100,19 @@ describe('trendsDataLogic', () => {})})+ describe('actionNames', () => {+ it('for a response that names its action series', async () => {+ await expectLogic(logic, () => {+ builtDataNodeLogic.actions.loadDataSuccess({+ results: trendResult.result,+ action_names: { '7': 'Signed up' },+ } as TrendsQueryResponse)+ }).toMatchValues({+ actionNames: { '7': 'Signed up' },+ })+ })+ })+describe('indexedResults', () => {it('for standard trend', async () => {const insight: Partial<InsightModel> = {diff --git a/products/product_analytics/frontend/insights/trends/trendsDataLogic.ts b/products/product_analytics/frontend/insights/trends/trendsDataLogic.tsindex 9b180ac794df..de60741a90a3 100644--- a/products/product_analytics/frontend/insights/trends/trendsDataLogic.ts+++ b/products/product_analytics/frontend/insights/trends/trendsDataLogic.ts@@ -27,7 +27,7 @@ import {getTrendResultCustomizationColorToken,getTrendResultCustomizationKey,} from 'scenes/insights/utils'-import { getResultSeriesIndex } from 'scenes/insights/utils/resultSeries'+import { ActionNames, getResultSeriesIndex } from 'scenes/insights/utils/resultSeries'import { isSharedView } from '~/exporter/exporterViewLogic'import {@@ -167,6 +167,7 @@ export interface trendsDataLogicValues {trendsFilter: TrendsFilter | null | undefined // insightVizDataLogicvizSpecificOptions: VizSpecificOptions | null | undefined // insightVizDataLogicyAxisScaleType: string | null | undefined // insightVizDataLogic+ actionNames: ActionNamesalertSeries: EventsNode[]areAllSeriesVisible: booleanbreakdownValuesLoading: boolean@@ -291,6 +292,7 @@ export interface trendsDataLogicMeta {| null) => EventsNode[]results: (insightData: Record<string, any>) => TrendResult[]+ actionNames: (insightData: Record<string, any>) => ActionNameshasBreakdownMore: (insightData: Record<string, any>, isTrends: boolean) => booleanhasPersonsModal: (formula: string | null | undefined,@@ -572,6 +574,11 @@ export const trendsDataLogic = kea<trendsDataLogicType>([},],+ actionNames: [+ (s) => [s.insightData],+ (insightData: Record<string, any>): ActionNames => insightData.action_names ?? {},+ ],+hasBreakdownMore: [(s) => [s.insightData, s.isTrends],(insightData: Record<string, any>, isTrends: boolean) => {diff --git a/products/product_analytics/mcp/apps/explainChart/ExplainChartView.tsx b/products/product_analytics/mcp/apps/explainChart/ExplainChartView.tsxindex f68a0e61e8af..466ff3055a08 100644--- a/products/product_analytics/mcp/apps/explainChart/ExplainChartView.tsx+++ b/products/product_analytics/mcp/apps/explainChart/ExplainChartView.tsx@@ -58,7 +58,7 @@ function seriesNoteOf(data: ExplainChartData): string | null {return null}const series = data.results[data.seriesIndex]- const label = series?.label || series?.action?.name || `series ${data.seriesIndex + 1}`+ const label = series?.label || `series ${data.seriesIndex + 1}`return `This follows ${label}, one of the ${data.results.length} series on the chart.`}diff --git a/products/product_analytics/mcp/apps/explainChart/explainChartTypes.ts b/products/product_analytics/mcp/apps/explainChart/explainChartTypes.tsindex 1c42457808d7..2206e88e4a5c 100644--- a/products/product_analytics/mcp/apps/explainChart/explainChartTypes.ts+++ b/products/product_analytics/mcp/apps/explainChart/explainChartTypes.ts@@ -33,7 +33,6 @@ export interface StorySeriesResult {label?: stringdata?: number[]days?: string[]- action?: { name?: string }}export interface StoryTrendsQuery {diff --git a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsxindex 26eed316d7e1..d9107fbbe1a1 100644--- a/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx+++ b/products/replay_vision/frontend/replay_scanners/ReplayScannersScene.stories.tsx@@ -636,7 +636,7 @@ const trendDays = [const observationsTrend = {results: [{- action: { id: '$recording_observed', type: 'events', order: 0, name: '$recording_observed' },+ order: 0,label: 'Observations',count: 142,data: [8, 11, 9, 14, 10, 12, 7, 13, 9, 11, 10, 8, 12, 8],diff --git a/products/signals/frontend/inbox/__mocks__/reportMetricMocks.ts b/products/signals/frontend/inbox/__mocks__/reportMetricMocks.tsindex 9c4df1fa6911..7846ef4ba4b8 100644--- a/products/signals/frontend/inbox/__mocks__/reportMetricMocks.ts+++ b/products/signals/frontend/inbox/__mocks__/reportMetricMocks.ts@@ -237,15 +237,7 @@ export async function reportMetricQueryHandler({ request }: { request: Request }{result: [{- action: {- id: series?.event,- type: 'events',- order: 0,- name: series?.name,- custom_name: result.label,- math: series?.math,- properties: {},- },+ order: 0,label: result.label,count: result.data.at(-1) ?? 0,data: resultData,diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 0faa5146dec8..a80f80265cdb 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -5804,9 +5804,16 @@ export namespace Schemas {series_label?: string | null;}+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+ export type TrendsQueryResponseActionNames = {[key: string]: string} | null;+export type TrendsQueryResponseResultsItem = { [key: string]: unknown };export interface TrendsQueryResponse {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: TrendsQueryResponseActionNames;boxplot_data?: BoxPlotDatum[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -6925,9 +6932,16 @@ export namespace Schemas {version?: number | null;}+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+ export type StickinessQueryResponseActionNames = {[key: string]: string} | null;+export type StickinessQueryResponseResultsItem = { [key: string]: unknown };export interface StickinessQueryResponse {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: StickinessQueryResponseActionNames;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -7050,9 +7064,16 @@ export namespace Schemas {toggledLifecycles?: LifecycleToggle[] | null;}+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+ export type LifecycleQueryResponseActionNames = {[key: string]: string} | null;+export type LifecycleQueryResponseResultsItem = { [key: string]: unknown };export interface LifecycleQueryResponse {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: LifecycleQueryResponseActionNames;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */@@ -11252,6 +11273,12 @@ export namespace Schemas {readonly date_to?: string;} | null;+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+ export type InsightActionNames = {[key: string]: string} | null;+/*** Simplified serializer to speed response times when loading large amounts of objects.*/@@ -11351,6 +11378,11 @@ export namespace Schemas {readonly types: readonly unknown[] | null;/** @nullable */readonly resolved_date_range: InsightResolvedDateRange;+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+ readonly action_names: InsightActionNames;/** What ClickHouse read for this insight's last slow run, with the findings of its query scan. */readonly query_scan: unknown;/** Warnings from the run that produced these results. A `warehouse_sync` warning means the query read a data warehouse table whose sync failed, is paused, or is overdue, so the results can be out of date. Reflects the sync state when the results were computed. Null for shared insights. */@@ -88729,6 +88761,12 @@ export namespace Schemas {readonly date_to?: string;} | null;+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+ export type PatchedInsightActionNames = {[key: string]: string} | null;+/*** Simplified serializer to speed response times when loading large amounts of objects.*/@@ -88828,6 +88866,11 @@ export namespace Schemas {readonly types?: readonly unknown[] | null;/** @nullable */readonly resolved_date_range?: PatchedInsightResolvedDateRange;+ /**+ * The name of each action the insight's series reference, keyed by action id. A series saved without a name displays this name.+ * @nullable+ */+ readonly action_names?: PatchedInsightActionNames;/** What ClickHouse read for this insight's last slow run, with the findings of its query scan. */readonly query_scan?: unknown;/** Warnings from the run that produced these results. A `warehouse_sync` warning means the query read a data warehouse table whose sync failed, is paused, or is overdue, so the results can be out of date. Reflects the sync state when the results were computed. Null for shared insights. */@@ -101324,9 +101367,16 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+ export type QueryResponseAlternative60ActionNames = {[key: string]: string} | null;+export type QueryResponseAlternative60ResultsItem = { [key: string]: unknown };export interface QueryResponseAlternative60 {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: QueryResponseAlternative60ActionNames;boxplot_data?: BoxPlotDatum[] | null;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;@@ -101441,9 +101491,16 @@ export namespace Schemas {warnings?: (DataWarehouseSyncWarning | AccessControlFilterWarning)[] | null;}+ /**+ * The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id.+ */+ export type QueryResponseAlternative65ActionNames = {[key: string]: string} | null;+export type QueryResponseAlternative65ResultsItem = { [key: string]: unknown };export interface QueryResponseAlternative65 {+ /** The name of each action the query's series reference, keyed by action id. A series saved without a `name` displays this name, because the query holds only the action's id. */+ action_names?: QueryResponseAlternative65ActionNames;/** Query error. Returned only if 'explain' or `modifiers.debug` is true. Throws an error otherwise. */error?: string | null;/** Generated HogQL query. */diff --git a/services/mcp/src/ui-apps/components/types.ts b/services/mcp/src/ui-apps/components/types.tsindex 0730f332d1eb..3db7e92a89dc 100644--- a/services/mcp/src/ui-apps/components/types.ts+++ b/services/mcp/src/ui-apps/components/types.ts@@ -108,9 +108,6 @@ export interface TrendsResultItem {/** Slope graph only: the last bucket is the current, still-accumulating period (set by the* backend SlopeGraphTrendsQueryRunner) so the slope dashes the provisional end like the insight. */incomplete_end?: boolean- action?: {- name?: string- }}export type TrendsResult = TrendsResultItem[]diff --git a/services/mcp/src/ui-apps/components/utils.ts b/services/mcp/src/ui-apps/components/utils.tsindex e9f235434a89..bb25041c00b6 100644--- a/services/mcp/src/ui-apps/components/utils.ts+++ b/services/mcp/src/ui-apps/components/utils.ts@@ -102,8 +102,8 @@ export function formatTooltipDate(dateStr: string, interval?: string): string {return time ? `${day} ${time}` : day}-export function getSeriesLabel(item: { label?: string; action?: { name?: string } }, index: number): string {- return item.label || item.action?.name || `Series ${index + 1}`+export function getSeriesLabel(item: { label?: string }, index: number): string {+ return item.label || `Series ${index + 1}`}export function buildProportionBarSeries(results: TrendsResultItem[], getColor: (index: number) => string): Series[] {diff --git a/services/mcp/tests/unit/insight-visualizations.test.ts b/services/mcp/tests/unit/insight-visualizations.test.tsindex a85f578d62ac..f69b4f56bdd3 100644--- a/services/mcp/tests/unit/insight-visualizations.test.ts+++ b/services/mcp/tests/unit/insight-visualizations.test.ts@@ -232,9 +232,8 @@ describe('insight visualizations', () => {})describe('getSeriesLabel', () => {- it('prefers label, then action name, then a positional fallback', () => {- expect(getSeriesLabel({ label: 'Pageviews', action: { name: '$pageview' } }, 0)).toBe('Pageviews')- expect(getSeriesLabel({ action: { name: '$pageview' } }, 0)).toBe('$pageview')+ it('prefers label, then a positional fallback', () => {+ expect(getSeriesLabel({ label: 'Pageviews' }, 0)).toBe('Pageviews')expect(getSeriesLabel({}, 2)).toBe('Series 3')})})