Pixelex.Destinations.HTTP (Pixelex v0.1.0)

Copy Markdown View Source

The one HTTP call every destination makes, and the reasoning behind each of its three options.

retry: :transient

Req does not retry POST by default, and every conversion here is a POST. A single 502 from an ad platform silently drops the conversion that ad spend is optimised against. Retrying is safe precisely because every event carries a deterministic event_id derived from the row it describes, and all of these platforms deduplicate on it — a replay cannot double-count.

Ten seconds

These run inside an Oban job, not a request, so the ceiling exists to free the worker rather than to protect a page.

Testing without a live ad account

:req_options is merged into every request, which is how the suite asserts on exact payloads without an account:

config :pixelex, req_options: [plug: {Req.Test, PixelexStub}]

Worth having beyond tests: the payload shape is the part that fails silently. A wrong field name gets a 200 and matches nothing.

A 2xx is not success

Some platforms answer 200 with the error in the body — TikTok's {"code": 40001} is the standard trap — so each destination supplies its own :success predicate. Treating a 2xx as delivery is how a broken integration reports itself as healthy for a month.

Summary

Types

result()

@type result() :: :ok | {:error, term()}

Functions

post(platform, url, body, opts \\ [])

@spec post(atom(), String.t(), map(), keyword()) :: result()

POST body as JSON to url.