fix(email): make the welcome email unsubscribable via a Resend automation

Merged
SA
2mo ago
+30-12

Problem

The welcome email was a direct resend.emails.send() from the signup hook. Resend adds no unsubscribe link and no List-Unsubscribe headers to direct sends: {{{RESEND_UNSUBSCRIBE_URL}}} is only filled in for broadcasts and automations. A new signup had to reply to support@ to be removed (CAN-SPAM and deliverability problem).

Change

  • The signup hook emits user.welcome for every signup instead of sending the email. It stays unconditional in both A/B arms. It is a new event because user.signed_up is withheld from the control arm.
  • sync-automations.ts defines a welcome automation: user.welcome → send the activation-00-welcome template.
  • 00-welcome.tsx accepts unsubscribeUrl, the same as 01-first-agent. The published template was rendered with unsubscribeUrl="{{{RESEND_UNSUBSCRIBE_URL}}}".

Already live in Resend (safe before deploy: nothing emits user.welcome until this merges)

  • Template activation-00-welcome (d9966fba-…) published: from Superset <noreply@superset.sh>, subject Welcome to Superset, reply-to support@superset.sh.
  • Automation welcome (01a0cb8b-2688-…) created and enabled. sync-automations.ts dry run reports it up to date.

Verification

  • Fired user.welcome for two test addresses; both emails delivered.
  • The raw MIME of the satya@superset.sh copy has List-Unsubscribe: <https://unsubscribe.resend.com/?token=…> and List-Unsubscribe-Post: List-Unsubscribe=One-Click, and the footer shows an Unsubscribe link to the same URL. DKIM, SPF and DMARC pass.
  • The event created the Resend contact for an address that had none. This matters for control-arm users, who previously never became contacts.
  • bun run lint, typecheck (auth, email, api), and tests (auth, email) pass.

Notes

  • The footer no longer says "This email was sent to ". That matches the live drip templates.
  • Welcome delivery now depends on the welcome automation staying enabled.
  • Unrelated drift: the sync dry run wants to replace pro-cancellation-feedback, because the live automation no longer matches the script. I did not apply it.

Summary by cubic

Switches the welcome email from a direct send to a Resend automation so new signups get an unsubscribe link and List-Unsubscribe headers. Direct sends carry neither, so users had to email support to be removed.

  • The signup hook now emits user.welcome for every signup (both A/B arms) instead of sending the email.
  • The welcome automation sends the activation-00-welcome template, which now accepts unsubscribeUrl.
  • The footer no longer shows the recipient's address, matching the live drip templates.

Summary by CodeRabbit

  • New Features
    • Welcome emails are now delivered through an automated email workflow.
    • Welcome messages include unsubscribe options and standard list-unsubscribe headers.
    • The welcome email template now supports personalized unsubscribe links.
    • Welcome email delivery remains consistent across signup experience variants.
  • Improvements
    • Welcome email delivery can now be managed centrally through the email automation system.