Skip to content

Commit

Permalink
Beachfront Bid Adapter: add Unified ID 2.0 support (#6770)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalis authored and idettman committed May 21, 2021
1 parent b28420f commit 0296451
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
7 changes: 4 additions & 3 deletions modules/beachfrontBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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;
};
}
Expand Down Expand Up @@ -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;
}
Expand Down
28 changes: 28 additions & 0 deletions test/spec/modules/beachfrontBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -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 () {
Expand Down

0 comments on commit 0296451

Please sign in to comment.