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

Triplelift Bid Adapter: add PubCommon ID support #6352

Merged
merged 4 commits into from
Feb 24, 2021
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
27 changes: 16 additions & 11 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ function _buildPostBody(bidRequests) {
});

let eids = [
...getUnifiedIdEids(bidRequests),
...getIdentityLinkEids(bidRequests),
...getCriteoEids(bidRequests)
...getUnifiedIdEids([bidRequests[0]]),
...getIdentityLinkEids([bidRequests[0]]),
...getCriteoEids([bidRequests[0]]),
...getPubCommonEids([bidRequests[0]])
];

if (eids.length > 0) {
Expand Down Expand Up @@ -239,20 +240,24 @@ function _getExt(schain, fpd) {
return ext;
}

function getUnifiedIdEids(bidRequests) {
return getEids(bidRequests, 'tdid', 'adserver.org', 'TDID');
function getUnifiedIdEids(bidRequest) {
return getEids(bidRequest, 'tdid', 'adserver.org', 'TDID');
}

function getIdentityLinkEids(bidRequests) {
return getEids(bidRequests, 'idl_env', 'liveramp.com', 'idl');
function getIdentityLinkEids(bidRequest) {
return getEids(bidRequest, 'idl_env', 'liveramp.com', 'idl');
}

function getCriteoEids(bidRequests) {
return getEids(bidRequests, 'criteoId', 'criteo.com', 'criteoId');
function getCriteoEids(bidRequest) {
return getEids(bidRequest, 'criteoId', 'criteo.com', 'criteoId');
}

function getEids(bidRequests, type, source, rtiPartner) {
return bidRequests
function getPubCommonEids(bidRequest) {
return getEids(bidRequest, 'pubcid', 'pubcid.org', 'pubcid');
}

function getEids(bidRequest, type, source, rtiPartner) {
return bidRequest
.map(getUserId(type)) // bids -> userIds of a certain type
.filter((x) => !!x) // filter out null userIds
.map(formatEid(source, rtiPartner)); // userIds -> eid objects
Expand Down
21 changes: 17 additions & 4 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,16 @@ describe('triplelift adapter', function () {
});
});

it('should add user ids from multiple bid requests', function () {
it('should consolidate user ids from multiple bid requests', function () {
const tdidId = '6bca7f6b-a98a-46c0-be05-6020f7604598';
const idlEnvId = 'XY6104gr0njcH9UDIR7ysFFJcm2XNpqeJTYslleJ_cMlsFOfZI';
const criteoId = '53e30ea700424f7bbdd793b02abc5d7';
const pubcid = '3261d8ad-435d-481d-abd1-9f1a9ec99f0e';

const bidRequestsMultiple = [
{ ...bidRequests[0], userId: { tdid: tdidId } },
{ ...bidRequests[0], userId: { idl_env: idlEnvId } },
{ ...bidRequests[0], userId: { criteoId: criteoId } }
{ ...bidRequests[0], userId: { tdid: tdidId, idl_env: idlEnvId, criteoId, pubcid } },
{ ...bidRequests[0], userId: { tdid: tdidId, idl_env: idlEnvId, criteoId, pubcid } },
{ ...bidRequests[0], userId: { tdid: tdidId, idl_env: idlEnvId, criteoId, pubcid } }
];

const request = tripleliftAdapterSpec.buildRequests(bidRequestsMultiple, bidderRequest);
Expand Down Expand Up @@ -549,10 +550,22 @@ describe('triplelift adapter', function () {
ext: { rtiPartner: 'criteoId' }
}
]
},
{
source: 'pubcid.org',
uids: [
{
id: '3261d8ad-435d-481d-abd1-9f1a9ec99f0e',
ext: { rtiPartner: 'pubcid' }
}
]
}
]
}
});

expect(payload.user.ext.eids).to.be.an('array');
expect(payload.user.ext.eids).to.have.lengthOf(4);
});

it('should return a query string for TL call', function () {
Expand Down