Skip to content

Commit

Permalink
Add tradedesk user id to appnexus adapter (#5346)
Browse files Browse the repository at this point in the history
* Add tradedesk id support

* Updating appnexus payload for criteo

Co-authored-by: Jaimin Panchal <email@example.com>
  • Loading branch information
jaiminpanchal27 and Jaimin Panchal authored Jun 30, 2020
1 parent 76d5c51 commit c9bcc95
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
22 changes: 17 additions & 5 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,26 @@ export const spec = {
});
}

let eids = [];
const criteoId = utils.deepAccess(bidRequests[0], `userId.criteoId`);
if (criteoId) {
let tpuids = [];
tpuids.push({
'provider': 'criteo',
'user_id': criteoId
eids.push({
source: 'criteo.com',
id: criteoId
});
payload.tpuids = tpuids;
}

const tdid = utils.deepAccess(bidRequests[0], `userId.tdid`);
if (tdid) {
eids.push({
source: 'adserver.org',
id: tdid,
rti_partner: 'TDID'
});
}

if (eids.length) {
payload.eids = eids;
}

if (tags[0].publisher_id) {
Expand Down
34 changes: 22 additions & 12 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -738,18 +738,6 @@ describe('AppNexusAdapter', function () {
});
});

it('should populate tpids array when userId is available', function () {
const bidRequest = Object.assign({}, bidRequests[0], {
userId: {
criteoId: 'sample-userid'
}
});

const request = spec.buildRequests([bidRequest]);
const payload = JSON.parse(request.data);
expect(payload.tpuids).to.deep.equal([{provider: 'criteo', user_id: 'sample-userid'}]);
});

it('should populate schain if available', function () {
const bidRequest = Object.assign({}, bidRequests[0], {
schain: {
Expand Down Expand Up @@ -819,6 +807,28 @@ describe('AppNexusAdapter', function () {
const request = spec.buildRequests(bidRequests, bidderRequest);
expect(request.options).to.deep.equal({withCredentials: false});
});

it('should populate eids array when ttd id and criteo is available', function () {
const bidRequest = Object.assign({}, bidRequests[0], {
userId: {
tdid: 'sample-userid',
criteoId: 'sample-criteo-userid'
}
});

const request = spec.buildRequests([bidRequest]);
const payload = JSON.parse(request.data);
expect(payload.eids).to.deep.include({
source: 'adserver.org',
id: 'sample-userid',
rti_partner: 'TDID'
});

expect(payload.eids).to.deep.include({
source: 'criteo.com',
id: 'sample-criteo-userid',
});
});
})

describe('interpretResponse', function () {
Expand Down

0 comments on commit c9bcc95

Please sign in to comment.