From d670ba43a1209b58b5cec93d3ff5ffdebe98a973 Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Tue, 13 Sep 2022 16:38:24 +0200 Subject: [PATCH 1/5] [CM-587] Allow resolving uid2 and custom attributes --- modules/liveIntentIdSystem.js | 26 +++++++++-- package-lock.json | 16 +++---- package.json | 2 +- .../modules/liveIntentIdMinimalSystem_spec.js | 46 ++++++++++++++++--- test/spec/modules/liveIntentIdSystem_spec.js | 46 ++++++++++++++++--- 5 files changed, 108 insertions(+), 28 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 68cbb3b2412..98d5dc20756 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -66,7 +66,8 @@ function initializeLiveConnect(configParams) { const publisherId = configParams.publisherId || 'any'; const identityResolutionConfig = { source: 'prebid', - publisherId: publisherId + publisherId: publisherId, + requestedAttributes: [ 'nonId' ].concat(configParams.extraRequestedAttributes || [ ]) }; if (configParams.url) { identityResolutionConfig.url = configParams.url @@ -136,9 +137,24 @@ export const liveIntentIdSubmodule = { decode(value, config) { const configParams = (config && config.params) || {}; function composeIdObject(value) { - const base = { 'lipbid': value.unifiedId }; - delete value.unifiedId; - return { 'lipb': { ...base, ...value } }; + // old versions stored lipbid in unifiedId. Ensure that we can still read the data. + value.lipbid = value.nonId || value.unifiedId + delete value.unifiedId + + const result = { 'lipb': value } + + // Lift usage of uid2 by exposing uid2 if we were asked to resolve it. + // As adapters are applied in lexicographical order, we will always + // be overwritten by the 'proper' uid2 module if it is present. + if (value.uid2) { + result.uid2 = { 'id': value.uid2 } + } + + return result + } + + function isValid(value) { + return value && (typeof value['unifiedId'] === 'string' || typeof value['nonId'] === 'string') } if (!liveConnect) { @@ -146,7 +162,7 @@ export const liveIntentIdSubmodule = { } tryFireEvent(); - return (value && typeof value['unifiedId'] === 'string') ? composeIdObject(value) : undefined; + return isValid(value) ? composeIdObject(value) : undefined; }, /** diff --git a/package-lock.json b/package-lock.json index 1665b80db6e..aff080f744f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "prebid.js", - "version": "7.15.0-pre", + "version": "7.16.0-pre", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.16.7", @@ -22,7 +22,7 @@ "express": "^4.15.4", "fun-hooks": "^0.9.9", "just-clone": "^1.0.2", - "live-connect-js": "2.3.3" + "live-connect-js": "2.4.0-alpha.1" }, "devDependencies": { "@babel/eslint-parser": "^7.16.5", @@ -14416,9 +14416,9 @@ "dev": true }, "node_modules/live-connect-js": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.3.3.tgz", - "integrity": "sha512-WfY6v1jVutW/OGPvm0OaWAHc0MvB5MDdSuniZ+n9cpCltArWHTJtAsjWe8T+ACmdLAlZS9z7hzL3ntLnq+J0yQ==", + "version": "2.4.0-alpha.1", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.4.0-alpha.1.tgz", + "integrity": "sha512-5MB+CZE8uL40xk69+GqsVEScXlK3vbhVxDkAY0eV1qbrBmeC7JUd1b9uZA5mx9r6tjR2KEa36eqw31JexJ/aQw==", "dependencies": { "tiny-hashes": "1.0.1" }, @@ -33706,9 +33706,9 @@ "dev": true }, "live-connect-js": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.3.3.tgz", - "integrity": "sha512-WfY6v1jVutW/OGPvm0OaWAHc0MvB5MDdSuniZ+n9cpCltArWHTJtAsjWe8T+ACmdLAlZS9z7hzL3ntLnq+J0yQ==", + "version": "2.4.0-alpha.1", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.4.0-alpha.1.tgz", + "integrity": "sha512-5MB+CZE8uL40xk69+GqsVEScXlK3vbhVxDkAY0eV1qbrBmeC7JUd1b9uZA5mx9r6tjR2KEa36eqw31JexJ/aQw==", "requires": { "tiny-hashes": "1.0.1" } diff --git a/package.json b/package.json index f91ad0bab9e..0a9d972df68 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "express": "^4.15.4", "fun-hooks": "^0.9.9", "just-clone": "^1.0.2", - "live-connect-js": "2.3.3" + "live-connect-js": "2.4.0-alpha.1" }, "optionalDependencies": { "fsevents": "^2.3.2" diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index b0f97ae0300..475fce5f90e 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -64,7 +64,7 @@ describe('LiveIntentMinimalId', function() { let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899'); + expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); request.respond( 200, responseHeader, @@ -85,7 +85,7 @@ describe('LiveIntentMinimalId', function() { } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899'); + expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId'); request.respond( 200, responseHeader, @@ -100,7 +100,7 @@ describe('LiveIntentMinimalId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899'); + expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId'); request.respond( 200, responseHeader, @@ -115,7 +115,7 @@ describe('LiveIntentMinimalId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899'); + expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId'); request.respond( 503, responseHeader, @@ -132,7 +132,7 @@ describe('LiveIntentMinimalId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}`); + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&resolve=nonId`); request.respond( 200, responseHeader, @@ -155,7 +155,7 @@ describe('LiveIntentMinimalId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc`); + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc&resolve=nonId`); request.respond( 200, responseHeader, @@ -177,7 +177,7 @@ describe('LiveIntentMinimalId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; - expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D'); + expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D&resolve=nonId'); request.respond( 200, responseHeader, @@ -185,4 +185,36 @@ describe('LiveIntentMinimalId', function() { ); expect(callBackSpy.calledOnce).to.be.true; }); + + it('should decode a unifiedId to lipbId and remove it', function() { + const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); + expect(result).to.eql({'lipb': {'lipbid': 'data'}}); + }); + + it('should decode a nonId to lipbId', function() { + const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); + expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}}); + }); + + it('should resolve extra attributes', function() { + let callBackSpy = sinon.spy(); + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ extraRequestedAttributes: ['foo'] } + } }).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`); + request.respond( + 200, + responseHeader, + JSON.stringify({}) + ); + expect(callBackSpy.calledOnce).to.be.true; + }); + + it('should decode a uid2 to a seperate 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'}}); + }); }); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 1ea7b5be4ad..b2058a90824 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -133,7 +133,7 @@ describe('LiveIntentId', function() { let submoduleCallback = liveIntentIdSubmodule.getId({ params: {...defaultConfigParams.params, ...{'url': 'https://dummy.liveintent.com/idex'}} }).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; - expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899'); + expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/prebid/89899?resolve=nonId'); request.respond( 204, responseHeader @@ -153,7 +153,7 @@ describe('LiveIntentId', function() { } }).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; - expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899'); + expect(request.url).to.be.eq('https://dummy.liveintent.com/idex/rubicon/89899?resolve=nonId'); request.respond( 200, responseHeader, @@ -168,7 +168,7 @@ describe('LiveIntentId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; - expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899'); + expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId'); request.respond( 200, responseHeader, @@ -183,7 +183,7 @@ describe('LiveIntentId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; - expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899'); + expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?resolve=nonId'); request.respond( 503, responseHeader, @@ -200,7 +200,7 @@ describe('LiveIntentId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(defaultConfigParams).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; - expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}`); + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&resolve=nonId`); request.respond( 200, responseHeader, @@ -223,7 +223,7 @@ describe('LiveIntentId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; - expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc`); + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?duid=${oldCookie}&_thirdPC=third-pc&resolve=nonId`); request.respond( 200, responseHeader, @@ -245,7 +245,7 @@ describe('LiveIntentId', function() { let submoduleCallback = liveIntentIdSubmodule.getId(configParams).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; - expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D'); + expect(request.url).to.be.eq('https://idx.liadm.com/idex/prebid/89899?_thirdPC=%7B%22key%22%3A%22value%22%7D&resolve=nonId'); request.respond( 200, responseHeader, @@ -259,4 +259,36 @@ describe('LiveIntentId', function() { liveIntentIdSubmodule.getId(defaultConfigParams); expect(imgStub.getCall(0).args[0]).to.match(/.*ae=.+/); }); + + it('should decode a unifiedId to lipbId and remove it', function() { + const result = liveIntentIdSubmodule.decode({ unifiedId: 'data' }); + expect(result).to.eql({'lipb': {'lipbid': 'data'}}); + }); + + it('should decode a nonId to lipbId', function() { + const result = liveIntentIdSubmodule.decode({ nonId: 'data' }); + expect(result).to.eql({'lipb': {'lipbid': 'data', 'nonId': 'data'}}); + }); + + it('should resolve extra attributes', function() { + let callBackSpy = sinon.spy(); + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ extraRequestedAttributes: ['foo'] } + } }).callback; + submoduleCallback(callBackSpy); + let request = server.requests[1]; + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=nonId&resolve=foo`); + request.respond( + 200, + responseHeader, + JSON.stringify({}) + ); + expect(callBackSpy.calledOnce).to.be.true; + }); + + it('should decode a uid2 to a seperate 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'}}); + }); }); From 8e840d2c6ee09b9eba31d98d5001f330d7b13b0e Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Wed, 14 Sep 2022 11:06:18 +0200 Subject: [PATCH 2/5] change order of conditions --- modules/liveIntentIdSystem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 98d5dc20756..e2e03212416 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -154,7 +154,7 @@ export const liveIntentIdSubmodule = { } function isValid(value) { - return value && (typeof value['unifiedId'] === 'string' || typeof value['nonId'] === 'string') + return value && (typeof value['nonId'] === 'string' || typeof value['unifiedId'] === 'string') } if (!liveConnect) { From 46e90edf70b80e49432aa0fdca39621fa624283a Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Wed, 14 Sep 2022 14:26:58 +0200 Subject: [PATCH 3/5] update config format --- modules/liveIntentIdSystem.js | 38 ++++++++++++++----- .../modules/liveIntentIdMinimalSystem_spec.js | 26 ++++++++++++- test/spec/modules/liveIntentIdSystem_spec.js | 26 ++++++++++++- 3 files changed, 76 insertions(+), 14 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index e2e03212416..5a41d3501cd 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -14,6 +14,7 @@ import { MinimalLiveConnect } from 'live-connect-js/esm/minimal-live-connect.js' const MODULE_NAME = 'liveIntentId'; export const storage = getStorageManager({gvlid: null, moduleName: MODULE_NAME}); +const defaultRequestedAttributes = {'nonId': true} const calls = { ajaxGet: (url, onSuccess, onError, timeout) => { ajaxBuilder(timeout)( @@ -57,6 +58,23 @@ function parseLiveIntentCollectorConfig(collectConfig) { return config; } +/** + * Create requestedAttributes array to pass to liveconnect + * @function + * @param {Object} overrides - object with boolean values that will override defaults { 'foo': true, 'bar': false } + * @returns {Array} + */ +function parseExtraRequestedAttributes(overrides) { + function createParameterArray(config) { + return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [k] : []); + } + if (typeof overrides === 'object') { + return createParameterArray({...defaultRequestedAttributes, ...overrides}) + } else { + return createParameterArray(defaultRequestedAttributes); + } +} + function initializeLiveConnect(configParams) { configParams = configParams || {}; if (liveConnect) { @@ -67,7 +85,7 @@ function initializeLiveConnect(configParams) { const identityResolutionConfig = { source: 'prebid', publisherId: publisherId, - requestedAttributes: [ 'nonId' ].concat(configParams.extraRequestedAttributes || [ ]) + requestedAttributes: parseExtraRequestedAttributes(configParams.extraRequestedAttributes) }; if (configParams.url) { identityResolutionConfig.url = configParams.url @@ -137,11 +155,15 @@ export const liveIntentIdSubmodule = { decode(value, config) { const configParams = (config && config.params) || {}; function composeIdObject(value) { - // old versions stored lipbid in unifiedId. Ensure that we can still read the data. - value.lipbid = value.nonId || value.unifiedId - delete value.unifiedId + const result = {}; - const result = { 'lipb': value } + // old versions stored lipbid in unifiedId. Ensure that we can still read the data. + const lipbid = value.nonId || value.unifiedId + if (lipbid) { + value.lipbid = lipbid + delete value.unifiedId + result.lipb = value + } // Lift usage of uid2 by exposing uid2 if we were asked to resolve it. // As adapters are applied in lexicographical order, we will always @@ -153,16 +175,12 @@ export const liveIntentIdSubmodule = { return result } - function isValid(value) { - return value && (typeof value['nonId'] === 'string' || typeof value['unifiedId'] === 'string') - } - if (!liveConnect) { initializeLiveConnect(configParams); } tryFireEvent(); - return isValid(value) ? composeIdObject(value) : undefined; + return composeIdObject(value); }, /** diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index 475fce5f90e..d7ce291e7b9 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -47,7 +47,7 @@ describe('LiveIntentMinimalId', function() { it('should not return a decoded identifier when the unifiedId is not present in the value', function() { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); - expect(result).to.be.undefined; + expect(result).to.be.eql({}); }); it('should initialize LiveConnect and send no data', function() { @@ -200,7 +200,7 @@ describe('LiveIntentMinimalId', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ extraRequestedAttributes: ['foo'] } + ...{ extraRequestedAttributes: { 'foo': true, 'bar': false } } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; @@ -217,4 +217,26 @@ describe('LiveIntentMinimalId', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar'}}); }); + + it('should decode values with uid2 but no nonId', function() { + const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); + expect(result).to.eql({'uid2': {'id': 'bar'}}); + }); + + it('should allow disabling nonId resolution', function() { + let callBackSpy = sinon.spy(); + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ extraRequestedAttributes: { 'nonId': false, 'uid2': true } } + } }).callback; + submoduleCallback(callBackSpy); + let request = server.requests[0]; + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=uid2`); + request.respond( + 200, + responseHeader, + JSON.stringify({}) + ); + expect(callBackSpy.calledOnce).to.be.true; + }); }); diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index b2058a90824..3f260adf01d 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -111,7 +111,7 @@ describe('LiveIntentId', function() { it('should not return a decoded identifier when the unifiedId is not present in the value', function() { const result = liveIntentIdSubmodule.decode({ additionalData: 'data' }); - expect(result).to.be.undefined; + expect(result).to.be.eql({}); }); it('should fire an event when decode', function() { @@ -274,7 +274,7 @@ describe('LiveIntentId', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ extraRequestedAttributes: ['foo'] } + ...{ extraRequestedAttributes: { 'foo': true, 'bar': false } } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; @@ -291,4 +291,26 @@ describe('LiveIntentId', function() { const result = liveIntentIdSubmodule.decode({ nonId: 'foo', uid2: 'bar' }); expect(result).to.eql({'lipb': {'lipbid': 'foo', 'nonId': 'foo', 'uid2': 'bar'}, 'uid2': {'id': 'bar'}}); }); + + it('should decode values with uid2 but no nonId', function() { + const result = liveIntentIdSubmodule.decode({ uid2: 'bar' }); + expect(result).to.eql({'uid2': {'id': 'bar'}}); + }); + + it('should allow disabling nonId resolution', function() { + let callBackSpy = sinon.spy(); + let submoduleCallback = liveIntentIdSubmodule.getId({ params: { + ...defaultConfigParams.params, + ...{ extraRequestedAttributes: { 'nonId': false, 'uid2': true } } + } }).callback; + submoduleCallback(callBackSpy); + let request = server.requests[1]; + expect(request.url).to.be.eq(`https://idx.liadm.com/idex/prebid/89899?resolve=uid2`); + request.respond( + 200, + responseHeader, + JSON.stringify({}) + ); + expect(callBackSpy.calledOnce).to.be.true; + }); }); From 0b7794b90eb0df71f1fd5721fa7de8caa905f778 Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Wed, 14 Sep 2022 16:55:23 +0200 Subject: [PATCH 4/5] update parameter name --- modules/liveIntentIdSystem.js | 4 ++-- test/spec/modules/liveIntentIdMinimalSystem_spec.js | 4 ++-- test/spec/modules/liveIntentIdSystem_spec.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/liveIntentIdSystem.js b/modules/liveIntentIdSystem.js index 5a41d3501cd..724bf5ece6a 100644 --- a/modules/liveIntentIdSystem.js +++ b/modules/liveIntentIdSystem.js @@ -64,7 +64,7 @@ function parseLiveIntentCollectorConfig(collectConfig) { * @param {Object} overrides - object with boolean values that will override defaults { 'foo': true, 'bar': false } * @returns {Array} */ -function parseExtraRequestedAttributes(overrides) { +function parseRequestedAttributes(overrides) { function createParameterArray(config) { return Object.entries(config).flatMap(([k, v]) => (typeof v === 'boolean' && v) ? [k] : []); } @@ -85,7 +85,7 @@ function initializeLiveConnect(configParams) { const identityResolutionConfig = { source: 'prebid', publisherId: publisherId, - requestedAttributes: parseExtraRequestedAttributes(configParams.extraRequestedAttributes) + requestedAttributes: parseRequestedAttributes(configParams.requestedAttributesOverrides) }; if (configParams.url) { identityResolutionConfig.url = configParams.url diff --git a/test/spec/modules/liveIntentIdMinimalSystem_spec.js b/test/spec/modules/liveIntentIdMinimalSystem_spec.js index d7ce291e7b9..6a5afa58da2 100644 --- a/test/spec/modules/liveIntentIdMinimalSystem_spec.js +++ b/test/spec/modules/liveIntentIdMinimalSystem_spec.js @@ -200,7 +200,7 @@ describe('LiveIntentMinimalId', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ extraRequestedAttributes: { 'foo': true, 'bar': false } } + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; @@ -227,7 +227,7 @@ describe('LiveIntentMinimalId', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ extraRequestedAttributes: { 'nonId': false, 'uid2': true } } + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[0]; diff --git a/test/spec/modules/liveIntentIdSystem_spec.js b/test/spec/modules/liveIntentIdSystem_spec.js index 3f260adf01d..3c22cda1154 100644 --- a/test/spec/modules/liveIntentIdSystem_spec.js +++ b/test/spec/modules/liveIntentIdSystem_spec.js @@ -274,7 +274,7 @@ describe('LiveIntentId', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ extraRequestedAttributes: { 'foo': true, 'bar': false } } + ...{ requestedAttributesOverrides: { 'foo': true, 'bar': false } } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; @@ -301,7 +301,7 @@ describe('LiveIntentId', function() { let callBackSpy = sinon.spy(); let submoduleCallback = liveIntentIdSubmodule.getId({ params: { ...defaultConfigParams.params, - ...{ extraRequestedAttributes: { 'nonId': false, 'uid2': true } } + ...{ requestedAttributesOverrides: { 'nonId': false, 'uid2': true } } } }).callback; submoduleCallback(callBackSpy); let request = server.requests[1]; From 2fa9850d2664dd494c90a269bea2beb5aaf6f14b Mon Sep 17 00:00:00 2001 From: Maxim Schuwalow Date: Thu, 29 Sep 2022 16:38:21 +0200 Subject: [PATCH 5/5] use release version of live-connect --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index aff080f744f..acdcfafc1cd 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": "2.4.0-alpha.1" + "live-connect-js": "2.4.0" }, "devDependencies": { "@babel/eslint-parser": "^7.16.5", @@ -14416,9 +14416,9 @@ "dev": true }, "node_modules/live-connect-js": { - "version": "2.4.0-alpha.1", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.4.0-alpha.1.tgz", - "integrity": "sha512-5MB+CZE8uL40xk69+GqsVEScXlK3vbhVxDkAY0eV1qbrBmeC7JUd1b9uZA5mx9r6tjR2KEa36eqw31JexJ/aQw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.4.0.tgz", + "integrity": "sha512-MSBLKfnXoxH+pqwji/Mf8yZu3VZMq4tnNfwMw7NTWN5a+TBM6f0RWgwui1YMA3nHmMhX/nzxxsso0SkyKcF0fA==", "dependencies": { "tiny-hashes": "1.0.1" }, @@ -33706,9 +33706,9 @@ "dev": true }, "live-connect-js": { - "version": "2.4.0-alpha.1", - "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.4.0-alpha.1.tgz", - "integrity": "sha512-5MB+CZE8uL40xk69+GqsVEScXlK3vbhVxDkAY0eV1qbrBmeC7JUd1b9uZA5mx9r6tjR2KEa36eqw31JexJ/aQw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/live-connect-js/-/live-connect-js-2.4.0.tgz", + "integrity": "sha512-MSBLKfnXoxH+pqwji/Mf8yZu3VZMq4tnNfwMw7NTWN5a+TBM6f0RWgwui1YMA3nHmMhX/nzxxsso0SkyKcF0fA==", "requires": { "tiny-hashes": "1.0.1" } diff --git a/package.json b/package.json index 0a9d972df68..dd31448fef9 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "express": "^4.15.4", "fun-hooks": "^0.9.9", "just-clone": "^1.0.2", - "live-connect-js": "2.4.0-alpha.1" + "live-connect-js": "2.4.0" }, "optionalDependencies": { "fsevents": "^2.3.2"