From e361c15e27d2a879300a20750ab4fdcad0370fcb Mon Sep 17 00:00:00 2001 From: yuvalgg Date: Tue, 15 Sep 2020 11:53:01 +0300 Subject: [PATCH 1/3] Intent iq id to use plain id string --- modules/intentIqIdSystem.js | 136 +++++++++++++++---------------- test/spec/modules/userId_spec.js | 8 +- 2 files changed, 72 insertions(+), 72 deletions(-) diff --git a/modules/intentIqIdSystem.js b/modules/intentIqIdSystem.js index 7d497ea9b1a..a9f2b01ffde 100644 --- a/modules/intentIqIdSystem.js +++ b/modules/intentIqIdSystem.js @@ -1,68 +1,68 @@ -/** - * This module adds IntentIqId to the User ID module - * The {@link module:modules/userId} module is required - * @module modules/intentIqIdSystem - * @requires module:modules/userId - */ - -import * as utils from '../src/utils.js' -import {ajax} from '../src/ajax.js'; -import {submodule} from '../src/hook.js' - -const MODULE_NAME = 'intentIqId'; - -/** @type {Submodule} */ -export const intentIqIdSubmodule = { - /** - * used to link submodule with config - * @type {string} - */ - name: MODULE_NAME, - /** - * decode the stored id value for passing to bid requests - * @function - * @param {{ctrid:string}} value - * @returns {{intentIqId:string}} - */ - decode(value) { - return (value && typeof value['ctrid'] === 'string') ? { 'intentIqId': value['ctrid'] } : undefined; - }, - /** - * performs action to obtain id and return a value in the callback's response argument - * @function - * @param {SubmoduleParams} [configParams] - * @returns {IdResponse|undefined} - */ - getId(configParams) { - if (!configParams || typeof configParams.partner !== 'number') { - utils.logError('User ID - intentIqId submodule requires a valid partner to be defined'); - return; - } - - // use protocol relative urls for http or https - const url = `https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=${configParams.partner}&pt=17&dpn=1`; - const resp = function (callback) { - const callbacks = { - success: response => { - let responseObj; - if (response) { - try { - responseObj = JSON.parse(response); - } catch (error) { - utils.logError(error); - } - } - callback(responseObj); - }, - error: error => { - utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error); - callback(); - } - }; - ajax(url, callbacks, undefined, {method: 'GET', withCredentials: true}); - }; - return {callback: resp}; - } -}; - -submodule('userId', intentIqIdSubmodule); +/** + * This module adds IntentIqId to the User ID module + * The {@link module:modules/userId} module is required + * @module modules/intentIqIdSystem + * @requires module:modules/userId + */ + +import * as utils from '../src/utils.js' +import {ajax} from '../src/ajax.js'; +import {submodule} from '../src/hook.js' + +const MODULE_NAME = 'intentIqId'; + +/** @type {Submodule} */ +export const intentIqIdSubmodule = { + /** + * used to link submodule with config + * @type {string} + */ + name: MODULE_NAME, + /** + * decode the stored id value for passing to bid requests + * @function + * @param {{string}} value + * @returns {{intentIqId:string}} + */ + decode(value) { + return (value != undefined && value != '') ? { 'intentIqId': value } : undefined; + }, + /** + * performs action to obtain id and return a value in the callback's response argument + * @function + * @param {SubmoduleParams} [configParams] + * @returns {IdResponse|undefined} + */ + getId(configParams) { + if (!configParams || typeof configParams.partner !== 'number') { + utils.logError('User ID - intentIqId submodule requires a valid partner to be defined'); + return; + } + + // use protocol relative urls for http or https + const url = `https://api.intentiq.com/profiles_engine/ProfilesEngineServlet?at=39&mi=10&dpi=${configParams.partner}&pt=17&dpn=1`; + const resp = function (callback) { + const callbacks = { + success: response => { + let responseObj; + if (response) { + try { + responseObj = JSON.parse(response); + } catch (error) { + utils.logError(error); + } + } + callback(responseObj); + }, + error: error => { + utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error); + callback(); + } + }; + ajax(url, callbacks, undefined, {method: 'GET', withCredentials: true}); + }; + return {callback: resp}; + } +}; + +submodule('userId', intentIqIdSubmodule); diff --git a/test/spec/modules/userId_spec.js b/test/spec/modules/userId_spec.js index 167187a281f..ff65c7c47d8 100644 --- a/test/spec/modules/userId_spec.js +++ b/test/spec/modules/userId_spec.js @@ -1099,7 +1099,7 @@ describe('User ID', function() { it('test hook from intentIqId cookies', function(done) { // simulate existing browser local storage values - coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'abcdefghijk'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('intentIqId', 'abcdefghijk', (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([intentIqIdSubmodule]); init(config); @@ -1176,7 +1176,7 @@ describe('User ID', function() { coreStorage.setCookie('idl_env', 'AiGNC8Z5ONyZKSpIPf', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString())); @@ -1248,7 +1248,7 @@ describe('User ID', function() { coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), (new Date(Date.now() + 5000).toUTCString())); - coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); setSubmoduleRegistry([]); @@ -1355,7 +1355,7 @@ describe('User ID', function() { coreStorage.setCookie('britepoolid', JSON.stringify({'primaryBPID': 'testbritepoolid'}), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('netId', JSON.stringify({'netId': 'testnetId'}), new Date(Date.now() + 5000).toUTCString()); coreStorage.setCookie('sharedid', JSON.stringify({'id': 'test_sharedId', 'ts': 1590525289611}), new Date(Date.now() + 5000).toUTCString()); - coreStorage.setCookie('intentIqId', JSON.stringify({'ctrid': 'testintentIqId'}), (new Date(Date.now() + 5000).toUTCString())); + coreStorage.setCookie('intentIqId', 'testintentIqId', (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('IDP', btoa(JSON.stringify('zeotapId')), (new Date(Date.now() + 5000).toUTCString())); coreStorage.setCookie('MOCKID', JSON.stringify({'MOCKID': '123456778'}), new Date(Date.now() + 5000).toUTCString()); From fd44332a24e28ce7efb653e93144c3128470d61d Mon Sep 17 00:00:00 2001 From: yuvalgg Date: Tue, 15 Sep 2020 13:14:11 +0300 Subject: [PATCH 2/3] getId from http resp as a string instead of as a json object --- modules/intentIqIdSystem.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/intentIqIdSystem.js b/modules/intentIqIdSystem.js index a9f2b01ffde..4f954352603 100644 --- a/modules/intentIqIdSystem.js +++ b/modules/intentIqIdSystem.js @@ -25,7 +25,7 @@ export const intentIqIdSubmodule = { * @returns {{intentIqId:string}} */ decode(value) { - return (value != undefined && value != '') ? { 'intentIqId': value } : undefined; + return (value && value != '') ? { 'intentIqId': value } : undefined; }, /** * performs action to obtain id and return a value in the callback's response argument @@ -46,11 +46,7 @@ export const intentIqIdSubmodule = { success: response => { let responseObj; if (response) { - try { - responseObj = JSON.parse(response); - } catch (error) { - utils.logError(error); - } + responseObj = response; } callback(responseObj); }, From 187ddae9bf70da3c47d6f88e9105e0097785edc0 Mon Sep 17 00:00:00 2001 From: yuvalgg Date: Tue, 15 Sep 2020 13:21:11 +0300 Subject: [PATCH 3/3] getId from http resp as a string instead of as a json object --- modules/intentIqIdSystem.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/modules/intentIqIdSystem.js b/modules/intentIqIdSystem.js index 4f954352603..242b227f89f 100644 --- a/modules/intentIqIdSystem.js +++ b/modules/intentIqIdSystem.js @@ -44,11 +44,7 @@ export const intentIqIdSubmodule = { const resp = function (callback) { const callbacks = { success: response => { - let responseObj; - if (response) { - responseObj = response; - } - callback(responseObj); + callback(response); }, error: error => { utils.logError(`${MODULE_NAME}: ID fetch encountered an error`, error);