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(charts): keep app metric timestamps unique (#97674)

Sam Penningtone213e9334a99
diff --git a/frontend/src/lib/components/AppMetrics/AppMetricsSparkline.tsx b/frontend/src/lib/components/AppMetrics/AppMetricsSparkline.tsx
index 9954328cdccf..674278c36134 100644
--- a/frontend/src/lib/components/AppMetrics/AppMetricsSparkline.tsx
+++ b/frontend/src/lib/components/AppMetrics/AppMetricsSparkline.tsx
@@ -3,6 +3,7 @@ import { useEffect, useMemo } from 'react'
import { useInView } from 'react-intersection-observer'
import { LemonSkeleton } from '@posthog/lemon-ui'
+import { createTooltipDateFormatter } from '@posthog/quill-charts'
import { Sparkline, SparklineTimeSeries } from 'lib/components/Sparkline'
import { inStorybookTestRunner } from 'lib/utils/dom'
@@ -66,6 +67,17 @@ export function AppMetricsSparkline({
}, [appMetricsTrends, params, successMetricNames, metricLabels, metricColors])
const labels = appMetricsTrends?.labels || []
+ const renderLabel = useMemo(
+ () =>
+ appMetricsTrends
+ ? createTooltipDateFormatter({
+ interval: appMetricsTrends.interval,
+ timezone: appMetricsTrends.timezone,
+ allDays: appMetricsTrends.labels,
+ })
+ : undefined,
+ [appMetricsTrends?.interval, appMetricsTrends?.labels, appMetricsTrends?.timezone]
+ )
return (
<div ref={inViewRef}>
@@ -74,7 +86,13 @@ export function AppMetricsSparkline({
) : !appMetricsTrends || appMetricsTrendsLoading ? (
<LemonSkeleton className="h-8 max-w-24" />
) : (
- <Sparkline labels={labels} data={displayData} type={type} className="h-8 max-w-24" />
+ <Sparkline
+ labels={labels}
+ data={displayData}
+ type={type}
+ className="h-8 max-w-24"
+ renderLabel={renderLabel}
+ />
)}
</div>
)
diff --git a/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.test.tsx b/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.test.tsx
new file mode 100644
index 000000000000..2508e6254115
--- /dev/null
+++ b/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.test.tsx
@@ -0,0 +1,36 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, waitFor } from '@testing-library/react'
+
+import { ensureJsdom, getHogChart, hoverAtIndex, hoverUntilTooltip } from '@posthog/quill-charts/testing'
+
+import { AppMetricsTimeSeriesChart } from './AppMetricsTimeSeriesChart'
+
+ensureJsdom()
+
+afterEach(cleanup)
+
+describe('AppMetricsTimeSeriesChart', () => {
+ it('distinguishes repeated local hours in the tooltip', async () => {
+ const labels = ['2026-11-01T01:00:00-07:00', '2026-11-01T01:00:00-08:00']
+ const { container } = render(
+ <div className="h-64 w-96">
+ <AppMetricsTimeSeriesChart
+ timeSeries={{
+ labels,
+ interval: 'hour',
+ timezone: 'US/Pacific',
+ series: [{ name: 'success', values: [2, 3] }],
+ }}
+ />
+ </div>
+ )
+ const chart = getHogChart(container)
+
+ const tooltip = await hoverUntilTooltip(chart.element, 0, labels.length)
+ expect(tooltip).toHaveTextContent('Sun, Nov 1, 01:00 (-07:00)')
+
+ hoverAtIndex(chart.element, 1, labels.length)
+ await waitFor(() => expect(tooltip).toHaveTextContent('Sun, Nov 1, 01:00 (-08:00)'))
+ })
+})
diff --git a/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.tsx b/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.tsx
index 80df9ac4fa4d..e15f82476061 100644
--- a/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.tsx
+++ b/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.tsx
@@ -1,15 +1,9 @@
import clsx from 'clsx'
import { useMemo } from 'react'
-import {
- type Series,
- TimeSeriesLineChart,
- type TimeSeriesLineChartConfig,
- createXAxisTickCallback,
-} from '@posthog/quill-charts'
+import { type Series, TimeSeriesLineChart, type TimeSeriesLineChartConfig } from '@posthog/quill-charts'
import { useChartConfig, useChartTheme } from 'lib/charts/hooks'
-import { dayjs } from 'lib/dayjs'
import { AppMetricsTimeSeriesResponse } from './appMetricsLogic'
@@ -52,14 +46,13 @@ export function AppMetricsTimeSeriesChart({
)
const labels = timeSeries.labels
- const config = useChartConfig<TimeSeriesLineChartConfig>(() => {
- // Labels arrive from appMetricsLogic pre-formatted in the team's timezone ('YYYY-MM-DD',
- // or 'YYYY-MM-DD HH:mm' for sub-day intervals), so parse them as naive local strings.
- const hasTimePart = labels.some((label) => label.includes(' '))
- return {
+ const config = useChartConfig<TimeSeriesLineChartConfig>(
+ () => ({
xAxis: {
hide: minimal,
- tickFormatter: createXAxisTickCallback({ allDays: labels, timezone: 'UTC' }),
+ timezone: timeSeries.timezone,
+ interval: timeSeries.interval,
+ allDays: labels,
},
yAxis: { hide: minimal, showGrid: !minimal },
...(minimal ? { showAxisLines: { x: false, y: false } as const } : {}),
@@ -68,10 +61,10 @@ export function AppMetricsTimeSeriesChart({
placement: 'cursor',
pinnable: true,
sortedByValue: true,
- labelFormatter: (label: string) => dayjs(label).format(hasTimePart ? 'MMM D, HH:mm' : 'MMM D, YYYY'),
},
- }
- }, [labels, minimal, showLegend])
+ }),
+ [labels, minimal, showLegend, timeSeries.interval, timeSeries.timezone]
+ )
return (
<div className={clsx('relative flex h-full w-full flex-col', className)}>
diff --git a/frontend/src/lib/components/AppMetrics/appMetricsLogic.test.ts b/frontend/src/lib/components/AppMetrics/appMetricsLogic.test.ts
new file mode 100644
index 000000000000..4e510e27d836
--- /dev/null
+++ b/frontend/src/lib/components/AppMetrics/appMetricsLogic.test.ts
@@ -0,0 +1,36 @@
+import api from 'lib/api'
+
+import type { HogQLQueryResponse } from '~/queries/schema/schema-general'
+
+import { loadAppMetricsTimeSeries } from './appMetricsLogic'
+
+describe('app metrics logic', () => {
+ afterEach(() => {
+ jest.restoreAllMocks()
+ })
+
+ it('keeps ISO offsets that distinguish repeated local hours', async () => {
+ const labels = ['2026-11-01T01:00:00-07:00', '2026-11-01T01:00:00-08:00']
+ jest.spyOn(api, 'queryHogQL').mockResolvedValue({
+ results: [[labels, 'success', [2, 3]]],
+ } as HogQLQueryResponse)
+
+ const result = await loadAppMetricsTimeSeries(
+ {
+ appSource: 'hog_flow',
+ breakdownBy: 'metric_kind',
+ interval: 'hour',
+ dateFrom: '2026-11-01T00:00:00-07:00',
+ dateTo: '2026-11-01T03:00:00-08:00',
+ },
+ 'US/Pacific'
+ )
+
+ expect(result).toEqual({
+ labels,
+ interval: 'hour',
+ timezone: 'US/Pacific',
+ series: [{ name: 'success', values: [2, 3] }],
+ })
+ })
+})
diff --git a/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts b/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts
index 391162ec270e..9f96ad41a90b 100644
--- a/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts
+++ b/frontend/src/lib/components/AppMetrics/appMetricsLogic.ts
@@ -54,6 +54,8 @@ export type AppMetricsTimeSeriesRequest = AppMetricsCommonParams
export type AppMetricsTimeSeriesResponse = {
labels: string[]
+ interval: NonNullable<AppMetricsCommonParams['interval']>
+ timezone: string
series: {
name: string
values: number[]
@@ -152,7 +154,7 @@ ORDER BY total DESC LIMIT ${request.limit}`) as HogQLQueryString
return res
}
-const loadAppMetricsTimeSeries = async (
+export const loadAppMetricsTimeSeries = async (
request: AppMetricsTimeSeriesRequest,
timezone: string
): Promise<AppMetricsTimeSeriesResponse> => {
@@ -256,19 +258,10 @@ const loadAppMetricsTimeSeries = async (
{ refresh: 'force_blocking' }
)
- const labels = response.results?.[0]?.[0].map((label: string) => {
- switch (interval) {
- case 'day':
- return dayjs(label).tz(timezone).format('YYYY-MM-DD')
- case 'hour':
- return dayjs(label).tz(timezone).format('YYYY-MM-DD HH:mm')
- case 'minute':
- return dayjs(label).tz(timezone).format('YYYY-MM-DD HH:mm')
- }
- })
-
return {
- labels: labels || [],
+ labels: (response.results?.[0]?.[0] as string[] | undefined) ?? [],
+ interval,
+ timezone,
series:
response.results?.map((result) => ({
name: result[1],
@@ -464,7 +457,7 @@ export const appMetricsLogic = kea<appMetricsLogicType>([
}
return {
- labels: targetTrend.labels,
+ ...targetTrend,
series: [series],
}
},
diff --git a/frontend/src/scenes/real-time-usage/realTimeUsageLogic.test.ts b/frontend/src/scenes/real-time-usage/realTimeUsageLogic.test.ts
index 794177060b1f..76a012d742be 100644
--- a/frontend/src/scenes/real-time-usage/realTimeUsageLogic.test.ts
+++ b/frontend/src/scenes/real-time-usage/realTimeUsageLogic.test.ts
@@ -31,6 +31,14 @@ describe('real-time usage logic', () => {
expect(logic.values.selectedProjectIds).toEqual([])
})
+ it('returns raw UTC labels and the chart interval', () => {
+ const { timeSeries } = parseUsageData([], '1d', '5m', false)
+
+ expect(timeSeries.interval).toBe('minute')
+ expect(timeSeries.timezone).toBe('UTC')
+ expect(timeSeries.labels.every((label) => label.endsWith('Z'))).toBe(true)
+ })
+
it('keeps projects separate when the project breakdown is enabled', () => {
const bucket = Math.floor(Date.now() / 1000 / 3600) * 3600
const usageData = parseUsageData(
diff --git a/frontend/src/scenes/real-time-usage/realTimeUsageLogic.ts b/frontend/src/scenes/real-time-usage/realTimeUsageLogic.ts
index 5a0dfb35f3e7..d952e8c4e42f 100644
--- a/frontend/src/scenes/real-time-usage/realTimeUsageLogic.ts
+++ b/frontend/src/scenes/real-time-usage/realTimeUsageLogic.ts
@@ -162,8 +162,9 @@ export function parseUsageData(
(a, b) => b.quantity - a.quantity || a.producerId.localeCompare(b.producerId)
),
timeSeries: {
- // Buckets are UTC-aligned, so label them in UTC rather than in the reader's timezone.
- labels: starts.map((start) => dayjs.unix(start).utc().format('YYYY-MM-DD HH:mm')),
+ labels: starts.map((start) => dayjs.unix(start).toISOString()),
+ interval: granularity === '5m' ? 'minute' : granularity,
+ timezone: 'UTC',
series: Array.from(series.entries()).map(([key, values]) => ({
name: breakdownByProject ? key.replace(/^\d+:/, '') : key,
values: starts.map((start) => values.get(start) ?? 0),
diff --git a/packages/quill/packages/charts/src/docs/tooltips.md b/packages/quill/packages/charts/src/docs/tooltips.md
index 717c3a94e486..6b6c8952429a 100644
--- a/packages/quill/packages/charts/src/docs/tooltips.md
+++ b/packages/quill/packages/charts/src/docs/tooltips.md
@@ -24,7 +24,7 @@ A render prop, if given, owns the content and these fields are ignored.
Usable from a custom `tooltip` render prop by spreading the context: `<DefaultTooltip {...ctx} footer="..." />`.
- `valueFormatter(value, entry)` gets the row's `seriesData` entry as the second argument, so each row can format with its own `series.meta` (per-column currency or duration). It may return a node, not only a string. A formatter that takes only `value` stays compatible. Defaults to `toLocaleString`.
-- `labelFormatter(label)` transforms the raw x-axis label in the header. On time-series charts with `xAxis.timezone` and `interval` set, it defaults to an interval-aware date formatter that includes the weekday for single-day buckets ("Sat, Jun 6, 2026", "Sat, Jun 6, 14:00"); week and month buckets span days, so "Jun 1, 2026", "Jun 2026". An explicit `labelFormatter` still wins.
+- `labelFormatter(label)` transforms the raw x-axis label in the header. On time-series charts with `xAxis.timezone` and `interval` set, it defaults to an interval-aware date formatter that includes the weekday for single-day buckets ("Sat, Jun 6, 2026", "Sat, Jun 6, 14:00"); week and month buckets span days, so "Jun 1, 2026", "Jun 2026". Set `xAxis.allDays` when the labels can include repeated local times during a daylight-saving fallback. The formatter then adds the UTC offset to distinguish those times. An explicit `labelFormatter` still wins.
- `labelRenderer(entry)` overrides how each row's label renders (default: the series label). Use it for richer labels such as breakdown-value pills. Rows share one grid (swatch, label, value), so a renderer that pushes part of its label right lines up as a column down the tooltip.
- `showHeader` (default true) toggles the header row. Pass false where there is no meaningful header (pie slices, aggregated single-column bars).
- `showTotal` appends a row summing the visible series. It excludes `overlay` series (goal lines) and series with `visibility.total: false` (a percentage column beside counts; the row itself still renders), and is suppressed when fewer than two summable series remain. `totalFormatter` defaults to `valueFormatter` applied with the first summable row's entry; `totalLabel` defaults to `'Total'`.
diff --git a/packages/quill/packages/charts/src/index.ts b/packages/quill/packages/charts/src/index.ts
index 4594c923ad0d..a4284473a1a2 100644
--- a/packages/quill/packages/charts/src/index.ts
+++ b/packages/quill/packages/charts/src/index.ts
@@ -185,7 +185,7 @@ export type { AnomalyMarker } from './overlays/AnomalyPointsLayer'
export { movingAverageKey } from './charts/utils/derived-series'
// Timeseries utils
-export { createXAxisTickCallback } from './utils/dates'
+export { createTooltipDateFormatter, createXAxisTickCallback } from './utils/dates'
export type { TimeInterval } from './utils/dates'
export { buildYTickFormatter } from './utils/y-formatters'
export type { YAxisFormat, YFormatterConfig } from './utils/y-formatters'
diff --git a/packages/quill/packages/charts/src/utils/dates.test.ts b/packages/quill/packages/charts/src/utils/dates.test.ts
index ecbe3954e177..52efbf01f2bd 100644
--- a/packages/quill/packages/charts/src/utils/dates.test.ts
+++ b/packages/quill/packages/charts/src/utils/dates.test.ts
@@ -355,6 +355,8 @@ describe('createTooltipDateFormatter', () => {
// Week/month buckets span multiple days, so a weekday would mislead
{ interval: 'week' as const, label: '2026-06-01', expected: 'Jun 1, 2026' },
{ interval: 'month' as const, label: '2026-06-01', expected: 'Jun 2026' },
+ { interval: 'quarter' as const, label: '2026-06-01', expected: 'Q2 2026' },
+ { interval: 'year' as const, label: '2026-01-01', expected: '2026' },
])('formats a $interval bucket header', ({ interval, label, expected }) => {
const format = createTooltipDateFormatter({ interval, timezone: 'UTC' })
expect(format(label)).toBe(expected)
@@ -366,6 +368,13 @@ describe('createTooltipDateFormatter', () => {
expect(format('2026-06-07T02:00:00Z')).toBe('Sat, Jun 6, 19:00')
})
+ it('adds offsets to repeated local times during a DST fallback', () => {
+ const labels = ['2026-11-01T01:00:00-07:00', '2026-11-01T01:00:00-08:00']
+ const format = createTooltipDateFormatter({ interval: 'hour', timezone: 'US/Pacific', allDays: labels })
+
+ expect(labels.map(format)).toEqual(['Sun, Nov 1, 01:00 (-07:00)', 'Sun, Nov 1, 01:00 (-08:00)'])
+ })
+
it('passes non-date labels through unchanged', () => {
const format = createTooltipDateFormatter({ interval: 'day', timezone: 'UTC' })
expect(format('not-a-date')).toBe('not-a-date')
diff --git a/packages/quill/packages/charts/src/utils/dates.ts b/packages/quill/packages/charts/src/utils/dates.ts
index cc0590f86de3..d13068befa19 100644
--- a/packages/quill/packages/charts/src/utils/dates.ts
+++ b/packages/quill/packages/charts/src/utils/dates.ts
@@ -56,35 +56,59 @@ export function createXAxisTickCallback({
export const parseDateForAxis = parseDateInTimezone
/** Full date label for a tooltip header. Unlike the sparse, abbreviated axis ticks, every point
- * gets a complete, unambiguous label, with the weekday when the bucket names a single day
- * ("Sat, Jun 6, 2026", "Sat, Jun 6, 14:00" — but week/month buckets span days, so no weekday).
+ * gets a complete label. Single-day buckets include the weekday, while longer buckets do not.
+ * Repeated local times include their UTC offsets when `allDays` identifies a DST fallback.
* Non-date labels pass through unchanged. */
export function createTooltipDateFormatter({
interval,
timezone,
+ allDays,
}: {
interval: TimeInterval
timezone: string
+ allDays?: string[]
}): (label: string) => string {
+ const formattedOffsets = new Map<string, Set<string>>()
+ if (interval === 'second' || interval === 'minute' || interval === 'hour') {
+ for (const label of allDays ?? []) {
+ const date = parseDateInTimezone(label, timezone)
+ if (date.isValid()) {
+ const formatted = formatTooltipDate(date, interval)
+ const offsets = formattedOffsets.get(formatted) ?? new Set<string>()
+ offsets.add(date.format('Z'))
+ formattedOffsets.set(formatted, offsets)
+ }
+ }
+ }
+
return (label: string): string => {
const date = parseDateInTimezone(label, timezone)
if (!date.isValid()) {
return label
}
- switch (interval) {
- case 'second':
- return date.format('ddd, MMM D, HH:mm:ss')
- case 'minute':
- case 'hour':
- return date.format('ddd, MMM D, HH:mm')
- case 'month':
- return date.format('MMM YYYY')
- case 'week':
- return date.format('MMM D, YYYY')
- case 'day':
- default:
- return date.format('ddd, MMM D, YYYY')
- }
+ const formatted = formatTooltipDate(date, interval)
+ return (formattedOffsets.get(formatted)?.size ?? 0) > 1 ? `${formatted} (${date.format('Z')})` : formatted
+ }
+}
+
+function formatTooltipDate(date: Dayjs, interval: TimeInterval): string {
+ switch (interval) {
+ case 'second':
+ return date.format('ddd, MMM D, HH:mm:ss')
+ case 'minute':
+ case 'hour':
+ return date.format('ddd, MMM D, HH:mm')
+ case 'month':
+ return date.format('MMM YYYY')
+ case 'quarter':
+ return `Q${Math.floor(date.month() / 3) + 1} ${date.year()}`
+ case 'year':
+ return date.format('YYYY')
+ case 'week':
+ return date.format('MMM D, YYYY')
+ case 'day':
+ default:
+ return date.format('ddd, MMM D, YYYY')
}
}
diff --git a/packages/quill/packages/charts/src/utils/use-axis-formatters.ts b/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
index 7714e143a073..d176e1a6d9e8 100644
--- a/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
+++ b/packages/quill/packages/charts/src/utils/use-axis-formatters.ts
@@ -82,8 +82,11 @@ export function useTimeSeriesTooltipConfig(
if (tooltip?.labelFormatter || !timezone || !interval) {
return tooltip
}
- return { ...tooltip, labelFormatter: createTooltipDateFormatter({ interval, timezone }) }
- }, [tooltip, timezone, interval])
+ return {
+ ...tooltip,
+ labelFormatter: createTooltipDateFormatter({ interval, timezone, allDays: xAxis?.allDays }),
+ }
+ }, [tooltip, timezone, interval, xAxis?.allDays])
}
/** Non-hook resolution of a {@link YAxisConfig} into a tick formatter. An explicit `tickFormatter`
diff --git a/products/workflows/frontend/Workflows/WorkflowMetricCard.tsx b/products/workflows/frontend/Workflows/WorkflowMetricCard.tsx
index 6cc8444f8341..583c3135081a 100644
--- a/products/workflows/frontend/Workflows/WorkflowMetricCard.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowMetricCard.tsx
@@ -4,6 +4,7 @@ import { type ErrorInfo, type ReactNode, useCallback, useMemo } from 'react'
import { IconArrowRight, IconInfo } from '@posthog/icons'
import {
DefaultTooltip,
+ createTooltipDateFormatter,
useChartTheme,
type ChangeColor,
type MetricChange,
@@ -22,7 +23,6 @@ import { cn, Skeleton, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger
import { getColorVar } from 'lib/colors'
import { AppMetricsTimeSeriesResponse } from 'lib/components/AppMetrics/appMetricsLogic'
-import { dayjs } from 'lib/dayjs'
import { formatPercentageDiff, humanFriendlyNumber } from 'lib/utils/numbers'
const SPARKLINE_HEIGHT = 160
@@ -135,22 +135,28 @@ export function WorkflowMetricCard({
}, [total, totalPreviousPeriod])
const neutral = neutralChange()
-
- // Labels arrive pre-formatted in the team timezone ('YYYY-MM-DD', or '… HH:mm' for sub-day
- // intervals), so parse them as naive local strings for the tooltip header.
+ const labelFormatter = useMemo(
+ () =>
+ timeSeries
+ ? createTooltipDateFormatter({
+ interval: timeSeries.interval,
+ timezone: timeSeries.timezone,
+ allDays: timeSeries.labels,
+ })
+ : undefined,
+ [timeSeries?.interval, timeSeries?.labels, timeSeries?.timezone]
+ )
const renderTooltip = useCallback(
(ctx: TooltipContext) => (
<DefaultTooltip
{...ctx}
sortedByValue
showTotal
- labelFormatter={(label: string) =>
- dayjs(label).format(label.includes(' ') ? 'MMM D, HH:mm' : 'MMM D, YYYY')
- }
+ labelFormatter={labelFormatter}
valueFormatter={(value: number) => humanFriendlyNumber(value)}
/>
),
- []
+ [labelFormatter]
)
const cardClassName = cn(
diff --git a/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsx b/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsx
index 50bf97471c25..f90c6a35eeb0 100644
--- a/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsx
@@ -294,9 +294,12 @@ export function WorkflowMetricsSummary({
// and its tooltip break the total down by channel.
const emailSeries = getSingleTrendSeries('email_sent', previous)
const pushSeries = getSingleTrendSeries('push_sent', previous)
- const labels = emailSeries?.labels ?? pushSeries?.labels ?? []
+ const source = emailSeries ?? pushSeries
+ if (!source) {
+ return null
+ }
return {
- labels,
+ ...source,
series: [
{ name: 'Emails sent', values: emailSeries?.series[0]?.values ?? [] },
{ name: 'Push notifications sent', values: pushSeries?.series[0]?.values ?? [] },
diff --git a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.ts b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.ts
index 9dd864fe0f33..bb74f47a8b20 100644
--- a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.ts
+++ b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.ts
@@ -14,6 +14,8 @@ import {
const series = (labels: string[], ...namedValues: [string, number[]][]): AppMetricsTimeSeriesResponse => ({
labels,
+ interval: 'day',
+ timezone: 'UTC',
series: namedValues.map(([name, values]) => ({ name, values })),
})
diff --git a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.ts b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.ts
index 70c10ce082d1..4f8f7be4f916 100644
--- a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.ts
+++ b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.ts
@@ -1209,18 +1209,19 @@ export const workflowMetricsSummaryLogic = kea<workflowMetricsSummaryLogicType>(
messagingChannels: { hasEmail: boolean; hasPush: boolean },
sentSummaryLabel: string
): AppMetricsTimeSeriesResponse | null => {
- if (!appMetricsTrends && !completedTrends) {
+ const source = appMetricsTrends ?? completedTrends
+ if (!source) {
return null
}
- const labels = appMetricsTrends?.labels ?? completedTrends?.labels ?? []
+ const labels = source.labels
const zero = (): number[] => Array.from({ length: labels.length }, () => 0)
const seriesFor = (metricName: string): number[] =>
appMetricsTrends?.series.find((x: { name: string }) => x.name === metricName)?.values ?? zero()
const completedValues = getCompletedSingleTrendSeries('succeeded')?.series[0]?.values ?? zero()
return {
- labels,
+ ...source,
series: SUMMARY_METRIC_KEYS.flatMap((summaryMetric) => {
if (summaryMetric === 'completed') {
return [{ name: WORKFLOW_SUMMARY_METRICS.completed.name, values: completedValues }]
@@ -1401,7 +1402,7 @@ export function withDisplayName(
}
return {
- labels: series.labels,
+ ...series,
series: series.series.map((item) => ({
...item,
name: displayName,
@@ -1414,14 +1415,15 @@ export function subtractSeries(
subtrahendSeries: AppMetricsTimeSeriesResponse | null,
displayName: string
): AppMetricsTimeSeriesResponse | null {
- if (!minuendSeries && !subtrahendSeries) {
+ const source = minuendSeries ?? subtrahendSeries
+ if (!source) {
return null
}
- const labels = minuendSeries?.labels ?? subtrahendSeries?.labels ?? []
+ const labels = source.labels
return {
- labels,
+ ...source,
series: [
{
name: displayName,