Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions lib/addons/prebid/analytics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,41 @@ describe("OptablePrebidAnalytics", () => {
expect(result.optableSources).toEqual(["uidapi.com", "id5-sync.com"]);
expect(result.liveintentEIDs).toEqual(["uidapi.com"]);
});

it("keeps an Optable EID when a later non-Optable EID shares its source", async () => {
const result = await analytics.toWitness(
{
auctionId: "auction-shared-source",
bidderRequests: [
{
bidderCode: "bidder1",
bidderRequestId: "req-1",
ortb2: {
site: { domain: "example.com" },
user: {
ext: { eids: [{ inserter: "optable.co", matcher: "uid2", source: "uidapi.com" }] },
eids: [{ source: "uidapi.com", uids: [{ id: "li", ext: { provider: "liveintent.com" } }] }],
},
},
bids: [],
},
],
bidsReceived: [],
noBids: [],
timeoutBids: [],
},
[]
);

expect(result.bidderRequests[0]).toMatchObject({
optableTargetingDone: true,
optableMatchers: ["uid2"],
optableSources: ["uidapi.com"],
});
expect(result.optableMatchers).toEqual(["uid2"]);
expect(result.optableSources).toEqual(["uidapi.com"]);
expect(result.optableTargetingDone).toBe("1");
});
});

describe("trackAuctionEnd", () => {
Expand Down
4 changes: 2 additions & 2 deletions lib/addons/prebid/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ class OptablePrebidAnalytics {
const { bidderCode, bidderRequestId, bids = [] } = br;
const domain = br.ortb2.site?.domain ?? "unknown";
const allEids = [...(br.ortb2.user?.ext?.eids ?? []), ...(br.ortb2.user?.eids ?? [])];
// Deduplicate EIDs by source
const eids = Array.from(new Map(allEids.map((eid: any) => [eid.source, eid])).values());
// Deduplicate EIDs by source and inserter, so another inserter's EID can't hide Optable's
const eids = Array.from(new Map(allEids.map((eid: any) => [`${eid.source}|${eid.inserter}`, eid])).values());

// Optable EIDs
const optableEIDS = eids.filter((e: { inserter: string }) => e.inserter === "optable.co");
Expand Down