Skip to content

Commit

Permalink
Conversant Bid Adapter adds support for extended ids
Browse files Browse the repository at this point in the history
  • Loading branch information
pycnvr committed Nov 13, 2019
1 parent afdce98 commit 82f0622
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
46 changes: 46 additions & 0 deletions modules/conversantBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ export const spec = {
userExt.fpc = pubcid;
}

// Add Eids if available
const eids = collectEids(validBidRequests);
if (eids.length > 0) {
userExt.eids = eids;
}

// Only add the user object if it's not empty
if (!utils.isEmpty(userExt)) {
payload.user = {ext: userExt};
Expand Down Expand Up @@ -287,4 +293,44 @@ function copyOptProperty(src, dst, dstName) {
}
}

/**
* Collect IDs from validBidRequests and store them as an extended id array
* @param bidRequests valid bid requests
*/
function collectEids(bidRequests) {
const request = bidRequests[0]; // bidRequests have the same userId object
const eids = [];

addEid(eids, request, 'userId.tdid', 'adserver.org');
addEid(eids, request, 'userId.idl_env', 'liveramp.com');
addEid(eids, request, 'userId.criteoId', 'criteo.com');
addEid(eids, request, 'userId.id5id', 'id5-sync.com');
addEid(eids, request, 'userId.parrableid', 'parrable.com');

addEid(eids, request, 'userId.digitrustid.data.id', 'digitru.st');
addEid(eids, request, 'userId.lipb.lipbid', 'liveintent.com');

return eids;
}

/**
* Extract and push a single extended id into eids array
* @param eids Array of extended IDs
* @param idObj Object containing IDs
* @param keyPath Nested properties expressed as a path
* @param source Source for the ID
*/
function addEid(eids, idObj, keyPath, source) {
const id = utils.deepAccess(idObj, keyPath);
if (id) {
eids.push({
source: source,
uids: [{
id: id,
atype: 1
}]
});
}
}

registerBidder(spec);
20 changes: 20 additions & 0 deletions test/spec/modules/conversantBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ describe('Conversant adapter tests', function() {
// construct http post payload
const payload = spec.buildRequests(requests).data;
expect(payload).to.have.deep.nested.property('user.ext.fpc', 12345);
expect(payload).to.not.have.nested.property('user.ext.eids');
});

it('Verify User ID publisher commond id support', function() {
Expand All @@ -387,6 +388,7 @@ describe('Conversant adapter tests', function() {
// construct http post payload
const payload = spec.buildRequests(requests).data;
expect(payload).to.have.deep.nested.property('user.ext.fpc', 67890);
expect(payload).to.not.have.nested.property('user.ext.eids');
});

it('Verify GDPR bid request', function() {
Expand Down Expand Up @@ -415,4 +417,22 @@ describe('Conversant adapter tests', function() {
expect(payload).to.have.deep.nested.property('user.ext.consent', '');
expect(payload).to.not.have.deep.nested.property('regs.ext.gdpr');
});

describe('Extended ID', function() {
it('Verify unifiedid and liveramp', function() {
// clone bidRequests
let requests = utils.deepClone(bidRequests);

// add pubcid to every entry
requests.forEach((unit) => {
Object.assign(unit, {userId: {pubcid: 112233, tdid: 223344, idl_env: 334455}});
});
// construct http post payload
const payload = spec.buildRequests(requests).data;
expect(payload).to.have.deep.nested.property('user.ext.eids', [
{source: 'adserver.org', uids: [{id: 223344, atype: 1}]},
{source: 'liveramp.com', uids: [{id: 334455, atype: 1}]}
]);
});
});
});

0 comments on commit 82f0622

Please sign in to comment.