Skip to main content

What it is for

This page explains, for technical readers and curious operators, what happens between “a coupon was redeemed” and “an email left”. It replaces the old “Notifications (OneSignal)” introduction of Documentation, which described a dispatcher that no longer sends anything.
Diagram: a business flow calls notify with an event; an invalid payload leaves the occurrence rejected; a valid one records an occurrence, resolves the recipients and takes one decision per channel with the template and the rules; what is not sent keeps its reason in Traceability; each send goes through the queue and the lane of its channel to the provider, which reports delivery events that feed the timeline, the suppressions and the metrics.

From the business fact to the provider: occurrence, decisions, queue, lane and provider.

The pieces

notify(): one door for every producer

A producer (the Club, payments, onboarding, a cron) never chooses a channel, a template or a text. It only says which event happened and passes its data:
Everything else is configuration of the module: which channels are on, which template is published, which rules apply. That is why a business unit can change a notification without a new version of the system.

The event registry

Events are declared in the code, one file per domain, and copied to the catalog by a migration. The catalog can switch an event or a channel on and off and adjust its rules; it cannot create events or change their data.

What happens on each call

  1. Event. The key is looked up in the registry and the catalog. An unknown key is a programming error.
  2. Data. The data is checked against the schema. Invalid data leaves the occurrence Rejected with the reason Invalid data, and nothing is sent.
  3. Occurrence. The occurrence is recorded once per event and idempotency key. Calling again with the same key returns the first occurrence and sends nothing new.
  4. Event active. An event turned off or deprecated skips every channel (Event inactive).
  5. Recipients. The audience is resolved into people or addresses. None: No recipient.
  6. Language and timezone of each recipient, from their account.
  7. Each channel and recipient, in this order, where the first failure decides: channel on, published template, translation (Spanish if the language is missing), render, address, suppression, preference, frequency cap, quiet hours, delay. If everything passes, the send is written and queued (or scheduled).
  8. Fallback. A channel declared as fallback of another runs only when that one was skipped or suppressed, or later fails at delivery.
  9. Close. The occurrence ends Completed or No send, and later moves with its sends’ delivery.
Each reason of steps 2 to 8 is explained in States and reasons.

Why it works this way

What changed from the old design

The old dispatcher file still exists as a thin wrapper over the core and no production code calls it. Old-shape queue messages are still translated for one more release.

Technical detail