Skip to content

Commit f0d8c70

Browse files
pm-harshad-manerjvelicaria
authored andcommitted
Conversant bid adapter to use userIdAsEids (prebid#4967)
* added support for pubcommon, digitrust, id5id * added support for IdentityLink * changed the source for id5 * added unit test cases * changed source param for identityLink * using userIdAsEids
1 parent 20e8e51 commit f0d8c70

File tree

2 files changed

+20
-29
lines changed

2 files changed

+20
-29
lines changed

modules/conversantBidAdapter.js

+16-28
Original file line numberDiff line numberDiff line change
@@ -314,36 +314,24 @@ function copyOptProperty(src, dst, dstName) {
314314
function collectEids(bidRequests) {
315315
const request = bidRequests[0]; // bidRequests have the same userId object
316316
const eids = [];
317-
318-
addEid(eids, request, 'userId.tdid', 'adserver.org');
319-
addEid(eids, request, 'userId.idl_env', 'liveramp.com');
320-
addEid(eids, request, 'userId.criteoId', 'criteo.com');
321-
addEid(eids, request, 'userId.id5id', 'id5-sync.com');
322-
addEid(eids, request, 'userId.parrableid', 'parrable.com');
323-
addEid(eids, request, 'userId.digitrustid.data.id', 'digitru.st');
324-
addEid(eids, request, 'userId.lipb.lipbid', 'liveintent.com');
325-
326-
return eids;
327-
}
328-
329-
/**
330-
* Extract and push a single extended id into eids array
331-
* @param eids Array of extended IDs
332-
* @param idObj Object containing IDs
333-
* @param keyPath Nested properties expressed as a path
334-
* @param source Source for the ID
335-
*/
336-
function addEid(eids, idObj, keyPath, source) {
337-
const id = utils.deepAccess(idObj, keyPath);
338-
if (id) {
339-
eids.push({
340-
source: source,
341-
uids: [{
342-
id: id,
343-
atype: 1
344-
}]
317+
if (utils.isArray(request.userIdAsEids) && request.userIdAsEids.length > 0) {
318+
// later following white-list can be converted to block-list if needed
319+
const requiredSourceValues = {
320+
'adserver.org': 1,
321+
'liveramp.com': 1,
322+
'criteo.com': 1,
323+
'id5-sync.com': 1,
324+
'parrable.com': 1,
325+
'digitru.st': 1,
326+
'liveintent.com': 1
327+
};
328+
request.userIdAsEids.forEach(function(eid) {
329+
if (requiredSourceValues.hasOwnProperty(eid.source)) {
330+
eids.push(eid);
331+
}
345332
});
346333
}
334+
return eids;
347335
}
348336

349337
/**

test/spec/modules/conversantBidAdapter_spec.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {expect} from 'chai';
22
import {spec} from 'modules/conversantBidAdapter.js';
33
import * as utils from 'src/utils.js';
4+
import { createEidsArray } from 'modules/userId/eids.js';
45

56
describe('Conversant adapter tests', function() {
67
const siteId = '108060';
@@ -395,6 +396,7 @@ describe('Conversant adapter tests', function() {
395396
// add pubcid to every entry
396397
requests.forEach((unit) => {
397398
Object.assign(unit, {userId: {pubcid: 67890}});
399+
Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)});
398400
});
399401
// construct http post payload
400402
const payload = spec.buildRequests(requests).data;
@@ -469,11 +471,12 @@ describe('Conversant adapter tests', function() {
469471
// add pubcid to every entry
470472
requests.forEach((unit) => {
471473
Object.assign(unit, {userId: {pubcid: 112233, tdid: 223344, idl_env: 334455}});
474+
Object.assign(unit, {userIdAsEids: createEidsArray(unit.userId)});
472475
});
473476
// construct http post payload
474477
const payload = spec.buildRequests(requests).data;
475478
expect(payload).to.have.deep.nested.property('user.ext.eids', [
476-
{source: 'adserver.org', uids: [{id: 223344, atype: 1}]},
479+
{source: 'adserver.org', uids: [{id: 223344, atype: 1, ext: {rtiPartner: 'TDID'}}]},
477480
{source: 'liveramp.com', uids: [{id: 334455, atype: 1}]}
478481
]);
479482
});

0 commit comments

Comments
 (0)