Skip to content

Conversation

@sethconve
Copy link

This is a proposal on how to start handling resend webhooks with more detail over time. There is a simple mechanism for aggregate counting which might hit OCC if we get a bunch of bounces at once. Do we want to schedule an aggregator function instead of mutating them one at a time?

ianmacartney and others added 11 commits July 25, 2025 17:39
(cherry picked from commit 8942f0d)
(cherry picked from commit 2ae026c)
(cherry picked from commit 14b0a63)
(cherry picked from commit 0eadce1)
This doesn't quite give us the ability to track how many were delivered, bounced, etc yet, as it does not tell us which email recipient bounced, or complained. They intend to improve the API early november at which point we can integrate that information
…ious if you send to 100 recipients for one email?
@sethconve sethconve marked this pull request as draft October 27, 2025 18:40
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 27, 2025

Open in StackBlitz

npm i https://pkg.pr.new/get-convex/resend/@convex-dev/resend@39

commit: b218f06

Comment on lines +58 to +61
bounceCount: v.optional(v.number()),
complaintCount: v.optional(v.number()),
failedCount: v.optional(v.number()),
deliveryDelayedCount: v.optional(v.number()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry that when things do fail, we'll get a flood of these. It'd be a great time to have the key-based batching workpool (I have ideas but not yet started) to enqueue events and handle them per-email... but right now I say we force a status query to get details by listing them all.

We could also surface a status that does a "distinct" lookup on the events for a given email, which would be bounded enough that for each email we could be checking e.g. if there were any bounces/ failures, etc. and maybe have the details of "how many" surfaced with an email-specific query. or just do the full count for now and see if folks with lots of to addresses need a more efficient one later..

...email,
status: "failed",
finalizedAt: Date.now(),
failedCount: (email.failedCount ?? 0) + 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we're going to update a global status, let's establish a hierarchy - so it will at most have each status once. e.g. if it got a complaint then maybe it never gets updated with any status after that.
suggestion to start:

  1. sent
  2. delivery_delayed
  3. delivered
  4. bounced
  5. opened
  6. clicked
  7. complained

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.

4 participants