From 2e55667eacef4ccf07d9d8ec087ab740b13b1ffc Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Tue, 29 Jun 2021 10:59:47 -0300 Subject: [PATCH 1/8] navegg userid --- modules/.submodules.json | 5 +-- modules/naveggId.js | 83 ++++++++++++++++++++++++++++++++++++++++ modules/naveggId.md | 22 +++++++++++ modules/userId/eids.js | 11 +++--- modules/userId/eids.md | 15 ++++---- 5 files changed, 121 insertions(+), 15 deletions(-) create mode 100644 modules/naveggId.js create mode 100644 modules/naveggId.md diff --git a/modules/.submodules.json b/modules/.submodules.json index 555e8adaefa..b67abed844b 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -28,9 +28,9 @@ "uid2IdSystem", "admixerIdSystem", "dmdIdSystem", - "akamaiDAPId", "flocIdSystem", - "amxIdSystem" + "amxIdSystem", + "naveggId" ], "adpod": [ "freeWheelAdserverVideo", @@ -43,7 +43,6 @@ "haloRtdProvider", "iasRtdProvider", "jwplayerRtdProvider", - "medianetRtdProvider", "optimeraRtdProvider", "permutiveRtdProvider", "reconciliationRtdProvider", diff --git a/modules/naveggId.js b/modules/naveggId.js new file mode 100644 index 00000000000..66ec18dedd8 --- /dev/null +++ b/modules/naveggId.js @@ -0,0 +1,83 @@ +/** + * This module adds naveggId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/naveggId + * @requires module:modules/userId + */ +import * as utils from '../src/utils.js' +import { submodule } from '../src/hook.js'; +import { getStorageManager } from '../src/storageManager.js'; + +const MODULE_NAME = 'naveggId'; +export const storage = getStorageManager(); + +function readnaveggIdFromLocalStorage() { + return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage('nvggid') : null; +} + +function readnaveggIDFromCookie() { + return storage.cookiesAreEnabled ? storage.getCookie('nvggid') : null; +} + +function readoldnaveggIDFromCookie() { + return storage.cookiesAreEnabled ? storage.getCookie('nid') : null; +} + +function readnvgIDFromCookie() { + return storage.cookiesAreEnabled ? storage.findSimilarCookies('nvg')[0] : null; +} + +function readnavIDFromCookie() { + return storage.cookiesAreEnabled ? storage.findSimilarCookies('nav')[0] : null; +} + +function readnvgnavFromLocalStorage() { + var i, results = []; + const query = '^nvg|^nav'; + for (i in window.localStorage) { + if (i.match(query) || (!query && typeof i === 'string')) { + return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(i.match(query).input) : null; + } + } +} + +/** @type {Submodule} */ +export const naveggIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + /** + * decode the stored id value for passing to bid requests + * @function + * @param { Object | string | undefined } value + * @return { Object | string | undefined } + */ + decode(value) { + const naveggIdVal = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined; + return naveggIdVal ? { + 'naveggId': naveggIdVal + } : undefined; + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} config + * @return {{id: string | undefined } | undefined} + */ + getId() { + const naveggIdString = readnaveggIdFromLocalStorage() || readnaveggIDFromCookie() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie() || readnvgnavFromLocalStorage(); + + if (typeof naveggIdString == 'string' && naveggIdString) { + try { + return { id: naveggIdString }; + // return { id: naveggIdString ? { naveggId: naveggIdString } : undefined } + } catch (error) { + utils.logError(error); + } + } + return undefined; + } +}; +submodule('userId', naveggIdSubmodule); diff --git a/modules/naveggId.md b/modules/naveggId.md new file mode 100644 index 00000000000..f758fbc9d5d --- /dev/null +++ b/modules/naveggId.md @@ -0,0 +1,22 @@ +## Navegg User ID Submodule + +For assistance setting up your module please contact us at [prebid@navegg.com](prebid@navegg.com). + +### Prebid Params + +Individual params may be set for the IDx Submodule. +``` +pbjs.setConfig({ + userSync: { + userIds: [{ + name: 'naveggId', + }] + } +}); +``` +## Parameter Descriptions for the `userSync` Configuration Section +The below parameters apply only to the naveggID integration. + +| Param under usersync.userIds[] | Scope | Type | Description | Example | +| --- | --- | --- | --- | --- | +| name | Required | String | ID of the module - `"naveggId"` | `"naveggId"` | diff --git a/modules/userId/eids.js b/modules/userId/eids.js index 32f7c163f3c..ad232b3e17d 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -11,6 +11,12 @@ const USER_IDS_CONFIG = { atype: 1 }, + // naveggId + 'naveggId': { + source: 'navegg.com', + atype: 1 + }, + // pubCommonId 'pubcid': { source: 'pubcid.org', @@ -203,11 +209,6 @@ const USER_IDS_CONFIG = { source: 'deepintent.com', atype: 3 }, - // Akamai Data Activation Platform (DAP) - 'dapId': { - source: 'akamai.com', - atype: 1 - }, // Admixer Id 'admixerId': { source: 'admixer.net', diff --git a/modules/userId/eids.md b/modules/userId/eids.md index 279a5a0cb49..4fe3a6ca453 100644 --- a/modules/userId/eids.md +++ b/modules/userId/eids.md @@ -21,6 +21,14 @@ userIdAsEids = [ }] }, + { + source: 'navegg.com', + uids: [{ + id: 'naveggId', + atype: 1 + }] + }, + { source: 'neustar.biz', uids: [{ @@ -182,13 +190,6 @@ userIdAsEids = [ atype: 3 }] }, - { - source: 'akamai.com', - uids: [{ - id: 'some-random-id-value', - atype: 1 - }] - }, { source: 'deepintent.com', uids: [{ From 2d62bb750b70825f0ba702f3eb018c84806bf38a Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Tue, 29 Jun 2021 15:00:24 -0300 Subject: [PATCH 2/8] remove unused variable results --- modules/naveggId.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/naveggId.js b/modules/naveggId.js index 66ec18dedd8..dade5169279 100644 --- a/modules/naveggId.js +++ b/modules/naveggId.js @@ -32,7 +32,7 @@ function readnavIDFromCookie() { } function readnvgnavFromLocalStorage() { - var i, results = []; + var i; const query = '^nvg|^nav'; for (i in window.localStorage) { if (i.match(query) || (!query && typeof i === 'string')) { From aa6763d16b4b499b39f5840cfa607fcbe20cc482 Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Wed, 11 Aug 2021 17:55:49 -0300 Subject: [PATCH 3/8] fix submodules json --- modules/.submodules.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/.submodules.json b/modules/.submodules.json index 874aaa75eae..9c59cec80ba 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -30,7 +30,7 @@ "dmdIdSystem", "flocIdSystem", "amxIdSystem", - "naveggId" + "naveggId", "imuIdSystem" ], "adpod": [ From f728b092ce508f26ad2441b7d84c4d15cc6105b6 Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Fri, 13 Aug 2021 16:56:19 -0300 Subject: [PATCH 4/8] unit test to find navegg id --- modules/naveggId.js | 30 +++++++++++++++--------------- test/spec/modules/naveggId_spec.js | 9 +++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 test/spec/modules/naveggId_spec.js diff --git a/modules/naveggId.js b/modules/naveggId.js index dade5169279..3044f480db0 100644 --- a/modules/naveggId.js +++ b/modules/naveggId.js @@ -24,11 +24,11 @@ function readoldnaveggIDFromCookie() { } function readnvgIDFromCookie() { - return storage.cookiesAreEnabled ? storage.findSimilarCookies('nvg')[0] : null; + return storage.cookiesAreEnabled ? (storage.findSimilarCookies('nvg') ? storage.findSimilarCookies('nvg')[0] : null) : null; } function readnavIDFromCookie() { - return storage.cookiesAreEnabled ? storage.findSimilarCookies('nav')[0] : null; + return storage.cookiesAreEnabled ? (storage.findSimilarCookies('nav') ? storage.findSimilarCookies('nav')[0] : null) : null; } function readnvgnavFromLocalStorage() { @@ -44,16 +44,16 @@ function readnvgnavFromLocalStorage() { /** @type {Submodule} */ export const naveggIdSubmodule = { /** - * used to link submodule with config - * @type {string} - */ + * used to link submodule with config + * @type {string} + */ name: MODULE_NAME, /** - * decode the stored id value for passing to bid requests - * @function - * @param { Object | string | undefined } value - * @return { Object | string | undefined } - */ + * decode the stored id value for passing to bid requests + * @function + * @param { Object | string | undefined } value + * @return { Object | string | undefined } + */ decode(value) { const naveggIdVal = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined; return naveggIdVal ? { @@ -61,11 +61,11 @@ export const naveggIdSubmodule = { } : undefined; }, /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleConfig} config - * @return {{id: string | undefined } | undefined} - */ + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} config + * @return {{id: string | undefined } | undefined} + */ getId() { const naveggIdString = readnaveggIdFromLocalStorage() || readnaveggIDFromCookie() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie() || readnvgnavFromLocalStorage(); diff --git a/test/spec/modules/naveggId_spec.js b/test/spec/modules/naveggId_spec.js new file mode 100644 index 00000000000..a3416dda190 --- /dev/null +++ b/test/spec/modules/naveggId_spec.js @@ -0,0 +1,9 @@ +import { naveggIdSubmodule } from 'modules/naveggId.js'; + +describe('naveggId', function () { + describe('should NOT find navegg id', function () { + let id = naveggIdSubmodule.getId(); + + expect(id).to.be.undefined; + }); +}); From 86617439d753127d1d8bfd583e1f4e77aa843555 Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Wed, 18 Aug 2021 13:35:10 -0300 Subject: [PATCH 5/8] Adjustments according to revision --- modules/.submodules.json | 2 + modules/{naveggId.js => naveggIdSystem.js} | 45 +++++++++++-------- modules/{naveggId.md => naveggIdSystem.md} | 0 modules/userId/userId.md | 3 ++ ...aveggId_spec.js => naveggIdSystem_spec.js} | 2 +- 5 files changed, 32 insertions(+), 20 deletions(-) rename modules/{naveggId.js => naveggIdSystem.js} (61%) rename modules/{naveggId.md => naveggIdSystem.md} (100%) rename test/spec/modules/{naveggId_spec.js => naveggIdSystem_spec.js} (73%) diff --git a/modules/.submodules.json b/modules/.submodules.json index 9c59cec80ba..f08db109bb6 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -28,6 +28,7 @@ "uid2IdSystem", "admixerIdSystem", "dmdIdSystem", + "akamaiDAPId", "flocIdSystem", "amxIdSystem", "naveggId", @@ -44,6 +45,7 @@ "haloRtdProvider", "iasRtdProvider", "jwplayerRtdProvider", + "medianetRtdProvider", "optimeraRtdProvider", "permutiveRtdProvider", "reconciliationRtdProvider", diff --git a/modules/naveggId.js b/modules/naveggIdSystem.js similarity index 61% rename from modules/naveggId.js rename to modules/naveggIdSystem.js index 3044f480db0..c37530b4151 100644 --- a/modules/naveggId.js +++ b/modules/naveggIdSystem.js @@ -9,18 +9,21 @@ import { submodule } from '../src/hook.js'; import { getStorageManager } from '../src/storageManager.js'; const MODULE_NAME = 'naveggId'; +const OLD_NAVEGG_ID = 'nid'; +const NAVEGG_ID = 'nvggid' + export const storage = getStorageManager(); function readnaveggIdFromLocalStorage() { - return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage('nvggid') : null; + return storage.getDataFromLocalStorage(NAVEGG_ID); } function readnaveggIDFromCookie() { - return storage.cookiesAreEnabled ? storage.getCookie('nvggid') : null; + return storage.cookiesAreEnabled ? storage.getCookie(NAVEGG_ID) : null; } function readoldnaveggIDFromCookie() { - return storage.cookiesAreEnabled ? storage.getCookie('nid') : null; + return storage.cookiesAreEnabled ? storage.getCookie(OLD_NAVEGG_ID) : null; } function readnvgIDFromCookie() { @@ -36,7 +39,7 @@ function readnvgnavFromLocalStorage() { const query = '^nvg|^nav'; for (i in window.localStorage) { if (i.match(query) || (!query && typeof i === 'string')) { - return storage.localStorageIsEnabled ? storage.getDataFromLocalStorage(i.match(query).input) : null; + return storage.getDataFromLocalStorage(i.match(query).input); } } } @@ -44,16 +47,16 @@ function readnvgnavFromLocalStorage() { /** @type {Submodule} */ export const naveggIdSubmodule = { /** - * used to link submodule with config - * @type {string} - */ + * used to link submodule with config + * @type {string} + */ name: MODULE_NAME, /** - * decode the stored id value for passing to bid requests - * @function - * @param { Object | string | undefined } value - * @return { Object | string | undefined } - */ + * decode the stored id value for passing to bid requests + * @function + * @param { Object | string | undefined } value + * @return { Object | string | undefined } + */ decode(value) { const naveggIdVal = value ? utils.isStr(value) ? value : utils.isPlainObject(value) ? value.id : undefined : undefined; return naveggIdVal ? { @@ -61,18 +64,22 @@ export const naveggIdSubmodule = { } : undefined; }, /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleConfig} config - * @return {{id: string | undefined } | undefined} - */ + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleConfig} config + * @return {{id: string | undefined } | undefined} + */ getId() { - const naveggIdString = readnaveggIdFromLocalStorage() || readnaveggIDFromCookie() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie() || readnvgnavFromLocalStorage(); + let naveggIdStringFromLocalStorage = null; + if (storage.localStorageIsEnabled) { + naveggIdStringFromLocalStorage = readnaveggIdFromLocalStorage() || readnvgnavFromLocalStorage(); + } + + const naveggIdString = naveggIdStringFromLocalStorage || readnaveggIDFromCookie() || readoldnaveggIDFromCookie() || readnvgIDFromCookie() || readnavIDFromCookie(); if (typeof naveggIdString == 'string' && naveggIdString) { try { return { id: naveggIdString }; - // return { id: naveggIdString ? { naveggId: naveggIdString } : undefined } } catch (error) { utils.logError(error); } diff --git a/modules/naveggId.md b/modules/naveggIdSystem.md similarity index 100% rename from modules/naveggId.md rename to modules/naveggIdSystem.md diff --git a/modules/userId/userId.md b/modules/userId/userId.md index bbbe995983a..03e8da20a29 100644 --- a/modules/userId/userId.md +++ b/modules/userId/userId.md @@ -301,6 +301,9 @@ pbjs.setConfig({ { name: "novatiq", value: { "snowflake": "81b001ec-8914-488c-a96e-8c220d4ee08895ef" } + }, + { + name: 'naveggId', }], syncDelay: 5000 } diff --git a/test/spec/modules/naveggId_spec.js b/test/spec/modules/naveggIdSystem_spec.js similarity index 73% rename from test/spec/modules/naveggId_spec.js rename to test/spec/modules/naveggIdSystem_spec.js index a3416dda190..cdafe573c62 100644 --- a/test/spec/modules/naveggId_spec.js +++ b/test/spec/modules/naveggIdSystem_spec.js @@ -1,4 +1,4 @@ -import { naveggIdSubmodule } from 'modules/naveggId.js'; +import { naveggIdSubmodule } from 'modules/naveggIdSystem.js'; describe('naveggId', function () { describe('should NOT find navegg id', function () { From 0c9a9ebb59b40bb606b39edc3eb633a14dc6ee50 Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Fri, 20 Aug 2021 18:32:25 -0300 Subject: [PATCH 6/8] new unit tests --- test/spec/modules/naveggIdSystem_spec.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/spec/modules/naveggIdSystem_spec.js b/test/spec/modules/naveggIdSystem_spec.js index cdafe573c62..c0973a05372 100644 --- a/test/spec/modules/naveggIdSystem_spec.js +++ b/test/spec/modules/naveggIdSystem_spec.js @@ -1,9 +1,21 @@ -import { naveggIdSubmodule } from 'modules/naveggIdSystem.js'; +import { naveggIdSubmodule, storage } from 'modules/naveggIdSystem.js'; describe('naveggId', function () { - describe('should NOT find navegg id', function () { + it('should NOT find navegg id', function () { let id = naveggIdSubmodule.getId(); expect(id).to.be.undefined; }); + + it('getId() should return "test-nid" id from cookie OLD_NAVEGG_ID', function() { + sinon.stub(storage, 'getCookie').withArgs('nid').returns('test-nid'); + let id = naveggIdSubmodule.getId(); + expect(id).to.be.deep.equal({id: 'test-nid'}) + }) + + it('getId() should return "test-nvggid" id from local storage NAVEGG_ID', function() { + sinon.stub(storage, 'getDataFromLocalStorage').withArgs('nvggid').returns('test-ninvggidd'); + let id = naveggIdSubmodule.getId(); + expect(id).to.be.deep.equal({id: 'test-ninvggidd'}) + }) }); From 29535b4854a7a24b5fd4e379ecfcac518e6d2a1c Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Tue, 31 Aug 2021 10:29:37 -0300 Subject: [PATCH 7/8] add akamai module --- modules/userId/eids.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/userId/eids.js b/modules/userId/eids.js index eae85fac10d..4fb09cdd3a4 100644 --- a/modules/userId/eids.js +++ b/modules/userId/eids.js @@ -205,6 +205,11 @@ const USER_IDS_CONFIG = { return data.id; } }, + // Akamai Data Activation Platform (DAP) + 'dapId': { + source: 'akamai.com', + atype: 1 + }, 'deepintentId': { source: 'deepintent.com', atype: 3 From bae4e4d862398b0af920550b0b213929bd443ea6 Mon Sep 17 00:00:00 2001 From: Hugo Penha Date: Tue, 31 Aug 2021 10:43:14 -0300 Subject: [PATCH 8/8] add akamai module --- modules/userId/eids.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/userId/eids.md b/modules/userId/eids.md index 4fe3a6ca453..0a819974340 100644 --- a/modules/userId/eids.md +++ b/modules/userId/eids.md @@ -183,6 +183,13 @@ userIdAsEids = [ atype: 3 }] }, + { + source: 'akamai.com', + uids: [{ + id: 'some-random-id-value', + atype: 1 + }] + }, { source: 'admixer.net', uids: [{