:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(customer-analytics): let overview tile subtitles be blank (#124515)
jake sciotto914477568cb6
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.mdindex 5dd35e9bb213..aa09699cf8bd 100644--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md@@ -129,7 +129,7 @@ A custom-property column is editable unless its definition is canonical or has a**Overview tile math** (`accountsOverviewTilesLogic` / `AccountsOverviewTilesEditor`). A tile's metric is a discriminated union: `count`, the column aggregations `sum`/`avg`/`min`/`max`/`median`, and `count_threshold`. `tileQueryMetric` translates these into the typed `AccountsTableMetric` union. Column aggregations carry an optional `scale` multiplier, and threshold tiles translate into typed custom-property filters when clicked.-**Tile display** (title / subtitle / value format). A tile also carries two optional presentation fields, independent of the metric: `caption` (custom subtitle) and `format` (`TileValueFormat` = `unit`/`currency`/`percentage`, a subset of `OverviewGrid`'s `WebAnalyticsItemKind` so `format ?? 'unit'` maps 1:1 to the render `kind`). `tileCaption(tile)` resolves the subtitle: the trimmed custom `caption` when set, else `autoCaption(tile)` (the derived `agg of col × n` / `col op val` text; `count` has no derived caption, so a custom one is the only subtitle it can show). The editor edits `caption` (empty → `undefined`) and `format` (`unit` → `undefined`); both flow through the row's `emit(patch)` merge so a metric edit never drops them. Render formatting lives in `OverviewGrid.formatItem`: `currency` uses the team `baseCurrency`, `percentage` treats the value as already in percent units (`85` → "85%", combine with `scale × 100` for a 0-1 fraction). Both fields ride along in `properties.tiles` (no backend/schema/migration) and default cleanly for older saved/legacy tiles.+**Tile display** (title / subtitle / value format). A tile also carries two optional presentation fields, independent of the metric: `caption` (custom subtitle) and `format` (`TileValueFormat` = `unit`/`currency`/`percentage`, a subset of `OverviewGrid`'s `WebAnalyticsItemKind` so `format ?? 'unit'` maps 1:1 to the render `kind`). `tileCaption(tile)` resolves the subtitle: `autoCaption(tile)` while `caption` is unset (the derived `agg of col × n` / `col op val` text; `count` has no derived caption, so a custom one is the only subtitle it can show), the trimmed `caption` when it has text, and no subtitle when `caption` is blank. The editor shows the derived caption as input text, not as a placeholder, so a person can clear it. A cleared input stores `''`. Input text equal to the derived caption stores `undefined`, so the subtitle keeps following metric edits. The editor also edits `format` (`unit` → `undefined`). Both fields flow through the row's `emit(patch)` merge so a metric edit never drops them. Render formatting lives in `OverviewGrid.formatItem`: `currency` uses the team `baseCurrency`, `percentage` treats the value as already in percent units (`85` → "85%", combine with `scale × 100` for a 0-1 fraction). Both fields ride along in `properties.tiles` (no backend/schema/migration) and default cleanly for older saved/legacy tiles.### Sorting (hybrid client / server)diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsOverviewTilesEditor.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsOverviewTilesEditor.tsxindex 5918b4516d27..09aeb21a27c0 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsOverviewTilesEditor.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsOverviewTilesEditor.tsx@@ -263,8 +263,10 @@ function TileEditorRow({ tile, numericColumns, onChange, onRemove }: TileEditorRemit({ label: labelAfterMetricChange(nextMetric), metric: nextMetric })}+ // A cleared input stores a blank caption, which hides the subtitle. Text equal to the derived+ // caption stays unset, so the subtitle keeps following later metric edits.const onCaptionChange = (value: string): void => {- emit({ caption: value.trim() ? value : undefined })+ emit({ caption: value === autoCaption(tile) ? undefined : value })}const onFormatChange = (format: TileValueFormat): void => {@@ -302,9 +304,9 @@ function TileEditorRow({ tile, numericColumns, onChange, onRemove }: TileEditorR</div><div className="pl-6"><LemonInput- value={tile.caption ?? ''}+ value={tile.caption ?? autoCaption(tile) ?? ''}onChange={onCaptionChange}- placeholder={autoCaption(tile) ?? 'Subtitle (optional)'}+ placeholder="Subtitle (optional)"size="small"fullWidthdata-attr={`accounts-overview-tile-caption-${tile.id}`}diff --git a/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.tsindex a8e57c0b3edb..a6a20ab633a1 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.ts@@ -158,13 +158,14 @@ describe('tileCaption', () => {}const count: AccountsOverviewTile = { id: 'c', label: 'Accounts', metric: { type: 'count' } }- // A custom caption must win over the derived one, an empty/whitespace caption must fall- // back to it, and, since count tiles have no derived caption, a custom caption is the- // only way they get a subtitle at all. A regression in the precedence silently either- // drops the user's subtitle or blanks the auto one.+ // A custom caption must win over the derived one, an unset caption must fall back to it,+ // and a blank caption must hide the subtitle. Count tiles have no derived caption, so a+ // custom caption is the only way they get a subtitle at all. A regression in the precedence+ // silently drops the user's subtitle, blanks the auto one, or brings the auto one back over+ // a subtitle that the user cleared.it.each<[string, AccountsOverviewTile, string | undefined]>([['custom overrides derived', { ...sum, caption: 'Monthly recurring' }, 'Monthly recurring'],- ['whitespace-only caption falls back to derived', { ...sum, caption: ' ' }, 'sum of MRR'],+ ['whitespace-only caption hides the subtitle', { ...sum, caption: ' ' }, undefined],['undefined caption uses derived', sum, 'sum of MRR'],['derived caption keeps the scale suffix',diff --git a/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.tsindex 07939790c485..6c2deec7987d 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.ts@@ -80,7 +80,7 @@ export interface AccountsOverviewTile {id: stringlabel: stringmetric: AccountsOverviewTileMetric- // Custom subtitle; empty/whitespace/undefined falls back to the auto-derived caption.+ // Custom subtitle. Undefined shows the auto-derived caption, and a blank string hides the subtitle.caption?: string// Value display format; undefined renders as a plain unit.format?: TileValueFormat@@ -180,11 +180,11 @@ export function autoCaption(tile: AccountsOverviewTile): string | undefined {}}-// The subtitle shown on a tile: the user's custom caption when set, else the-// auto-derived one. A whitespace-only caption is treated as unset.+// The subtitle shown on a tile: the auto-derived one while the caption is unset, else the+// user's caption. A blank or whitespace-only caption hides the subtitle.export function tileCaption(tile: AccountsOverviewTile): string | undefined {const custom = tile.caption?.trim()- return custom ? custom : autoCaption(tile)+ return custom === undefined ? autoCaption(tile) : custom || undefined}export function tileToRowFilter(tile: AccountsOverviewTile): AccountsTableCustomPropertyFilter | null {