From 0296451f49fbe167e6937c74c93678d0130b99fc Mon Sep 17 00:00:00 2001 From: John Salis Date: Mon, 17 May 2021 14:35:27 -0400 Subject: [PATCH] Beachfront Bid Adapter: add Unified ID 2.0 support (#6770) --- modules/beachfrontBidAdapter.js | 7 +++-- .../spec/modules/beachfrontBidAdapter_spec.js | 28 +++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/modules/beachfrontBidAdapter.js b/modules/beachfrontBidAdapter.js index 8ddc0ca5ba9..7466b3d6a68 100644 --- a/modules/beachfrontBidAdapter.js +++ b/modules/beachfrontBidAdapter.js @@ -19,7 +19,8 @@ export const DEFAULT_MIMES = ['video/mp4', 'application/javascript']; export const SUPPORTED_USER_IDS = [ { key: 'tdid', source: 'adserver.org', rtiPartner: 'TDID', queryParam: 'tdid' }, - { key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' } + { key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' }, + { key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' } ]; let appId = ''; @@ -279,7 +280,7 @@ function getEids(bid) { function getUserId(bid) { return ({ key, source, rtiPartner }) => { - let id = bid.userId && bid.userId[key]; + let id = utils.deepAccess(bid, `userId.${key}`); return id ? formatEid(id, source, rtiPartner) : null; }; } @@ -428,7 +429,7 @@ function createBannerRequestData(bids, bidderRequest) { } SUPPORTED_USER_IDS.forEach(({ key, queryParam }) => { - let id = bids[0] && bids[0].userId && bids[0].userId[key]; + let id = utils.deepAccess(bids, `0.userId.${key}`) if (id) { payload[queryParam] = id; } diff --git a/test/spec/modules/beachfrontBidAdapter_spec.js b/test/spec/modules/beachfrontBidAdapter_spec.js index c7ae5c799ac..605ccc464cb 100644 --- a/test/spec/modules/beachfrontBidAdapter_spec.js +++ b/test/spec/modules/beachfrontBidAdapter_spec.js @@ -333,6 +333,24 @@ describe('BeachfrontAdapter', function () { }] }); }); + + it('must add the Unified ID 2.0 to the request', () => { + const uid2 = { id: '4321' }; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { video: {} }; + bidRequest.userId = { uid2 }; + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.user.ext.eids[0]).to.deep.equal({ + source: 'uidapi.com', + uids: [{ + id: uid2.id, + ext: { + rtiPartner: 'UID2' + } + }] + }); + }); }); describe('for banner bids', function () { @@ -506,6 +524,16 @@ describe('BeachfrontAdapter', function () { const data = requests[0].data; expect(data.idl).to.equal(idl_env); }); + + it('must add the Unified ID 2.0 to the request', () => { + const uid2 = { id: '4321' }; + const bidRequest = bidRequests[0]; + bidRequest.mediaTypes = { banner: {} }; + bidRequest.userId = { uid2 }; + const requests = spec.buildRequests([ bidRequest ]); + const data = requests[0].data; + expect(data.uid2).to.equal(uid2.id); + }); }); describe('for multi-format bids', function () {