Skip to content

[SES-PHASE-1-8] - PLU-744: add bounce rate tracking (exploration)#1634

Open
m0nggh wants to merge 1 commit into
feat/ses/add-env-varsfrom
feat/ses/add-bounce-rate-tracking
Open

[SES-PHASE-1-8] - PLU-744: add bounce rate tracking (exploration)#1634
m0nggh wants to merge 1 commit into
feat/ses/add-env-varsfrom
feat/ses/add-bounce-rate-tracking

Conversation

@m0nggh
Copy link
Copy Markdown
Contributor

@m0nggh m0nggh commented May 20, 2026

TL;DR

Add DogStatsD metrics tracking for SES email events (sent, bounced, complained).

WHY???

  • AWS reviews/suspends senders whose bounce rate stays above ~5/10% or complaint rate above ~0.5%.
  • SES's own CloudWatch reputation metrics are account-level, not per-configuration-set.
  • We can track and monitor internally since we have full context of whether an email is bounced or not

What changed?

A new incrementMetric helper wraps the DogStatsD tracer client to provide a reusable way to emit counter metrics. This helper is now called in three places:

  • When an email is successfully sent via SES (in both email-helper.ts and ses-email-helper.ts), emitting ses.email.sent
  • When a bounce event is processed, emitting ses.email.bounce tagged with bounce_type and bounce_sub_type
  • When a complaint event is processed, emitting ses.email.complaint tagged with complaint_feedback_type

How to test?

To test locally, DogStatsD writes UDP packets to 127.0.0.1:8125. Sniff with nc:

# Terminal A — listen
nc -ul 8125
# Terminal B — start app
cd packages/backend && npm run dev

Tried testing on uat

  • Trigger a transactional email send and verify the ses.email.sent metric appears in Datadog
  • Simulate or observe a bounce/complaint SES event being processed and verify the corresponding metrics appear with the correct tags in Datadog
  • Run the existing test suite, which has been updated to mock the new incrementMetric helper

Why make this change?

Visibility into SES email delivery health was limited. By tracking sent, bounce, and complaint counts as metrics in Datadog, we can monitor delivery rates, detect spikes in bounces or complaints, and set up alerts without relying solely on logs.

@m0nggh m0nggh changed the title add bounce rate tracking draft [SES-PHASE-1-8] - PLU-744: add bounce rate tracking (exploration) May 20, 2026
@linear
Copy link
Copy Markdown

linear Bot commented May 20, 2026

PLU-744

@m0nggh m0nggh marked this pull request as ready for review May 21, 2026 07:35
@m0nggh m0nggh requested a review from a team as a code owner May 21, 2026 07:35
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from b152844 to fcf855e Compare May 22, 2026 11:16
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from d24c3a0 to a60b320 Compare May 22, 2026 11:16
}),
}),
)
incrementMetric('ses.email.sent')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: technically we can avoid multiple calls to this and just increment by total number of successfully sent emails inside the postman action itself.

But keeping it here is also ok, i dont think there is any material difference

Copy link
Copy Markdown
Contributor

@ogp-weeloong ogp-weeloong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from a60b320 to 9a41983 Compare June 8, 2026 09:03
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from fcf855e to 1741d4f Compare June 8, 2026 09:03
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from 9a41983 to ff1bad2 Compare June 8, 2026 11:01
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from 1741d4f to 34a472f Compare June 8, 2026 11:01
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from ff1bad2 to a32f27a Compare June 8, 2026 12:02
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from 34a472f to 0d5d0c3 Compare June 8, 2026 12:02
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from a32f27a to f020b93 Compare June 8, 2026 12:04
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch 2 times, most recently from 9ed7d91 to 91509c9 Compare June 8, 2026 15:02
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from f020b93 to 69fb6dc Compare June 8, 2026 15:02
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from 91509c9 to d903145 Compare June 8, 2026 15:03
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from 69fb6dc to 46fc7be Compare June 8, 2026 15:03
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from d903145 to de10911 Compare June 8, 2026 16:00
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch 2 times, most recently from 4d4108d to 921f21a Compare June 8, 2026 16:02
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch 2 times, most recently from 6cc0f29 to f9b2bb3 Compare June 8, 2026 16:48
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from 921f21a to aab629b Compare June 8, 2026 16:48
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from f9b2bb3 to 09f6135 Compare June 8, 2026 16:50
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from aab629b to 97d3b6f Compare June 8, 2026 16:50
@m0nggh m0nggh force-pushed the feat/ses/add-bounce-rate-tracking branch from 09f6135 to eb4acd4 Compare June 8, 2026 16:57
@m0nggh m0nggh force-pushed the feat/ses/add-env-vars branch from 97d3b6f to 555afa8 Compare June 8, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants