Karta. Tracking. Rewriter
(Karta v1.0.0)
Personalises an outgoing message for one recipient, before it is signed:
tracked links and the open pixel in its HTML (Karta.Tracking.HTML), and
the List-Unsubscribe and List-Unsubscribe-Post header fields (RFC
8058).
Which parts change. Only HTML that is the message's text: text/html
leaves that are not attachments, in a charset whose ASCII bytes mean
ASCII (none, US-ASCII, UTF-8, ISO-8859-*, Windows-125x), with a 7bit,
8bit, binary, quoted-printable or base64 transfer encoding. Plain-text
parts, attachments and attached messages never change, and a message
that cannot be parsed keeps its body. A changed part keeps its transfer
encoding, except that a 7bit, 8bit or binary part with a line over 998
octets afterwards becomes quoted-printable.
Which links. links/2 lists the trackable links of those parts once
per URL, leaving out links to the tracking host itself and the URLs of
the message's own List-Unsubscribe field: an unsubscribe link is never
tracked.
List-Unsubscribe. Added only when the message has neither field of
its own (an application's own List-Unsubscribe is kept as it is);
List-Unsubscribe-Post: List-Unsubscribe=One-Click only with an https
URL, as RFC 8058 requires. Both are appended to the header block, so the
DKIM signature made afterwards covers them (Karta.Auth.DKIM.Signer
signs and oversigns them).
Summary
Types
What to do for one recipient: link gives the tracked URL for a
trackable URL (or nil to keep it), pixel is the open pixel's URL and
unsubscribe the one-click unsubscribe URL; nil leaves each out.
Types
@type plan() :: %{ link: Karta.Tracking.HTML.link_fun() | nil, pixel: String.t() | nil, unsubscribe: String.t() | nil }
What to do for one recipient: link gives the tracked URL for a
trackable URL (or nil to keep it), pixel is the open pixel's URL and
unsubscribe the one-click unsubscribe URL; nil leaves each out.
Functions
The distinct trackable URLs of the message's HTML, in order (at most
1000), without links under base_url and without the message's
own unsubscribe URLs.
The message as sent to one recipient. See the module doc and plan/0.