Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversant Bid Adapter adds support for extended ids #4462

Merged
merged 3 commits into from
Nov 18, 2019
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
45 changes: 45 additions & 0 deletions modules/conversantBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,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 @@ -294,6 +300,45 @@ 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
}]
});
}
}

/**
* Look for a stored value from both cookie and local storage and return the first value found.
* @param key Key for the search
Expand Down
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 @@ -416,6 +418,24 @@ describe('Conversant adapter tests', function() {
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}]}
]);
});
});

describe('direct reading pubcid', function() {
const ID_NAME = '_pubcid';
const CUSTOM_ID_NAME = 'myid';
Expand Down