From d3540152b086bc4419924a750fd5e6a7369258e3 Mon Sep 17 00:00:00 2001 From: wiem Date: Thu, 14 Dec 2023 20:23:56 +0100 Subject: [PATCH 1/7] add thetradedesk id --- modules/liveIntentIdSystem.js | 4 +++ modules/userId/eids.js | 14 +++++++++ modules/userId/eids.md | 8 +++++ package-lock.json | 30 +++++++++--------- package.json | 2 +- test/spec/modules/eids_spec.js | 33 ++++++++++++++++++++ test/spec/modules/liveIntentIdSystem_spec.js | 5 +++ 7 files changed, 80 insertions(+), 16 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index a17af227886..7290164eaf4 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -217,6 +217,10 @@ export const liveIntentIdSubmodule = { result.sovrn = { 'id': value.sovrn } } + if (value.thetradedesk) { + result.thetradedesk = { 'id': value.thetradedesk } + } + return result } diff --git a/modules/userId/eids.js b/modules/userId/eids.js index 661f576ca6a..4c15791b149 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -207,6 +207,20 @@ export const USER_IDS_CONFIG = { } }, + // thetradedesk + 'thetradedesk': { + source: 'adserver.org', + atype: 3, + getValue: function(data) { + return data.id; + }, + getUidExt: function(data) { + if (data.ext) { + return data.ext; + } + } + }, + // britepoolId 'britepoolid': { source: 'britepool.com', diff --git a/modules/userId/eids.md b/modules/userId/eids.md index 62f7449c8c5..362a1482b57 100644 --- a/modules/userId/eids.md +++ b/modules/userId/eids.md @@ -146,6 +146,14 @@ userIdAsEids = [ }] }, + { + source: 'adserver.org', + uids: [{ + id: 'some-random-id-value', + atype: 3 + }] + }, + { source: 'merkleinc.com', uids: [{ diff --git a/package-lock.json b/package-lock.json index cdc4ab5ab28..7ed814ffc5b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "express": "^4.15.4", "fun-hooks": "^0.9.9", "just-clone": "^1.0.2", - "live-connect-js": "^6.3.0" + "live-connect-js": "^6.3.1" }, "devDependencies": { "@babel/eslint-parser": "^7.16.5", @@ -16232,19 +16232,19 @@ "dev": true }, "node_modules/live-connect-common": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.2.tgz", - "integrity": "sha512-K3LNKd9CpREDJbXGdwKqPojjQaxd4G6c7OAD6Yzp3wsCWTH2hV8xNAbUksSOpOcVyyOT9ilteEFXIJQJrbODxQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.3.tgz", + "integrity": "sha512-ZPycT04ROBUvPiksnLTunrKC3ROhBSeO99fQ+4qMIkgKwP2CvS44L7fK+0WFV4nAi+65KbzSng7JWcSlckfw8w==", "engines": { "node": ">=18" } }, "node_modules/live-connect-js": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.3.0.tgz", - "integrity": "sha512-1SnXQZq9gxHIb0scXPX1Da1rQ0oY2sloMGgeRreTAwhCtdQEuip/IYwgOh3/ZeZ6yT6iG9FLb7+AjORC4pO46g==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.3.1.tgz", + "integrity": "sha512-VUfPGTVNXweNKhj3zT1vQWggP/i8Vih3EyFPaMgONSzwM1QW4QMSkL2XXx+zCookketQhGQ97KrExU19HR1M+A==", "dependencies": { - "live-connect-common": "^v3.0.2", + "live-connect-common": "^v3.0.3", "tiny-hashes": "1.0.1" }, "engines": { @@ -37883,16 +37883,16 @@ "dev": true }, "live-connect-common": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.2.tgz", - "integrity": "sha512-K3LNKd9CpREDJbXGdwKqPojjQaxd4G6c7OAD6Yzp3wsCWTH2hV8xNAbUksSOpOcVyyOT9ilteEFXIJQJrbODxQ==" + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/live-connect-common/-/live-connect-common-3.0.3.tgz", + "integrity": "sha512-ZPycT04ROBUvPiksnLTunrKC3ROhBSeO99fQ+4qMIkgKwP2CvS44L7fK+0WFV4nAi+65KbzSng7JWcSlckfw8w==" }, "live-connect-js": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.3.0.tgz", - "integrity": "sha512-1SnXQZq9gxHIb0scXPX1Da1rQ0oY2sloMGgeRreTAwhCtdQEuip/IYwgOh3/ZeZ6yT6iG9FLb7+AjORC4pO46g==", + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-6.3.1.tgz", + "integrity": "sha512-VUfPGTVNXweNKhj3zT1vQWggP/i8Vih3EyFPaMgONSzwM1QW4QMSkL2XXx+zCookketQhGQ97KrExU19HR1M+A==", "requires": { - "live-connect-common": "^v3.0.2", + "live-connect-common": "^v3.0.3", "tiny-hashes": "1.0.1" } }, diff --git a/package.json b/package.json index 7d5374960c8..ba701540d69 100644 --- a/package.json +++ b/package.json @@ -132,7 +132,7 @@ "express": "^4.15.4", "fun-hooks": "^0.9.9", "just-clone": "^1.0.2", - "live-connect-js": "^6.3.0" + "live-connect-js": "^6.3.1" }, "optionalDependencies": { "fsevents": "^2.3.2" diff --git a/test/spec/modules/eids_spec.js b/test/spec/modules/eids_spec.js index 00cc8570c92..1b09727cc65 100644 --- a/test/spec/modules/eids_spec.js +++ b/test/spec/modules/eids_spec.js @@ -297,6 +297,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('britepoolId', function() { const userId = { britepoolid: 'some-random-id-value' diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 45b5e5d17f5..b58a5f43b7c 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -388,6 +388,11 @@ describe('LiveIntentId', function() { expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'sovrn': 'bar'}, 'sovrn': {'id': 'bar'}}); }); + it('should decode a thetradedesk id to a seperate object when present', function() { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}}); + }); + it('should decode a magnite id to a seperate 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'}}); From 786bb57a6f3769cb9a908344628724b5c0d592b0 Mon Sep 17 00:00:00 2001 From: wiem Date: Fri, 15 Dec 2023 10:56:14 +0100 Subject: [PATCH 2/7] adjust eid --- modules/liveIntentIdSystem.js | 3 ++- modules/userId/eids.md | 5 ++++- test/spec/modules/liveIntentIdMinimalSystem_spec.js | 5 +++++ test/spec/modules/liveIntentIdSystem_spec.js | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 7290164eaf4..06440d9f982 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -14,6 +14,7 @@ import {MODULE_TYPE_UID} from '../src/activities/modules.js'; const EVENTS_TOPIC = 'pre_lips' const MODULE_NAME = 'liveIntentId'; +const LI_PROVIDER_DOMAIN = 'liveintent.com'; export const storage = getStorageManager({moduleType: MODULE_TYPE_UID, moduleName: MODULE_NAME}); const defaultRequestedAttributes = {'nonId': true} const calls = { @@ -218,7 +219,7 @@ export const liveIntentIdSubmodule = { } if (value.thetradedesk) { - result.thetradedesk = { 'id': value.thetradedesk } + result.thetradedesk = { 'id': value.thetradedesk, ext: { provider: LI_PROVIDER_DOMAIN } } } return result diff --git a/modules/userId/eids.md b/modules/userId/eids.md index 362a1482b57..b7327f889cd 100644 --- a/modules/userId/eids.md +++ b/modules/userId/eids.md @@ -150,7 +150,10 @@ userIdAsEids = [ source: 'adserver.org', uids: [{ id: 'some-random-id-value', - atype: 3 + atype: 3, + ext: { + provider: 'liveintent.com' + } }] }, diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 340489da4d0..b553ca40b77 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -266,6 +266,11 @@ describe('LiveIntentMinimalId', function() { expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'sovrn': 'bar'}, 'sovrn': {'id': 'bar'}}); }); + it('should decode a thetradedesk id to a seperate object when present', function() { + const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}}); + }); + it('should allow disabling nonId resolution', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index b58a5f43b7c..1e973ad20eb 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -390,7 +390,7 @@ describe('LiveIntentId', function() { it('should decode a thetradedesk id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}}); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}, 'ext': {'provider': 'liveintent.com'}}); }); it('should decode a magnite id to a seperate object when present', function() { From 845fbca1710298995405c66a555b105909ba71ab Mon Sep 17 00:00:00 2001 From: wiem Date: Fri, 15 Dec 2023 11:08:02 +0100 Subject: [PATCH 3/7] fix typo --- test/spec/modules/liveIntentIdMinimalSystem_spec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index b553ca40b77..61cc834833e 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -241,7 +241,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'}}); }); @@ -251,22 +251,22 @@ describe('LiveIntentMinimalId', function() { expect(result).to.eql({'uid2': {'id': 'bar'}}); }); - 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'}}); }); - 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'}}); }); - 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'}}); }); - it('should decode a thetradedesk id to a seperate object when present', function() { + it('should decode a thetradedesk id to a separate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}}); }); From be19b2662dffc3549fc18d315496b0910f9a644c Mon Sep 17 00:00:00 2001 From: wiem Date: Fri, 15 Dec 2023 11:09:06 +0100 Subject: [PATCH 4/7] fix test --- test/spec/modules/liveIntentIdMinimalSystem_spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 61cc834833e..8590af4befe 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -268,7 +268,7 @@ describe('LiveIntentMinimalId', function() { it('should decode a thetradedesk id to a separate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}}); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}, 'ext': {'provider': 'liveintent.com'}}); }); it('should allow disabling nonId resolution', function() { From 0f2005e35e54993821c3e0534cd9e139b0ef88cf Mon Sep 17 00:00:00 2001 From: wiem Date: Fri, 15 Dec 2023 11:17:32 +0100 Subject: [PATCH 5/7] fix test --- test/spec/modules/liveIntentIdMinimalSystem_spec.js | 2 +- test/spec/modules/liveIntentIdSystem_spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 8590af4befe..cc89ab9b2d0 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -268,7 +268,7 @@ describe('LiveIntentMinimalId', function() { it('should decode a thetradedesk id to a separate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}, 'ext': {'provider': 'liveintent.com'}}); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); it('should allow disabling nonId resolution', function() { diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 1e973ad20eb..39c916d707e 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -390,7 +390,7 @@ describe('LiveIntentId', function() { it('should decode a thetradedesk id to a seperate object when present', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar'}, 'ext': {'provider': 'liveintent.com'}}); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); it('should decode a magnite id to a seperate object when present', function() { From be67d393a513a9793671535cb0b3387d0f4fe5d9 Mon Sep 17 00:00:00 2001 From: wiem Date: Wed, 20 Dec 2023 16:15:00 +0100 Subject: [PATCH 6/7] use the page domain as an ext provider for tdd --- .../modules/liveIntentIdMinimalSystem_spec.js | 12 +++++-- test/spec/modules/liveIntentIdSystem_spec.js | 33 +++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 81e414b389e..cb7c957a4c5 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -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} }; @@ -14,6 +15,7 @@ describe('LiveIntentMinimalId', function() { let getCookieStub; let getDataFromLocalStorageStub; let imgStub; + let refererInfoStub; beforeEach(function() { liveIntentIdSubmodule.setModuleMode('minimal'); @@ -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() { @@ -32,6 +35,7 @@ describe('LiveIntentMinimalId', function() { logErrorStub.restore(); uspConsentDataStub.restore(); gdprConsentDataStub.restore(); + refererInfoStub.restore(); liveIntentIdSubmodule.setModuleMode('minimal'); resetLiveIntentIdSubmodule(); }); @@ -266,19 +270,21 @@ describe('LiveIntentMinimalId', function() { expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'sovrn': 'bar'}, 'sovrn': {'id': 'bar', 'ext': {'provider': 'liveintent.com'}}}); }); - it('should decode a openx id to a seperate object when present', function() { + it('should decode a 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 a pubmatic id to a seperate object when present', function() { + it('should decode a 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': 'liveintent.com'}}}); + expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'id': 'bar', 'ext': {'provider': provider}}}); }); it('should allow disabling nonId resolution', function() { diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 62592eb2fba..4e5b3eac391 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -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'; @@ -16,6 +18,7 @@ describe('LiveIntentId', function() { let getCookieStub; let getDataFromLocalStorageStub; let imgStub; + let refererInfoStub; beforeEach(function() { liveIntentIdSubmodule.setModuleMode('standard'); @@ -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() { @@ -36,6 +40,7 @@ describe('LiveIntentId', function() { uspConsentDataStub.restore(); gdprConsentDataStub.restore(); gppConsentDataStub.restore(); + refererInfoStub.restore(); resetLiveIntentIdSubmodule(); }); @@ -368,42 +373,37 @@ describe('LiveIntentId', 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'}}}); }); - 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 openx id to a seperate object when present', function() { + it('should decode a 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 a pubmatic id to a seperate object when present', function() { + it('should decode a 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 seperate object when present', function() { - const result = liveIntentIdSubmodule.decode({ nonId: 'foo', thetradedesk: 'bar' }); - expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'thetradedesk': 'bar'}, 'thetradedesk': {'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'}}}); }); @@ -413,11 +413,18 @@ describe('LiveIntentId', function() { expect(result).to.eql({'uid2': {'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 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: { From e26f4befecd235568fa9a60f8d0918046710b0aa Mon Sep 17 00:00:00 2001 From: wiem Date: Wed, 20 Dec 2023 16:35:47 +0100 Subject: [PATCH 7/7] refactoring --- modules/liveIntentIdSystem.js | 3 ++- test/spec/modules/liveIntentIdMinimalSystem_spec.js | 2 +- test/spec/modules/liveIntentIdSystem_spec.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 73acd4e1b0f..62a96a243d4 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -11,6 +11,7 @@ import { LiveConnect } from 'live-connect-js'; // eslint-disable-line prebid/val import { gdprDataHandler, uspDataHandler, gppDataHandler } from '../src/adapterManager.js'; import {getStorageManager} from '../src/storageManager.js'; import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +import { getRefererInfo } from '../src/refererDetection.js'; const EVENTS_TOPIC = 'pre_lips' const MODULE_NAME = 'liveIntentId'; @@ -227,7 +228,7 @@ export const liveIntentIdSubmodule = { } if (value.thetradedesk) { - result.thetradedesk = { 'id': value.thetradedesk, ext: { provider: LI_PROVIDER_DOMAIN } } + result.thetradedesk = { 'id': value.thetradedesk, ext: { provider: getRefererInfo().domain || LI_PROVIDER_DOMAIN } } } return result diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index cb7c957a4c5..8457803ea87 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -281,7 +281,7 @@ describe('LiveIntentMinimalId', function() { }); it('should decode a thetradedesk id to a separate object when present', function() { - const provider = 'liveintent.com' + const provider = 'example.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}}}); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 4e5b3eac391..91f61bdc7bc 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -419,7 +419,7 @@ describe('LiveIntentId', function() { }); it('should decode a thetradedesk id to a separate object when present', function() { - const provider = 'liveintent.com' + const provider = 'example.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}}});