Shared referral partner attribution logic.
Provides atomic visitor partner attribution updates and helper functions used by the redirect and beacon click flows.
Summary
Functions
Sets the referral cookie on a conn. Returns conn unchanged if context is nil.
Merges referral context into event attrs. Returns attrs unchanged if context is nil.
Atomically updates visitor partner attribution.
Functions
Sets the referral cookie on a conn. Returns conn unchanged if context is nil.
Merges referral context into event attrs. Returns attrs unchanged if context is nil.
Atomically updates visitor partner attribution.
Last-touch fields are updated unconditionally. First-touch fields are
written only when first_partner_id IS NULL, using a conditional
update_all with a WHERE guard. This makes first-touch atomic — if two
concurrent requests both see nil, only one UPDATE will match the IS NULL
condition in the database, preventing double-write races.