diff --git a/nodejs/src/cdp/services/messaging/email.service.test.ts b/nodejs/src/cdp/services/messaging/email.service.test.ts index 7c3cd05338a0..456ffcc500cb 100644 --- a/nodejs/src/cdp/services/messaging/email.service.test.ts +++ b/nodejs/src/cdp/services/messaging/email.service.test.ts @@ -1140,6 +1140,10 @@ describe('EmailService', () => { expect(result.error).toBeUndefined() expect(result.metrics.map((m) => m.metric_name)).toEqual(['email_missing_recipient']) expect(result.skipped).toBe(true) + expect(result.emailSendResult).toEqual({ + status: 'skipped', + reason: expect.stringContaining('the recipient has no email address'), + }) expect(invocation.state.vmState?.stack).toEqual([{ success: false }]) }) diff --git a/nodejs/src/cdp/services/messaging/email.service.ts b/nodejs/src/cdp/services/messaging/email.service.ts index ff83d8746de4..0f6f513a0572 100644 --- a/nodejs/src/cdp/services/messaging/email.service.ts +++ b/nodejs/src/cdp/services/messaging/email.service.ts @@ -492,10 +492,10 @@ export class EmailService { // so record a skip with its own metric instead of an `email_failed`. Otherwise one project // with bad data inflates the platform send failure rate. if (!params.to?.email?.trim()) { - addLog( - 'warn', + const skipReason = 'Skipping send: the recipient has no email address. Add a filter so only people with an email address reach this step.' - ) + addLog('warn', skipReason) + result.emailSendResult = { status: 'skipped', reason: skipReason } if (!isTest) { result.metrics.push({ team_id: invocation.teamId,