From 417f168cacd4d04f742aba1ad3c85014cf5a9a43 Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Thu, 10 Mar 2022 12:01:09 +0530 Subject: [PATCH 1/8] changes to support refreshuserids use case for sso --- src_new/constants.js | 2 +- src_new/util.idhub.js | 96 +++++++++++++------------- test/util.spec.js | 154 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 201 insertions(+), 51 deletions(-) diff --git a/src_new/constants.js b/src_new/constants.js index 2839cd35..7ea962ba 100644 --- a/src_new/constants.js +++ b/src_new/constants.js @@ -103,7 +103,7 @@ exports.CONFIG = { "AB_TEST_ENABLED": "abTestEnabled", "TIMEOUT_ADJUSTMENT": 50, "SSO_ENABLED": "ssoEnabled", - "SSO_INTEGRATION_TIMEOUT": 2500 + "SSO_INTEGRATION_TIMEOUT": 0 }; exports.METADATA_MACROS = { diff --git a/src_new/util.idhub.js b/src_new/util.idhub.js index c7c1a272..98db467d 100644 --- a/src_new/util.idhub.js +++ b/src_new/util.idhub.js @@ -349,47 +349,54 @@ exports.getNestedObjectFromString = function (sourceObject, separator, key, valu return sourceObject; }; +exports.getLiverampParams = function(params) { + if (params.params.cssSelectors && params.params.cssSelectors.length > 0) { + params.params.cssSelectors = params.params.cssSelectors.split(","); + } + var userIdentity = owpbjs.getUserIdentities() || {}; + var enableSSO = CONFIG.isSSOEnabled() || false; + var detectionMechanism = params.params.detectionMechanism; + var enableCustomId = params.params.enableCustomId === "true" ? true : false; + var atsObject = { + "placementID": params.params.pid, + "storageType": params.params.storageType, + "logging": params.params.logging //"error" + }; + if (enableCustomId) { + atsObject.accountID = params.params.accountID; + atsObject.customerIDRegex = params.params.customerIDRegex; + atsObject.detectionSubject = "customerIdentifier"; + } + + switch (detectionMechanism) { + case undefined: + case 'detect': + atsObject.detectionType = params.params.detectionType; + atsObject.urlParameter = params.params.urlParameter; + atsObject.cssSelectors = params.params.cssSelectors; + atsObject.detectDynamicNodes = params.params.detectDynamicNodes; + break; + case 'direct': + var emailHash = enableSSO && userIdentity.emailHash ? userIdentity.emailHash : userIdentity.pubProvidedEmailHash ? userIdentity.pubProvidedEmailHash : undefined; + atsObject.emailHashes = emailHash && [emailHash['MD5'], emailHash['SHA1'], emailHash['SHA256']] || undefined; + /* do we want to keep sso data under direct option? + if yes, if sso is enabled and 'direct' is selected as detection mechanism, sso emails will be sent to ats script. + if sso is disabled, and 'direct' is selected as detection mechanism, we will look for publisher provided email ids, and if available the hashes will be sent to ats script. + */ + if (enableCustomId && refThis.isFunction(owpbjs.getUserIdentities) && owpbjs.getUserIdentities() !== undefined) { + atsObject.customerID = owpbjs.getUserIdentities().customerID || undefined; + } + break; + }; + return atsObject; +}; exports.initLiveRampAts = function (params) { function addATS() { var atsScript = document.createElement("script"); - if (params.params.cssSelectors && params.params.cssSelectors.length > 0) { - params.params.cssSelectors = params.params.cssSelectors.split(","); - } - var userIdentity = owpbjs.getUserIdentities() || {}; - var enableSSO = CONFIG.isSSOEnabled() || false; - var detectionMechanism = params.params.detectionMechanism; - var customIdSupport = params.params.customIdSupport === "1" ? true : false; - var atsObject = { - "placementID": params.params.pid, - "storageType": params.params.storageType, - "logging": params.params.logging //"error" - }; - switch (detectionMechanism) { - case undefined: - case 'detect': - atsObject.detectionType = params.params.detectionType; - atsObject.urlParameter = params.params.urlParameter; - atsObject.cssSelectors = params.params.cssSelectors; - atsObject.detectDynamicNodes = params.params.detectDynamicNodes; - break; - case 'direct': - if (customIdSupport) { - if (parseInt(params.params.accountId) === NaN) { - utils.logWarning("Liveramp ATS.js - customID is enabled, but accountID param missing. Ignoring customId config") - } else { - atsObject.accountID = params.params.accountID; - } - } - break; - }; - + var atsObject = refThis.getLiverampParams(params); atsScript.onload = function () { - userIdentity = owpbjs.getUserIdentities() || {}; - atsObject.emailHashes = enableSSO && userIdentity.emailHash ? [userIdentity.emailHash['MD5'], userIdentity.emailHash['SHA1'], userIdentity.emailHash['SHA256']] : undefined; - /*if (detectionMechanism === "direct" && customIdSupport && !isNaN(parseInt(params.params.accountId))) { - atsObject.customID = userIdentity.emailHash['SHA256']; - }*/ + console.log("object sent to ats script - ", atsObject); window.ats.start(atsObject); }; atsScript.src = "https://ats.rlcdn.com/ats.js"; @@ -409,19 +416,9 @@ exports.initZeoTapJs = function(params) { var n = document, t = window; var userIdentity = owpbjs.getUserIdentities() || {}; var userIdentityObject = { - email: userIdentity.email || "", - cellno: userIdentity.cellNo || "", - loginid: userIdentity.loginId || "", - fpuid: userIdentity.fpuid || "", - cellno_cc: userIdentity.cellNoCC || "" + email: userIdentity.emailHash || "" }; var e=n.createElement("script"); - var initialsationObject = { - partnerId:params.partnerId, - allowIDP: true, - useConsent: (CONFIG.getCCPA() || CONFIG.getGdpr()), - checkForCMP: (CONFIG.getCCPA() || CONFIG.getGdpr()) - }; e.type="text/javascript", e.crossorigin="anonymous" e.async=!0 , @@ -441,8 +438,9 @@ exports.initZeoTapJs = function(params) { }(t[o]) }(n,["callMethod"],"_q"), t.zeotap=n, - t.zeotap.callMethod("init",initialsationObject) - t.zeotap.callMethod("setUserIdentities",userIdentityObject); + t.zeotap.callMethod("init",{partnerId:params.partnerId, allowIDP: true}) + t.zeotap.callMethod("setConsent",CONFIG.getCCPA(), 365) + t.zeotap.callMethod("setUserIdentities",userIdentityObject, true); } if (document.readyState == 'complete') { diff --git a/test/util.spec.js b/test/util.spec.js index 6b84fbad..da330a5b 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -3026,7 +3026,11 @@ describe('UTIL', function() { function onSSOLogin() {}; function getUserIdentities() { return { - email: "zeotaptestrab@gmail.com" + email: "zeotaptestrab@gmail.com", + customerID: "custid_123", + pubProvidedEmailHash: { + MD5: '4e8fb772f3a4034906153f2d4258ee5c', SHA1: 'e770f63ff1d3eb07b589b4ab972009b5ad8d836b', SHA256: 'ee278943de84e5d6243578ee1a1057bcce0e50daad9755f45dfa64b60b13bc5d' + } } } window.owpbjs = { @@ -3099,6 +3103,154 @@ describe('UTIL', function() { done(); }); + it('should pass accountID, customerIDRegex, detectionMechanism and customerID to ats script if custom ID is enabled ', function(done){ + var lrParams = { + name: "identityLink", + params: { + pid: "23", + loadATS: "true", + storageType: "localstorage", + detectionType: "scrapeAndUrl", + urlParameter: "eparam", + cssSelectors: "input[type=text], input[type=email]", + logging: "info", + enableCustomId: "true", + accountID: "123_acc", + customerIDRegex: "[0-9a-zA-Z_]*", + detectionMechanism: "direct" + }, + storage: { + type: "cookie", + name: "somenamevalue", + expires: "60" + } + } + var expectedResult = { + placementID: '23', + storageType: 'localstorage', + logging: 'info', + accountID: '123_acc', + customerIDRegex: '[0-9a-zA-Z_]*', + detectionSubject: 'customerIdentifier', + emailHashes: ['4e8fb772f3a4034906153f2d4258ee5c', 'e770f63ff1d3eb07b589b4ab972009b5ad8d836b', 'ee278943de84e5d6243578ee1a1057bcce0e50daad9755f45dfa64b60b13bc5d'], + customerID: 'custid_123' + }; + var result = UTIL.getLiverampParams(lrParams); + result.should.deep.equal(expectedResult); + done(); + }); + + it('should not pass accountID, customerID, customerIDRegex and customerIdentifier data to ats script if custom ID is disabled ', function(done){ + var lrParams = { + name: "identityLink", + params: { + pid: "23", + loadATS: "true", + storageType: "localstorage", + detectionType: "scrapeAndUrl", + urlParameter: "eparam", + cssSelectors: "input[type=text], input[type=email]", + logging: "info", + enableCustomId: "false", + accountID: "123_acc", + customerIDRegex: "[0-9a-zA-Z_]*", + detectionMechanism: "direct" + }, + storage: { + type: "cookie", + name: "somenamevalue", + expires: "60" + } + }; + + var expectedResult = { + placementID: '23', + storageType: 'localstorage', + logging: 'info', + emailHashes: ['4e8fb772f3a4034906153f2d4258ee5c', 'e770f63ff1d3eb07b589b4ab972009b5ad8d836b', 'ee278943de84e5d6243578ee1a1057bcce0e50daad9755f45dfa64b60b13bc5d'] + }; + + var result = UTIL.getLiverampParams(lrParams); + result.should.deep.equal(expectedResult); + + done(); + }); + + it('should not pass detectionType, urlParameter, cssSelectors data to ats script if detectionMechanism is direct', function(done){ + var lrParams = { + name: "identityLink", + params: { + pid: "23", + loadATS: "true", + storageType: "localstorage", + detectionType: "scrapeAndUrl", + urlParameter: "eparam", + cssSelectors: "input[type=text], input[type=email]", + logging: "info", + enableCustomId: "false", + accountID: "123_acc", + customerIDRegex: "[0-9a-zA-Z_]*", + detectionMechanism: "direct" + }, + storage: { + type: "cookie", + name: "somenamevalue", + expires: "60" + } + }; + + var expectedResult = { + placementID: '23', + storageType: 'localstorage', + logging: 'info', + emailHashes: ['4e8fb772f3a4034906153f2d4258ee5c', 'e770f63ff1d3eb07b589b4ab972009b5ad8d836b', 'ee278943de84e5d6243578ee1a1057bcce0e50daad9755f45dfa64b60b13bc5d'] + }; + + var result = UTIL.getLiverampParams(lrParams); + result.should.deep.equal(expectedResult); + + done(); + }); + + it('should pass detectionType, urlParameter, cssSelectors data to ats script if detectionMechanism is detect', function(done){ + var lrParams = { + name: "identityLink", + params: { + pid: "23", + loadATS: "true", + storageType: "localstorage", + detectionType: "scrapeAndUrl", + urlParameter: "eparam", + cssSelectors: "input[type=text], input[type=email]", + logging: "info", + enableCustomId: "false", + accountID: "123_acc", + customerIDRegex: "[0-9a-zA-Z_]*", + detectionMechanism: "detect", + detectDynamicNodes: "false" + }, + storage: { + type: "cookie", + name: "somenamevalue", + expires: "60" + } + }; + + var expectedResult = { + placementID: '23', + storageType: 'localstorage', + logging: 'info', + detectionType: 'scrapeAndUrl', + urlParameter: 'eparam', + cssSelectors: ['input[type=text]', ' input[type=email]'], + detectDynamicNodes: "false" + }; + var result = UTIL.getLiverampParams(lrParams); + result.should.deep.equal(expectedResult); + + done(); + }); + it('should call initZeoTapJs if zeotap partner is configured and initZeotap is set to true', function(done) { var zeotapParams = { name: "zeotapIdPlus", From 0958e6d8722c9020681a13bc60ba561527009948 Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Mon, 21 Mar 2022 12:02:10 +0530 Subject: [PATCH 2/8] changes for refreshuserid use case for openwrap profiles --- src_new/constants.js | 3 +- src_new/util.idhub.js | 10 +---- src_new/util.js | 89 ++++++++++++++++++++++--------------------- 3 files changed, 48 insertions(+), 54 deletions(-) diff --git a/src_new/constants.js b/src_new/constants.js index 7ea962ba..99320789 100644 --- a/src_new/constants.js +++ b/src_new/constants.js @@ -102,8 +102,7 @@ exports.CONFIG = { "USE_PREBID_KEYS": "usePBJSKeys", "AB_TEST_ENABLED": "abTestEnabled", "TIMEOUT_ADJUSTMENT": 50, - "SSO_ENABLED": "ssoEnabled", - "SSO_INTEGRATION_TIMEOUT": 0 + "SSO_ENABLED": "ssoEnabled" }; exports.METADATA_MACROS = { diff --git a/src_new/util.idhub.js b/src_new/util.idhub.js index 98db467d..5841af4b 100644 --- a/src_new/util.idhub.js +++ b/src_new/util.idhub.js @@ -262,17 +262,11 @@ exports.getUserIdParams = function (params) { refThis.logWarning(CONSTANTS.MESSAGES.IDENTITY.M3, ex); } } - var ssoTimeout = window.PWT && window.PWT.ssoEnabled ? CONSTANTS.CONFIG.SSO_INTEGRATION_TIMEOUT : 0; - ssoTimeout += window.PWT.fbTimeout ? window.PWT.fbTimeout : 0; if (userIdParams && userIdParams.params && userIdParams.params["loadATS"] == "true") { - setTimeout(function() { - refThis.initLiveRampAts(userIdParams); - }, ssoTimeout); + refThis.initLiveRampAts(userIdParams); } if(userIdParams && userIdParams.params && userIdParams.params['loadIDP'] == 'true'){ - setTimeout(function() { - refThis.initZeoTapJs(userIdParams); - }, 0); + refThis.initZeoTapJs(userIdParams); } return userIdParams; }; diff --git a/src_new/util.js b/src_new/util.js index 090efc4c..2d555eb6 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -1643,48 +1643,54 @@ exports.updateUserIds = function(bid){ } }; // endRemoveIf(removeIdHubOnlyRelatedCode) +exports.getLiverampParams = function(params) { + if (params.params.cssSelectors && params.params.cssSelectors.length > 0) { + params.params.cssSelectors = params.params.cssSelectors.split(","); + } + var userIdentity = owpbjs.getUserIdentities() || {}; + var enableSSO = CONFIG.isSSOEnabled() || false; + var detectionMechanism = params.params.detectionMechanism; + var enableCustomId = params.params.enableCustomId === "true" ? true : false; + var atsObject = { + "placementID": params.params.pid, + "storageType": params.params.storageType, + "logging": params.params.logging //"error" + }; + if (enableCustomId) { + atsObject.accountID = params.params.accountID; + atsObject.customerIDRegex = params.params.customerIDRegex; + atsObject.detectionSubject = "customerIdentifier"; + } + + switch (detectionMechanism) { + case undefined: + case 'detect': + atsObject.detectionType = params.params.detectionType; + atsObject.urlParameter = params.params.urlParameter; + atsObject.cssSelectors = params.params.cssSelectors; + atsObject.detectDynamicNodes = params.params.detectDynamicNodes; + break; + case 'direct': + var emailHash = enableSSO && userIdentity.emailHash ? userIdentity.emailHash : userIdentity.pubProvidedEmailHash ? userIdentity.pubProvidedEmailHash : undefined; + atsObject.emailHashes = emailHash && [emailHash['MD5'], emailHash['SHA1'], emailHash['SHA256']] || undefined; + /* do we want to keep sso data under direct option? + if yes, if sso is enabled and 'direct' is selected as detection mechanism, sso emails will be sent to ats script. + if sso is disabled, and 'direct' is selected as detection mechanism, we will look for publisher provided email ids, and if available the hashes will be sent to ats script. + */ + if (enableCustomId && refThis.isFunction(owpbjs.getUserIdentities) && owpbjs.getUserIdentities() !== undefined) { + atsObject.customerID = owpbjs.getUserIdentities().customerID || undefined; + } + break; + }; + return atsObject; +}; exports.initLiveRampAts = function (params) { function addATS() { var atsScript = document.createElement("script"); - if (params.params.cssSelectors && params.params.cssSelectors.length > 0) { - params.params.cssSelectors = params.params.cssSelectors.split(","); - } - var userIdentity = owpbjs.getUserIdentities() || {}; - var enableSSO = CONFIG.isSSOEnabled() || false; - var detectionMechanism = params.params.detectionMechanism; - var customIdSupport = params.params.customIdSupport === "1" ? true : false; - var atsObject = { - "placementID": params.params.pid, - "storageType": params.params.storageType, - "logging": params.params.logging //"error" - }; - switch (detectionMechanism) { - case undefined: - case 'detect': - atsObject.detectionType = params.params.detectionType; - atsObject.urlParameter = params.params.urlParameter; - atsObject.cssSelectors = params.params.cssSelectors; - atsObject.detectDynamicNodes = params.params.detectDynamicNodes; - break; - case 'direct': - if (customIdSupport) { - if (parseInt(params.params.accountId) === NaN) { - utils.logWarning("Liveramp ATS.js - customID is enabled, but accountID param missing. Ignoring customId config") - } else { - atsObject.accountID = params.params.accountID; - } - } - break; - }; - + var atsObject = refThis.getLiverampParams(params); atsScript.onload = function () { - userIdentity = owpbjs.getUserIdentities() || {}; - atsObject.emailHashes = enableSSO && userIdentity.emailHash ? [userIdentity.emailHash['MD5'], userIdentity.emailHash['SHA1'], userIdentity.emailHash['SHA256']] : undefined; - /* -- need this code for customid support - if (detectionMechanism === "direct" && customIdSupport && !isNaN(parseInt(params.params.accountId))) { - atsObject.customID = userIdentity.emailHash['SHA256']; - }*/ + console.log("object sent to ats script - ", atsObject); window.ats.start(atsObject); }; atsScript.src = "https://ats.rlcdn.com/ats.js"; @@ -1711,12 +1717,6 @@ exports.initZeoTapJs = function(params) { cellno_cc: userIdentity.cellNoCC || "" }; var e=n.createElement("script"); - var initialsationObject = { - partnerId:params.partnerId, - allowIDP: true, - useConsent: (CONFIG.getCCPA() || CONFIG.getGdpr()), - checkForCMP: (CONFIG.getCCPA() || CONFIG.getGdpr()) - }; e.type="text/javascript", e.crossorigin="anonymous" e.async=!0 , @@ -1736,7 +1736,8 @@ exports.initZeoTapJs = function(params) { }(t[o]) }(n,["callMethod"],"_q"), t.zeotap=n, - t.zeotap.callMethod("init",initialsationObject) + t.zeotap.callMethod("init",{partnerId:params.partnerId, allowIDP: true}) + t.zeotap.callMethod("setConsent",CONFIG.getCCPA(), 365) t.zeotap.callMethod("setUserIdentities",userIdentityObject); } From 383ba0c8556e4433f10fdcb468d740685e2f8fc5 Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Mon, 21 Mar 2022 12:06:32 +0530 Subject: [PATCH 3/8] changes for refreshuserid use case for openwrap profiles --- src_new/util.idhub.js | 2 +- src_new/util.js | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src_new/util.idhub.js b/src_new/util.idhub.js index 5841af4b..deac7ab2 100644 --- a/src_new/util.idhub.js +++ b/src_new/util.idhub.js @@ -263,7 +263,7 @@ exports.getUserIdParams = function (params) { } } if (userIdParams && userIdParams.params && userIdParams.params["loadATS"] == "true") { - refThis.initLiveRampAts(userIdParams); + refThis.initLiveRampAts(userIdParams); } if(userIdParams && userIdParams.params && userIdParams.params['loadIDP'] == 'true'){ refThis.initZeoTapJs(userIdParams); diff --git a/src_new/util.js b/src_new/util.js index 2d555eb6..d4998312 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -1383,17 +1383,12 @@ exports.getUserIdParams = function(params){ refThis.logWarning(CONSTANTS.MESSAGES.IDENTITY.M3, ex); } } - var ssoTimeout = window.PWT && window.PWT.ssoEnabled ? CONSTANTS.CONFIG.SSO_INTEGRATION_TIMEOUT + 500 : 0; - // additional timeout of 500ms added for OW profiles. should be removed from here once we start supporting pre-pending code snippet for OW profile. + if (userIdParams && userIdParams.params && userIdParams.params["loadATS"] == "true") { - setTimeout(function() { - refThis.initLiveRampAts(userIdParams); - }, ssoTimeout); + refThis.initLiveRampAts(userIdParams); } if(userIdParams && userIdParams.params && userIdParams.params['loadIDP'] == 'true'){ - setTimeout(function() { refThis.initZeoTapJs(userIdParams); - }, 0); } return userIdParams; }; From 75433ce43d5af2bb00079f843b8d3feb9e2430cc Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Mon, 21 Mar 2022 12:11:54 +0530 Subject: [PATCH 4/8] pulled in zeotap changes from nightly5.x --- src_new/util.idhub.js | 9 +++++++-- src_new/util.js | 17 +++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src_new/util.idhub.js b/src_new/util.idhub.js index deac7ab2..488fca90 100644 --- a/src_new/util.idhub.js +++ b/src_new/util.idhub.js @@ -419,6 +419,12 @@ exports.initZeoTapJs = function(params) { e.src="https://content.zeotap.com/sdk/idp.min.js", e.onload=function(){}; n=n.getElementsByTagName("script")[0]; + var initialsationObject = { + partnerId:params.partnerId, + allowIDP: true, + useConsent: (CONFIG.getCCPA() || CONFIG.getGdpr()), + checkForCMP: (CONFIG.getCCPA() || CONFIG.getGdpr()) + }; n.parentNode.insertBefore(e,n); n=t.zeotap||{_q:[],_qcmp:[]}; @@ -432,8 +438,7 @@ exports.initZeoTapJs = function(params) { }(t[o]) }(n,["callMethod"],"_q"), t.zeotap=n, - t.zeotap.callMethod("init",{partnerId:params.partnerId, allowIDP: true}) - t.zeotap.callMethod("setConsent",CONFIG.getCCPA(), 365) + t.zeotap.callMethod("init",initialsationObject), t.zeotap.callMethod("setUserIdentities",userIdentityObject, true); } diff --git a/src_new/util.js b/src_new/util.js index d4998312..21ded5c2 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -1705,11 +1705,7 @@ exports.initZeoTapJs = function(params) { var n = document, t = window; var userIdentity = owpbjs.getUserIdentities() || {}; var userIdentityObject = { - email: userIdentity.email || "", - cellno: userIdentity.cellNo || "", - loginid: userIdentity.loginId || "", - fpuid: userIdentity.fpuid || "", - cellno_cc: userIdentity.cellNoCC || "" + email: userIdentity.emailHash || "" }; var e=n.createElement("script"); e.type="text/javascript", @@ -1718,6 +1714,12 @@ exports.initZeoTapJs = function(params) { e.src="https://content.zeotap.com/sdk/idp.min.js", e.onload=function(){}; n=n.getElementsByTagName("script")[0]; + var initialsationObject = { + partnerId:params.partnerId, + allowIDP: true, + useConsent: (CONFIG.getCCPA() || CONFIG.getGdpr()), + checkForCMP: (CONFIG.getCCPA() || CONFIG.getGdpr()) + }; n.parentNode.insertBefore(e,n); n=t.zeotap||{_q:[],_qcmp:[]}; @@ -1731,9 +1733,8 @@ exports.initZeoTapJs = function(params) { }(t[o]) }(n,["callMethod"],"_q"), t.zeotap=n, - t.zeotap.callMethod("init",{partnerId:params.partnerId, allowIDP: true}) - t.zeotap.callMethod("setConsent",CONFIG.getCCPA(), 365) - t.zeotap.callMethod("setUserIdentities",userIdentityObject); + t.zeotap.callMethod("init",initialsationObject), + t.zeotap.callMethod("setUserIdentities",userIdentityObject, true); } if (document.readyState == 'complete') { From 71c10c7b5832e902cf444374a64d5570d5edf296 Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Mon, 21 Mar 2022 18:02:31 +0530 Subject: [PATCH 5/8] moved onSSOLogin fn call outside the loop --- src_new/util.idhub.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src_new/util.idhub.js b/src_new/util.idhub.js index 488fca90..7c4216dc 100644 --- a/src_new/util.idhub.js +++ b/src_new/util.idhub.js @@ -233,6 +233,7 @@ exports.addHookOnFunction = function (theObject, useProto, functionName, newFunc exports.getUserIdConfiguration = function () { var userIdConfs = []; + owpbjs.onSSOLogin({}); refThis.forEachOnObject(CONFIG.getIdentityPartners(), function (parterId, partnerValues) { if (!CONSTANTS.EXCLUDE_PARTNER_LIST.includes(parterId)) { userIdConfs.push(refThis.getUserIdParams(partnerValues)); @@ -246,7 +247,6 @@ exports.getUserIdParams = function (params) { var userIdParams = {}; refThis.applyDataTypeChangesIfApplicable(params); refThis.applyCustomParamValuesfApplicable(params); - owpbjs.onSSOLogin({}); for (var key in params) { try { if (CONSTANTS.EXCLUDE_IDENTITY_PARAMS.indexOf(key) == -1) { From 8f21d2cb9ffc535321d3dcabed7d24002b2c6371 Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Tue, 22 Mar 2022 18:03:10 +0530 Subject: [PATCH 6/8] move onSSOLogin function call outside the loop --- src_new/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src_new/util.js b/src_new/util.js index 21ded5c2..31fc4197 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -1309,6 +1309,7 @@ exports.getConfigFromRegex = function(klmsForPartner, generatedKey){ // removeIf(removeUserIdRelatedCode) exports.getUserIdConfiguration = function(){ var userIdConfs = []; + owpbjs.onSSOLogin({}); refThis.forEachOnObject(CONFIG.getIdentityPartners(),function(parterId, partnerValues){ if (CONSTANTS.EXCLUDE_PARTNER_LIST.indexOf(parterId) < 0) { userIdConfs.push(refThis.getUserIdParams(partnerValues)); @@ -1366,7 +1367,6 @@ exports.getUserIdParams = function(params){ var userIdParams= {}; refThis.applyDataTypeChangesIfApplicable(params); refThis.applyCustomParamValuesfApplicable(params); - owpbjs.onSSOLogin({}); for(var key in params){ try{ if(CONSTANTS.EXCLUDE_IDENTITY_PARAMS.indexOf(key) == -1) { From a8dc9dc7fd6c3baf0d649842e7587e3928696d6e Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Tue, 22 Mar 2022 19:26:22 +0530 Subject: [PATCH 7/8] changes to test cases according to refresheruserid changes --- test/util.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/util.spec.js b/test/util.spec.js index da330a5b..1bba1ebc 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -3077,7 +3077,7 @@ describe('UTIL', function() { "storage.expires": "60" }; var result = UTIL.getUserIdParams(lrParams); - window.setTimeout.called.should.be.true; + UTIL.initLiveRampAts.should.be.calledOnce; window.owpbjs = undefined; done(); }); @@ -3098,7 +3098,7 @@ describe('UTIL', function() { "storage.expires": "60" }; var result = UTIL.getUserIdParams(lrParams); - window.setTimeout.called.should.be.false; + UTIL.initLiveRampAts.should.not.be.called; window.owpbjs = undefined; done(); }); @@ -3261,7 +3261,7 @@ describe('UTIL', function() { "params.loadIDP": "true" }; var result = UTIL.getUserIdParams(zeotapParams); - window.setTimeout.called.should.be.true; + UTIL.initZeoTapJs.should.be.calledOnce; window.owpbjs = undefined; done(); }); @@ -3276,7 +3276,7 @@ describe('UTIL', function() { "params.loadIDP": "false" }; var result = UTIL.getUserIdParams(zeotapParams); - window.setTimeout.called.should.be.false; + UTIL.initZeoTapJs.should.not.be.called; window.owpbjs = undefined; done(); }); From 2ae1c785f7fb140a559b738f8f950d78fa6e9f32 Mon Sep 17 00:00:00 2001 From: Manasi Moghe Date: Wed, 23 Mar 2022 10:30:06 +0530 Subject: [PATCH 8/8] added additional check for window.ats.start function --- src_new/util.idhub.js | 2 +- src_new/util.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src_new/util.idhub.js b/src_new/util.idhub.js index 7c4216dc..60b61abe 100644 --- a/src_new/util.idhub.js +++ b/src_new/util.idhub.js @@ -391,7 +391,7 @@ exports.initLiveRampAts = function (params) { var atsObject = refThis.getLiverampParams(params); atsScript.onload = function () { console.log("object sent to ats script - ", atsObject); - window.ats.start(atsObject); + window.ats && window.ats.start(atsObject); }; atsScript.src = "https://ats.rlcdn.com/ats.js"; document.body.appendChild(atsScript); diff --git a/src_new/util.js b/src_new/util.js index 31fc4197..761d6830 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -1686,7 +1686,7 @@ exports.initLiveRampAts = function (params) { var atsObject = refThis.getLiverampParams(params); atsScript.onload = function () { console.log("object sent to ats script - ", atsObject); - window.ats.start(atsObject); + window.ats && window.ats.start(atsObject); }; atsScript.src = "https://ats.rlcdn.com/ats.js"; document.body.appendChild(atsScript);