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): type TrendResult.action as nullable for formula series (#72373)

Thomas Obermüller33d85a6550ef
diff --git a/frontend/src/lib/components/InsightLabel/index.tsx b/frontend/src/lib/components/InsightLabel/index.tsx
index d79b4a9a64ef..d0ebb5945b57 100644
--- a/frontend/src/lib/components/InsightLabel/index.tsx
+++ b/frontend/src/lib/components/InsightLabel/index.tsx
@@ -29,7 +29,7 @@ export enum IconSize {
// InsightsLabel pretty prints the action (or event) returned from /insights
interface InsightsLabelProps {
seriesColor?: string
- action?: ActionFilter
+ action?: ActionFilter | null
value?: string
className?: string
breakdownValue?: BreakdownKeyType
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index d6a5de6b0033..30d8489d35ac 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -3392,7 +3392,8 @@ export interface TrendAPIResponse<ResultType = TrendResult[]> {
}
export interface TrendResult {
- action: ActionFilter
+ /** Series entity. `null` for formula results, which aren't backed by a single entity. */
+ action: ActionFilter | null
actions?: ActionFilter[]
count: number
data: number[]
diff --git a/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.ts b/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.ts
index a1f3b2551ffe..71b300d1a98b 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.ts
+++ b/products/product_analytics/frontend/insights/trends/TrendsPieChart/trendsPieTransforms.ts
@@ -36,7 +36,7 @@ export function buildTrendsPieSeries<R extends IndexedTrendResult>(
data: [r.aggregated_value ?? 0],
color: opts.getColor(r, index),
meta: {
- action: r.action,
+ action: r.action ?? undefined,
breakdown_value: r.breakdown_value,
compare_label: r.compare_label,
days: r.days,
diff --git a/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.ts b/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.ts
index 5748dfd49913..8ca04ec18085 100644
--- a/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.ts
+++ b/products/product_analytics/frontend/insights/trends/shared/trendsSeriesMeta.ts
@@ -14,7 +14,7 @@ export type TrendsSeriesMeta = {
}
export const buildTrendsSeriesMeta = (r: IndexedTrendResult): TrendsSeriesMeta => ({
- action: r.action,
+ action: r.action ?? undefined,
breakdown_value: r.breakdown_value,
compare_label: r.compare_label,
days: r.days,
diff --git a/products/revenue_analytics/frontend/nodes/revenueAnalyticsChartTransforms.ts b/products/revenue_analytics/frontend/nodes/revenueAnalyticsChartTransforms.ts
index eddc0961a5f8..24445d7648d8 100644
--- a/products/revenue_analytics/frontend/nodes/revenueAnalyticsChartTransforms.ts
+++ b/products/revenue_analytics/frontend/nodes/revenueAnalyticsChartTransforms.ts
@@ -28,7 +28,7 @@ export function buildRevenueAnalyticsSeries(
fill: kind === 'area' ? {} : undefined,
stroke: dashFromIndex !== undefined ? { partial: { fromIndex: dashFromIndex } } : undefined,
meta: {
- action: dataset.action,
+ action: dataset.action ?? undefined,
breakdown_value: dataset.breakdown_value,
days: dataset.days,
order: dataset.action?.order ?? index,