Skip to content

eidCache: let firstPartyMatchers keep a third-party EID over a first-party one - #362

Open
etiennelatendresse-optable wants to merge 2 commits into
masterfrom
eid-cache-matcher-preference
Open

etiennelatendresse-optable wants to merge 2 commits into
masterfrom
eid-cache-matcher-preference

Conversation

@etiennelatendresse-optable

@etiennelatendresse-optable etiennelatendresse-optable commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Why

When targeting and tokenize both resolve the same source, mergeCache kept whichever landed last, so a first-party result could overwrite a third-party one that carried more. Deciding by the EID's label instead of arrival order lets the two calls run in parallel.

What changed

  • mergeCache takes a firstPartyMatchers option. With it set, a first-party EID no longer displaces a third-party one already cached on that source, and the kept EID keeps its refs.
  • An EID with no matcher counts as third-party.
  • CachedEid carries matcher, which the SDK already read untyped in the analytics and event paths.
  • Without the option, every new EID still wins its source, and a source sent with no uids is still revoked.

How to Test

  • Tested
  • Docs updated — if this adds, changes or removes anything a consumer calls, update the module's .md alongside the code (for example lib/addons/<addon>.md) and the matching README section. New addons ship with a new .md.

Notes

  • Breaking change
  • Requires release

@etiennelatendresse-optable
etiennelatendresse-optable marked this pull request as ready for review October 8, 2026 18:07
Comment thread lib/core/eid-cache.ts
newEids.forEach((eid) => {
if (!eid.uids?.length) return;
const held = eidMap.get(eid.source);
if (held && isFirstParty(eid) && !isFirstParty(held)) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude says thirdparty already in cache can't be revoked by first party. Can you verify this isn't the case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, are you asking me if the claude claim is false or if its true that third-party cache cant be revoked by first party? Basically, do we want:
Revocation always wins regardless of party
or
A first-party call revokes only its own entries, so it cant revoke third-party

Comment thread lib/core/eid-cache.ts
newEids.forEach((eid) => {
if (!eid.uids?.length) return;
const held = eidMap.get(eid.source);
if (held && isFirstParty(eid) && !isFirstParty(held)) return;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also claude says that the refresh data can be mixed up here. WE need to apply the selection logic higher up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cant reproduce this. Ran all 18 combinations of old matcher + new matcher + new-ref present and the surviving ref always belonged to the surviving EID

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