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

Add tradedesk user id to appnexus adapter #5346

Merged
merged 2 commits into from
Jun 30, 2020
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
22 changes: 17 additions & 5 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,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