diff --git a/static/app/types/workflowEngine/automations.tsx b/static/app/types/workflowEngine/automations.tsx
index bd4f0687bc21..23c142710f76 100644
--- a/static/app/types/workflowEngine/automations.tsx
+++ b/static/app/types/workflowEngine/automations.tsx
@@ -48,11 +48,6 @@ export interface AutomationFireHistory {
detector?: Detector;
}
-export type AutomationStats = {
- count: number;
- date: string;
-};
-
/**
* Warning information about the status of actions in an automation.
*/
diff --git a/static/app/views/automations/components/automationStatsChart.timeRange.spec.tsx b/static/app/views/automations/components/automationStatsChart.timeRange.spec.tsx
index cecdccd7a041..c6577e59a8d7 100644
--- a/static/app/views/automations/components/automationStatsChart.timeRange.spec.tsx
+++ b/static/app/views/automations/components/automationStatsChart.timeRange.spec.tsx
@@ -55,24 +55,4 @@ describe('AutomationStatsChart time range', () => {
xAxis: {type: 'time', min: start, max: end},
});
});
-
- it('continues to accept the legacy response during deployment', async () => {
- MockApiClient.addMockResponse({
- url: '/organizations/org-slug/workflows/123/stats/',
- body: [{date: '2026-01-13T20:00:00Z', count: 1}],
- });
-
- render(
- ,
- {organization}
- );
-
- expect(await screen.findByText('1')).toBeInTheDocument();
- });
});
diff --git a/static/app/views/automations/components/automationStatsChart.tsx b/static/app/views/automations/components/automationStatsChart.tsx
index 4d7a0d4eeaf2..70ff1f44f841 100644
--- a/static/app/views/automations/components/automationStatsChart.tsx
+++ b/static/app/views/automations/components/automationStatsChart.tsx
@@ -14,7 +14,7 @@ import {PanelBody} from 'sentry/components/panels/panelBody';
import {PanelFooter} from 'sentry/components/panels/panelFooter';
import {Placeholder} from 'sentry/components/placeholder';
import {t} from 'sentry/locale';
-import type {Automation, AutomationStats} from 'sentry/types/workflowEngine/automations';
+import type {Automation} from 'sentry/types/workflowEngine/automations';
import {apiOptions} from 'sentry/utils/api/apiOptions';
import {getUtcDateString, getUtcToLocalDateObject} from 'sentry/utils/dates';
import {useOrganization} from 'sentry/utils/useOrganization';
@@ -30,38 +30,9 @@ type WorkflowStatsResponse = {
end: number;
start: number;
};
- timeSeries: TimeSeries[];
+ timeSeries: [TimeSeries];
};
-type WorkflowStatsApiResponse = AutomationStats[] | WorkflowStatsResponse;
-
-type WorkflowStats = {
- values: TimeSeries['values'];
- timeframe?: WorkflowStatsResponse['meta'];
-};
-
-function normalizeWorkflowStatsResponse(
- response: WorkflowStatsApiResponse | undefined
-): WorkflowStats | undefined {
- if (!response) {
- return undefined;
- }
-
- if (Array.isArray(response)) {
- return {
- values: response.map(({date, count}) => ({
- timestamp: Date.parse(date),
- value: count,
- })),
- };
- }
-
- return {
- timeframe: response.meta,
- values: response.timeSeries[0]?.values ?? [],
- };
-}
-
export function AutomationStatsChart({
automationId,
period,
@@ -73,11 +44,11 @@ export function AutomationStatsChart({
const organization = useOrganization();
const chartZoomProps = useChartZoom({saveOnZoom: true});
const {
- data: statsResponse,
+ data: stats,
isPending,
isError,
} = useQuery(
- apiOptions.as()(
+ apiOptions.as()(
'/organizations/$organizationIdOrSlug/workflows/$workflowId/stats/',
{
path: {organizationIdOrSlug: organization.slug, workflowId: automationId},
@@ -92,9 +63,8 @@ export function AutomationStatsChart({
)
);
- const stats = normalizeWorkflowStatsResponse(statsResponse);
const totalAlertsTriggered =
- stats?.values.reduce((acc, curr) => acc + (curr.value ?? 0), 0) ?? 0;
+ stats?.timeSeries[0].values.reduce((acc, curr) => acc + (curr.value ?? 0), 0) ?? 0;
return (
@@ -121,18 +91,14 @@ export function AutomationStatsChart({
yAxis={{
minInterval: 1,
}}
- xAxis={
- stats.timeframe
- ? {
- min: stats.timeframe.start,
- max: stats.timeframe.end,
- }
- : undefined
- }
+ xAxis={{
+ min: stats.meta.start,
+ max: stats.meta.end,
+ }}
series={[
{
seriesName: t('Alerts Triggered'),
- data: stats.values.map(({timestamp, value}) => ({
+ data: stats.timeSeries[0].values.map(({timestamp, value}) => ({
name: timestamp,
value: value ?? 0,
})),
diff --git a/static/app/views/automations/detail.spec.tsx b/static/app/views/automations/detail.spec.tsx
index bb2f5cd64242..4461159b48c0 100644
--- a/static/app/views/automations/detail.spec.tsx
+++ b/static/app/views/automations/detail.spec.tsx
@@ -85,7 +85,20 @@ describe('AutomationDetail', () => {
MockApiClient.addMockResponse({
url: '/organizations/org-slug/workflows/123/stats/',
- body: [],
+ body: {
+ meta: {dataset: 'workflow', start: 0, end: 60 * 60 * 1000},
+ timeSeries: [
+ {
+ yAxis: 'count()',
+ values: [],
+ meta: {
+ interval: 60 * 60 * 1000,
+ valueType: 'integer',
+ valueUnit: null,
+ },
+ },
+ ],
+ },
});
MockApiClient.addMockResponse({