Skip to content

Commit

Permalink
PubMatic adds support for bidUserIdAsEids (prebid#5397)
Browse files Browse the repository at this point in the history
* added support for pubcommon, digitrust, id5id

* added support for IdentityLink

* changed the source for id5

* added unit test cases

* changed source param for identityLink

* id value should be string only

* id value should be string; changed test data

* pubmatic using userIdAsEids

commented unnecessary code
PubMatic will no longer read Digitrust from config or independent library setup
PubMatic will no loner read TTDID from config or independent library setup

* chnages in test cases for userIdAsEids

commented unnecessary test cases
PubMatic will no longer read Digitrust from config or independent library setup
PubMatic will no loner read TTDID from config or independent library setup

* deleted commented code and test cases

* deleted a commented line

* lint effect
  • Loading branch information
pm-harshad-mane authored and iggyfisk committed Jun 22, 2020
1 parent 046cb20 commit aa12f36
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 536 deletions.
88 changes: 3 additions & 85 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const USER_SYNC_URL_IFRAME = 'https://ads.pubmatic.com/AdServer/js/showad.js#PIX
const USER_SYNC_URL_IMAGE = 'https://image8.pubmatic.com/AdServer/ImgSync?p=';
const DEFAULT_CURRENCY = 'USD';
const AUCTION_TYPE = 1;
const PUBMATIC_DIGITRUST_KEY = 'nFIn8aLzbd';
const UNDEFINED = undefined;
const DEFAULT_WIDTH = 0;
const DEFAULT_HEIGHT = 0;
Expand Down Expand Up @@ -617,91 +616,10 @@ function _addFloorFromFloorModule(impObj, bid) {
impObj.bidfloor = ((!isNaN(bidFloor) && bidFloor > 0) ? bidFloor : UNDEFINED);
}

function _getDigiTrustObject(key) {
function getDigiTrustId() {
let digiTrustUser = window.DigiTrust && (config.getConfig('digiTrustId') || window.DigiTrust.getUser({member: key}));
return (digiTrustUser && digiTrustUser.success && digiTrustUser.identity) || null;
}
let digiTrustId = getDigiTrustId();
// Verify there is an ID and this user has not opted out
if (!digiTrustId || (digiTrustId.privacy && digiTrustId.privacy.optout)) {
return null;
}
return digiTrustId;
}

function _handleDigitrustId(eids) {
let digiTrustId = _getDigiTrustObject(PUBMATIC_DIGITRUST_KEY);
if (digiTrustId !== null) {
eids.push({
'source': 'digitru.st',
'uids': [{
'id': digiTrustId.id || '',
'atype': 1,
'ext': {
'keyv': parseInt(digiTrustId.keyv) || 0
}
}]
});
}
}

function _handleTTDId(eids, validBidRequests) {
let ttdId = null;
let adsrvrOrgId = config.getConfig('adsrvrOrgId');
if (utils.isStr(utils.deepAccess(validBidRequests, '0.userId.tdid'))) {
ttdId = validBidRequests[0].userId.tdid;
} else if (adsrvrOrgId && utils.isStr(adsrvrOrgId.TDID)) {
ttdId = adsrvrOrgId.TDID;
}

if (ttdId !== null) {
eids.push({
'source': 'adserver.org',
'uids': [{
'id': ttdId,
'atype': 1,
'ext': {
'rtiPartner': 'TDID'
}
}]
});
}
}

/**
* Produces external userid object in ortb 3.0 model.
*/
function _addExternalUserId(eids, value, source, atype) {
if (utils.isStr(value)) {
eids.push({
source,
uids: [{
id: value,
atype
}]
});
}
}

function _handleEids(payload, validBidRequests) {
let eids = [];
_handleDigitrustId(eids);
_handleTTDId(eids, validBidRequests);
const bidRequest = validBidRequests[0];
if (bidRequest && bidRequest.userId) {
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.pubcid`), 'pubcid.org', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.digitrustid.data.id`), 'digitru.st', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.id5id`), 'id5-sync.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.criteoId`), 'criteo.com', 1);// replacing criteoRtus
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.idl_env`), 'liveramp.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.lipb.lipbid`), 'liveintent.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.parrableid`), 'parrable.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.britepoolid`), 'britepool.com', 1);
_addExternalUserId(eids, utils.deepAccess(bidRequest, `userId.netId`), 'netid.de', 1);
}
if (eids.length > 0) {
payload.user.eids = eids;
const bidUserIdAsEids = utils.deepAccess(validBidRequests, '0.userIdAsEids');
if (utils.isArray(bidUserIdAsEids) && bidUserIdAsEids.length > 0) {
utils.deepSetValue(payload, 'user.eids', bidUserIdAsEids);
}
}

Expand Down
Loading

0 comments on commit aa12f36

Please sign in to comment.