Skip to content

Commit

Permalink
Pass TTD cookie through prebid endpoint (#11119)
Browse files Browse the repository at this point in the history
  • Loading branch information
wi101 authored Feb 20, 2024
1 parent 0606e77 commit 6ecd4a9
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 8 deletions.
17 changes: 17 additions & 0 deletions modules/liveIntentIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../src/adapterM
import {getStorageManager} from '../src/storageManager.js';
import {MODULE_TYPE_UID} from '../src/activities/modules.js';
import {UID2_EIDS} from '../libraries/uid2Eids/uid2Eids.js';
import { getRefererInfo } from '../src/refererDetection.js';

/**
* @typedef {import('../modules/userId/index.js').Submodule} Submodule
Expand Down Expand Up @@ -234,6 +235,10 @@ export const liveIntentIdSubmodule = {
result.sovrn = { 'id': value.sovrn, ext: { provider: LI_PROVIDER_DOMAIN } }
}

if (value.thetradedesk) {
result.thetradedesk = { 'id': value.thetradedesk, ext: { provider: getRefererInfo().domain || LI_PROVIDER_DOMAIN } }
}

return result
}

Expand Down Expand Up @@ -371,6 +376,18 @@ export const liveIntentIdSubmodule = {
return data.ext;
}
}
},
'thetradedesk': {
source: 'adserver.org',
atype: 3,
getValue: function(data) {
return data.id;
},
getUidExt: function(data) {
if (data.ext) {
return data.ext;
}
}
}
}
};
Expand Down
11 changes: 11 additions & 0 deletions modules/userId/eids.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ userIdAsEids = [
}
}]
},
{
source: 'adserver.org',
uids: [{
id: 'some-random-id-value',
atype: 3,
ext: {
provider: 'liveintent.com'
}
}]
},
{
source: 'rubiconproject.com',
Expand Down
33 changes: 33 additions & 0 deletions test/spec/modules/eids_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,39 @@ describe('eids array generation for known sub-modules', function() {
});
});

it('thetradedesk', function() {
const userId = {
thetradedesk: {'id': 'sample_id'}
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'adserver.org',
uids: [{
id: 'sample_id',
atype: 3
}]
});
});

it('thetradedesk with ext', function() {
const userId = {
thetradedesk: {'id': 'sample_id', 'ext': {'provider': 'some.provider.com'}}
};
const newEids = createEidsArray(userId);
expect(newEids.length).to.equal(1);
expect(newEids[0]).to.deep.equal({
source: 'adserver.org',
uids: [{
id: 'sample_id',
atype: 3,
ext: {
provider: 'some.provider.com'
}
}]
});
});

it('liveIntentId; getValue call and NO ext', function() {
const userId = {
lipb: {
Expand Down
27 changes: 19 additions & 8 deletions test/spec/modules/liveIntentIdMinimalSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as utils from 'src/utils.js';
import { gdprDataHandler, uspDataHandler } from '../../../src/adapterManager.js';
import { server } from 'test/mocks/xhr.js';
import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } from 'modules/liveIntentIdSystem.js';
import * as refererDetection from '../../../src/refererDetection.js';

const PUBLISHER_ID = '89899';
const defaultConfigParams = { params: {publisherId: PUBLISHER_ID} };
Expand All @@ -14,6 +15,7 @@ describe('LiveIntentMinimalId', function() {
let getCookieStub;
let getDataFromLocalStorageStub;
let imgStub;
let refererInfoStub;

beforeEach(function() {
liveIntentIdSubmodule.setModuleMode('minimal');
Expand All @@ -23,6 +25,7 @@ describe('LiveIntentMinimalId', function() {
logErrorStub = sinon.stub(utils, 'logError');
uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData');
gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData');
refererInfoStub = sinon.stub(refererDetection, 'getRefererInfo');
});

afterEach(function() {
Expand All @@ -32,6 +35,7 @@ describe('LiveIntentMinimalId', function() {
logErrorStub.restore();
uspConsentDataStub.restore();
gdprConsentDataStub.restore();
refererInfoStub.restore();
liveIntentIdSubmodule.setModuleMode('minimal');
resetLiveIntentIdSubmodule();
});
Expand Down Expand Up @@ -241,7 +245,7 @@ describe('LiveIntentMinimalId', function() {
expect(callBackSpy.calledOnce).to.be.true;
});

it('should decode a uid2 to a seperate object when present', function() {
it('should decode a uid2 to a separate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});
Expand All @@ -251,41 +255,48 @@ describe('LiveIntentMinimalId', function() {
expect(result).to.eql({'uid2': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode a bidswitch id to a seperate object when present', function() {
it('should decode a bidswitch id to a separate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', bidswitch: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'bidswitch': 'bar'}, 'bidswitch': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode a medianet id to a seperate object when present', function() {
it('should decode a medianet id to a separate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', medianet: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'medianet': 'bar'}, 'medianet': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode a sovrn id to a seperate object when present', function() {
it('should decode a sovrn id to a separate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', sovrn: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'sovrn': 'bar'}, 'sovrn': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode a magnite id to a seperate object when present', function() {
it('should decode a magnite id to a separate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', magnite: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'magnite': 'bar'}, 'magnite': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode an index id to a seperate object when present', function() {
it('should decode an index id to a separate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', index: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'index': 'bar'}, 'index': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode an openx id to a seperate object when present', function () {
it('should decode an openx id to a separate object when present', function () {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', openx: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'openx': 'bar'}, 'openx': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode an pubmatic id to a seperate object when present', function() {
it('should decode an pubmatic id to a separate object when present', function() {
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', pubmatic: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'pubmatic': 'bar'}, 'pubmatic': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode a thetradedesk id to a separate object when present', function() {
const provider = 'liveintent.com'
refererInfoStub.returns({domain: provider})
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar', 'ext': {'provider': provider}}});
});

it('should allow disabling nonId resolution', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand Down
12 changes: 12 additions & 0 deletions test/spec/modules/liveIntentIdSystem_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { liveIntentIdSubmodule, reset as resetLiveIntentIdSubmodule, storage } f
import * as utils from 'src/utils.js';
import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../../../src/adapterManager.js';
import { server } from 'test/mocks/xhr.js';
import * as refererDetection from '../../../src/refererDetection.js';

resetLiveIntentIdSubmodule();
liveIntentIdSubmodule.setModuleMode('standard')
const PUBLISHER_ID = '89899';
Expand All @@ -16,6 +18,7 @@ describe('LiveIntentId', function() {
let getCookieStub;
let getDataFromLocalStorageStub;
let imgStub;
let refererInfoStub;

beforeEach(function() {
liveIntentIdSubmodule.setModuleMode('standard');
Expand All @@ -26,6 +29,7 @@ describe('LiveIntentId', function() {
uspConsentDataStub = sinon.stub(uspDataHandler, 'getConsentData');
gdprConsentDataStub = sinon.stub(gdprDataHandler, 'getConsentData');
gppConsentDataStub = sinon.stub(gppDataHandler, 'getConsentData');
refererInfoStub = sinon.stub(refererDetection, 'getRefererInfo');
});

afterEach(function() {
Expand All @@ -36,6 +40,7 @@ describe('LiveIntentId', function() {
uspConsentDataStub.restore();
gdprConsentDataStub.restore();
gppConsentDataStub.restore();
refererInfoStub.restore();
resetLiveIntentIdSubmodule();
});

Expand Down Expand Up @@ -423,6 +428,13 @@ describe('LiveIntentId', function() {
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'pubmatic': 'bar'}, 'pubmatic': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}});
});

it('should decode a thetradedesk id to a separate object when present', function() {
const provider = 'liveintent.com'
refererInfoStub.returns({domain: provider})
const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' });
expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar', 'ext': {'provider': provider}}});
});

it('should allow disabling nonId resolution', function() {
let callBackSpy = sinon.spy();
let submoduleCallback = liveIntentIdSubmodule.getId({ params: {
Expand Down

0 comments on commit 6ecd4a9

Please sign in to comment.