From 5a2f0eca68057561f5c78621b98133dc45849043 Mon Sep 17 00:00:00 2001 From: Nitin Shirsat Date: Tue, 4 Apr 2023 11:37:26 +0530 Subject: [PATCH 01/17] GPP config set to prebid --- src_new/adapters/prebid.js | 15 +++++++++++++++ src_new/config.js | 16 +++++++++++++++- src_new/constants.js | 8 +++++++- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src_new/adapters/prebid.js b/src_new/adapters/prebid.js index 9e6e2ff3..1bd2d395 100644 --- a/src_new/adapters/prebid.js +++ b/src_new/adapters/prebid.js @@ -840,6 +840,20 @@ function assignCcpaConfigIfRequired(prebidConfig){ exports.assignCcpaConfigIfRequired = assignCcpaConfigIfRequired; +function assignGppConfigIfRequired(prebidConfig) { + if (CONFIG.getGppConsent()) { + if (!prebidConfig["consentManagement"]) { + prebidConfig["consentManagement"] = {}; + } + prebidConfig["consentManagement"]['gpp'] = { + cmpApi: CONFIG.getGppCmpApi(), + timeout: CONFIG.getGppTimeout() + }; + } +} + +exports.assignGppConfigIfRequired = assignGppConfigIfRequired; + function assignCurrencyConfigIfRequired(prebidConfig){ if(CONFIG.getAdServerCurrency()){ // get AdServer currency from Config @@ -1022,6 +1036,7 @@ function setPrebidConfig(){ refThis.assignUserSyncConfig(prebidConfig); refThis.assignGdprConfigIfRequired(prebidConfig); refThis.assignCcpaConfigIfRequired(prebidConfig); + refThis.assignGppConfigIfRequired(prebidConfig); refThis.assignCurrencyConfigIfRequired(prebidConfig); refThis.assignSchainConfigIfRequired(prebidConfig); refThis.assignSingleRequestConfigForBidders(prebidConfig); diff --git a/src_new/config.js b/src_new/config.js index 8127a616..ff5967a4 100644 --- a/src_new/config.js +++ b/src_new/config.js @@ -447,4 +447,18 @@ exports.createMacros = function() { exports.getMarketplaceBidders = function(){ return config.pwt.marketplaceBidders ? config.pwt.marketplaceBidders.split(',') : false; -} \ No newline at end of file +} + +exports.getGppConsent = function () { + var gpp = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] || CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT; + return gpp === "1"; +}; + +exports.getGppCmpApi = function () { + return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] || CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI; +}; + +exports.getGppTimeout = function () { + var gppTimeout = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT]; + return gppTimeout ? window.parseInt(gppTimeout) : CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT; +}; \ No newline at end of file diff --git a/src_new/constants.js b/src_new/constants.js index 0f5e0e78..b5fb34bd 100644 --- a/src_new/constants.js +++ b/src_new/constants.js @@ -109,7 +109,13 @@ exports.CONFIG = { "AB_TEST_ENABLED": "abTestEnabled", "TIMEOUT_ADJUSTMENT": 50, "SSO_ENABLED": "ssoEnabled", - "FLOOR_SOURCE": "floorSource" + "FLOOR_SOURCE": "floorSource", + "GPP_CONSENT": "gpp", + "GPP_CMPAPI": "gppCmpApi", + "GPP_TIMEOUT": "gppTimeout", + "DEFAULT_GPP_CONSENT": "0", + "DEFAULT_GPP_CMPAPI": "iab", + "DEFAULT_GPP_TIMEOUT": 10000, }; exports.METADATA_MACROS = { From af4a99b89cc0640902ac58fb9742301407c78e77 Mon Sep 17 00:00:00 2001 From: Nitin Shirsat Date: Wed, 5 Apr 2023 16:47:44 +0530 Subject: [PATCH 02/17] Set GPP related config to prebid via OW --- src_new/conf.js | 5 ++- test/adapters/prebid.spec.js | 11 ++++++ test/config.spec.js | 66 ++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src_new/conf.js b/src_new/conf.js index a00391f9..8813c337 100644 --- a/src_new/conf.js +++ b/src_new/conf.js @@ -24,7 +24,10 @@ exports.pwt = { owv:"v21.4.0", abTestEnabled:"0", pubAnalyticsAdapter: "0", - reduceCodeSize:1 + reduceCodeSize:1, + gpp: "0", + gppCmpApi: "iab", + gppTimeout: "10000" }; // singleImpression is used to enable feature of sending single impression for multiple size ad slot earlier there were multiple impression for multiple sizes diff --git a/test/adapters/prebid.spec.js b/test/adapters/prebid.spec.js index 2b6a1d6a..ca313845 100644 --- a/test/adapters/prebid.spec.js +++ b/test/adapters/prebid.spec.js @@ -1108,6 +1108,10 @@ describe('ADAPTER: Prebid', function() { sinon.spy(CONFIG, 'getCCPATimeout'); sinon.stub(CONFIG, 'getCCPA').returns(true); + sinon.spy(CONFIG, 'getGppTimeout'); + sinon.spy(CONFIG, 'getGppCmpApi'); + sinon.stub(CONFIG, 'getGppConsent').returns(true); + sinon.stub(BM, 'resetBid', function(){}); sinon.stub(BM, 'setSizes', function(){}); @@ -1178,6 +1182,10 @@ describe('ADAPTER: Prebid', function() { CONFIG.getCCPA.restore(); CONFIG.getCCPATimeout.restore(); + CONFIG.getGppConsent.restore(); + CONFIG.getGppCmpApi.restore(); + CONFIG.getGppTimeout.restore(); + BM.resetBid.restore(); BM.setSizes.restore(); @@ -1249,6 +1257,9 @@ describe('ADAPTER: Prebid', function() { CONFIG.getCCPA().should.be.true; CONFIG.getCCPACmpApi().should.be.called; CONFIG.getCCPATimeout().should.be.called; + CONFIG.getGppConsent().should.be.true; + CONFIG.getGppCmpApi().should.be.called; + CONFIG.getGppTimeout().should.be.called; done(); }); diff --git a/test/config.spec.js b/test/config.spec.js index 753027ba..6dca7650 100644 --- a/test/config.spec.js +++ b/test/config.spec.js @@ -2411,4 +2411,70 @@ describe('Config', function() { done(); }); }); + + describe('#Gpp', function() { + beforeEach(function(done){ + if(!CONF[CONSTANTS.CONFIG.COMMON]) { + CONF[CONSTANTS.CONFIG.COMMON] = {}; + } + done(); + }); + + describe('#getGpp', function() { + it('is a function', function(done) { + CONFIG.getGppConsent.should.be.a('function'); + done(); + }); + + it('should return true, as it is set to "1"', function(done) { + CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] = "1"; + CONFIG.getGppConsent().should.be.true; + done(); + }); + + it('should return default value for gpp which is '+(CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT === "1")+', as it is NOT set', function(done) { + delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT]; + CONFIG.getGppConsent().should.be.equal((CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT === "1")); + done(); + }); + }); + + describe('#getGppCmpApi', function() { + it('is a function', function(done) { + CONFIG.getGppCmpApi.should.be.a('function'); + done(); + }); + + it('should return iab, as it is set to iab', function(done) { + CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] = 'iab'; + CONFIG.getGppCmpApi().should.be.equal('iab'); + done(); + }); + + it('should return default cmp which is '+CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI+', as it is NOT set', function(done) { + delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI]; + CONFIG.getGppCmpApi().should.be.equal(CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI); + done(); + }); + }); + + describe('#getGppTimeout', function() { + it('is a function', function(done) { + CONFIG.getGppTimeout.should.be.a('function'); + done(); + }); + + it('should return 5000, as it is set to 5000', function(done) { + CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT] = 5000; + CONFIG.getGppTimeout().should.be.equal(5000); + done(); + }); + + it('should return default value for gpp timeout which is '+CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT+', as it is NOT set', function(done) { + delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT]; + CONFIG.getGppTimeout().should.be.equal(CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT); + done(); + }); + }); + }); }); From 97438ea436b47276233d2a7a542078ab88842f7f Mon Sep 17 00:00:00 2001 From: Nitin Shirsat Date: Fri, 7 Apr 2023 16:46:27 +0530 Subject: [PATCH 03/17] Add code to set gpp config to IDHUB --- src_new/adapters/prebid.js | 9 ++---- src_new/config.idhub.js | 17 +++++++++++ src_new/controllers/idhub.js | 7 +++++ src_new/owIdhubCommon.js | 15 ++++++++++ test/owIdhubCommon.spec.js | 58 ++++++++++++++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 src_new/owIdhubCommon.js create mode 100644 test/owIdhubCommon.spec.js diff --git a/src_new/adapters/prebid.js b/src_new/adapters/prebid.js index 1bd2d395..85790d7f 100644 --- a/src_new/adapters/prebid.js +++ b/src_new/adapters/prebid.js @@ -10,6 +10,7 @@ var BID = require("../bid.js"); var util = require("../util.js"); var bidManager = require("../bidManager.js"); var CONF = require("../conf.js"); +var owIdhubCommon = require("../owIdhubCommon.js"); var parentAdapterID = CONSTANTS.COMMON.PARENT_ADAPTER_PREBID; @@ -842,13 +843,7 @@ exports.assignCcpaConfigIfRequired = assignCcpaConfigIfRequired; function assignGppConfigIfRequired(prebidConfig) { if (CONFIG.getGppConsent()) { - if (!prebidConfig["consentManagement"]) { - prebidConfig["consentManagement"] = {}; - } - prebidConfig["consentManagement"]['gpp'] = { - cmpApi: CONFIG.getGppCmpApi(), - timeout: CONFIG.getGppTimeout() - }; + prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); } } diff --git a/src_new/config.idhub.js b/src_new/config.idhub.js index c0bfab5a..e2b65753 100644 --- a/src_new/config.idhub.js +++ b/src_new/config.idhub.js @@ -64,6 +64,23 @@ exports.getCCPATimeout = function() { return ccpaTimeout ? window.parseInt(ccpaTimeout) : CONSTANTS.CONFIG.DEFAULT_CCPA_TIMEOUT; }; +// needed +exports.getGppConsent = function () { + var gpp = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] || CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT; + return gpp === "1"; +}; + +// needed +exports.getGppCmpApi = function () { + return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] || CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI; +}; + +// needed +exports.getGppTimeout = function() { + var gppTimeout = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT]; + return gppTimeout ? window.parseInt(gppTimeout) : CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT; +}; + exports.getProfileID = function () { return config.pwt[CONSTANTS.CONFIG.PROFILE_ID] || "0"; }; diff --git a/src_new/controllers/idhub.js b/src_new/controllers/idhub.js index e7fa9c98..ab8a43dd 100644 --- a/src_new/controllers/idhub.js +++ b/src_new/controllers/idhub.js @@ -5,6 +5,7 @@ var CONFIG = require("../config.idhub.js"); var CONSTANTS = require("../constants.js"); var util = require("../util.idhub.js"); +var owIdhubCommon = require("../owIdhubCommon.js"); var refThis = this; var pbNameSpace = CONFIG.isIdentityOnly() ? CONSTANTS.COMMON.IH_NAMESPACE : CONSTANTS.COMMON.PREBID_NAMESPACE; @@ -57,6 +58,12 @@ refThis.setConfig = function(){ timeout: CONFIG.getCCPATimeout(), }; } + + // Set Gpp consent config + if (CONFIG.getGppConsent()) { + prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); + } + window.IHPWT.ssoEnabled = CONFIG.isSSOEnabled() || false; if(CONFIG.isUserIdModuleEnabled()){ prebidConfig["userSync"]["userIds"] = util.getUserIdConfiguration(); diff --git a/src_new/owIdhubCommon.js b/src_new/owIdhubCommon.js new file mode 100644 index 00000000..f25b4f8e --- /dev/null +++ b/src_new/owIdhubCommon.js @@ -0,0 +1,15 @@ +// NOTE: This file will contains only common code/function used in OW and IDHUB. +// Do not import any other file into it. + + +exports.setConsentConfig = function (prebidConfig, key, cmpApi, timeout) { + prebidConfig = prebidConfig || {}; + if (!prebidConfig["consentManagement"]) { + prebidConfig["consentManagement"] = {}; + } + prebidConfig["consentManagement"][key] = { + cmpApi: cmpApi, + timeout: timeout + }; + return prebidConfig; +}; \ No newline at end of file diff --git a/test/owIdhubCommon.spec.js b/test/owIdhubCommon.spec.js new file mode 100644 index 00000000..6bede58a --- /dev/null +++ b/test/owIdhubCommon.spec.js @@ -0,0 +1,58 @@ +/* global describe, it, xit, sinon, expect */ +// var sinon = require("sinon"); +var should = require("chai").should(); +var expect = require("chai").expect; +var OWIDHUBCOMMON = require("../src_new/owIdhubCommon"); + +describe('owIdhubCommon', function() { + describe('setConsentConfig', function() { + var prebidConfig = {}; + var cmpApi = 'iab'; + var timeout = 2000; + + it('setConsentConfig a function', function(done) { + OWIDHUBCOMMON.setConsentConfig.should.be.a('function'); + done(); + }); + + it('should set consent management config when its not present', function(done) { + var expPrebidConfig = { + consentManagement: { + gpp: { + cmpApi, + timeout + } + } + }; + const actPrebifConfig = OWIDHUBCOMMON.setConsentConfig(prebidConfig, 'gpp', cmpApi, timeout); + expect(actPrebifConfig).to.be.deep.equal(expPrebidConfig); + done(); + }); + + it('should set consent management config when its present', function(done) { + var prebidConfig = { + consentManagement: { + gdpr: { + cmpApi, + timeout + } + } + } + var expPrebidConfig = { + consentManagement: { + gdpr: { + cmpApi, + timeout + }, + gpp: { + cmpApi, + timeout + } + } + }; + const actPrebifConfig = OWIDHUBCOMMON.setConsentConfig(prebidConfig, 'gpp', cmpApi, timeout); + expect(actPrebifConfig).to.be.deep.equal(expPrebidConfig); + done(); + }); + }); +}); \ No newline at end of file From 55ebda40fc6be3e9169afb22daf01e4abe1e0709 Mon Sep 17 00:00:00 2001 From: Nitin Shirsat Date: Fri, 7 Apr 2023 17:51:28 +0530 Subject: [PATCH 04/17] Setting this config to PBJS_NAMESPACE as prebid needs to read consent from CMP and set it in a bidderRequest. --- src_new/controllers/idhub.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src_new/controllers/idhub.js b/src_new/controllers/idhub.js index ab8a43dd..d966f50a 100644 --- a/src_new/controllers/idhub.js +++ b/src_new/controllers/idhub.js @@ -61,7 +61,9 @@ refThis.setConfig = function(){ // Set Gpp consent config if (CONFIG.getGppConsent()) { - prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); + consentConfig = owIdhubCommon.setConsentConfig({}, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); + // Setting this config to PBJS_NAMESPACE as prebid needs to read consent from CMP and set it in a bidderRequest. + window[CONFIG.PBJS_NAMESPACE].setConfig(consentConfig); } window.IHPWT.ssoEnabled = CONFIG.isSSOEnabled() || false; From be872ac35191edb6cdeb90356b7944f6f15665ff Mon Sep 17 00:00:00 2001 From: Nitin Shirsat Date: Tue, 11 Apr 2023 17:05:58 +0530 Subject: [PATCH 05/17] Add gpp config to OW namespace in case of IH profiles --- src_new/controllers/idhub.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src_new/controllers/idhub.js b/src_new/controllers/idhub.js index d966f50a..ab8a43dd 100644 --- a/src_new/controllers/idhub.js +++ b/src_new/controllers/idhub.js @@ -61,9 +61,7 @@ refThis.setConfig = function(){ // Set Gpp consent config if (CONFIG.getGppConsent()) { - consentConfig = owIdhubCommon.setConsentConfig({}, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); - // Setting this config to PBJS_NAMESPACE as prebid needs to read consent from CMP and set it in a bidderRequest. - window[CONFIG.PBJS_NAMESPACE].setConfig(consentConfig); + prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); } window.IHPWT.ssoEnabled = CONFIG.isSSOEnabled() || false; From 13039de98722344abaea379e1a83c3b3b26d6c55 Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Thu, 4 May 2023 14:23:17 +0530 Subject: [PATCH 06/17] Call added to geo detection module --- src_new/adapters/prebid.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src_new/adapters/prebid.js b/src_new/adapters/prebid.js index cc4f8ae3..e070148c 100644 --- a/src_new/adapters/prebid.js +++ b/src_new/adapters/prebid.js @@ -10,7 +10,6 @@ var BID = require("../bid.js"); var util = require("../util.js"); var bidManager = require("../bidManager.js"); var CONF = require("../conf.js"); - var parentAdapterID = CONSTANTS.COMMON.PARENT_ADAPTER_PREBID; var pbNameSpace = /*CONFIG.isIdentityOnly() ? CONSTANTS.COMMON.IH_NAMESPACE : */ CONSTANTS.COMMON.PREBID_NAMESPACE; @@ -1350,12 +1349,18 @@ function initPbjsConfig(){ util.logError("PreBid js is not loaded"); return; } - window[pbNameSpace].logging = util.isDebugLogEnabled(); - refThis.realignPubmaticAdapters(); - refThis.setPrebidConfig(); - refThis.configureBidderAliasesIfAvailable(); - refThis.enablePrebidPubMaticAnalyticIfRequired(); - refThis.setPbjsBidderSettingsIfRequired(); + + var geoDetectionURL = CONF.pwt.gdURL; + window[pbNameSpace].detectLocation(geoDetectionURL, CONF.pwt.regionPath, function(loc) { + console.log("REGION : " + (loc.error || loc.region)); + CONF.pwt.gdLoc = loc; // TODO change this location to store data + window[pbNameSpace].logging = util.isDebugLogEnabled(); + refThis.realignPubmaticAdapters(); + refThis.setPrebidConfig(); + refThis.configureBidderAliasesIfAvailable(); + refThis.enablePrebidPubMaticAnalyticIfRequired(); + refThis.setPbjsBidderSettingsIfRequired(); + }); } exports.initPbjsConfig = initPbjsConfig; From ef8782edfa1c068dbcae3dd081a1706df9e8db94 Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Mon, 8 May 2023 16:09:30 +0530 Subject: [PATCH 07/17] UOE-9150 --- src_new/util.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src_new/util.js b/src_new/util.js index 84f2423b..6efe9e56 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -1616,6 +1616,14 @@ exports.generateMonetizationPixel = function(slotID, theBid){ var iiid = window.PWT.bidMap[slotID].getImpressionID(); var isRefreshed = (window.PWT.newAdUnits && window.PWT.newAdUnits[iiid] && window.PWT.newAdUnits[iiid][slotID] && window.PWT.newAdUnits[iiid][slotID]['pubmaticAutoRefresh'] && window.PWT.newAdUnits[iiid][slotID]['pubmaticAutoRefresh']['isRefreshed']) ? 1 : 0; // var impressionID = PWT.bidMap[slotID].impressionID; + const adv = refThis.getAdDomain(theBid.pbbid || theBid) || undefined; + const fskp = window.PWT.floorData ? + (window.PWT.floorData[iiid] ? + (window.PWT.floorData[iiid].floorRequestData ? + (window.PWT.floorData[iiid].floorRequestData.skipped == false ? 0 : 1) : + undefined) + : undefined) + : undefined; pixelURL += "pubid=" + pubId; pixelURL += "&purl=" + window.encodeURIComponent(refThis.metaInfo.pageURL); @@ -1642,13 +1650,12 @@ exports.generateMonetizationPixel = function(slotID, theBid){ ('&psz=' + window.encodeURIComponent(theBid.getSize())) : '&psz=' + window.encodeURIComponent(theBid.width + 'x' + theBid.height)); pixelURL += '&tgid=' + window.encodeURIComponent(refThis.getTgid()); - pixelURL += '&adv=' + window.encodeURIComponent(refThis.getAdDomain(theBid) || undefined); + adv && (pixelURL += '&adv=' + window.encodeURIComponent(adv)); pixelURL += '&orig=' + window.encodeURIComponent((refThis.metaInfo && refThis.metaInfo.pageDomain) || ''); pixelURL += '&ss=' + window.encodeURIComponent(refThis.isFunction(theBid.getServerSideStatus) ? (theBid.getServerSideStatus() ? 1 : 0) : (CONFIG.isServerSideAdapter(adapterId) ? 1 : 0)); - pixelURL += '&fskp=' + window.encodeURIComponent(window.PWT.floorData ? (window.PWT.floorData[iiid] ? - (window.PWT.floorData[iiid].floorRequestData ? (window.PWT.floorData[iiid].floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined) : undefined); + fskp && (pixelURL += '&fskp=' + window.encodeURIComponent(fskp)); pixelURL += '&af=' + window.encodeURIComponent(refThis.isFunction(theBid.getAdFormat) ? theBid.getAdFormat() : (theBid.mediaType || undefined)); From 3cd6c81ecf2589432094c77c72485955abd0229a Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Mon, 8 May 2023 19:31:00 +0530 Subject: [PATCH 08/17] Fixed test case --- test/bidManager.spec.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/test/bidManager.spec.js b/test/bidManager.spec.js index 8a84f077..01b31d00 100644 --- a/test/bidManager.spec.js +++ b/test/bidManager.spec.js @@ -1367,7 +1367,7 @@ describe('bidManager BIDMgr', function() { window.Image.called.should.be.true; UTIL.getCurrentTimestamp.called.should.be.true; - window.encodeURIComponent.callCount.should.be.equal(23); + window.encodeURIComponent.callCount.should.be.equal(21); done(); }); @@ -1376,6 +1376,15 @@ describe('bidManager BIDMgr', function() { it('should generate proper pixelURL ', function(done) { var pixelURL = CONSTANTS.COMMON.PROTOCOL + CONFIG.getMonetizationPixelURL(); + var adv = UTIL.getAdDomain(theBid) || undefined; + var fskp = window.PWT.floorData ? + (window.PWT.floorData[impressionID] ? + (window.PWT.floorData[impressionID].floorRequestData ? + (window.PWT.floorData[impressionID].floorRequestData.skipped == false ? 0 : 1) : + undefined) : + undefined) : + undefined; + pixelURL += "pubid=" + CONFIG.getPublisherId(); pixelURL += "&purl=" + window.encodeURIComponent(UTIL.metaInfo.pageURL); pixelURL += "&tst=" + UTIL.getCurrentTimestamp(); @@ -1401,13 +1410,12 @@ describe('bidManager BIDMgr', function() { ('&psz=' + window.encodeURIComponent(theBid.getSize())) : '&psz=' + window.encodeURIComponent(theBid.width + 'x' + theBid.height)); pixelURL += '&tgid=' + window.encodeURIComponent(UTIL.getTgid()); - pixelURL += '&adv=' + window.encodeURIComponent(UTIL.getAdDomain(theBid) || undefined); + adv && (pixelURL += '&adv=' + window.encodeURIComponent(adv)); pixelURL += '&orig=' + window.encodeURIComponent((UTIL.metaInfo && UTIL.metaInfo.pageDomain) || ''); pixelURL += '&ss=' + window.encodeURIComponent(UTIL.isFunction(theBid.getServerSideStatus) ? (theBid.getServerSideStatus() ? 1 : 0) : (CONFIG.isServerSideAdapter(adapterId) ? 1 : 0)); - pixelURL += '&fskp=' + window.encodeURIComponent(window.PWT.floorData ? (window.PWT.floorData[impressionID] ? - (window.PWT.floorData[impressionID].floorRequestData ? (window.PWT.floorData[impressionID].floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined) : undefined); + fskp && (pixelURL += '&fskp=' + window.encodeURIComponent(fskp)); pixelURL += '&af=' + window.encodeURIComponent(UTIL.isFunction(theBid.getAdFormat) ? theBid.getAdFormat() : (theBid.mediaType || undefined)); @@ -1422,6 +1430,15 @@ describe('bidManager BIDMgr', function() { theBid.adapterID = "pubmatic21"; CONFIG.getAdapterNameForAlias.returns('pubmatic'); var pixelURL = CONSTANTS.COMMON.PROTOCOL + CONFIG.getMonetizationPixelURL(); + var adv = UTIL.getAdDomain(theBid) || undefined; + var fskp = window.PWT.floorData ? + (window.PWT.floorData[impressionID] ? + (window.PWT.floorData[impressionID].floorRequestData ? + (window.PWT.floorData[impressionID].floorRequestData.skipped == false ? 0 : 1) : + undefined) : + undefined) : + undefined; + pixelURL += "pubid=" + CONFIG.getPublisherId(); pixelURL += "&purl=" + window.encodeURIComponent(UTIL.metaInfo.pageURL); pixelURL += "&tst=" + UTIL.getCurrentTimestamp(); @@ -1447,13 +1464,12 @@ describe('bidManager BIDMgr', function() { ('&psz=' + window.encodeURIComponent(theBid.getSize())) : '&psz=' + window.encodeURIComponent(theBid.width + 'x' + theBid.height)); pixelURL += '&tgid=' + window.encodeURIComponent(UTIL.getTgid()); - pixelURL += '&adv=' + window.encodeURIComponent(UTIL.getAdDomain(theBid) || undefined); + adv && (pixelURL += '&adv=' + window.encodeURIComponent(adv)); pixelURL += '&orig=' + window.encodeURIComponent((UTIL.metaInfo && UTIL.metaInfo.pageDomain) || ''); pixelURL += '&ss=' + window.encodeURIComponent(UTIL.isFunction(theBid.getServerSideStatus) ? (theBid.getServerSideStatus() ? 1 : 0) : (CONFIG.isServerSideAdapter(adapterId) ? 1 : 0)); - pixelURL += '&fskp=' + window.encodeURIComponent(window.PWT.floorData ? (window.PWT.floorData[impressionID] ? - (window.PWT.floorData[impressionID].floorRequestData ? (window.PWT.floorData[impressionID].floorRequestData.skipped == false ? 0 : 1) : undefined) : undefined) : undefined); + fskp && (pixelURL += '&fskp=' + window.encodeURIComponent(fskp)); pixelURL += '&af=' + window.encodeURIComponent(UTIL.isFunction(theBid.getAdFormat) ? theBid.getAdFormat() : (theBid.mediaType || undefined)); From da89e6f11e50c10f70bc0f3ef0dfce57dc026136 Mon Sep 17 00:00:00 2001 From: kapil-tuptewar Date: Wed, 10 May 2023 15:56:30 +0530 Subject: [PATCH 09/17] Reading & writing to local storage --- src_new/bidManager.js | 2 +- src_new/util.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src_new/bidManager.js b/src_new/bidManager.js index c4f71447..e80de061 100644 --- a/src_new/bidManager.js +++ b/src_new/bidManager.js @@ -389,8 +389,8 @@ exports.displayCreative = function(theDocument, bidID){ // TDD, i/o : done if (frequencyDepth !== null && frequencyDepth.slotLevelFrquencyDepth) { frequencyDepth.slotLevelFrquencyDepth[frequencyDepth.codeAdUnitMap[divID]].impressionServed = frequencyDepth.slotLevelFrquencyDepth[frequencyDepth.codeAdUnitMap[divID]].impressionServed + 1; frequencyDepth.impressionServed = frequencyDepth.impressionServed + 1; + localStorage.setItem(PREFIX + window.location.hostname, JSON.stringify(frequencyDepth)); } - localStorage.setItem(PREFIX + window.location.hostname, JSON.stringify(frequencyDepth)); } }; // endRemoveIf(removeLegacyAnalyticsRelatedCode) diff --git a/src_new/util.js b/src_new/util.js index 6efe9e56..b1d34311 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -899,8 +899,8 @@ exports.safeFrameCommunicationProtocol = function(msg){ if (frequencyDepth !== null && frequencyDepth.slotLevelFrquencyDepth) { frequencyDepth.slotLevelFrquencyDepth[frequencyDepth.codeAdUnitMap[bidSlotId && bidSlotId.slotid]].impressionServed = frequencyDepth.slotLevelFrquencyDepth[frequencyDepth.codeAdUnitMap[bidSlotId && bidSlotId.slotid]].impressionServed + 1; frequencyDepth.impressionServed = frequencyDepth.impressionServed + 1; + localStorage.setItem('PROFILE_AUCTION_INFO_' + window.location.hostname, JSON.stringify(frequencyDepth)); } - localStorage.setItem('PROFILE_AUCTION_INFO_' + window.location.hostname, JSON.stringify(frequencyDepth)); }catch(e){} }; // endRemoveIf(removeLegacyAnalyticsRelatedCode) From 5d16aa8f5904568d72adf407370891c3066a88b1 Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Thu, 11 May 2023 11:53:41 +0530 Subject: [PATCH 10/17] UOE-9161 --- 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 6efe9e56..3741b607 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -1655,7 +1655,7 @@ exports.generateMonetizationPixel = function(slotID, theBid){ pixelURL += '&ss=' + window.encodeURIComponent(refThis.isFunction(theBid.getServerSideStatus) ? (theBid.getServerSideStatus() ? 1 : 0) : (CONFIG.isServerSideAdapter(adapterId) ? 1 : 0)); - fskp && (pixelURL += '&fskp=' + window.encodeURIComponent(fskp)); + (fskp != undefined) && (pixelURL += '&fskp=' + window.encodeURIComponent(fskp)); pixelURL += '&af=' + window.encodeURIComponent(refThis.isFunction(theBid.getAdFormat) ? theBid.getAdFormat() : (theBid.mediaType || undefined)); From 812cf4ab80d009f97bec0e293b4b5773e293fe08 Mon Sep 17 00:00:00 2001 From: kapil-tuptewar Date: Wed, 24 May 2023 12:11:52 +0530 Subject: [PATCH 11/17] Commented gdpr.js as it is not in use --- src_new/gdpr.js | 350 ++++++++++++++++++++++++------------------------ 1 file changed, 175 insertions(+), 175 deletions(-) diff --git a/src_new/gdpr.js b/src_new/gdpr.js index 1de414ac..d44ae9b0 100644 --- a/src_new/gdpr.js +++ b/src_new/gdpr.js @@ -1,175 +1,175 @@ -var localStorageKey = "OpenWrap"; -var DUMMY_PUB_ID = 909090; - -// Adding util here creating cyclic dependecies between the modules so avoided it & added two util function manually -function isA(object, testForType) { - return toString.call(object) === "[object " + testForType + "]"; -} - -var isFunction = function (object) { - return isA(object, "Function"); -}; - -var isLocalStoreEnabled = (function () { - try { - return window.localStorage && isFunction(window.localStorage.getItem) && isFunction(window.localStorage.setItem); - } catch (e) { - return false; - } -})(); - -/* - localStorage = { - localStorageKey : { - pubID: { - c: "encoded user consent" - } - } - } -*/ - -var setConsentDataInLS = function (pubId, dataType, data, gdprApplies) { - var pm; - - if (!isLocalStoreEnabled) { - return; - } - try { - pm = window.localStorage.getItem(localStorageKey); - } catch (e) {} - if (pm && typeof pm === "string") { - try { - pm = JSON.parse(pm); - } catch (e) { - pm = {}; - } - } else { - pm = {}; - } - if (pm) { - if (!pm.hasOwnProperty(pubId)) { - pm[pubId] = {}; - } - pm[pubId].t = (new Date()).getTime(); - pm[pubId][dataType] = data; - if (dataType == "c") { - pm[pubId]["g"] = gdprApplies ? 1 : 0; - } - } - try { - window.localStorage.setItem(localStorageKey, JSON.stringify(pm)); - } catch (e) {} -}; - -/* start-test-block */ -exports.setConsentDataInLS = setConsentDataInLS; -/* end-test-block */ - -exports.isCmpFound = function () { - return !!window.__cmp; -}; - -/** - * getUserConsentDataFromCMP() method return nothing - * Here, We try to call get the ConsentData for vendorConsents from CMP using getConsentData() method - * Once, We get that we will this data in Local Storage againg a dummy ID - * If CMP is not detected in current document we try to look into upper iframe & fetch the infoa - */ -exports.getUserConsentDataFromCMP = function () { - // Adding dummy pubId to store data against - var pubId = DUMMY_PUB_ID; //CONFIG.getPublisherId(); - var callId = 0; - var getConsentDataReq = { - __cmp: { - callId: "iframe:" + (++callId), - command: "getConsentData" - } - }; - - function receiveMessage(event) { - if (event && event.data && event.data.__cmp && event.data.__cmp.result) { - var result = event.data.__cmp.result; - - if (result && result.consentData) { - /** - * CMP API 1.1 - result is object which includes - * { - * consentData: base64 string, - * gdprApplies: boolean - * } - */ - setConsentDataInLS(pubId, "c", result.consentData, result.gdprApplies); - } else if (typeof result === "string") { - // CMP API 1.0 - result is base64 consent string - setConsentDataInLS(pubId, "c", result); - } - } - } - - function callCMP() { - window.__cmp("getConsentData", "vendorConsents", function (result) { - if (result && result.consentData) { - setConsentDataInLS(pubId, "c", result.consentData, result.gdprApplies); - } else if (typeof result === "string") { - setConsentDataInLS(pubId, "c", result); - } - }); - } - - if (window.__cmp) { - if (typeof window.__cmp === "function") { - callCMP(); - } else { - setTimeout(function () { - if (typeof window.__cmp === "function") { - callCMP(); - } - }, 500); - } - } else { - // we may be inside an iframe and CMP may exist outside, so we"ll use postMessage to interact with CMP - window.top.postMessage(getConsentDataReq, "*"); - window.addEventListener("message", receiveMessage); - } -}; - -/** - * getUserConsentDataFromLS() method return the object { c: "XXX", g: 0/1 } - * Here c is Consent String We got from CMP APIs - * & g is gdpr flag i.e. gdprApplies in terms of CMP 1.1 API - * @return {object} { c: String, g: Number 0/1 } - */ - -exports.getUserConsentDataFromLS = function () { - // Adding dummy pubId to store data against - var pubId = DUMMY_PUB_ID; - var data = {c: "", g: 0}; - - if (!isLocalStoreEnabled) { - return data; - } - var pm; - - try { - pm = window.localStorage.getItem(localStorageKey); - } catch (e) {} - if (pm && typeof pm === "string") { - try { - pm = JSON.parse(pm); - } catch (e) { - pm = {}; - } - if (pm.hasOwnProperty(pubId)) { - var pmRecord = pm[pubId]; - - if (pmRecord && pmRecord.c && pmRecord.t) { - // check timestamp of data and current; if older than a day do not use it - if (pmRecord.t && parseInt(pmRecord.t, 10) > ((new Date()).getTime() - (24 * 60 * 60 * 1000))) { - data.c = pmRecord.c; - data.g = pmRecord.g; - } - } - } - } - return data; -}; +// var localStorageKey = "OpenWrap"; +// var DUMMY_PUB_ID = 909090; + +// // Adding util here creating cyclic dependecies between the modules so avoided it & added two util function manually +// function isA(object, testForType) { +// return toString.call(object) === "[object " + testForType + "]"; +// } + +// var isFunction = function (object) { +// return isA(object, "Function"); +// }; + +// var isLocalStoreEnabled = (function () { +// try { +// return window.localStorage && isFunction(window.localStorage.getItem) && isFunction(window.localStorage.setItem); +// } catch (e) { +// return false; +// } +// })(); + +// /* +// localStorage = { +// localStorageKey : { +// pubID: { +// c: "encoded user consent" +// } +// } +// } +// */ + +// var setConsentDataInLS = function (pubId, dataType, data, gdprApplies) { +// var pm; + +// if (!isLocalStoreEnabled) { +// return; +// } +// try { +// pm = window.localStorage.getItem(localStorageKey); +// } catch (e) {} +// if (pm && typeof pm === "string") { +// try { +// pm = JSON.parse(pm); +// } catch (e) { +// pm = {}; +// } +// } else { +// pm = {}; +// } +// if (pm) { +// if (!pm.hasOwnProperty(pubId)) { +// pm[pubId] = {}; +// } +// pm[pubId].t = (new Date()).getTime(); +// pm[pubId][dataType] = data; +// if (dataType == "c") { +// pm[pubId]["g"] = gdprApplies ? 1 : 0; +// } +// } +// try { +// window.localStorage.setItem(localStorageKey, JSON.stringify(pm)); +// } catch (e) {} +// }; + +// /* start-test-block */ +// exports.setConsentDataInLS = setConsentDataInLS; +// /* end-test-block */ + +// exports.isCmpFound = function () { +// return !!window.__cmp; +// }; + +// /** +// * getUserConsentDataFromCMP() method return nothing +// * Here, We try to call get the ConsentData for vendorConsents from CMP using getConsentData() method +// * Once, We get that we will this data in Local Storage againg a dummy ID +// * If CMP is not detected in current document we try to look into upper iframe & fetch the infoa +// */ +// exports.getUserConsentDataFromCMP = function () { +// // Adding dummy pubId to store data against +// var pubId = DUMMY_PUB_ID; //CONFIG.getPublisherId(); +// var callId = 0; +// var getConsentDataReq = { +// __cmp: { +// callId: "iframe:" + (++callId), +// command: "getConsentData" +// } +// }; + +// function receiveMessage(event) { +// if (event && event.data && event.data.__cmp && event.data.__cmp.result) { +// var result = event.data.__cmp.result; + +// if (result && result.consentData) { +// /** +// * CMP API 1.1 - result is object which includes +// * { +// * consentData: base64 string, +// * gdprApplies: boolean +// * } +// */ +// setConsentDataInLS(pubId, "c", result.consentData, result.gdprApplies); +// } else if (typeof result === "string") { +// // CMP API 1.0 - result is base64 consent string +// setConsentDataInLS(pubId, "c", result); +// } +// } +// } + +// function callCMP() { +// window.__cmp("getConsentData", "vendorConsents", function (result) { +// if (result && result.consentData) { +// setConsentDataInLS(pubId, "c", result.consentData, result.gdprApplies); +// } else if (typeof result === "string") { +// setConsentDataInLS(pubId, "c", result); +// } +// }); +// } + +// if (window.__cmp) { +// if (typeof window.__cmp === "function") { +// callCMP(); +// } else { +// setTimeout(function () { +// if (typeof window.__cmp === "function") { +// callCMP(); +// } +// }, 500); +// } +// } else { +// // we may be inside an iframe and CMP may exist outside, so we"ll use postMessage to interact with CMP +// window.top.postMessage(getConsentDataReq, "*"); +// window.addEventListener("message", receiveMessage); +// } +// }; + +// /** +// * getUserConsentDataFromLS() method return the object { c: "XXX", g: 0/1 } +// * Here c is Consent String We got from CMP APIs +// * & g is gdpr flag i.e. gdprApplies in terms of CMP 1.1 API +// * @return {object} { c: String, g: Number 0/1 } +// */ + +// exports.getUserConsentDataFromLS = function () { +// // Adding dummy pubId to store data against +// var pubId = DUMMY_PUB_ID; +// var data = {c: "", g: 0}; + +// if (!isLocalStoreEnabled) { +// return data; +// } +// var pm; + +// try { +// pm = window.localStorage.getItem(localStorageKey); +// } catch (e) {} +// if (pm && typeof pm === "string") { +// try { +// pm = JSON.parse(pm); +// } catch (e) { +// pm = {}; +// } +// if (pm.hasOwnProperty(pubId)) { +// var pmRecord = pm[pubId]; + +// if (pmRecord && pmRecord.c && pmRecord.t) { +// // check timestamp of data and current; if older than a day do not use it +// if (pmRecord.t && parseInt(pmRecord.t, 10) > ((new Date()).getTime() - (24 * 60 * 60 * 1000))) { +// data.c = pmRecord.c; +// data.g = pmRecord.g; +// } +// } +// } +// } +// return data; +// }; From c97f432cd65000e374545c84346a856a0825e04e Mon Sep 17 00:00:00 2001 From: kapil-tuptewar Date: Wed, 24 May 2023 14:14:34 +0530 Subject: [PATCH 12/17] Removed test cases related to GDPR file --- test/bidManager.spec.js | 6 +- test/gdpr.spec.js | 264 ++++++++++++++++++++-------------------- 2 files changed, 135 insertions(+), 135 deletions(-) diff --git a/test/bidManager.spec.js b/test/bidManager.spec.js index 01b31d00..84f81da6 100644 --- a/test/bidManager.spec.js +++ b/test/bidManager.spec.js @@ -7,7 +7,7 @@ var BIDMgr = require('../src_new/bidManager'); var CONFIG = require("../src_new/config.js"); var CONSTANTS = require("../src_new/constants.js"); var UTIL = require("../src_new/util.js"); -var GDPR = require("../src_new/gdpr.js"); +// var GDPR = require("../src_new/gdpr.js"); var bmEntry = require("../src_new/bmEntry.js"); var bmEntryContstuctor = require("../src_new/bmEntry.js").BMEntry; var AdapterEntry = require("../src_new/adapterEntry").AdapterEntry; @@ -1133,7 +1133,7 @@ describe('bidManager BIDMgr', function() { var timeNow = new Date().getTime(); sinon.stub(UTIL, "getCurrentTimestamp").returns(timeNow); - sinon.spy(GDPR, "getUserConsentDataFromLS"); + // sinon.spy(GDPR, "getUserConsentDataFromLS"); sinon.spy(UTIL, "forEachOnObject"); slotID_1 = "Slot_1"; @@ -1168,7 +1168,7 @@ describe('bidManager BIDMgr', function() { UTIL.getCurrentTimestamp.restore(); UTIL.forEachOnObject.restore(); - GDPR.getUserConsentDataFromLS.restore(); + // GDPR.getUserConsentDataFromLS.restore(); window.PWT = null; BIDMgr.analyticalPixelCallback.restore(); diff --git a/test/gdpr.spec.js b/test/gdpr.spec.js index 7b0bbd9e..0ba74b21 100644 --- a/test/gdpr.spec.js +++ b/test/gdpr.spec.js @@ -1,132 +1,132 @@ -/* global describe, it, xit, sinon, expect */ -// var sinon = require("sinon"); -var should = require("chai").should(); -var expect = require("chai").expect; - -var GDPR = require("../src_new/gdpr.js"); - -var DUMMY_PUB_ID = 909090; -var win = { - __cmp: function (a, b, c) { - c({ - consentData: "MOCK_DATA_STRING" - }); - }, - addEventListener: function (a, b) { - b({ - consentData: "MOCK_DATA_STRING" - }); - }, - localStorage: { - getItem: function (key) { - return '{"909090":{"t":94524546538377,"c":"MOCK_DATA_STRING","g":1}}'; - }, - setItem: function () { - - } - } -}; - -describe('GDPR', function() { - - describe('#isCmpFound', function() { - - it("is a function", function(done) { - GDPR.isCmpFound.should.be.a("function"); - done(); - }); - - it("should return boolean value", function(done) { - var window = win; - GDPR.isCmpFound().should.be.a("boolean"); - done(); - }); - }); - - describe('#setConsentDataInLS', function() { - - it("is a function", function(done) { - GDPR.setConsentDataInLS.should.be.a("function"); - done(); - }); - - it("should return if localStorage is not enabled", function(done) { - var window = { - localStorage: { - getItem: function () { - return "mock-data"; - } - } - }; - var x = GDPR.setConsentDataInLS(DUMMY_PUB_ID, "c", "MOCK_DATA", true); - window.localStorage.getItem.should.not.be.called; - done(); - }); - - it("should save data in localStorage", function(done) { - var window = win; - var x = GDPR.setConsentDataInLS(DUMMY_PUB_ID, "c", "", false); - window.localStorage.getItem.should.be.called; - window.localStorage.setItem.should.be.called; - done(); - }); - }); - - describe('#getUserConsentDataFromCMP', function() { - - it("is a function", function(done) { - GDPR.getUserConsentDataFromCMP.should.be.a("function"); - done(); - }); - - it("should get consentData from CMP Apis", function(done) { - var window = win; - GDPR.getUserConsentDataFromCMP(); - window.__cmp.should.be.called; - window.addEventListener.should.not.be.called; - GDPR.setConsentDataInLS.should.be.called; - done(); - }); - - it("should get consentData from Upper Iframe if CMP not present", function(done) { - window = { - __cmp: null - }; - GDPR.getUserConsentDataFromCMP(); - window.addEventListener.should.be.called; - GDPR.setConsentDataInLS.should.be.called; - done(); - }); - }); - - describe('#getUserConsentDataFromLS', function() { - it("is a function", function(done) { - GDPR.getUserConsentDataFromLS.should.be.a("function"); - done(); - }); - - it("should return default value", function(done) { - var window = { - localStorage: { - getItem: function () { - return "mock-data"; - } - } - }; - var consentData = GDPR.getUserConsentDataFromLS(); - window.localStorage.getItem.should.not.be.called; - consentData.should.deep.equal({ c: "", g: 0 }); - done(); - }); - - it("should return expected value", function(done) { - var window = win; - GDPR.setConsentDataInLS(DUMMY_PUB_ID, "c", "MOCK_DATA", true) - var consentData = GDPR.getUserConsentDataFromLS(); - window.localStorage.getItem.should.be.called; - consentData.should.deep.equal({ c: "MOCK_DATA", g: 1 }); - done(); - }); - }); - -}); \ No newline at end of file +// /* global describe, it, xit, sinon, expect */ +// // var sinon = require("sinon"); +// var should = require("chai").should(); +// var expect = require("chai").expect; + +// var GDPR = require("../src_new/gdpr.js"); + +// var DUMMY_PUB_ID = 909090; +// var win = { +// __cmp: function (a, b, c) { +// c({ +// consentData: "MOCK_DATA_STRING" +// }); +// }, +// addEventListener: function (a, b) { +// b({ +// consentData: "MOCK_DATA_STRING" +// }); +// }, +// localStorage: { +// getItem: function (key) { +// return '{"909090":{"t":94524546538377,"c":"MOCK_DATA_STRING","g":1}}'; +// }, +// setItem: function () { + +// } +// } +// }; + +// describe('GDPR', function() { + +// describe('#isCmpFound', function() { + +// it("is a function", function(done) { +// GDPR.isCmpFound.should.be.a("function"); +// done(); +// }); + +// it("should return boolean value", function(done) { +// var window = win; +// GDPR.isCmpFound().should.be.a("boolean"); +// done(); +// }); +// }); + +// describe('#setConsentDataInLS', function() { + +// it("is a function", function(done) { +// GDPR.setConsentDataInLS.should.be.a("function"); +// done(); +// }); + +// it("should return if localStorage is not enabled", function(done) { +// var window = { +// localStorage: { +// getItem: function () { +// return "mock-data"; +// } +// } +// }; +// var x = GDPR.setConsentDataInLS(DUMMY_PUB_ID, "c", "MOCK_DATA", true); +// window.localStorage.getItem.should.not.be.called; +// done(); +// }); + +// it("should save data in localStorage", function(done) { +// var window = win; +// var x = GDPR.setConsentDataInLS(DUMMY_PUB_ID, "c", "", false); +// window.localStorage.getItem.should.be.called; +// window.localStorage.setItem.should.be.called; +// done(); +// }); +// }); + +// describe('#getUserConsentDataFromCMP', function() { + +// it("is a function", function(done) { +// GDPR.getUserConsentDataFromCMP.should.be.a("function"); +// done(); +// }); + +// it("should get consentData from CMP Apis", function(done) { +// var window = win; +// GDPR.getUserConsentDataFromCMP(); +// window.__cmp.should.be.called; +// window.addEventListener.should.not.be.called; +// GDPR.setConsentDataInLS.should.be.called; +// done(); +// }); + +// it("should get consentData from Upper Iframe if CMP not present", function(done) { +// window = { +// __cmp: null +// }; +// GDPR.getUserConsentDataFromCMP(); +// window.addEventListener.should.be.called; +// GDPR.setConsentDataInLS.should.be.called; +// done(); +// }); +// }); + +// describe('#getUserConsentDataFromLS', function() { +// it("is a function", function(done) { +// GDPR.getUserConsentDataFromLS.should.be.a("function"); +// done(); +// }); + +// it("should return default value", function(done) { +// var window = { +// localStorage: { +// getItem: function () { +// return "mock-data"; +// } +// } +// }; +// var consentData = GDPR.getUserConsentDataFromLS(); +// window.localStorage.getItem.should.not.be.called; +// consentData.should.deep.equal({ c: "", g: 0 }); +// done(); +// }); + +// it("should return expected value", function(done) { +// var window = win; +// GDPR.setConsentDataInLS(DUMMY_PUB_ID, "c", "MOCK_DATA", true) +// var consentData = GDPR.getUserConsentDataFromLS(); +// window.localStorage.getItem.should.be.called; +// consentData.should.deep.equal({ c: "MOCK_DATA", g: 1 }); +// done(); +// }); +// }); + +// }); \ No newline at end of file From ad364554a466b44772fd89ad46268d60f8eaa8a6 Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Wed, 24 May 2023 18:22:45 +0530 Subject: [PATCH 13/17] Additional changes to execute after location is fetched --- src_new/adapters/prebid.js | 34 ++-- src_new/conf.js | 301 ++++++++++------------------------- src_new/config.js | 17 +- src_new/constants.js | 11 +- src_new/controllers/idhub.js | 9 +- 5 files changed, 142 insertions(+), 230 deletions(-) diff --git a/src_new/adapters/prebid.js b/src_new/adapters/prebid.js index e070148c..98e789a0 100644 --- a/src_new/adapters/prebid.js +++ b/src_new/adapters/prebid.js @@ -13,6 +13,7 @@ var CONF = require("../conf.js"); var parentAdapterID = CONSTANTS.COMMON.PARENT_ADAPTER_PREBID; var pbNameSpace = /*CONFIG.isIdentityOnly() ? CONSTANTS.COMMON.IH_NAMESPACE : */ CONSTANTS.COMMON.PREBID_NAMESPACE; +var geoDetectionURL = 'https://www.ebay.com/defaultLocation.json'; //TODO update this /* start-test-block */ exports.parentAdapterID = parentAdapterID; @@ -819,7 +820,10 @@ function assignUserSyncConfig(prebidConfig){ exports.assignUserSyncConfig = assignUserSyncConfig; function assignGdprConfigIfRequired(prebidConfig){ - if (CONFIG.getGdpr()) { + var region = CONFIG.getRegion(); + util.log("User region detected: " + region + ", GDPR enabled: " + CONFIG.getGdpr()); + + if(CONFIG.getGdpr() && (region != CONSTANTS.REGIONS.NON_EUROPE)) { if(!prebidConfig["consentManagement"]){ prebidConfig["consentManagement"] = {}; } @@ -829,6 +833,8 @@ function assignGdprConfigIfRequired(prebidConfig){ allowAuctionWithoutConsent: CONFIG.getAwc() // Auction without consent }; } + (region == CONSTANTS.REGIONS.EUROPE) && !CONFIG.getGdpr() && + util.logWarning("User is from EU region but GDPR is not enabled"); } exports.assignGdprConfigIfRequired = assignGdprConfigIfRequired; @@ -1342,6 +1348,15 @@ function pbjsBidsBackHandler(bidResponses, activeSlots) { exports.pbjsBidsBackHandler = pbjsBidsBackHandler; +function initConfig() { + window[pbNameSpace].logging = util.isDebugLogEnabled(); + refThis.realignPubmaticAdapters(); + refThis.setPrebidConfig(); + refThis.configureBidderAliasesIfAvailable(); + refThis.enablePrebidPubMaticAnalyticIfRequired(); + refThis.setPbjsBidderSettingsIfRequired(); +} + // this function will be called by controllers, // will take care of setting the config as it is configured thru UI function initPbjsConfig(){ @@ -1350,17 +1365,14 @@ function initPbjsConfig(){ return; } - var geoDetectionURL = CONF.pwt.gdURL; - window[pbNameSpace].detectLocation(geoDetectionURL, CONF.pwt.regionPath, function(loc) { - console.log("REGION : " + (loc.error || loc.region)); - CONF.pwt.gdLoc = loc; // TODO change this location to store data - window[pbNameSpace].logging = util.isDebugLogEnabled(); - refThis.realignPubmaticAdapters(); - refThis.setPrebidConfig(); - refThis.configureBidderAliasesIfAvailable(); - refThis.enablePrebidPubMaticAnalyticIfRequired(); - refThis.setPbjsBidderSettingsIfRequired(); + window[pbNameSpace].detectLocation(geoDetectionURL, function(loc) { + CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.LOCATION] = loc;// Confirm this location + CONFIG.isGeoDetectionEnabled() && initConfig(); // to execute this synchronously }); + + if(!CONFIG.isGeoDetectionEnabled()) { + initConfig(); + } } exports.initPbjsConfig = initPbjsConfig; diff --git a/src_new/conf.js b/src_new/conf.js index a00391f9..09020b76 100644 --- a/src_new/conf.js +++ b/src_new/conf.js @@ -1,224 +1,93 @@ exports.pwt = { - t: "3000", - pid: "46", - gcv: "11", - pdvid: "4", - pubid: "9999", - dataURL: "t.test-domain.com/logger?", - winURL: "t.test-domain.com/tracker?", - adserver: "CUSTOM", - gdpr: "0", - cmpApi: "iab", - gdprTimeout: "10000", - awc: "1", - disableAjaxTimeout: true, - adServerCurrency: "INR", + pid: "6066", + gcv: "204", + pdvid: "28", + pubid: "5890", + dataURL: "t.pubmatic.com/wl?", + winURL: "t.pubmatic.com/wt?", + owv: "v26.5.0", + pbv: "v7.25.0", + usePBSAdapter: "0", + reduceCodeSize: "1", + metaDataPattern: 0, + sendAllBids: "0", + adserver: "DFP", + gdpr: "1", + cmp: 0, + gdprTimeout: 0, + awc: 0, + platform: "display", + refreshInterval: 0, + priceGranularity: 0, + adServerCurrency: "EUR", singleImpression: "1", - identityEnabled: "0", - identityConsumers: "EB,TAM,Prebid", - identityOnly: "0", + identityEnabled: 0, + identityConsumers: 0, ccpa: "0", - ccpaCmpApi: "iab", - ccpaTimeout: "10000", - pbv:"v4.33.0", - owv:"v21.4.0", - abTestEnabled:"0", + ccpaCmpApi: 0, + ccpaTimeout: 0, + sChain: "0", + sChainObj: 0, + auTimeout: "2000", + t: "2000", + ssTimeout: 0, + prebidObjName: 0, pubAnalyticsAdapter: "0", - reduceCodeSize:1 -}; - -// singleImpression is used to enable feature of sending single impression for multiple size ad slot earlier there were multiple impression for multiple sizes - -//below is the config for test purpose only -exports.testConfigDetails = { + usePBJSKeys: "0", + abTestEnabled: "0", + testGroupSize: 0, + testType: 0, + granularityMultiplier: 0, + floorPriceModuleEnabled: "0", + floorSource: 0, + floorAuctionDelay: 0, + jsonUrl: 0, + ssoEnabled: 0, + autoRefreshAdslots: "0", + videoAdDuration: 0, + videoAdDurationMatching: 0, + adPodConfiguration: 0, + customPriceGranularityConfig: 0, + marketplaceBidders: 0, + owRedirectURL: 0, + topicsFPDModule: 0, + pbGlobalVarNamespace: "owpbjs", + owGlobalVarNamespace: "PWT", + floorType: 0, + gpp: "0", + gppCmpApi: 0, + gppTimeout: 0, + countryFilterMode: 0, + countryCodes: 0, + gdURL: "https://www.ebay.com/defaultLocation.json", + regionPath: "location.with.some.nesting.region", + disableAjaxTimeout: false + }; + + // singleImpression is used to enable feature of sending single impression for multiple size ad slot earlier there were multiple impression for multiple sizes + + //below is the config for test purpose only + exports.testConfigDetails = { "testGroupSize": 99 -}; -//below is the config for test purpose only -exports.test_pwt = { + }; + //below is the config for test purpose only + exports.test_pwt = { "t": 5000 -}; -exports.adapters = { + }; + exports.adapters = { pubmatic: { - rev_share: "0.0", - throttle: "100", - publisherId: "156209", - kgp: "_W_x_H_@_W_x_H_:_AUI_" - }, - audienceNetwork: { - rev_share: "0.0", - throttle: "100", - kgp: "_DIV_", - klm: { - "Div_1": { - placementId: "8801674" - }, - "Div-2": { - placementId: "8801685" - } - } - }, - sekindoUM: { - rev_share: "0.0", - throttle: "100", - kgp: "_DIV_", - klm: { - "Div_1": { - spaceId: 14071 - }, - "Div-2": { - spaceId: 14071 - } - } - }, - appnexus: { - rev_share: "0.0", - throttle: "100", - kgp: "_DIV_", - klm: { - "Div_1": { - placementId: "8801674", - "video.mimes": "", - "video.minduration": "" - }, - "Div-2": { - placementId: "8801685" - } - } - }, - pulsepoint: { - cp: "521732", - rev_share: "0.0", - throttle: "100", - kgp: "_DIV_", - klm: { - "Div_1": { - ct: "76835" - }, - "Div-2": { - ct: "147007" - } - } - }, - rubicon: { - accountId: "10998", - rev_share: "0.0", - timeout: "1000", - throttle: "100", - pt: 0, - serverSideEnabled: "0", - amp: 0, - video: 0, - "in-app": 0, - kgp_rx: "_AU_@_DIV_@_W_x_H_", - klm_rx: [{ - rx: { - DIV: ".*", - AU: "^/43743431/DMDemo", - SIZE: "728x90" - }, - rx_config: { - zoneId: "869224", - siteId: "178620", - floor: "0" - } - }] + publisherId: "5890", + kgp: "_AU_@_W_x_H_:_AUI_", + sk: "true", + rev_share: "0.0", + timeout: 0, + throttle: "100", + pt: 0, + serverSideEnabled: "0", + amp: 0, + video: 0, + "in-app": 0, + display: 0 } -}; - -exports.identityPartners = { - pubCommonId: { - name: "pubCommonId", - "storage.type": "cookie", - "storage.name": "_myPubCommonId", - "storage.expires": "1825" - }, - identityLink: { - name: "identityLink", - "params.pid": "23", - "storage.type": "cookie", - "params.loadAts": "true", // or false// boolean default is false, - "params.placementID": "23", - "params.storageType": "localstorage", - "params.detectionType": "scrapeAndUrl", - "params.urlParameter": "eparam", - "params.cssSelectors": ["input[type=text]", "input[type=email]"], - "params.logging": "info", - "storage.name": "somenamevalue", - "storage.expires": "60" - }, - criteo: { - name: "criteo", - }, - unifiedId: { - name: "unifiedId", - "params.url": "https://match.adsrvr.org/track/rid?ttd_pid=PubMatic&fmt=json", - "storage.type": "cookie", - "storage.name": "_myUnifiedId", - "storage.expires": "1825" - } -}; - - -/// AD UNIT AU1 -// Read Config File and Get Video Config -// 1. Video Config is available -// 2. Check if Defaut Video is Enabled or not -// 3. Generate Config of slot based on KGP of Default Video it would be _AU_ // AU1 -// 4. Loop on slotConfig for that generated slot config in pt.3 -// 5. DIV1 -> Apply based on condtions (enabled,) -// 6. DIV5 -> It will increase Latency - -exports.slotConfig = { - "configPattern": "_DIV_", - "config": { - "Div1": { - "banner": { - "enabled": true - }, - "native": { - "enabled": true, - "config": { - "image": { - "required": true, - "sizes": [150, 50] - }, - "title": { - "required": true, - "len": 80 - }, - "sponsoredBy": { - "required": true - }, - "body": { - "required": true - } - } - }, - "video": { - "enabled": true, - "config": { - "context": "instream", - "connectiontype": [1, 2, 6], - "minduration": 10, - "maxduration": 50, - "battr": [ - 6, - 7 - ], - "skip": 1, - "skipmin": 10, - "skipafter": 15 - }, - "partnerConfig": { - "pubmatic": { - "outstreamAU": "pubmatic-test" - } - } - }, - - }, - "AU2": { - "banner": {} - } - } -}; \ No newline at end of file + }; + diff --git a/src_new/config.js b/src_new/config.js index 8127a616..0e2bccfc 100644 --- a/src_new/config.js +++ b/src_new/config.js @@ -447,4 +447,19 @@ exports.createMacros = function() { exports.getMarketplaceBidders = function(){ return config.pwt.marketplaceBidders ? config.pwt.marketplaceBidders.split(',') : false; -} \ No newline at end of file +} + +exports.getRegion = function() { + var loc = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.LOCATION]; + //TODO we might need to update this on the basis of actual API response + if(loc && loc.location && loc.location.region) { + return (CONSTANTS.EUROPE_REGION.indexOf(loc.location.region.toLowerCase()) > -1) ? + CONSTANTS.REGIONS.EUROPE : CONSTANTS.REGIONS.NON_EUROPE; + } else { + return CONSTANTS.REGIONS.ERROR; + } +} + +exports.isGeoDetectionEnabled = function() { + return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.GEO_DETECTION_ENABLED]; +} diff --git a/src_new/constants.js b/src_new/constants.js index 0f5e0e78..dfd88df4 100644 --- a/src_new/constants.js +++ b/src_new/constants.js @@ -51,7 +51,9 @@ exports.COMMON = { "IH_ANALYTICS_ADAPTER_EXPIRY": "ihAnalyticsAdapterExpiry", "IH_ANALYTICS_ADAPTER_DEFAULT_EXPIRY": 7, "EXTERNAL_FLOOR_WO_CONFIG": "External Floor w/o Config", - "HARD_FLOOR": "hard" + "HARD_FLOOR": "hard", + "LOCATION": "location", + "GEO_DETECTION_ENABLED": "gdEnabled" }; exports.CONFIG = { @@ -343,3 +345,10 @@ exports.REGEX_BROWSERS = [/\b(?:crmo|crios)\/([\w\.]+)/i,/edg(?:e|ios|a)?\/([\w\ /(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i]; exports.BROWSER_MAPPING = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,42,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64, 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90]; + +exports.EUROPE_REGION = ["europe", "eu"]; +exports.REGIONS = { + "ERROR": "ERROR", + "NON_EUROPE": "Non-EU", + "EUROPE": "EU", +} diff --git a/src_new/controllers/idhub.js b/src_new/controllers/idhub.js index e7fa9c98..2efc12b1 100644 --- a/src_new/controllers/idhub.js +++ b/src_new/controllers/idhub.js @@ -2,6 +2,7 @@ // tdod: we can still reduce the build size for idhub by, // - create a separate constants.js with limited required functions +var OW_CONFIG = require("../config.js"); var CONFIG = require("../config.idhub.js"); var CONSTANTS = require("../constants.js"); var util = require("../util.idhub.js"); @@ -37,7 +38,10 @@ refThis.setConfig = function(){ } }; - if (CONFIG.getGdpr()) { + var region = OW_CONFIG.getRegion(); + util.log("User region detected: " + region + ", GDPR enabled: " + CONFIG.getGdpr()); + + if(CONFIG.getGdpr() && (region != CONSTANTS.REGIONS.NON_EUROPE)) { if(!prebidConfig["consentManagement"]){ prebidConfig["consentManagement"] = {}; } @@ -47,6 +51,9 @@ refThis.setConfig = function(){ allowAuctionWithoutConsent: CONFIG.getAwc() }; } + (region == CONSTANTS.REGIONS.EUROPE) && !CONFIG.getGdpr() && + util.logWarning("User is from EU region but GDPR is not enabled"); + if (CONFIG.getCCPA()) { if(!prebidConfig["consentManagement"]){ From ce3f06657b139c811499252c56f5d85791755b16 Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Wed, 24 May 2023 18:34:10 +0530 Subject: [PATCH 14/17] Commiting original conf.js file --- src_new/conf.js | 301 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 216 insertions(+), 85 deletions(-) diff --git a/src_new/conf.js b/src_new/conf.js index 09020b76..a00391f9 100644 --- a/src_new/conf.js +++ b/src_new/conf.js @@ -1,93 +1,224 @@ exports.pwt = { - pid: "6066", - gcv: "204", - pdvid: "28", - pubid: "5890", - dataURL: "t.pubmatic.com/wl?", - winURL: "t.pubmatic.com/wt?", - owv: "v26.5.0", - pbv: "v7.25.0", - usePBSAdapter: "0", - reduceCodeSize: "1", - metaDataPattern: 0, - sendAllBids: "0", - adserver: "DFP", - gdpr: "1", - cmp: 0, - gdprTimeout: 0, - awc: 0, - platform: "display", - refreshInterval: 0, - priceGranularity: 0, - adServerCurrency: "EUR", + t: "3000", + pid: "46", + gcv: "11", + pdvid: "4", + pubid: "9999", + dataURL: "t.test-domain.com/logger?", + winURL: "t.test-domain.com/tracker?", + adserver: "CUSTOM", + gdpr: "0", + cmpApi: "iab", + gdprTimeout: "10000", + awc: "1", + disableAjaxTimeout: true, + adServerCurrency: "INR", singleImpression: "1", - identityEnabled: 0, - identityConsumers: 0, + identityEnabled: "0", + identityConsumers: "EB,TAM,Prebid", + identityOnly: "0", ccpa: "0", - ccpaCmpApi: 0, - ccpaTimeout: 0, - sChain: "0", - sChainObj: 0, - auTimeout: "2000", - t: "2000", - ssTimeout: 0, - prebidObjName: 0, + ccpaCmpApi: "iab", + ccpaTimeout: "10000", + pbv:"v4.33.0", + owv:"v21.4.0", + abTestEnabled:"0", pubAnalyticsAdapter: "0", - usePBJSKeys: "0", - abTestEnabled: "0", - testGroupSize: 0, - testType: 0, - granularityMultiplier: 0, - floorPriceModuleEnabled: "0", - floorSource: 0, - floorAuctionDelay: 0, - jsonUrl: 0, - ssoEnabled: 0, - autoRefreshAdslots: "0", - videoAdDuration: 0, - videoAdDurationMatching: 0, - adPodConfiguration: 0, - customPriceGranularityConfig: 0, - marketplaceBidders: 0, - owRedirectURL: 0, - topicsFPDModule: 0, - pbGlobalVarNamespace: "owpbjs", - owGlobalVarNamespace: "PWT", - floorType: 0, - gpp: "0", - gppCmpApi: 0, - gppTimeout: 0, - countryFilterMode: 0, - countryCodes: 0, - gdURL: "https://www.ebay.com/defaultLocation.json", - regionPath: "location.with.some.nesting.region", - disableAjaxTimeout: false - }; - - // singleImpression is used to enable feature of sending single impression for multiple size ad slot earlier there were multiple impression for multiple sizes - - //below is the config for test purpose only - exports.testConfigDetails = { + reduceCodeSize:1 +}; + +// singleImpression is used to enable feature of sending single impression for multiple size ad slot earlier there were multiple impression for multiple sizes + +//below is the config for test purpose only +exports.testConfigDetails = { "testGroupSize": 99 - }; - //below is the config for test purpose only - exports.test_pwt = { +}; +//below is the config for test purpose only +exports.test_pwt = { "t": 5000 - }; - exports.adapters = { +}; +exports.adapters = { pubmatic: { - publisherId: "5890", - kgp: "_AU_@_W_x_H_:_AUI_", - sk: "true", - rev_share: "0.0", - timeout: 0, - throttle: "100", - pt: 0, - serverSideEnabled: "0", - amp: 0, - video: 0, - "in-app": 0, - display: 0 + rev_share: "0.0", + throttle: "100", + publisherId: "156209", + kgp: "_W_x_H_@_W_x_H_:_AUI_" + }, + audienceNetwork: { + rev_share: "0.0", + throttle: "100", + kgp: "_DIV_", + klm: { + "Div_1": { + placementId: "8801674" + }, + "Div-2": { + placementId: "8801685" + } + } + }, + sekindoUM: { + rev_share: "0.0", + throttle: "100", + kgp: "_DIV_", + klm: { + "Div_1": { + spaceId: 14071 + }, + "Div-2": { + spaceId: 14071 + } + } + }, + appnexus: { + rev_share: "0.0", + throttle: "100", + kgp: "_DIV_", + klm: { + "Div_1": { + placementId: "8801674", + "video.mimes": "", + "video.minduration": "" + }, + "Div-2": { + placementId: "8801685" + } + } + }, + pulsepoint: { + cp: "521732", + rev_share: "0.0", + throttle: "100", + kgp: "_DIV_", + klm: { + "Div_1": { + ct: "76835" + }, + "Div-2": { + ct: "147007" + } + } + }, + rubicon: { + accountId: "10998", + rev_share: "0.0", + timeout: "1000", + throttle: "100", + pt: 0, + serverSideEnabled: "0", + amp: 0, + video: 0, + "in-app": 0, + kgp_rx: "_AU_@_DIV_@_W_x_H_", + klm_rx: [{ + rx: { + DIV: ".*", + AU: "^/43743431/DMDemo", + SIZE: "728x90" + }, + rx_config: { + zoneId: "869224", + siteId: "178620", + floor: "0" + } + }] } - }; - +}; + +exports.identityPartners = { + pubCommonId: { + name: "pubCommonId", + "storage.type": "cookie", + "storage.name": "_myPubCommonId", + "storage.expires": "1825" + }, + identityLink: { + name: "identityLink", + "params.pid": "23", + "storage.type": "cookie", + "params.loadAts": "true", // or false// boolean default is false, + "params.placementID": "23", + "params.storageType": "localstorage", + "params.detectionType": "scrapeAndUrl", + "params.urlParameter": "eparam", + "params.cssSelectors": ["input[type=text]", "input[type=email]"], + "params.logging": "info", + "storage.name": "somenamevalue", + "storage.expires": "60" + }, + criteo: { + name: "criteo", + }, + unifiedId: { + name: "unifiedId", + "params.url": "https://match.adsrvr.org/track/rid?ttd_pid=PubMatic&fmt=json", + "storage.type": "cookie", + "storage.name": "_myUnifiedId", + "storage.expires": "1825" + } +}; + + +/// AD UNIT AU1 +// Read Config File and Get Video Config +// 1. Video Config is available +// 2. Check if Defaut Video is Enabled or not +// 3. Generate Config of slot based on KGP of Default Video it would be _AU_ // AU1 +// 4. Loop on slotConfig for that generated slot config in pt.3 +// 5. DIV1 -> Apply based on condtions (enabled,) +// 6. DIV5 -> It will increase Latency + +exports.slotConfig = { + "configPattern": "_DIV_", + "config": { + "Div1": { + "banner": { + "enabled": true + }, + "native": { + "enabled": true, + "config": { + "image": { + "required": true, + "sizes": [150, 50] + }, + "title": { + "required": true, + "len": 80 + }, + "sponsoredBy": { + "required": true + }, + "body": { + "required": true + } + } + }, + "video": { + "enabled": true, + "config": { + "context": "instream", + "connectiontype": [1, 2, 6], + "minduration": 10, + "maxduration": 50, + "battr": [ + 6, + 7 + ], + "skip": 1, + "skipmin": 10, + "skipafter": 15 + }, + "partnerConfig": { + "pubmatic": { + "outstreamAU": "pubmatic-test" + } + } + }, + + }, + "AU2": { + "banner": {} + } + } +}; \ No newline at end of file From 97362dd1f659599f3c1df8b6525748e416d413d1 Mon Sep 17 00:00:00 2001 From: Nitin Shirsat Date: Mon, 29 May 2023 15:55:26 +0530 Subject: [PATCH 15/17] Remove GPP changes from sa_changes branch --- src_new/adapters/prebid.js | 10 ------ src_new/conf.js | 5 +-- src_new/config.idhub.js | 17 ---------- src_new/config.js | 16 +-------- src_new/constants.js | 8 +---- src_new/controllers/idhub.js | 6 ---- src_new/owIdhubCommon.js | 15 -------- test/config.spec.js | 66 ------------------------------------ test/owIdhubCommon.spec.js | 58 ------------------------------- 9 files changed, 3 insertions(+), 198 deletions(-) delete mode 100644 src_new/owIdhubCommon.js delete mode 100644 test/owIdhubCommon.spec.js diff --git a/src_new/adapters/prebid.js b/src_new/adapters/prebid.js index eba53d74..0aff3bec 100644 --- a/src_new/adapters/prebid.js +++ b/src_new/adapters/prebid.js @@ -10,7 +10,6 @@ var BID = require("../bid.js"); var util = require("../util.js"); var bidManager = require("../bidManager.js"); var CONF = require("../conf.js"); -var owIdhubCommon = require("../owIdhubCommon.js"); var parentAdapterID = CONSTANTS.COMMON.PARENT_ADAPTER_PREBID; @@ -850,14 +849,6 @@ function assignCcpaConfigIfRequired(prebidConfig){ exports.assignCcpaConfigIfRequired = assignCcpaConfigIfRequired; -function assignGppConfigIfRequired(prebidConfig) { - if (CONFIG.getGppConsent()) { - prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); - } -} - -exports.assignGppConfigIfRequired = assignGppConfigIfRequired; - function assignCurrencyConfigIfRequired(prebidConfig){ if(CONFIG.getAdServerCurrency()){ // get AdServer currency from Config @@ -1043,7 +1034,6 @@ function setPrebidConfig(){ refThis.assignUserSyncConfig(prebidConfig); refThis.assignGdprConfigIfRequired(prebidConfig); refThis.assignCcpaConfigIfRequired(prebidConfig); - refThis.assignGppConfigIfRequired(prebidConfig); refThis.assignCurrencyConfigIfRequired(prebidConfig); refThis.assignSchainConfigIfRequired(prebidConfig); refThis.assignSingleRequestConfigForBidders(prebidConfig); diff --git a/src_new/conf.js b/src_new/conf.js index 8813c337..a00391f9 100644 --- a/src_new/conf.js +++ b/src_new/conf.js @@ -24,10 +24,7 @@ exports.pwt = { owv:"v21.4.0", abTestEnabled:"0", pubAnalyticsAdapter: "0", - reduceCodeSize:1, - gpp: "0", - gppCmpApi: "iab", - gppTimeout: "10000" + reduceCodeSize:1 }; // singleImpression is used to enable feature of sending single impression for multiple size ad slot earlier there were multiple impression for multiple sizes diff --git a/src_new/config.idhub.js b/src_new/config.idhub.js index e2b65753..c0bfab5a 100644 --- a/src_new/config.idhub.js +++ b/src_new/config.idhub.js @@ -64,23 +64,6 @@ exports.getCCPATimeout = function() { return ccpaTimeout ? window.parseInt(ccpaTimeout) : CONSTANTS.CONFIG.DEFAULT_CCPA_TIMEOUT; }; -// needed -exports.getGppConsent = function () { - var gpp = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] || CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT; - return gpp === "1"; -}; - -// needed -exports.getGppCmpApi = function () { - return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] || CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI; -}; - -// needed -exports.getGppTimeout = function() { - var gppTimeout = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT]; - return gppTimeout ? window.parseInt(gppTimeout) : CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT; -}; - exports.getProfileID = function () { return config.pwt[CONSTANTS.CONFIG.PROFILE_ID] || "0"; }; diff --git a/src_new/config.js b/src_new/config.js index ff5967a4..8127a616 100644 --- a/src_new/config.js +++ b/src_new/config.js @@ -447,18 +447,4 @@ exports.createMacros = function() { exports.getMarketplaceBidders = function(){ return config.pwt.marketplaceBidders ? config.pwt.marketplaceBidders.split(',') : false; -} - -exports.getGppConsent = function () { - var gpp = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] || CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT; - return gpp === "1"; -}; - -exports.getGppCmpApi = function () { - return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] || CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI; -}; - -exports.getGppTimeout = function () { - var gppTimeout = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT]; - return gppTimeout ? window.parseInt(gppTimeout) : CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT; -}; \ No newline at end of file +} \ No newline at end of file diff --git a/src_new/constants.js b/src_new/constants.js index b5fb34bd..0f5e0e78 100644 --- a/src_new/constants.js +++ b/src_new/constants.js @@ -109,13 +109,7 @@ exports.CONFIG = { "AB_TEST_ENABLED": "abTestEnabled", "TIMEOUT_ADJUSTMENT": 50, "SSO_ENABLED": "ssoEnabled", - "FLOOR_SOURCE": "floorSource", - "GPP_CONSENT": "gpp", - "GPP_CMPAPI": "gppCmpApi", - "GPP_TIMEOUT": "gppTimeout", - "DEFAULT_GPP_CONSENT": "0", - "DEFAULT_GPP_CMPAPI": "iab", - "DEFAULT_GPP_TIMEOUT": 10000, + "FLOOR_SOURCE": "floorSource" }; exports.METADATA_MACROS = { diff --git a/src_new/controllers/idhub.js b/src_new/controllers/idhub.js index e55a1ecf..1a9a5e33 100644 --- a/src_new/controllers/idhub.js +++ b/src_new/controllers/idhub.js @@ -5,7 +5,6 @@ var CONFIG = require("../config.idhub.js"); var CONSTANTS = require("../constants.js"); var util = require("../util.idhub.js"); -var owIdhubCommon = require("../owIdhubCommon.js"); var refThis = this; var pbNameSpace = CONFIG.isIdentityOnly() ? CONSTANTS.COMMON.IH_NAMESPACE : CONSTANTS.COMMON.PREBID_NAMESPACE; @@ -60,11 +59,6 @@ refThis.setConfig = function(){ }; } - // Set Gpp consent config - if (CONFIG.getGppConsent()) { - prebidConfig = owIdhubCommon.setConsentConfig(prebidConfig, "gpp", CONFIG.getGppCmpApi(), CONFIG.getGppTimeout()); - } - window.IHPWT.ssoEnabled = CONFIG.isSSOEnabled() || false; if(CONFIG.isUserIdModuleEnabled()){ prebidConfig["userSync"]["userIds"] = util.getUserIdConfiguration(); diff --git a/src_new/owIdhubCommon.js b/src_new/owIdhubCommon.js deleted file mode 100644 index f25b4f8e..00000000 --- a/src_new/owIdhubCommon.js +++ /dev/null @@ -1,15 +0,0 @@ -// NOTE: This file will contains only common code/function used in OW and IDHUB. -// Do not import any other file into it. - - -exports.setConsentConfig = function (prebidConfig, key, cmpApi, timeout) { - prebidConfig = prebidConfig || {}; - if (!prebidConfig["consentManagement"]) { - prebidConfig["consentManagement"] = {}; - } - prebidConfig["consentManagement"][key] = { - cmpApi: cmpApi, - timeout: timeout - }; - return prebidConfig; -}; \ No newline at end of file diff --git a/test/config.spec.js b/test/config.spec.js index 6dca7650..753027ba 100644 --- a/test/config.spec.js +++ b/test/config.spec.js @@ -2411,70 +2411,4 @@ describe('Config', function() { done(); }); }); - - describe('#Gpp', function() { - beforeEach(function(done){ - if(!CONF[CONSTANTS.CONFIG.COMMON]) { - CONF[CONSTANTS.CONFIG.COMMON] = {}; - } - done(); - }); - - describe('#getGpp', function() { - it('is a function', function(done) { - CONFIG.getGppConsent.should.be.a('function'); - done(); - }); - - it('should return true, as it is set to "1"', function(done) { - CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT] = "1"; - CONFIG.getGppConsent().should.be.true; - done(); - }); - - it('should return default value for gpp which is '+(CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT === "1")+', as it is NOT set', function(done) { - delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CONSENT]; - CONFIG.getGppConsent().should.be.equal((CONSTANTS.CONFIG.DEFAULT_GPP_CONSENT === "1")); - done(); - }); - }); - - describe('#getGppCmpApi', function() { - it('is a function', function(done) { - CONFIG.getGppCmpApi.should.be.a('function'); - done(); - }); - - it('should return iab, as it is set to iab', function(done) { - CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI] = 'iab'; - CONFIG.getGppCmpApi().should.be.equal('iab'); - done(); - }); - - it('should return default cmp which is '+CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI+', as it is NOT set', function(done) { - delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_CMPAPI]; - CONFIG.getGppCmpApi().should.be.equal(CONSTANTS.CONFIG.DEFAULT_GPP_CMPAPI); - done(); - }); - }); - - describe('#getGppTimeout', function() { - it('is a function', function(done) { - CONFIG.getGppTimeout.should.be.a('function'); - done(); - }); - - it('should return 5000, as it is set to 5000', function(done) { - CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT] = 5000; - CONFIG.getGppTimeout().should.be.equal(5000); - done(); - }); - - it('should return default value for gpp timeout which is '+CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT+', as it is NOT set', function(done) { - delete CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.GPP_TIMEOUT]; - CONFIG.getGppTimeout().should.be.equal(CONSTANTS.CONFIG.DEFAULT_GPP_TIMEOUT); - done(); - }); - }); - }); }); diff --git a/test/owIdhubCommon.spec.js b/test/owIdhubCommon.spec.js deleted file mode 100644 index 6bede58a..00000000 --- a/test/owIdhubCommon.spec.js +++ /dev/null @@ -1,58 +0,0 @@ -/* global describe, it, xit, sinon, expect */ -// var sinon = require("sinon"); -var should = require("chai").should(); -var expect = require("chai").expect; -var OWIDHUBCOMMON = require("../src_new/owIdhubCommon"); - -describe('owIdhubCommon', function() { - describe('setConsentConfig', function() { - var prebidConfig = {}; - var cmpApi = 'iab'; - var timeout = 2000; - - it('setConsentConfig a function', function(done) { - OWIDHUBCOMMON.setConsentConfig.should.be.a('function'); - done(); - }); - - it('should set consent management config when its not present', function(done) { - var expPrebidConfig = { - consentManagement: { - gpp: { - cmpApi, - timeout - } - } - }; - const actPrebifConfig = OWIDHUBCOMMON.setConsentConfig(prebidConfig, 'gpp', cmpApi, timeout); - expect(actPrebifConfig).to.be.deep.equal(expPrebidConfig); - done(); - }); - - it('should set consent management config when its present', function(done) { - var prebidConfig = { - consentManagement: { - gdpr: { - cmpApi, - timeout - } - } - } - var expPrebidConfig = { - consentManagement: { - gdpr: { - cmpApi, - timeout - }, - gpp: { - cmpApi, - timeout - } - } - }; - const actPrebifConfig = OWIDHUBCOMMON.setConsentConfig(prebidConfig, 'gpp', cmpApi, timeout); - expect(actPrebifConfig).to.be.deep.equal(expPrebidConfig); - done(); - }); - }); -}); \ No newline at end of file From 137a0e1028891617bd935638446fae867b99aa96 Mon Sep 17 00:00:00 2001 From: Nitin Shirsat Date: Mon, 29 May 2023 16:00:14 +0530 Subject: [PATCH 16/17] REmove GPP changes --- test/adapters/prebid.spec.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/test/adapters/prebid.spec.js b/test/adapters/prebid.spec.js index 2f31aac7..c9cb94a0 100644 --- a/test/adapters/prebid.spec.js +++ b/test/adapters/prebid.spec.js @@ -1279,9 +1279,6 @@ describe('ADAPTER: Prebid', function() { sinon.spy(CONFIG, 'getCCPATimeout'); sinon.stub(CONFIG, 'getCCPA').returns(true); - sinon.spy(CONFIG, 'getGppTimeout'); - sinon.spy(CONFIG, 'getGppCmpApi'); - sinon.stub(CONFIG, 'getGppConsent').returns(true); sinon.stub(BM, 'resetBid', function(){}); sinon.stub(BM, 'setSizes', function(){}); @@ -1353,10 +1350,6 @@ describe('ADAPTER: Prebid', function() { CONFIG.getCCPA.restore(); CONFIG.getCCPATimeout.restore(); - CONFIG.getGppConsent.restore(); - CONFIG.getGppCmpApi.restore(); - CONFIG.getGppTimeout.restore(); - BM.resetBid.restore(); BM.setSizes.restore(); @@ -1428,9 +1421,6 @@ describe('ADAPTER: Prebid', function() { CONFIG.getCCPA().should.be.true; CONFIG.getCCPACmpApi().should.be.called; CONFIG.getCCPATimeout().should.be.called; - CONFIG.getGppConsent().should.be.true; - CONFIG.getGppCmpApi().should.be.called; - CONFIG.getGppTimeout().should.be.called; done(); }); From 6105a9fc281e5ed6d06bb096578b9413117f478a Mon Sep 17 00:00:00 2001 From: pm-priyanka-deshmane Date: Tue, 6 Jun 2023 16:42:31 +0530 Subject: [PATCH 17/17] Local storage changes and expiry changes --- src_new/adapters/prebid.js | 39 +++++++++++++++++++++++++++--------- src_new/config.idhub.js | 11 +++++++++- src_new/config.js | 10 ++------- src_new/constants.js | 7 ------- src_new/controllers/idhub.js | 20 +++++++++++------- 5 files changed, 54 insertions(+), 33 deletions(-) diff --git a/src_new/adapters/prebid.js b/src_new/adapters/prebid.js index fefcebe6..398c36a1 100644 --- a/src_new/adapters/prebid.js +++ b/src_new/adapters/prebid.js @@ -14,6 +14,8 @@ var parentAdapterID = CONSTANTS.COMMON.PARENT_ADAPTER_PREBID; var pbNameSpace = /*CONFIG.isIdentityOnly() ? CONSTANTS.COMMON.IH_NAMESPACE : */ CONSTANTS.COMMON.PREBID_NAMESPACE; var geoDetectionURL = 'https://www.ebay.com/defaultLocation.json'; //TODO update this +var HOSTNAME = window.location.host; +var PREFIX = 'UINFO'; /* start-test-block */ exports.parentAdapterID = parentAdapterID; @@ -820,10 +822,18 @@ function assignUserSyncConfig(prebidConfig){ exports.assignUserSyncConfig = assignUserSyncConfig; function assignGdprConfigIfRequired(prebidConfig){ - var region = CONFIG.getRegion(); - util.log("User region detected: " + region + ", GDPR enabled: " + CONFIG.getGdpr()); + var isInGDPRRegion = CONFIG.isInGDPRRegion(); + util.log("User isInGDPRRegion: " + isInGDPRRegion + ", GDPR enabled: " + CONFIG.getGdpr()); - if(CONFIG.getGdpr() && (region != CONSTANTS.REGIONS.NON_EUROPE)) { + /* + If GEO detection is NOT enabled AND GDPR is enabled + OR + If GEO detection is enabled AND GDPR is enabled AND location is EU(or error) + THEN ENFORCE GDPR + */ + if(CONFIG.getGdpr() && (!CONFIG.isGeoDetectionEnabled() || + (CONFIG.isGeoDetectionEnabled() && isInGDPRRegion) + )) { if(!prebidConfig["consentManagement"]){ prebidConfig["consentManagement"] = {}; } @@ -834,7 +844,7 @@ function assignGdprConfigIfRequired(prebidConfig){ defaultGdprScope: true }; } - (region == CONSTANTS.REGIONS.EUROPE) && !CONFIG.getGdpr() && + isInGDPRRegion && !CONFIG.getGdpr() && util.logWarning("User is from EU region but GDPR is not enabled"); } @@ -1355,18 +1365,27 @@ function initConfig() { // this function will be called by controllers, // will take care of setting the config as it is configured thru UI function initPbjsConfig(){ + var LOCATION_INFO_VALIDITY = 2 * 24 * 60 * 60 * 1000; if(! window[pbNameSpace]){ // todo: move this code owt.js util.logError("PreBid js is not loaded"); return; } - window[pbNameSpace].detectLocation(geoDetectionURL, function(loc) { - CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.LOCATION] = loc;// Confirm this location - CONFIG.isGeoDetectionEnabled() && initConfig(); // to execute this synchronously - }); - - if(!CONFIG.isGeoDetectionEnabled()) { + var info = window[pbNameSpace].getDataFromLocalStorage(PREFIX + HOSTNAME, LOCATION_INFO_VALIDITY); + if(info) { // Got valid data + CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.LOCATION] = info; initConfig(); + } else { + window[pbNameSpace].detectLocation(geoDetectionURL + "?pubid=" + CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.CONFIG.PUBLISHER_ID], + function(loc) { + window[pbNameSpace].setAndStringifyToLocalStorage(PREFIX + HOSTNAME, loc); + CONF[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.LOCATION] = loc; + CONFIG.isGeoDetectionEnabled() && initConfig(); // to execute this synchronously + }); + + if(!CONFIG.isGeoDetectionEnabled()) { + initConfig(); // to execute this without waiting for geo + } } } exports.initPbjsConfig = initPbjsConfig; diff --git a/src_new/config.idhub.js b/src_new/config.idhub.js index c0bfab5a..fbbdf835 100644 --- a/src_new/config.idhub.js +++ b/src_new/config.idhub.js @@ -89,4 +89,13 @@ exports.getIHAnalyticsAdapterExpiry = function() { return parseInt(config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.IH_ANALYTICS_ADAPTER_EXPIRY]) || CONSTANTS.COMMON.IH_ANALYTICS_ADAPTER_DEFAULT_EXPIRY; }; -exports.PBJS_NAMESPACE = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.PBJS_NAMESPACE] || "pbjs"; \ No newline at end of file +exports.PBJS_NAMESPACE = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.PBJS_NAMESPACE] || "pbjs"; + +exports.isInGDPRRegion = function() { + var loc = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.LOCATION]; + return loc && loc.apply_gdpr; +} + +exports.isGeoDetectionEnabled = function() { + return config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.GEO_DETECTION_ENABLED]; +} diff --git a/src_new/config.js b/src_new/config.js index 3d3a7013..b40e44b5 100644 --- a/src_new/config.js +++ b/src_new/config.js @@ -458,15 +458,9 @@ exports.getMarketplaceBidders = function(){ return config.pwt.marketplaceBidders ? config.pwt.marketplaceBidders.split(',') : false; } -exports.getRegion = function() { +exports.isInGDPRRegion = function() { var loc = config[CONSTANTS.CONFIG.COMMON][CONSTANTS.COMMON.LOCATION]; - //TODO we might need to update this on the basis of actual API response - if(loc && loc.location && loc.location.region) { - return (CONSTANTS.EUROPE_REGION.indexOf(loc.location.region.toLowerCase()) > -1) ? - CONSTANTS.REGIONS.EUROPE : CONSTANTS.REGIONS.NON_EUROPE; - } else { - return CONSTANTS.REGIONS.ERROR; - } + return loc && loc.apply_gdpr; } exports.isGeoDetectionEnabled = function() { diff --git a/src_new/constants.js b/src_new/constants.js index 773dca0e..e9ef0893 100644 --- a/src_new/constants.js +++ b/src_new/constants.js @@ -349,10 +349,3 @@ exports.REGEX_BROWSERS = [/\b(?:crmo|crios)\/([\w\.]+)/i,/edg(?:e|ios|a)?\/([\w\ /(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i]; exports.BROWSER_MAPPING = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,42,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64, 65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90]; - -exports.EUROPE_REGION = ["europe", "eu"]; -exports.REGIONS = { - "ERROR": "ERROR", - "NON_EUROPE": "Non-EU", - "EUROPE": "EU", -} diff --git a/src_new/controllers/idhub.js b/src_new/controllers/idhub.js index 5bcac32e..75759751 100644 --- a/src_new/controllers/idhub.js +++ b/src_new/controllers/idhub.js @@ -2,7 +2,6 @@ // tdod: we can still reduce the build size for idhub by, // - create a separate constants.js with limited required functions -var OW_CONFIG = require("../config.js"); var CONFIG = require("../config.idhub.js"); var CONSTANTS = require("../constants.js"); var util = require("../util.idhub.js"); @@ -38,10 +37,18 @@ refThis.setConfig = function(){ } }; - var region = OW_CONFIG.getRegion(); - util.log("User region detected: " + region + ", GDPR enabled: " + CONFIG.getGdpr()); - - if(CONFIG.getGdpr() && (region != CONSTANTS.REGIONS.NON_EUROPE)) { + var isInGDPRRegion = CONFIG.isInGDPRRegion(); + util.log("User isInGDPRRegion: " + isInGDPRRegion + ", GDPR enabled: " + CONFIG.getGdpr()); + + /* + If GEO detection is NOT enabled AND GDPR is enabled + OR + If GEO detection is enabled AND GDPR is enabled AND location is EU(or error) + THEN ENFORCE GDPR + */ + if(CONFIG.getGdpr() && (!CONFIG.isGeoDetectionEnabled() || + (CONFIG.isGeoDetectionEnabled() && isInGDPRRegion) + )) { if(!prebidConfig["consentManagement"]){ prebidConfig["consentManagement"] = {}; } @@ -52,10 +59,9 @@ refThis.setConfig = function(){ defaultGdprScope: true }; } - (region == CONSTANTS.REGIONS.EUROPE) && !CONFIG.getGdpr() && + isInGDPRRegion && !CONFIG.getGdpr() && util.logWarning("User is from EU region but GDPR is not enabled"); - if (CONFIG.getCCPA()) { if(!prebidConfig["consentManagement"]){ prebidConfig["consentManagement"] = {};