Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(insights): render ActionsStackedBar trends display instead of blank tile (#67348)

Thomas Obermüller428d33f88043
diff --git a/frontend/src/exporter/ExportedInsight/ExportedInsight.tsx b/frontend/src/exporter/ExportedInsight/ExportedInsight.tsx
index a3792e3ba2d5..1035e0392ff1 100644
--- a/frontend/src/exporter/ExportedInsight/ExportedInsight.tsx
+++ b/frontend/src/exporter/ExportedInsight/ExportedInsight.tsx
@@ -20,7 +20,7 @@ import { InsightsTable } from 'scenes/insights/views/InsightsTable/InsightsTable
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
import { Query } from '~/queries/Query/Query'
import { SharingConfigurationSettings } from '~/queries/schema/schema-general'
-import { isDataTableNode, isInsightVizNode, isTrendsQuery } from '~/queries/utils'
+import { getDisplay, isDataTableNode, isInsightVizNode, isTrendsQuery } from '~/queries/utils'
import { ChartDisplayType, DataColorThemeModel, InsightLogicProps, InsightModel } from '~/types'
export function ExportedInsight({
@@ -55,8 +55,9 @@ export function ExportedInsight({
const { short_id, query, name, derived_name, description } = insight
const showWatermark = noHeader && !whitelabel
- const trendsDisplay =
- isInsightVizNode(query) && isTrendsQuery(query.source) ? query.source.trendsFilter?.display : undefined
+ // getDisplay rather than a raw trendsFilter read, so deprecated display aliases pick the same
+ // legend layout here as the chart they get normalized to.
+ const trendsDisplay = isInsightVizNode(query) && isTrendsQuery(query.source) ? getDisplay(query.source) : undefined
const isBoxPlot = trendsDisplay === ChartDisplayType.BoxPlot
const isMetric = trendsDisplay === ChartDisplayType.Metric
const showLegend =
diff --git a/frontend/src/queries/utils.test.ts b/frontend/src/queries/utils.test.ts
index d320299e4752..9c81ca09a642 100644
--- a/frontend/src/queries/utils.test.ts
+++ b/frontend/src/queries/utils.test.ts
@@ -15,6 +15,7 @@ import {
escapeDottedHogQLIdentifier,
escapeHogQLString,
escapePropertyAsHogQLIdentifier,
+ getDisplay,
hogql,
queryUsesDataWarehouse,
queryVizDefinitelyRendersToCanvas,
@@ -429,3 +430,28 @@ describe('dataWarehouseSourcesFromResponse', () => {
expect(dataWarehouseSourcesFromResponse(undefined)).toEqual([])
})
})
+
+describe('getDisplay', () => {
+ // ActionsStackedBar is a deprecated trends/stickiness alias of ActionsBar; the API and MCP
+ // accept it, and nothing downstream of getDisplay knows how to render it.
+ it.each([
+ [
+ 'trends',
+ {
+ kind: NodeKind.TrendsQuery,
+ series: [],
+ trendsFilter: { display: ChartDisplayType.ActionsStackedBar },
+ },
+ ],
+ [
+ 'stickiness',
+ {
+ kind: NodeKind.StickinessQuery,
+ series: [],
+ stickinessFilter: { display: ChartDisplayType.ActionsStackedBar },
+ },
+ ],
+ ])('normalizes the deprecated ActionsStackedBar alias to ActionsBar for %s', (_, query) => {
+ expect(getDisplay(query as InsightQueryNode)).toEqual(ChartDisplayType.ActionsBar)
+ })
+})
diff --git a/frontend/src/queries/utils.ts b/frontend/src/queries/utils.ts
index 825f101e0042..484e19984700 100644
--- a/frontend/src/queries/utils.ts
+++ b/frontend/src/queries/utils.ts
@@ -505,11 +505,17 @@ export const getInterval = (query: InsightQueryNode): IntervalType | undefined =
return undefined
}
+// For trends/stickiness, ActionsStackedBar is a deprecated alias of ActionsBar (which renders stacked):
+// the UI never emits it, but the API and MCP accept it. Normalizing here — the point all `display`
+// selectors derive from — makes such insights behave exactly like their UI-created equivalents.
+const normalizeDisplay = (display: ChartDisplayType | undefined): ChartDisplayType | undefined =>
+ display === ChartDisplayType.ActionsStackedBar ? ChartDisplayType.ActionsBar : display
+
export const getDisplay = (query: InsightQueryNode): ChartDisplayType | undefined => {
if (isStickinessQuery(query)) {
- return query.stickinessFilter?.display
+ return normalizeDisplay(query.stickinessFilter?.display)
} else if (isTrendsQuery(query)) {
- return query.trendsFilter?.display
+ return normalizeDisplay(query.trendsFilter?.display)
}
return undefined
}
diff --git a/frontend/src/scenes/trends/Trends.tsx b/frontend/src/scenes/trends/Trends.tsx
index fb117ddcd140..3b22eccb5042 100644
--- a/frontend/src/scenes/trends/Trends.tsx
+++ b/frontend/src/scenes/trends/Trends.tsx
@@ -93,21 +93,10 @@ export function TrendInsight({ view, context, embedded, inSharedMode, editMode }
inSharedMode,
}
- const renderViz = (): JSX.Element | undefined => {
+ const renderViz = (): JSX.Element => {
if (isLifecycle) {
return <TrendsLifecycleChart context={context} inSharedMode={inSharedMode} />
}
- if (
- !display ||
- display === ChartDisplayType.ActionsLineGraph ||
- display === ChartDisplayType.ActionsLineGraphCumulative ||
- display === ChartDisplayType.ActionsAreaGraph
- ) {
- if (isStickiness) {
- return <StickinessLineChart context={context} />
- }
- return <TrendsLineChart context={context} inSharedMode={inSharedMode} />
- }
if (display === ChartDisplayType.ActionsBar || display === ChartDisplayType.ActionsUnstackedBar) {
if (isStickiness) {
return <StickinessBarChart context={context} />
@@ -160,6 +149,12 @@ export function TrendInsight({ view, context, embedded, inSharedMode, editMode }
if (display === ChartDisplayType.SlopeGraph) {
return <TrendsSlopeChart context={context} />
}
+ // Line/area/cumulative displays land here, and so does any display value without a trends
+ // renderer (e.g. Auto, reachable via the API) — the default chart beats a blank tile.
+ if (isStickiness) {
+ return <StickinessLineChart context={context} />
+ }
+ return <TrendsLineChart context={context} inSharedMode={inSharedMode} />
}
return (
diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
index 25da2f260cc4..4447a354a54c 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
@@ -467,6 +467,26 @@ describe('TrendsBarChart (ActionsUnstackedBar)', () => {
})
})
+describe('TrendsBarChart (ActionsStackedBar)', () => {
+ // Regression for #66497: ActionsStackedBar is a deprecated alias of ActionsBar on trends
+ // queries — never emitted by the UI, but accepted from the API/MCP. It used to fall through
+ // the trends render dispatch and produce a blank tile; getDisplay() now normalizes it.
+ it('renders the stacked bar chart instead of a blank tile', async () => {
+ renderInsight({
+ query: buildTrendsQuery({
+ trendsFilter: { display: ChartDisplayType.ActionsStackedBar },
+ }),
+ })
+
+ await waitFor(
+ () => {
+ expect(screen.getByTestId('trend-bar-graph')).toBeInTheDocument()
+ },
+ { timeout: 5000 }
+ )
+ })
+})
+
describe('TrendsBarChart overlays', () => {
it('renders value labels when showValuesOnSeries is enabled', async () => {
renderInsight({
diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
index 01da077d3f41..bd75a6ed1351 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
@@ -536,6 +536,22 @@ describe('TrendsLineChart', () => {
})
})
+ describe('display fallback', () => {
+ it('renders the line chart for display types without a trends renderer', async () => {
+ // `Auto` is schema-valid on a trends query (reachable via the API/MCP) but has no
+ // dedicated branch in the trends render dispatch — it must not blank the tile.
+ renderInsight({
+ query: buildTrendsQuery({
+ trendsFilter: { display: ChartDisplayType.Auto },
+ }),
+ })
+
+ await waitFor(() => {
+ expect(screen.getByTestId('trend-line-graph')).toBeInTheDocument()
+ })
+ })
+ })
+
describe('click → persons modal', () => {
it('single series: direct click shows the actors for the clicked day', async () => {
renderInsight({ query: buildTrendsQuery() })