: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(cdp): bucket invocations sparkline in the project timezone (#80957)
Daniel Marchuke0fa3eaaf111
diff --git a/frontend/src/scenes/hog-functions/invocations/InvocationsSparkline.tsx b/frontend/src/scenes/hog-functions/invocations/InvocationsSparkline.tsxindex 8b4e4da6523c..003dc42316f7 100644--- a/frontend/src/scenes/hog-functions/invocations/InvocationsSparkline.tsx+++ b/frontend/src/scenes/hog-functions/invocations/InvocationsSparkline.tsx@@ -1,3 +1,4 @@+import { useValues } from 'kea'import { useCallback, useMemo, useState } from 'react'import { IconChevronDown } from '@posthog/icons'@@ -6,8 +7,9 @@ import { LemonButton, SpinnerOverlay } from '@posthog/lemon-ui'import { AnyScaleOptions, Sparkline } from 'lib/components/Sparkline'import { dayjs } from 'lib/dayjs'import { cn } from 'lib/utils/css-classes'+import { teamLogic } from 'scenes/teamLogic'-import { SparklineData } from './hogInvocationsLogic'+import { SparklineData, projectTimezoneOf } from './hogInvocationsLogic'interface InvocationsSparklineProps {data: SparklineData | null@@ -21,6 +23,11 @@ export function InvocationsSparkline({onDateRangeChange,}: InvocationsSparklineProps): JSX.Element | null {const [collapsed, setCollapsed] = useState(false)+ const { currentTeam } = useValues(teamLogic)+ // Buckets are cut in the project's timezone, so label them there too: in the viewer's zone a+ // project-local day can read as the day before. Resolved the same way the buckets are, or the+ // labels would fall back to UTC while the team is still loading and the bars would not.+ const projectTimezone = projectTimezoneOf(currentTeam)const { timeUnit, tickFormat } = useMemo(() => {const dates = data?.dates ?? []@@ -47,11 +54,11 @@ export function InvocationsSparkline({maxRotation: 0,maxTicksLimit: 6,font: { size: 10, lineHeight: 1 },- callback: (value: string | number) => dayjs(value).format(tickFormat),+ callback: (value: string | number) => dayjs(value).tz(projectTimezone).format(tickFormat),},time: { unit: timeUnit },}) as AnyScaleOptions,- [timeUnit, tickFormat]+ [timeUnit, tickFormat, projectTimezone])const onSelectionChange = useCallback(@@ -94,7 +101,7 @@ export function InvocationsSparkline({className="w-full h-full"onSelectionChange={onSelectionChange}withXScale={withXScale}- renderLabel={(label) => dayjs(label).format('D MMM YYYY HH:mm')}+ renderLabel={(label) => dayjs(label).tz(projectTimezone).format('D MMM YYYY HH:mm')}hideZerosInTooltipsortTooltipByCount/>diff --git a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.test.ts b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.test.tsindex 84c635729678..00e1b9d6c624 100644--- a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.test.ts+++ b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.test.ts@@ -1,6 +1,10 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'+import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import { dayjs } from 'lib/dayjs'+import { useMocks } from '~/mocks/jest'import { initKeaTests } from '~/test/init'@@ -140,4 +144,182 @@ describe('hogInvocationsLogic', () => {scoped.unmount()})})++ describe('sparkline buckets', () => {+ // ClickHouse buckets `toStartOf*` in the project timezone and returns the boundary with that+ // offset. Generating the lookup keys on the UTC grid instead lands them on a different instant,+ // every bucket resolves to 0, and the chart reads "No invocations in this window" while the+ // table below it is full. Both rows below are windows where that happened.+ it.each([+ { tier: 'daily (window over 7 days)', timezone: 'America/Los_Angeles', dateFrom: '-30d', unit: 'day' },+ { tier: 'hourly (half-hour offset project)', timezone: 'Asia/Kolkata', dateFrom: '-7d', unit: 'hour' },+ ] as const)('counts land in the bucket ClickHouse returned: $tier', async ({ timezone, dateFrom, unit }) => {+ // The boundary ClickHouse would return for a run 3 days ago, in the project's zone.+ const bucket = dayjs().tz(timezone).subtract(3, 'day').startOf(unit)+ useMocks({+ post: {+ // `format()` carries the project's offset, the way the query API serializes it.+ '/api/environments/:team_id/query/HogQLQuery/': () => [+ 200,+ { results: [[bucket.format(), 'succeeded', 5]] },+ ],+ },+ })+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, timezone })++ const logic = hogInvocationsLogic({ id: 'flow-1', functionKind: 'hog_flow' })+ logic.mount()+ logic.actions.setFilters({ date_from: dateFrom })+ await expectLogic(logic).toDispatchActions(['loadSparklineSuccess'])++ const { dates, series } = logic.values.sparkline!+ const index = dates.indexOf(bucket.toISOString())+ expect(index).toBeGreaterThanOrEqual(0)+ expect(series.find((s) => s.name === 'succeeded')!.values[index]).toBe(5)++ logic.unmount()+ })++ it('covers a window spanning a DST transition, one bucket per local day', async () => {+ // 1 Nov 2026 is 25 hours long in America/Los_Angeles. Stepping the instant by 24h drifts+ // off local midnight there, and re-snapping the drifted instant lands back on the same+ // bucket, which silently truncated the range at the transition.+ const timezone = 'America/Los_Angeles'+ useMocks({+ post: {+ '/api/environments/:team_id/query/HogQLQuery/': () => [200, { results: [] }],+ },+ })+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, timezone })++ const logic = hogInvocationsLogic({ id: 'flow-1', functionKind: 'hog_flow' })+ logic.mount()+ logic.actions.setFilters({ date_from: '2026-10-27', date_to: '2026-11-07' })+ await expectLogic(logic).toDispatchActions(['loadSparklineSuccess'])++ const { dates } = logic.values.sparkline!+ const localDays = dates.map((d) => dayjs(d).tz(timezone).format('MM-DD HH:mm'))+ expect(localDays[0]).toBe('10-27 00:00')+ expect(localDays[localDays.length - 1]).toBe('11-06 00:00')+ expect(new Set(localDays.map((d) => d.slice(6)))).toEqual(new Set(['00:00']))+ expect(new Set(localDays).size).toBe(localDays.length)++ logic.unmount()+ })++ it('falls back to the app context timezone before teamLogic has loaded the team', async () => {+ // `teamLogic` fetches the team when the page ships no app context, and `currentTeam` is+ // null until it lands. Bucketing on UTC there would empty the chart for every non-UTC+ // project, which is the bug this file is about.+ const timezone = 'America/Los_Angeles'+ const bucket = dayjs().tz(timezone).subtract(3, 'day').startOf('day')+ useMocks({+ post: {+ '/api/environments/:team_id/query/HogQLQuery/': () => [+ 200,+ { results: [[bucket.format(), 'succeeded', 2]] },+ ],+ },+ })+ // teamLogic unmounted, so the timezone can only come from app context.+ initKeaTests(false, { ...MOCK_DEFAULT_TEAM, timezone })++ const logic = hogInvocationsLogic({ id: 'flow-1', functionKind: 'hog_flow' })+ logic.mount()+ logic.actions.setFilters({ date_from: '-30d' })+ await expectLogic(logic).toDispatchActions(['loadSparklineSuccess'])++ const { dates, series } = logic.values.sparkline!+ const index = dates.indexOf(bucket.toISOString())+ expect(index).toBeGreaterThanOrEqual(0)+ expect(series.find((s) => s.name === 'succeeded')!.values[index]).toBe(2)+ expect(new Set(dates.map((d) => dayjs(d).tz(timezone).format('HH:mm')))).toEqual(new Set(['00:00']))++ logic.unmount()+ })++ it('sums both passes of a repeated fall-back hour into one bucket', async () => {+ // 01:00 happens twice on 1 Nov in America/Los_Angeles, so ClickHouse returns two rows+ // carrying the same wall clock. Joining on the instant splits them across two buckets+ // and leaves the axis a physical hour short of the runs it holds.+ const timezone = 'America/Los_Angeles'+ useMocks({+ post: {+ '/api/environments/:team_id/query/HogQLQuery/': () => [+ 200,+ {+ results: [+ ['2026-11-01T01:00:00-07:00', 'succeeded', 1],+ ['2026-11-01T01:00:00-08:00', 'succeeded', 4],+ ],+ },+ ],+ },+ })+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, timezone })++ const logic = hogInvocationsLogic({ id: 'flow-1', functionKind: 'hog_flow' })+ logic.mount()+ logic.actions.setFilters({ date_from: '2026-10-30', date_to: '2026-11-05' })+ await expectLogic(logic).toDispatchActions(['loadSparklineSuccess'])++ const { dates, series } = logic.values.sparkline!+ const oneAm = dates.filter((d) => dayjs(d).tz(timezone).format('MM-DD HH:mm') === '11-01 01:00')+ expect(oneAm).toHaveLength(1)+ const values = series.find((s) => s.name === 'succeeded')!.values+ expect(values[dates.indexOf(oneAm[0])]).toBe(5)++ logic.unmount()+ })++ it('starts an absolute range on the selected project-local day', async () => {+ // The date picker emits '2026-08-01' with no offset. Reading that as UTC midnight starts a+ // west-of-UTC project the previous evening, so the axis opens on a partial day labelled+ // 31 July and the queried window begins hours before the date the user picked.+ const timezone = 'America/Los_Angeles'+ useMocks({+ post: {+ '/api/environments/:team_id/query/HogQLQuery/': () => [200, { results: [] }],+ },+ })+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, timezone })++ const logic = hogInvocationsLogic({ id: 'flow-1', functionKind: 'hog_flow' })+ logic.mount()+ logic.actions.setFilters({ date_from: '2026-08-01', date_to: '2026-08-12' })+ await expectLogic(logic).toDispatchActions(['loadSparklineSuccess'])++ const walls = logic.values.sparkline!.dates.map((d) => dayjs(d).tz(timezone).format('MM-DD HH:mm'))+ expect(walls[0]).toBe('08-01 00:00')+ expect(walls[walls.length - 1]).toBe('08-11 00:00')++ logic.unmount()+ })++ it('drops a wall clock that a spring-forward skips', async () => {+ // 02:00 never happens on 14 Mar 2027 in America/Los_Angeles, so no run can carry it.+ // Keeping it would add a bucket nothing can ever fill, sharing an x position with 03:00.+ const timezone = 'America/Los_Angeles'+ useMocks({+ post: {+ '/api/environments/:team_id/query/HogQLQuery/': () => [200, { results: [] }],+ },+ })+ initKeaTests(true, { ...MOCK_DEFAULT_TEAM, timezone })++ const logic = hogInvocationsLogic({ id: 'flow-1', functionKind: 'hog_flow' })+ logic.mount()+ logic.actions.setFilters({ date_from: '2027-03-12', date_to: '2027-03-17' })+ await expectLogic(logic).toDispatchActions(['loadSparklineSuccess'])++ const { dates } = logic.values.sparkline!+ const walls = dates.map((d) => dayjs(d).tz(timezone).format('MM-DD HH:mm'))+ expect(walls).toContain('03-14 01:00')+ expect(walls).toContain('03-14 03:00')+ expect(walls).not.toContain('03-14 02:00')+ expect(new Set(dates).size).toBe(dates.length)++ logic.unmount()+ })+ })})diff --git a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsxindex a1a1d478170d..e077a5aea3a1 100644--- a/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx+++ b/frontend/src/scenes/hog-functions/invocations/hogInvocationsLogic.tsx@@ -7,6 +7,7 @@ import { lemonToast } from '@posthog/lemon-ui'import api, { ApiConfig } from 'lib/api'import { dayjs } from 'lib/dayjs'import { dateStringToDayJs } from 'lib/utils/dateFilters'+import { getAppContext } from 'lib/utils/getAppContext'import { teamLogic } from 'scenes/teamLogic'import { escapeHogQLString, hogql } from '~/queries/utils'@@ -295,22 +296,42 @@ const parseRelativeHours = (value: string | undefined): number | null => {return n * (hoursPerUnit[match[2]] ?? 0)}+/**+ * Timezone every HogQL date expression here resolves in: HogQL wraps DateTime+ * fields in `toTimeZone(field, team_tz)`, so both the window literals and the+ * sparkline's bucket boundaries have to be built in the team's zone, not UTC.+ *+ * App context is the second source because `teamLogic` fills `currentTeam` from it+ * synchronously on mount but falls back to a fetch when it is absent. Guessing UTC+ * during that fetch would bucket every boundary on the wrong grid and empty the chart.+ */+export const projectTimezoneOf = (currentTeam?: { timezone?: string } | null): string =>+ currentTeam?.timezone ?? getAppContext()?.current_team?.timezone ?? 'UTC'++const teamTimezone = (): string => projectTimezoneOf(teamLogic.findMounted()?.values.currentTeam)+/*** Resolve the filter's date range to concrete dayjs endpoints. Centralizing* this so the sparkline's bucket sizing AND its boundary generation see the* same window (otherwise the chart's x-axis can drift away from the actual* filter the table is using).+ *+ * A picked date carries no offset, so it resolves in the project timezone: "1 August" has to mean+ * that calendar day for the project, not a window starting the previous evening. Range values the+ * chart's own selection emits carry an offset, which dayjs honors over this argument, so those+ * still round-trip to the instant that was selected.*/export const resolveDateRange = (filters: {date_from?: stringdate_to?: string}): { start: dayjs.Dayjs; end: dayjs.Dayjs } => {- const end = filters.date_to ? (dateStringToDayJs(filters.date_to) ?? dayjs()) : dayjs()+ const timezone = teamTimezone()+ const end = filters.date_to ? (dateStringToDayJs(filters.date_to, timezone) ?? dayjs()) : dayjs()const relHours = parseRelativeHours(filters.date_from)if (relHours !== null) {return { start: end.subtract(relHours, 'hour'), end }}- const start = dateStringToDayJs(filters.date_from ?? null) ?? end.subtract(24, 'hour')+ const start = dateStringToDayJs(filters.date_from ?? null, timezone) ?? end.subtract(24, 'hour')return { start, end }}@@ -322,12 +343,9 @@ export const resolveDateRange = (filters: {*/export const dateClauseFor = (filters: HogInvocationsFilters): ReturnType<typeof hogql.raw> => {const { start, end } = resolveDateRange(filters)- // HogQL interprets bare datetime literals in the *team* timezone (DateTime- // fields are compared as toTimeZone(field, team_tz)), so format the window- // bounds in the team tz — NOT UTC — or the filter is shifted by the team's- // offset for any non-UTC project. Mirrors `toAbsoluteClickhouseTimestamp`.- const teamTimezone = teamLogic.findMounted()?.values.currentTeam?.timezone ?? 'UTC'- const fmt = (d: dayjs.Dayjs): string => d.tz(teamTimezone).format('YYYY-MM-DD HH:mm:ss.SSS')+ // Format the window bounds in the team tz — NOT UTC — or the filter is shifted+ // by the team's offset for any non-UTC project. Mirrors `toAbsoluteClickhouseTimestamp`.+ const fmt = (d: dayjs.Dayjs): string => d.tz(teamTimezone()).format('YYYY-MM-DD HH:mm:ss.SSS')return hogql.raw(`AND scheduled_at >= '${fmt(start)}' AND scheduled_at < '${fmt(end)}'`)}@@ -424,47 +442,101 @@ export const buildSearchClause = (/*** Tier selection for the sparkline. Each tier carries both the HogQL bucket- * expression and the equivalent client-side interval (in ms) so we can- * generate every bucket boundary in the filter range, not just the ones CH- * returned data for. Tiers (by total range): <24h minutely, ≤4d 15-min,- * ≤7d hourly, otherwise daily.+ * expression and its client-side step, so we can generate every bucket boundary+ * in the filter range, not just the ones CH returned data for. Tiers (by total+ * range): <24h minutely, ≤4d 15-min, ≤7d hourly, otherwise daily.*/+type SparklineStepUnit = 'minute' | 'hour' | 'day'interface SparklineTier {- intervalMs: number+ stepAmount: number+ stepUnit: SparklineStepUnitbucketExpr: string}const pickSparklineTier = (filters: HogInvocationsFilters): SparklineTier => {const { start, end } = resolveDateRange(filters)const hours = end.diff(start, 'hour')if (hours < 24) {- return { intervalMs: 60_000, bucketExpr: 'toStartOfMinute(first_scheduled)' }+ return { stepAmount: 1, stepUnit: 'minute', bucketExpr: 'toStartOfMinute(first_scheduled)' }}if (hours <= 4 * 24) {return {- intervalMs: 15 * 60_000,+ stepAmount: 15,+ stepUnit: 'minute',bucketExpr: 'toStartOfInterval(first_scheduled, INTERVAL 15 MINUTE)',}}if (hours <= 7 * 24) {- return { intervalMs: 60 * 60_000, bucketExpr: 'toStartOfHour(first_scheduled)' }+ return { stepAmount: 1, stepUnit: 'hour', bucketExpr: 'toStartOfHour(first_scheduled)' }+ }+ return { stepAmount: 1, stepUnit: 'day', bucketExpr: 'toStartOfDay(first_scheduled)' }+}++/**+ * Snap an instant down to a bucket boundary the way the tier's `toStartOf*`+ * does, i.e. in the *team* timezone. Snapping on the UTC epoch grid instead+ * silently loses every bucket for a non-UTC project: `toStartOfDay` returns+ * local midnight, so nothing matches a UTC midnight key and the whole chart+ * reads as empty.+ */+const snapToBucket = (t: dayjs.Dayjs, { stepAmount, stepUnit }: SparklineTier): dayjs.Dayjs => {+ const local = t.tz(teamTimezone())+ if (stepUnit === 'minute' && stepAmount > 1) {+ return local.startOf('hour').add(Math.floor(local.minute() / stepAmount) * stepAmount, 'minute')}- return { intervalMs: 24 * 60 * 60_000, bucketExpr: 'toStartOfDay(first_scheduled)' }+ return local.startOf(stepUnit)}/**- * Walk the filter range and emit every bucket boundary as an ISO string.- * Snaps to interval-aligned ms (matching CH's epoch-aligned- * `toStartOfInterval` / `toStartOfMinute` etc.), so the keys we use to look- * up CH counts line up regardless of timezone formatting.+ * Bucket key format, matching what ClickHouse renders a bucketed DateTime as. Buckets join on the+ * project's wall clock rather than on an instant: `toStartOfDay` returns local midnight, and the+ * offset it is stamped with is a rendering detail, not a second piece of data. Mirrors+ * `products/mcp_analytics/frontend/timeBuckets.ts`, which solves the same problem for its charts.*/-const generateSparklineBuckets = (filters: HogInvocationsFilters, intervalMs: number): string[] => {+const BUCKET_FORMAT = 'YYYY-MM-DD HH:mm:ss'+/** Enough for the widest tier (a minutely day is 1440); caps an absolute range picked far apart. */+const MAX_SPARKLINE_BUCKETS = 5000++/**+ * Normalize a bucket from the query to `BUCKET_FORMAT`. The value carries the project-tz wall clock+ * however ClickHouse rendered it: naive, `Z`-stamped, or offset-stamped like+ * `2026-08-04T00:00:00-07:00`. Strip the zone designator before parsing so those digits survive+ * verbatim; honoring the offset re-converts a wall clock that was never an instant, and every+ * bucket lands off the axis, which is what emptied this chart for non-UTC projects.+ */+const normalizeBucket = (raw: unknown): string => {+ const value = String(raw ?? '')+ return value ? dayjs.utc(value.replace(/(?:Z|[+-]\d{2}:?\d{2})$/, '')).format(BUCKET_FORMAT) : ''+}++/**+ * Every bucket key across the filter range, so the chart spans the whole window rather than+ * clipping to the buckets that had runs.+ *+ * Each key is re-anchored on the window start instead of accumulated on a cursor: dayjs carries the+ * original offset through `add`, so a range crossing a DST transition would drift off the boundary+ * ClickHouse bucketed to. A wall clock a spring-forward skips is dropped, since no run can hold it,+ * and a fall-back hour repeats one wall clock, which collapses to a single bucket holding both+ * passes.+ */+const generateSparklineBuckets = (filters: HogInvocationsFilters, tier: SparklineTier): string[] => {const { start, end } = resolveDateRange(filters)- const snap = (t: dayjs.Dayjs): number => Math.floor(t.valueOf() / intervalMs) * intervalMs- const out: string[] = []- for (let ms = snap(start); ms < end.valueOf(); ms += intervalMs) {- out.push(dayjs(ms).toISOString())+ const timezone = teamTimezone()+ const first = snapToBucket(start, tier)+ const keys: string[] = []+ const seen = new Set<string>()+ for (let i = 0; i < MAX_SPARKLINE_BUCKETS; i++) {+ const key = first.add(i * tier.stepAmount, tier.stepUnit).format(BUCKET_FORMAT)+ const instant = dayjs.tz(key, timezone)+ if (instant.valueOf() >= end.valueOf()) {+ break+ }+ if (instant.format(BUCKET_FORMAT) !== key || seen.has(key)) {+ continue+ }+ seen.add(key)+ keys.push(key)}- return out+ return keys}const SPARKLINE_STATUS_COLORS: Record<RunStatus, string> = {@@ -474,7 +546,8 @@ const SPARKLINE_STATUS_COLORS: Record<RunStatus, string> = {}async function fetchSparkline(props: HogInvocationsLogicProps, filters: HogInvocationsFilters): Promise<SparklineData> {- const { intervalMs, bucketExpr } = pickSparklineTier(filters)+ const tier = pickSparklineTier(filters)+ const { bucketExpr } = tier// Filters reference the SELECT aliases (status / error_kind) so we don't// re-wrap in argMax inline — that would collide with the alias and@@ -536,24 +609,26 @@ async function fetchSparkline(props: HogInvocationsLogicProps, filters: HogInvoc})- // Pivot CH results keyed on bucket-as-ms so the lookup is tolerant of- // string-format differences between CH's serialization and dayjs's- // ISO output.- const cellsByMs: Record<number, Record<RunStatus, number>> = {}+ // Pivot on the normalized bucket key, so a row joins on the project's wall clock however+ // ClickHouse rendered it. Counts accumulate: the hour a fall-back repeats comes back as two+ // rows carrying one wall clock, and the chart shows that hour once.+ const cellsByBucket: Record<string, Record<RunStatus, number>> = {}for (const row of response.results ?? []) {const [bucket, status, n] = row as unknown as [string, RunStatus, number]- if (!bucket) {+ const key = normalizeBucket(bucket)+ if (!key) {continue}- const ms = dayjs(bucket).valueOf()- cellsByMs[ms] = cellsByMs[ms] ?? { running: 0, succeeded: 0, failed: 0 }- cellsByMs[ms][status] = Number(n ?? 0)+ const cell = (cellsByBucket[key] = cellsByBucket[key] ?? { running: 0, succeeded: 0, failed: 0 })+ cell[status] = (cell[status] ?? 0) + Number(n ?? 0)}// Walk every bucket in the filter range — not just the ones CH returned// data for — so the chart's x-axis spans the user's selected window even// when activity is concentrated in a tiny slice of it.- const dates = generateSparklineBuckets(filters, intervalMs)- const buildValues = (status: RunStatus): number[] => dates.map((d) => cellsByMs[dayjs(d).valueOf()]?.[status] ?? 0)+ const buckets = generateSparklineBuckets(filters, tier)+ const timezone = teamTimezone()+ const dates = buckets.map((key) => dayjs.tz(key, timezone).toISOString())+ const buildValues = (status: RunStatus): number[] => buckets.map((key) => cellsByBucket[key]?.[status] ?? 0)const series: SparklineSeries[] = (['failed', 'running', 'succeeded'] as RunStatus[]).map((status) => ({name: status,color: SPARKLINE_STATUS_COLORS[status],