feat: add per-email tracking override to /v1/send - #433
Conversation
Adds an optional `tracking` boolean to POST /v1/send that overrides the project's tracking mode for a single email. Persisted as a nullable trackingOverride column on emails; when null, the project's TrackingMode applies as before. Campaigns and workflows are unaffected. Like MARKETING_ONLY, the override only takes effect when SES_CONFIGURATION_SET_NO_TRACKING is configured. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The tracking decision is duplicated in the BullMQ email processor, which is the path /v1/send actually takes (API enqueues, worker sends). The override was stored but never applied there. Apply it in the processor and extract the job handler to processEmailJob so the worker send path can be tested directly (pure extraction, no behavior change). Found during production verification of this feature. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Heads-up on a gap found while verifying this feature against a live v0.12.0 deployment: the original diff only applied the override in Pushed a fix in ab2ad0a:
Might be worth unifying the two send paths at some point so decisions like this live in one place — left that alone here to keep the PR focused. Posted by Claude on behalf of @chamby. |
|
@chamby I was looking for the same but would be nice if not just the API introduces it but also the UI through a simple toggle for templates and campaigns. |
Description
Adds an optional
trackingboolean toPOST /v1/sendthat overrides the project'sTrackingModefor a single email. Omitted → project mode applies exactly as today;false/true→ wins for that send.Implementation follows the existing plumbing:
trackingOverridecolumn onemails(+ migration) so the worker sees the override at send timeEmailService.sendEmail:email.trackingOverride ?? shouldTrackEmail(...)— the only behavioral change; campaigns and workflows are untouchedtracking: z.boolean().optional()inActionSchemas.send, passed throughActions.send→sendTransactionalEmailSame constraint as
MARKETING_ONLY: only effective whenSES_CONFIGURATION_SET_NO_TRACKINGis configured; when it isn't, the override is silently ignored. If you'd rather surface a warning in the response (or prefer the internal-header approach from the issue), happy to rework.Type of Change
feat:New feature (MINOR version bump)Testing
EmailService.test.ts: override beats project mode in both directions, null falls back to project mode, persistence fromsendTransactionalEmail, and schema accept/reject casesEmailServicesuite passes (51 tests);yarn build --filter=apiand lint cleanChecklist
Related Issues
Closes #432
Prepared by Claude (AI assistant) acting on behalf of Matthew Chambers (@chamby), who reviewed the approach.
🤖 Generated with Claude Code