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(dashboards): apply a pinned color saved without a breakdown type (#97322)

Thomas Obermüller2333e1c2255c
diff --git a/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts b/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts
index 7feb008b6965..69489b00cd0c 100644
--- a/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts
+++ b/frontend/src/scenes/dashboard/dashboardBreakdownColors.test.ts
@@ -1105,6 +1105,25 @@ describe('dashboardBreakdownColors', () => {
expect(findBreakdownColorConfig(configs, null, 'event')).toBeUndefined()
})
+ // Separate configs, because giving the shared list an untyped entry would satisfy the
+ // 'breakdown type must match' case above and remove what it checks.
+ it.each([
+ ['an entry with no type matches an event series', undefined, 'event', 'preset-9'],
+ ['an entry with no type matches a series with no type', undefined, undefined, 'preset-9'],
+ ['a null type reads the same as an omitted one', null, 'event', 'preset-9'],
+ // The default is `event`, not a wildcard, so an untyped entry must not colour a person
+ // series that happens to share the value.
+ ['an entry with no type does not match a person series', undefined, 'person', undefined],
+ ] as const)('%s', (_name, configType, seriesType, expectedToken) => {
+ const untypedConfigs = [
+ { breakdownValue: 'Chrome', breakdownType: configType, colorToken: 'preset-9' },
+ ] as BreakdownColorConfig[]
+
+ expect(findBreakdownColorConfig(untypedConfigs, 'Chrome', seriesType as any)?.colorToken).toEqual(
+ expectedToken
+ )
+ })
+
it('prefers a property-scoped entry and falls back to a property-less one', () => {
const scopedConfigs: BreakdownColorConfig[] = [
{ breakdownValue: 'Chrome', breakdownType: 'event', colorToken: 'preset-1' },
diff --git a/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts b/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts
index 7785797c1a37..bc604dbc2556 100644
--- a/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts
+++ b/frontend/src/scenes/dashboard/dashboardBreakdownColors.ts
@@ -115,9 +115,13 @@ export function breakdownConfigMatches(
}
// A property key already encodes each part's type, so scoped entries match on it alone;
// property-less entries keep the legacy value-and-type match under any property.
+ //
+ // Both sides default a missing type to `event`, as breakdownConfigIdentityMatches does. An entry
+ // written without a type, which the API accepts, would otherwise compare `undefined` against a
+ // real type and never match any series.
return config.breakdownProperty != null
? config.breakdownProperty === breakdownPropertyKey
- : config.breakdownType === (breakdownType ?? 'event')
+ : (config.breakdownType ?? 'event') === (breakdownType ?? 'event')
}
/** True when two configs denote the same entry: same normalized value, type, and property