: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(workflows): stop showing spam complaints as blocked emails (#83830)
Harley Alexander5143a9d0a856
diff --git a/nodejs/src/cdp/services/messaging/helpers/ses.ts b/nodejs/src/cdp/services/messaging/helpers/ses.tsindex 4b9b03963682..48be2e481189 100644--- a/nodejs/src/cdp/services/messaging/helpers/ses.ts+++ b/nodejs/src/cdp/services/messaging/helpers/ses.ts@@ -170,6 +170,9 @@ const EVENT_TYPE_TO_METRIC_NAME: Partial<Record<SesEventRecord['eventType'], MinClick: 'email_link_clicked',Delivery: 'email_delivered',Bounce: 'email_bounced',+ // A Complaint is a recipient's "report spam" relayed through the provider's feedback loop.+ // It stays recorded under email_blocked because complaint counts have always been stored+ // there; the UI surfaces the metric as "Marked as spam".Complaint: 'email_blocked',RenderingFailure: 'email_failed',Reject: 'email_failed',diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.tsindex 72db80f065c1..27f03ad4e487 100644--- a/nodejs/src/cdp/types.ts+++ b/nodejs/src/cdp/types.ts@@ -246,7 +246,6 @@ export type MinimalAppMetric = {| 'email_suppressed'| 'email_suspended'| 'email_blocked'- | 'email_spam'| 'email_unsubscribed'| 'email_untracked'| 'push_sent'diff --git a/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsx b/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsxindex 475b5dc8c9b6..50bf97471c25 100644--- a/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsx+++ b/products/workflows/frontend/Workflows/WorkflowMetricsSummary.tsx@@ -130,8 +130,8 @@ export function WorkflowMetricsSummary({metric: 'email_bounced' as EmailMetric,},{- label: 'blocked',- value: row.blocked,+ label: 'marked as spam',+ value: row.markedAsSpam,type: 'danger' as const,metric: 'email_blocked' as EmailMetric,},diff --git a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.ts b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.tsindex 5a7b2d7c1637..9dd864fe0f33 100644--- a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.ts+++ b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.test.ts@@ -89,7 +89,7 @@ describe('buildEmailMetricInvocationSearchParams', () => {const dateTo = '2026-07-13T00:00:00.000Z'// Each metric drills into the Invocations tab via the unified search box (`inv_search`), narrowed- // to the level that distinguishes it: bounced/blocked at WARN/ERROR, bounce prevented+ // to the level that distinguishes it: bounced/marked-as-spam at WARN/ERROR, bounce prevented// ("Skipping send") at INFO.it.each<[EmailMetric, Record<string, string>]>([[@@ -157,7 +157,7 @@ describe('buildEmailMetricRows', () => {const rows = buildEmailMetricRows([{ id: 'a1', name: 'Welcome email' }], {a1: {email_sent: 100,- email_delivered: 85, // reported value wins over the derived sent - bounced - blocked (= 90)+ email_delivered: 85, // reported value wins over the derived sent - bounced (= 94)email_opened: 40,email_link_clicked: 12,email_bounced: 6,@@ -176,7 +176,7 @@ describe('buildEmailMetricRows', () => {linkClicked: 12,bounced: 6,bouncePrevented: 2,- blocked: 4,+ markedAsSpam: 4,untracked: 7,trackedSends: 93,},@@ -190,9 +190,10 @@ describe('buildEmailMetricRows', () => {expect(row.trackedSends).toBe(10)})- // delivered falls back to sent - bounced - blocked (clamped at 0) when it wasn't collected.+ // delivered falls back to sent - bounced (clamped at 0) when it wasn't collected. Spam+ // complaints (email_blocked) are post-delivery reports, so they must not reduce delivered.it.each<{ totals: Partial<Record<EmailMetric, number>>; delivered: number }>([- { totals: { email_sent: 10, email_bounced: 3, email_blocked: 2 }, delivered: 5 },+ { totals: { email_sent: 10, email_bounced: 3, email_blocked: 2 }, delivered: 7 },{ totals: { email_sent: 1, email_bounced: 5 }, delivered: 0 },{ totals: {}, delivered: 0 },])('derives delivered=$delivered when email_delivered is absent', ({ totals, delivered }) => {diff --git a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.ts b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.tsindex 03c2aad62189..89a3407a189e 100644--- a/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.ts+++ b/products/workflows/frontend/Workflows/workflowMetricsSummaryLogic.ts@@ -116,7 +116,6 @@ export type EmailMetric =| 'email_bounced'| 'email_bounce_prevented'| 'email_blocked'- | 'email_spam'| 'email_untracked'| 'email_suspended'@@ -140,7 +139,9 @@ export type EmailMetricRow = {linkClicked: numberbounced: numberbouncePrevented: number- blocked: number+ // Spam complaints. Stored under the email_blocked metric name for continuity with+ // historical data (see the SES webhook handler's Complaint mapping).+ markedAsSpam: number// Sends without open/click tracking (step toggle off or no recipient consent). These can never// record opens/clicks, so engagement reads against trackedSends rather than sent.untracked: number@@ -180,7 +181,6 @@ export const METRIC_COLORS: Record<string, string> = {'Link clicked': getColorVar('data-color-5'),Bounced: getColorVar('data-color-6'),'Bounce prevented': getColorVar('data-color-7'),- Blocked: getColorVar('data-color-8'),'Marked as spam': getColorVar('data-color-9'),Untracked: getColorVar('data-color-10'),Suspended: getColorVar('data-color-11'),@@ -287,16 +287,11 @@ export const WORKFLOW_EMAIL_METRICS: Record<metricNames: ['email_bounce_prevented'],},email_blocked: {- name: 'Blocked',- description: 'Total number of emails that were blocked by the recipient server',- color: METRIC_COLORS['Blocked'],- metricNames: ['email_blocked'],- },- email_spam: {name: 'Marked as spam',- description: 'Total number of emails that were marked as spam by recipient server or recipient email client',+ description:+ 'Total number of emails recipients reported as spam, counted from mailbox provider feedback reports. Gmail does not send these reports, so a Gmail user marking an email as spam is not counted here, and no metric shows whether a message landed in the spam folder.',color: METRIC_COLORS['Marked as spam'],- metricNames: ['email_spam'],+ metricNames: ['email_blocked'],},email_untracked: {name: 'Untracked',@@ -402,7 +397,6 @@ const EMAIL_METRICS: EmailMetric[] = ['email_bounced','email_bounce_prevented','email_blocked',- 'email_spam','email_untracked','email_suspended',]@@ -1465,19 +1459,20 @@ export function buildEmailMetricRows(const totals = emailTotalsByActionId[action.id] || {}const sent = totals.email_sent ?? 0const bounced = totals.email_bounced ?? 0- const blocked = totals.email_blocked ?? 0+ const markedAsSpam = totals.email_blocked ?? 0const untracked = totals.email_untracked ?? 0return {id: action.id,email: action.name,- // Fallback to calculating delivered as sent - bounced - blocked if email_delivered metric is not available, since we were not always collecting this metric- delivered: totals.email_delivered ?? Math.max(0, sent - bounced - blocked),+ // Fallback to sent - bounced when email_delivered wasn't collected. Spam complaints are+ // feedback-loop reports recipients send after delivery, so they are not subtracted here.+ delivered: totals.email_delivered ?? Math.max(0, sent - bounced),sent,opened: totals.email_opened ?? 0,linkClicked: totals.email_link_clicked ?? 0,bounced,bouncePrevented: totals.email_bounce_prevented ?? 0,- blocked,+ markedAsSpam,untracked,trackedSends: Math.max(0, sent - untracked),}