From ad55be8d4ce9c7df142e2c1694edf51018f1efbe Mon Sep 17 00:00:00 2001 From: Parth Shah Date: Tue, 23 Apr 2024 18:13:29 +0530 Subject: [PATCH 1/7] fix user ids not being passed on page reload due to extendId func miss --- modules/deepintentDpesIdSystem.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/deepintentDpesIdSystem.js b/modules/deepintentDpesIdSystem.js index 2d3eae980cd..877ceb26db1 100644 --- a/modules/deepintentDpesIdSystem.js +++ b/modules/deepintentDpesIdSystem.js @@ -46,6 +46,9 @@ export const deepintentDpesSubmodule = { getId(config, consentData, cacheIdObj) { return cacheIdObj; }, + extendId(config, consentData, cacheIdObj) { + return cacheIdObj; + }, eids: { 'deepintentId': { source: 'deepintent.com', From ad5f8e4bce63f118f424ea3315f2d7fa3beecaf7 Mon Sep 17 00:00:00 2001 From: Parth Shah Date: Wed, 24 Apr 2024 15:09:46 +0530 Subject: [PATCH 2/7] remove extendId and add function to read value for eids --- modules/deepintentDpesIdSystem.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/deepintentDpesIdSystem.js b/modules/deepintentDpesIdSystem.js index 877ceb26db1..a1f1e29a4ce 100644 --- a/modules/deepintentDpesIdSystem.js +++ b/modules/deepintentDpesIdSystem.js @@ -8,6 +8,7 @@ import { submodule } from '../src/hook.js'; import {getStorageManager} from '../src/storageManager.js'; import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +import {isPlainObject} from '../src/utils.js'; /** * @typedef {import('../modules/userId/index.js').Submodule} Submodule @@ -46,13 +47,16 @@ export const deepintentDpesSubmodule = { getId(config, consentData, cacheIdObj) { return cacheIdObj; }, - extendId(config, consentData, cacheIdObj) { - return cacheIdObj; - }, eids: { 'deepintentId': { source: 'deepintent.com', - atype: 3 + atype: 3, + getValue: (userIdData) => { + if (isPlainObject(userIdData) && userIdData?.id) { + return userIdData.id; + } + return userIdData; + } }, }, }; From e22ae9c524d6dd47fd21f5aa47f6218fc0c5b455 Mon Sep 17 00:00:00 2001 From: Parth Shah Date: Thu, 25 Apr 2024 20:49:50 +0530 Subject: [PATCH 3/7] handle inconsistent localstorage values in deepintent id --- modules/deepintentDpesIdSystem.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/modules/deepintentDpesIdSystem.js b/modules/deepintentDpesIdSystem.js index a1f1e29a4ce..4920ca9c54a 100644 --- a/modules/deepintentDpesIdSystem.js +++ b/modules/deepintentDpesIdSystem.js @@ -45,18 +45,13 @@ export const deepintentDpesSubmodule = { * @return {{id: string | undefined} | undefined} */ getId(config, consentData, cacheIdObj) { - return cacheIdObj; + if (cacheIdObj?.id) return cacheIdObj; + return cacheIdObj ? {id: cacheIdObj} : cacheIdObj; }, eids: { 'deepintentId': { source: 'deepintent.com', atype: 3, - getValue: (userIdData) => { - if (isPlainObject(userIdData) && userIdData?.id) { - return userIdData.id; - } - return userIdData; - } }, }, }; From 0f6f14e425bee01b7a50312356172936e020f441 Mon Sep 17 00:00:00 2001 From: Parth Shah Date: Thu, 25 Apr 2024 20:57:59 +0530 Subject: [PATCH 4/7] remove unused imports --- modules/deepintentDpesIdSystem.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/deepintentDpesIdSystem.js b/modules/deepintentDpesIdSystem.js index 4920ca9c54a..7c95b54e65f 100644 --- a/modules/deepintentDpesIdSystem.js +++ b/modules/deepintentDpesIdSystem.js @@ -8,7 +8,6 @@ import { submodule } from '../src/hook.js'; import {getStorageManager} from '../src/storageManager.js'; import {MODULE_TYPE_UID} from '../src/activities/modules.js'; -import {isPlainObject} from '../src/utils.js'; /** * @typedef {import('../modules/userId/index.js').Submodule} Submodule @@ -51,7 +50,7 @@ export const deepintentDpesSubmodule = { eids: { 'deepintentId': { source: 'deepintent.com', - atype: 3, + atype: 3 }, }, }; From 3e7288ecdef0f45f82206d011bae8f0a5315801a Mon Sep 17 00:00:00 2001 From: Parth Shah Date: Thu, 25 Apr 2024 23:13:36 +0530 Subject: [PATCH 5/7] revert to getValue changes --- modules/deepintentDpesIdSystem.js | 12 +++++++++--- package-lock.json | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/deepintentDpesIdSystem.js b/modules/deepintentDpesIdSystem.js index 7c95b54e65f..a1f1e29a4ce 100644 --- a/modules/deepintentDpesIdSystem.js +++ b/modules/deepintentDpesIdSystem.js @@ -8,6 +8,7 @@ import { submodule } from '../src/hook.js'; import {getStorageManager} from '../src/storageManager.js'; import {MODULE_TYPE_UID} from '../src/activities/modules.js'; +import {isPlainObject} from '../src/utils.js'; /** * @typedef {import('../modules/userId/index.js').Submodule} Submodule @@ -44,13 +45,18 @@ export const deepintentDpesSubmodule = { * @return {{id: string | undefined} | undefined} */ getId(config, consentData, cacheIdObj) { - if (cacheIdObj?.id) return cacheIdObj; - return cacheIdObj ? {id: cacheIdObj} : cacheIdObj; + return cacheIdObj; }, eids: { 'deepintentId': { source: 'deepintent.com', - atype: 3 + atype: 3, + getValue: (userIdData) => { + if (isPlainObject(userIdData) && userIdData?.id) { + return userIdData.id; + } + return userIdData; + } }, }, }; diff --git a/package-lock.json b/package-lock.json index 47383455eaa..2edaabb902b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "prebid.js", - "version": "8.43.0-pre", + "version": "8.46.0-pre", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.16.7", From fae531ca6d2d617186e4c89d1723cb7e973f267d Mon Sep 17 00:00:00 2001 From: Parth Shah Date: Thu, 25 Apr 2024 23:20:38 +0530 Subject: [PATCH 6/7] revert version in package-lock --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 2edaabb902b..47383455eaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "prebid.js", - "version": "8.46.0-pre", + "version": "8.43.0-pre", "license": "Apache-2.0", "dependencies": { "@babel/core": "^7.16.7", From 9a8f93d874e97240c4be6ddaf8b6721b3c5299fc Mon Sep 17 00:00:00 2001 From: Parth Shah Date: Mon, 29 Apr 2024 17:14:38 +0530 Subject: [PATCH 7/7] update test suite for deepintent id system --- .../modules/deepintentDpesIdsystem_spec.js | 60 +++++++------------ 1 file changed, 23 insertions(+), 37 deletions(-) diff --git a/test/spec/modules/deepintentDpesIdsystem_spec.js b/test/spec/modules/deepintentDpesIdsystem_spec.js index 4c26b118a98..3bd1e71d8f6 100644 --- a/test/spec/modules/deepintentDpesIdsystem_spec.js +++ b/test/spec/modules/deepintentDpesIdsystem_spec.js @@ -1,12 +1,8 @@ import { expect } from 'chai'; -import {find} from 'src/polyfill.js'; -import { storage, deepintentDpesSubmodule } from 'modules/deepintentDpesIdSystem.js'; -import { init, requestBidsHook, setSubmoduleRegistry } from 'modules/userId/index.js'; -import { config } from 'src/config.js'; +import { deepintentDpesSubmodule } from 'modules/deepintentDpesIdSystem.js'; -const DI_COOKIE_NAME = '_dpes_id'; -const DI_COOKIE_STORED = '{"id":"2cf40748c4f7f60d343336e08f80dc99"}'; const DI_COOKIE_OBJECT = {id: '2cf40748c4f7f60d343336e08f80dc99'}; +const DI_UPDATED_STORAGE = '2cf40748c4f7f60d343336e08f80dc99'; const cookieConfig = { name: 'deepintentId', @@ -27,50 +23,40 @@ const html5Config = { } describe('Deepintent DPES System', () => { - let getDataFromLocalStorageStub, localStorageIsEnabledStub; - let getCookieStub, cookiesAreEnabledStub; - - beforeEach(() => { - getDataFromLocalStorageStub = sinon.stub(storage, 'getDataFromLocalStorage'); - localStorageIsEnabledStub = sinon.stub(storage, 'localStorageIsEnabled'); - getCookieStub = sinon.stub(storage, 'getCookie'); - cookiesAreEnabledStub = sinon.stub(storage, 'cookiesAreEnabled'); - }); - - afterEach(() => { - getDataFromLocalStorageStub.restore(); - localStorageIsEnabledStub.restore(); - getCookieStub.restore(); - cookiesAreEnabledStub.restore(); - }); - describe('Deepintent Dpes Sytsem: test "getId" method', () => { - it('Wrong config should fail the tests', () => { - // no config - expect(deepintentDpesSubmodule.getId()).to.be.eq(undefined); - expect(deepintentDpesSubmodule.getId({ })).to.be.eq(undefined); - - expect(deepintentDpesSubmodule.getId({params: {}, storage: {}})).to.be.eq(undefined); - expect(deepintentDpesSubmodule.getId({params: {}, storage: {type: 'cookie'}})).to.be.eq(undefined); - expect(deepintentDpesSubmodule.getId({params: {}, storage: {name: '_dpes_id'}})).to.be.eq(undefined); + it('If nothing is found in cache, return undefined', () => { + let diId = deepintentDpesSubmodule.getId({}, undefined, undefined); + expect(diId).to.be.eq(undefined); }); it('Get value stored in cookie for getId', () => { - getCookieStub.withArgs(DI_COOKIE_NAME).returns(DI_COOKIE_STORED); let diId = deepintentDpesSubmodule.getId(cookieConfig, undefined, DI_COOKIE_OBJECT); expect(diId).to.deep.equal(DI_COOKIE_OBJECT); }); it('provides the stored deepintentId if cookie is absent but present in local storage', () => { - getDataFromLocalStorageStub.withArgs(DI_COOKIE_NAME).returns(DI_COOKIE_STORED); - let idx = deepintentDpesSubmodule.getId(html5Config, undefined, DI_COOKIE_OBJECT); - expect(idx).to.deep.equal(DI_COOKIE_OBJECT); + let idx = deepintentDpesSubmodule.getId(html5Config, undefined, DI_UPDATED_STORAGE); + expect(idx).to.be.eq(DI_UPDATED_STORAGE); }); }); describe('Deepintent Dpes System : test "decode" method', () => { - it('Get the correct decoded value for dpes id', () => { - expect(deepintentDpesSubmodule.decode(DI_COOKIE_OBJECT, cookieConfig)).to.deep.equal({'deepintentId': {'id': '2cf40748c4f7f60d343336e08f80dc99'}}); + it('Get the correct decoded value for dpes id, if an object is set return object', () => { + expect(deepintentDpesSubmodule.decode(DI_COOKIE_OBJECT, cookieConfig)).to.deep.equal({'deepintentId': DI_COOKIE_OBJECT}); + }); + + it('Get the correct decoded value for dpes id, if a string is set return string', () => { + expect(deepintentDpesSubmodule.decode(DI_UPDATED_STORAGE, {})).to.deep.equal({'deepintentId': DI_UPDATED_STORAGE}); + }); + }); + + describe('Deepintent Dpes System : test "getValue" method in eids', () => { + it('Get the correct string value for dpes id, if an object is set in local storage', () => { + expect(deepintentDpesSubmodule.eids.deepintentId.getValue(DI_COOKIE_OBJECT)).to.be.equal(DI_UPDATED_STORAGE); + }); + + it('Get the correct string value for dpes id, if a string is set in local storage', () => { + expect(deepintentDpesSubmodule.eids.deepintentId.getValue(DI_UPDATED_STORAGE)).to.be.eq(DI_UPDATED_STORAGE); }); }); });