Skip to content

Emails 0.1.20: One settings section for all delivery event tracking

Emails 0.1.20 puts SES and Brevo event polling into one Delivery Event Tracking settings section and adds a reconcile job that restarts a poller that has stopped.

The section has one row per provider with its integration count, a tracking toggle, a state badge (Active, Idle when no integration is set up, Off or Stalled), the interval, the last poll, queued jobs, Brevo’s per-account opt-out, and Poll now and Restart. It replaces the polling controls in Amazon SES & SQS and the Brevo Events section. Poll now refuses a provider with nothing to poll.

Fixes: on a Brevo account shared with other senders, events for mail this app never sent filled the log with “unknown email” errors every cycle; they are now skipped quietly, and no placeholder log rows are created for them. SES with no queue URL no longer starts a poller that logs an error forever; it shows as idle.

Upgrading

Add event_tracker_reconcile: 1 (and brevo_polling: 1 if missing) to your Oban queues and {"*/2 * * * *", PhoenixKit.Modules.Emails.EventTrackerReconcileWorker} to the Cron plugin. mix phoenix_kit_emails.install prints the full snippet, including Oban.Plugins.Pruner and Oban.Plugins.Lifeline.

Full release notes: Emails 0.1.20

0.1.20 · 31 July 2026

Added

  • Universal event-tracker lifecycle. Every provider’s delivery-event poller now implements one EventTracker behaviour (eligible?/0 — is there a working event source at all — split from enabled?/0 — the operator’s toggle), is listed in a compile-time EventTrackerRegistry, and has its self-scheduling Oban chain started and stopped by a single stateless EventTrackerReconciler enforcing “iff should_run?/1, exactly one chain exists”. The invariant is enforced at the database by Oban’s own unique, so simultaneous reconciles on several nodes collapse to one chain. Adding a provider is: implement the behaviour, add the module to the registry. (#24)
  • EventTrackerReconcileWorker — a low-frequency Oban Cron entry in its own event_tracker_reconcile queue, and the correctness backbone of the above: it is the only trigger that can resurrect a chain that died or was never started (a SendProfile change emits no PubSub today). Boot and settings-toggle reconciles are latency polish on top. Requires new host config — see the installer output. (#24)
  • Unified “Delivery Event Tracking” settings section, one row per registered tracker: integration count, tracking toggle, a four-state badge (Active / Idle — no integration / Off / Stalled) with a per-state hint, editable interval, last poll, queued-job count, Brevo’s per-account polling opt-out, and Poll now / Restart actions. Replaces the polling controls that lived in the Amazon SES & SQS and Brevo Events sections; the latter is removed. (#24)
  • Log.exists_by_any_message_id?/1 and Emails.email_log_exists?/1 — a cheap indexed existence check across message_id and aws_message_id, no preloads, no struct load.

Fixed

  • Brevo polling on a shared account no longer floods the log. A Brevo account may be shared with other senders, so most polled events are for mail this app never sent; each one used to be dragged through the SES/SNS processor’s not-found path and surfaced as a loud [SYNC ISSUE] ... unknown email error, repeating every cycle until midnight. Such events are now skipped at :debug after a single existence check, with one :info summary per fetched page so the path stays observable — a page that is suddenly all skips is the signal. (#24)
  • SES no longer starts a poller with no queue URL. The queue-URL precondition that lived in the supervisor’s own boot gate is folded into eligible?/0, so a deployment with SES credentials and the toggle on but no queue configured no longer starts a chain at boot, has it resurrected every reconcile tick, and logs “SQS queue URL not configured” forever while the panel reports it as running. That state now reads “Idle — no integration”. (#24)
  • The supervisor’s two boot-gate predicates delegate to EventTracker.should_run?/1 instead of hand-copying the gate — the copies had already drifted in both directions (SES’s omitted the sender-aware gate, Brevo’s omitted the active-integration requirement).
  • Post-merge review fixes: the panel’s Last-poll column read “Never polled yet” for a healthy Brevo chain, because the generic timestamp came from Oban’s completed job history and Oban.Plugins.Pruner deletes those after 60s — well under Brevo’s 30s floor and 120s default. EventTracker gained an optional last_polled_at/0 callback, which BrevoPollingManager answers from the durable setting its job already writes every cycle.
  • Post-merge review fixes: the panel’s tracking toggle called the managers directly, and enable_polling/0 inserts a chain without consulting eligible?/0 — so turning SES on with no queue URL queued a chain for a tracker with nothing to poll (“Idle — no integration” beside a non-zero Queued count), and turning tracking off left its queued job behind. Both only self-corrected on the next reconcile tick, or never on a host that had not wired the Cron. The toggle now reconciles.
  • Post-merge review fixes: “Poll now” flashed success for a tracker with no working event source, having queued a forced job that could only wake up, fail its own eligibility gate and do nothing — the failure mode the button exists to prevent. It now refuses and says why.
  • Post-merge review fixes: the interval editor bound HTML step to the tracker’s minimum, so the browser rejected every value that was not a multiple of it (Brevo: 30s, 60s, 90s and nothing between) while the server accepted them.

Changed

  • New host Oban configuration is required for the reconcile backbone: a event_tracker_reconcile: 1 queue and a {"*/2 * * * *", PhoenixKit.Modules.Emails.EventTrackerReconcileWorker} crontab entry (plus brevo_polling: 1 if it was missing). Without them a tracker whose chain dies is never resurrected until the next app restart. mix phoenix_kit_emails.install prints the full snippet.
  • The installer’s printed plugins: list now includes Oban.Plugins.Pruner and Oban.Plugins.Lifeline, with an instruction to merge rather than replace an existing list. Lifeline is load-bearing here, not decorative: a poller job orphaned in :executing by a node that died mid-cycle is a permanent unique conflict for the reconciler, which can then never insert a successor — while the panel, counting that same row, keeps reporting the tracker as Active.
  • email_create_placeholder_logs no longer applies to polled Brevo events. On a shared account, creating a log row per orphaned event means materialising other senders’ traffic in this app’s email log. SES, where every event is by definition our own mail, is unchanged.
  • Dialyzer runs against a .dialyzer_ignore.exs carrying one narrowly-scoped entry for a pre-existing Gettext/Expo opaqueness false positive in the generated backend module.

Emails 0.1.20. Install or update: {:phoenix_kit_emails, "~> 0.1"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.