diff --git a/gulpfile.js b/gulpfile.js index aaa92e9f..416eee64 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -300,7 +300,8 @@ gulp.task('bundle-pwt-keys', function() { "UUID": "hb_uuid", "CACHE_ID": "hb_cache_id", "CACHE_HOST": "hb_cache_host", - "ADOMAIN" : "hb_adomain" + "ADOMAIN" : "hb_adomain", + "ACAT": "hb_acat", } } ] diff --git a/src_new/adapters/prebid.js b/src_new/adapters/prebid.js index 9e6e2ff3..cc4f8ae3 100644 --- a/src_new/adapters/prebid.js +++ b/src_new/adapters/prebid.js @@ -26,6 +26,7 @@ exports.kgpvMap = kgpvMap; var refThis = this; var onEventAdded = false; +var onAuctionEndEventAdded = false; var isPrebidPubMaticAnalyticsEnabled = CONFIG.isPrebidPubMaticAnalyticsEnabled(); var isSingleImpressionSettingEnabled = CONFIG.isSingleImpressionSettingEnabled(); var defaultAliases = CONSTANTS.DEFAULT_ALIASES; @@ -323,9 +324,16 @@ exports.pbBidRequestHandler = pbBidRequestHandler; // removeIf(removeLegacyAnalyticsRelatedCode) function pbAuctionEndHandler(args){ + window.PWT.newAdUnits = window.PWT.newAdUnits || {}; args.adUnits.forEach(function(adUnit){ if(!!adUnit.pubmaticAutoRefresh){ - window.PWT.adUnits[adUnit.code].pubmaticAutoRefresh = adUnit.pubmaticAutoRefresh; + if(!window.PWT.newAdUnits[window.PWT.bidMap[adUnit.code].impressionID]){ + window.PWT.newAdUnits[window.PWT.bidMap[adUnit.code].impressionID] = {}; + } + if(!window.PWT.newAdUnits[window.PWT.bidMap[adUnit.code].impressionID][adUnit.code]){ + window.PWT.newAdUnits[window.PWT.bidMap[adUnit.code].impressionID][adUnit.code] = {} + } + window.PWT.newAdUnits[window.PWT.bidMap[adUnit.code].impressionID][adUnit.code].pubmaticAutoRefresh = adUnit.pubmaticAutoRefresh; } }); } @@ -968,7 +976,10 @@ exports.addOnBidResponseHandler = addOnBidResponseHandler; // removeIf(removeLegacyAnalyticsRelatedCode) function addOnAuctionEndHandler(){ if(util.isFunction(window[pbNameSpace].onEvent)){ - window[pbNameSpace].onEvent('auctionEnd', refThis.pbAuctionEndHandler); + if(!onAuctionEndEventAdded){ + window[pbNameSpace].onEvent('auctionEnd', refThis.pbAuctionEndHandler); + onAuctionEndEventAdded = true; + } } else { util.logWarning("PreBid js onEvent method is not available"); return; @@ -1269,12 +1280,18 @@ exports.getPbjsAdServerTargetingConfig = getPbjsAdServerTargetingConfig; function setPbjsBidderSettingsIfRequired(){ if(isPrebidPubMaticAnalyticsEnabled === false){ + window[pbNameSpace].bidderSettings = { + 'standard': { + 'storageAllowed': true // marking the storage allowed as true for 7.39 upgrade + } + }; return; } window[pbNameSpace].bidderSettings = { 'standard': { 'suppressEmptyKeys': true, // this boolean flag can be used to avoid sending those empty values to the ad server. + 'storageAllowed': true // marking the storage allowed as true for 7.39 upgrade } }; diff --git a/src_new/bidManager.js b/src_new/bidManager.js index 10f9560d..29c4e172 100644 --- a/src_new/bidManager.js +++ b/src_new/bidManager.js @@ -598,7 +598,7 @@ function analyticalPixelCallback(slotID, bmEntry, impressionIDMap) { // TDD, i/o "is": refThis.getSlotLevelFrequencyDepth(frequencyDepth, 'impressionServed', adUnitInfo.adUnitId), "rc": refThis.getSlotLevelFrequencyDepth(frequencyDepth, 'slotCnt', adUnitInfo.adUnitId), "vw": frequencyDepth && frequencyDepth.viewedSlot && frequencyDepth.viewedSlot[adUnitInfo.adUnitId], - "rf": adUnitInfo.pubmaticAutoRefresh && adUnitInfo.pubmaticAutoRefresh.isRefreshed ? 1 : 0 + "rf": window.PWT.newAdUnits ? (window.PWT.newAdUnits[impressionID] ? (window.PWT.newAdUnits[impressionID][slotID] ? (window.PWT.newAdUnits[impressionID][slotID]['pubmaticAutoRefresh'] ? (window.PWT.newAdUnits[impressionID][slotID]['pubmaticAutoRefresh']['isRefreshed'] ? 1: 0 ) : 0): 0 ) : 0 ): 0, }; bmEntry.setExpired(); impressionIDMap[impressionID] = impressionIDMap[impressionID] || []; diff --git a/src_new/util.js b/src_new/util.js index ffcc455e..9acc5950 100644 --- a/src_new/util.js +++ b/src_new/util.js @@ -483,14 +483,10 @@ exports.displayCreative = function(theDocument, bid){ else{ refThis.resizeWindow(theDocument, bid.width, bid.height); if(bid.adHtml){ - if(bid.getAdapterID().toLowerCase() == "appier" || bid.getAdapterID().toLowerCase() == "deepintent"){ - bid.adHtml = refThis.replaceAuctionPrice(bid.adHtml, bid.getGrossEcpm()); - } + bid.adHtml = refThis.replaceAuctionPrice(bid.adHtml, bid.getGrossEcpm()); theDocument.write(bid.adHtml); }else if(bid.adUrl){ - if(bid.getAdapterID().toLowerCase() == "appier" || bid.getAdapterID().toLowerCase() == "deepintent"){ - bid.adUrl = refThis.replaceAuctionPrice(bid.adUrl, bid.getGrossEcpm()); - } + bid.adUrl = refThis.replaceAuctionPrice(bid.adUrl, bid.getGrossEcpm()); refThis.writeIframe(theDocument, bid.adUrl, bid.width, bid.height, ""); }else{ refThis.logError("creative details are not found"); @@ -1544,7 +1540,8 @@ exports.generateMonetizationPixel = function(slotID, theBid){ var origAdUnit = bidManager.getAdUnitInfo(slotID); adUnitId = origAdUnit.adUnitId || slotID; - var isRefreshed = origAdUnit.pubmaticAutoRefresh && origAdUnit.pubmaticAutoRefresh.isRefreshed ? 1 : 0; + 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; pixelURL += "pubid=" + pubId; pixelURL += "&purl=" + window.encodeURIComponent(refThis.metaInfo.pageURL); diff --git a/test/adapters/prebid.spec.js b/test/adapters/prebid.spec.js index 2b6a1d6a..6323ca45 100644 --- a/test/adapters/prebid.spec.js +++ b/test/adapters/prebid.spec.js @@ -1885,9 +1885,16 @@ describe('ADAPTER: Prebid', function() { beforeEach(function(done) { window.PWT = { - adUnits: { - "Div1": { - "code": 'Div1' + newAdUnits: { + "123123123":{ + "Div1": { + "code": 'Div1' + } + } + }, + bidMap:{ + "Div1" : { + impressionID: "123123123" } } } @@ -1895,7 +1902,7 @@ describe('ADAPTER: Prebid', function() { }); afterEach(function(done){ - window.PWT.adUnits = {}; + window.PWT.newAdUnits = {}; done(); }); @@ -1906,15 +1913,15 @@ describe('ADAPTER: Prebid', function() { it('should copy pubmaticAutoRefresh data into window.PWT.adUnit',function(done){ PREBID.pbAuctionEndHandler(auctionArgs); - expect(window.PWT.adUnits["Div1"]["pubmaticAutoRefresh"]).to.be.an.object; - expect(window.PWT.adUnits["Div1"]["pubmaticAutoRefresh"]["isRefreshed"]).to.be.true; + expect(window.PWT.newAdUnits["123123123"]["Div1"]["pubmaticAutoRefresh"]).to.be.an.object; + expect(window.PWT.newAdUnits["123123123"]["Div1"]["pubmaticAutoRefresh"]["isRefreshed"]).to.be.true; done(); }); it('should not copy pubmaticAutoRefresh data into window.PWT.adUnit when the entry is missing',function(done){ delete auctionArgs.adUnits[0].pubmaticAutoRefresh; PREBID.pbAuctionEndHandler(auctionArgs); - expect(window.PWT.adUnits["Div1"]["pubmaticAutoRefresh"]).to.be.undefined; + expect(window.PWT.newAdUnits["123123123"]["Div1"]["pubmaticAutoRefresh"]).to.be.undefined; done(); }); }); diff --git a/test/bidManager.spec.js b/test/bidManager.spec.js index 2325dfba..3a2e2cbf 100644 --- a/test/bidManager.spec.js +++ b/test/bidManager.spec.js @@ -1260,9 +1260,15 @@ describe('bidManager BIDMgr', function() { "divID": slotID, "code":slotID, "adUnitId": adUnitId, - "mediaTypes": {'banner': {'sizes': [0]}}, - "pubmaticAutoRefresh":{ - "isRefreshed": true + "mediaTypes": {'banner': {'sizes': [0]}} + } + }, + newAdUnits:{ + "123123":{ + "Slot_1":{ + "pubmaticAutoRefresh":{ + "isRefreshed": true + } } } } diff --git a/test/util.spec.js b/test/util.spec.js index ed5c9c09..8a9aba5c 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -919,7 +919,8 @@ describe('UTIL', function() { }, pbbid:{ mediaType:"banner" - } + }, + getGrossEcpm:function(){ return "10.55" } }; sinon.stub(UTIL, "resizeWindow") // .returns(true); @@ -976,38 +977,15 @@ describe('UTIL', function() { done(); }); - it('should have called replace Auction Price method of the passed object if bid is of APPIER', function(done) { - bid.getAdapterID = function(){ return "appier" }; - bid.getGrossEcpm = function(){ return "10.55" }; - UTIL.displayCreative(theDocument, bid); - theDocument.write.calledWith(bid.adHtml).should.be.true; - UTIL.replaceAuctionPrice.calledWith(bid.adHtml,bid.getGrossEcpm()).should.be.true; - done(); - }); - - it('should have called replace auction price and writeIframe method if adUrl is present in given bid and adHtml is not and bidder is appier', function(done) { - delete bid.adHtml; - bid.getAdapterID = function(){ return "appier" }; - bid.getGrossEcpm = function(){ return "10.55" }; - UTIL.displayCreative(theDocument, bid); - UTIL.replaceAuctionPrice.calledWith(bid.adUrl,bid.getGrossEcpm()).should.be.true; - UTIL.writeIframe.calledWith(theDocument, bid.adUrl, bid.width, bid.height, "").should.be.true; - done(); - }); - - it('should have called replace Auction Price method of the passed object if bid is of DeepIntent', function(done) { - bid.getAdapterID = function(){ return "deepintent" }; - bid.getGrossEcpm = function(){ return "10.55" }; + it('should have called replace Auction Price method of the passed object, irrespective of bidder', function(done) { UTIL.displayCreative(theDocument, bid); theDocument.write.calledWith(bid.adHtml).should.be.true; UTIL.replaceAuctionPrice.calledWith(bid.adHtml,bid.getGrossEcpm()).should.be.true; done(); }); - it('should have called replace auction price and writeIframe method if adUrl is present in given bid and adHtml is not and bidder is DeepIntent', function(done) { + it('should have called replace auction price and writeIframe method if adUrl is present in given bid and adHtml is not, irrespective of bidder', function(done) { delete bid.adHtml; - bid.getAdapterID = function(){ return "deepintent" }; - bid.getGrossEcpm = function(){ return "10.55" }; UTIL.displayCreative(theDocument, bid); UTIL.replaceAuctionPrice.calledWith(bid.adUrl,bid.getGrossEcpm()).should.be.true; UTIL.writeIframe.calledWith(theDocument, bid.adUrl, bid.width, bid.height, "").should.be.true;