Skip to content

Commit

Permalink
Merge pull request #2 from EMXDigital/liveramp_uid2_sidecar_support
Browse files Browse the repository at this point in the history
liveramp idl and uid2.0 support for prebid
  • Loading branch information
EMXDigital authored Jul 1, 2021
2 parents 5d71941 + 993346e commit f96690e
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
41 changes: 41 additions & 0 deletions modules/emx_digitalBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const RENDERER_URL = 'https://js.brealtime.com/outstream/1.30.0/bundle.js';
const ADAPTER_VERSION = '1.5.1';
const DEFAULT_CUR = 'USD';

const EIDS_SUPPORTED = [
{ key: 'idl_env', source: 'liveramp.com', rtiPartner: 'idl', queryParam: 'idl' },
{ key: 'uid2.id', source: 'uidapi.com', rtiPartner: 'UID2', queryParam: 'uid2' }
];

export const emxAdapter = {
validateSizes: (sizes) => {
if (!utils.isArray(sizes) || typeof sizes[0] === 'undefined') {
Expand Down Expand Up @@ -168,6 +173,27 @@ export const emxAdapter = {
}

return emxData;
},
// supporting eids
getEids(bidRequests) {
return EIDS_SUPPORTED
.map(emxAdapter.getUserId(bidRequests))
.filter(x => x);
},
getUserId(bidRequests) {
return ({ key, source, rtiPartner }) => {
let id = utils.deepAccess(bidRequests, `userId.${key}`);
return id ? emxAdapter.formatEid(id, source, rtiPartner) : null;
};
},
formatEid(id, source, rtiPartner) {
return {
source,
uids: [{
id,
ext: { rtiPartner }
}]
};
}
};

Expand Down Expand Up @@ -252,6 +278,21 @@ export const spec = {
if (bidderRequest && bidderRequest.uspConsent) {
emxData.us_privacy = bidderRequest.uspConsent
}

// adding eid support
if (bidderRequest.userId) {
let eids = emxAdapter.getEids(bidderRequest);
if (eids.length > 0) {
if (emxData.user && emxData.user.ext) {
emxData.user.ext.eids = eids;
} else {
emxData.user = {
ext: {eids}
};
}
}
}

return {
method: 'POST',
url,
Expand Down
34 changes: 34 additions & 0 deletions test/spec/modules/emx_digitalBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,40 @@ describe('emx_digital Adapter', function () {
expect(request.source.ext.schain).to.have.property('ver', '1.0');
expect(request.source.ext.schain.nodes[0].asi).to.equal(schainBidderRequest.bids[0].schain.nodes[0].asi);
});

it('should add liveramp identitylink id to request', () => {
const idl_env = '123';
const bidRequestWithID = utils.deepClone(bidderRequest);
bidRequestWithID.userId = { idl_env };
let requestWithID = spec.buildRequests(bidRequestWithID.bids, bidRequestWithID);
requestWithID = JSON.parse(requestWithID.data);
expect(requestWithID.user.ext.eids[0]).to.deep.equal({
source: 'liveramp.com',
uids: [{
id: idl_env,
ext: {
rtiPartner: 'idl'
}
}]
});
});

it('should add UID 2.0 to request', () => {
const uid2 = { id: '456' };
const bidRequestWithUID = utils.deepClone(bidderRequest);
bidRequestWithUID.userId = { uid2 };
let requestWithUID = spec.buildRequests(bidRequestWithUID.bids, bidRequestWithUID);
requestWithUID = JSON.parse(requestWithUID.data);
expect(requestWithUID.user.ext.eids[0]).to.deep.equal({
source: 'uidapi.com',
uids: [{
id: uid2.id,
ext: {
rtiPartner: 'UID2'
}
}]
});
});
});

describe('interpretResponse', function () {
Expand Down

0 comments on commit f96690e

Please sign in to comment.