PhoenixKit. Modules. Emails. BrevoEventNormalizer
(phoenix_kit_emails v0.1.17)
Copy Markdown
View Source
Normalizes a single event from Brevo's GET /v3/smtp/statistics/events
response into the same event-data shape SQSProcessor.process_email_event/1
already accepts for AWS SES — see that function's @doc for the exact
contract. SQSProcessor itself is untouched: every process_*_event/1
function stays SES-shaped, this module's only job is translating Brevo's
vocabulary into it.
A raw Brevo event looks like:
%{
"date" => "2017-03-12T12:30:00Z",
"email" => "john.smith@example.com",
"event" => "delivered",
"messageId" => "<201798300811.5787683@example.domain.com>",
"reason" => "...", # bounces/blocked/invalid/error only
"link" => "...", # clicks only
"ip" => "..." # opened/clicks only
}date is already full ISO 8601 with a Z offset — SQSProcessor's own
parse_timestamp/1 (DateTime.from_iso8601/1) accepts it unmodified, no
reformatting needed.
Summary
Functions
Normalizes a raw Brevo event.
Functions
Normalizes a raw Brevo event.
Returns
{:ok, event_data}— ready forSQSProcessor.process_email_event/1:ignore— a Brevo"requests"event (the send-request acknowledgement; we already log our own "send" event at send time, so this carries nothing new){:error, reason}— missing required fields, or an event type Brevo added since this mapping was written