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

LiveIntent UserId module: Add support for openpath #11119

Merged
merged 3 commits into from
Feb 20, 2024
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
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() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

please write tests to confirm the behavior when the uid1 module is also present

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