Skip to content

uid2: apply refresh outcomes to the targeting cache - #329

Merged
mosherBT merged 4 commits into
masterfrom
uid2-cache-apply
Sep 2, 2026
Merged

uid2: apply refresh outcomes to the targeting cache#329
mosherBT merged 4 commits into
masterfrom
uid2-cache-apply

Conversation

@mosherBT

@mosherBT mosherBT commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Why

A UID2 refresh outcome has to land in the targeting cache: a fresh token should replace the cached EID in place, and a dead one (opt-out, expired) should evict it. web-sdk has the protocol client (#328) but nothing that updates the cache.

What Changed

  • addons: applyUid2Refresh(config, source, result) in lib/addons/uid2-refresh.ts — on success, rewrites the matching EID's uids to [{ atype: 3, id: advertising_token }] and its _ref from the response body; on optout, invalid_token or expired_token, removes the EID; any other error leaves the cache untouched for retry. Updates each stored cache copy independently and sends the optable-targeting:change event after each write.
  • addons: RefreshableEID type (EID & { _ref?: Uid2RefData }).
  • core: LocalStorage.updateTargeting(update) — applies an update to every stored copy of the targeting response independently, so the private raw copy and a wrapper's merged public copy never overwrite each other.

How to Test

Unit tests cover: success rewrite (uids + _ref, other EIDs untouched, event sent), independent private/public copy updates, definitive-rejection eviction, transient errors leaving the cache untouched, unknown source no-op, empty cache no-op.

  • Tested
  • Docs updated

Notes

  • Breaking change
  • Requires release

@mosherBT
mosherBT requested review from a team as code owners August 26, 2026 18:38
@mosherBT mosherBT self-assigned this Aug 26, 2026
@mosherBT
mosherBT requested review from etiennelatendresse-optable and jplaroche and removed request for jeremy-cullen-ai August 26, 2026 19:04
@mosherBT
mosherBT merged commit 80583bc into master Sep 2, 2026
7 checks passed
@mosherBT
mosherBT deleted the uid2-cache-apply branch September 2, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants