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 adapter tdid support #3983

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
28 changes: 26 additions & 2 deletions modules/tripleliftBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const tripleliftAdapterSpec = {

buildRequests: function(bidRequests, bidderRequest) {
let tlCall = STR_ENDPOINT;
let data = _buildPostBody(bidRequests);
let data = _buildPostBody(bidRequests, bidderRequest);

tlCall = utils.tryAppendQueryString(tlCall, 'lib', 'prebid');
tlCall = utils.tryAppendQueryString(tlCall, 'v', '$prebid.version$');
Expand Down Expand Up @@ -78,7 +78,7 @@ export const tripleliftAdapterSpec = {
}
}

function _buildPostBody(bidRequests) {
function _buildPostBody(bidRequests, bidderRequest) {
let data = {};
data.imp = bidRequests.map(function(bid, index) {
return {
Expand All @@ -91,6 +91,13 @@ function _buildPostBody(bidRequests) {
}
});

let eids = handleConsortiaUserIds(bidderRequest)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add semicolon

if (eids.length > 0) {
data.user = {
ext: {eids}
}
}

return data;
}

Expand All @@ -108,6 +115,23 @@ function _isValidSize(size) {
return (size.length === 2 && typeof size[0] === 'number' && typeof size[1] === 'number');
}

function handleConsortiaUserIds(bidderRequest) {
let eids = [];
if (bidderRequest.userId && bidderRequest.userId.tdid) {
eids.push({
source: 'adserver.org',
uids: [{
id: bidderRequest.userId.tdid,
ext: {
rtiPartner: 'TDID'
}
}]
})
}

return eids;
}

function _buildResponseObject(bidderRequest, bid) {
let bidResponse = {};
let width = bid.width || 1;
Expand Down
43 changes: 31 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test/spec/modules/tripleliftBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ describe('triplelift adapter', function () {
gdprConsent: {
consentString: 'BOONm0NOONm0NABABAENAa-AAAARh7______b9_3__7_9uz_Kv_K7Vf7nnG072lPVA9LTOQ6gEaY',
gdprApplies: true
},
userId: {
tdid: '6bca7f6b-a98a-46c0-be05-6020f7604598'
}
};

Expand All @@ -112,6 +115,13 @@ describe('triplelift adapter', function () {
expect(payload.imp[0].banner.format).to.deep.equal([{w: 300, h: 250}, {w: 300, h: 600}]);
});

it('should add tdid to the payload if included', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
const payload = request.data;
expect(payload).to.exist;
expect(payload.user).to.deep.equal({ext: {eids: [{source: 'adserver.org', uids: [{id: '6bca7f6b-a98a-46c0-be05-6020f7604598', ext: {rtiPartner: 'TDID'}}]}]}});
});

it('should return a query string for TL call', function () {
const request = tripleliftAdapterSpec.buildRequests(bidRequests, bidderRequest);
const url = request.url;
Expand Down