diff --git a/modules/openxBidAdapter.js b/modules/openxBidAdapter.js index 1cc312da273..b425b80149a 100644 --- a/modules/openxBidAdapter.js +++ b/modules/openxBidAdapter.js @@ -10,6 +10,11 @@ const BIDDER_CODE = 'openx'; const BIDDER_CONFIG = 'hb_pb'; const BIDDER_VERSION = '2.1.0'; +let shouldSendBoPixel = true; +export function resetBoPixel() { + shouldSendBoPixel = true; +} + export const spec = { code: BIDDER_CODE, supportedMediaTypes: SUPPORTED_AD_TYPES, @@ -63,11 +68,6 @@ function isVideoRequest(bidRequest) { function createBannerBidResponses(oxResponseObj, {bids, startTime}) { let adUnits = oxResponseObj.ads.ad; let bidResponses = []; - let shouldSendBoPixel = bids[0].params.sendBoPixel; - if (shouldSendBoPixel === undefined) { - // Not specified, default to turned on - shouldSendBoPixel = true; - } for (let i = 0; i < adUnits.length; i++) { let adUnit = adUnits[i]; let adUnitIdx = parseInt(adUnit.idx, 10); @@ -103,10 +103,9 @@ function createBannerBidResponses(oxResponseObj, {bids, startTime}) { } bidResponse.ts = adUnit.ts; - if (shouldSendBoPixel && adUnit.ts) { - registerBeacon(BANNER, adUnit, startTime); - } bidResponses.push(bidResponse); + + registerBeacon(BANNER, adUnit, startTime); } return bidResponses; } @@ -300,11 +299,6 @@ function generateVideoParameters(bid) { } function createVideoBidResponses(response, {bid, startTime}) { - let shouldSendBoPixel = bid.params.sendBoPixel; - if (shouldSendBoPixel === undefined) { - // Not specified, default to turned on - shouldSendBoPixel = true; - } let bidResponses = []; if (response !== undefined && response.vastUrl !== '' && response.pub_rev !== '') { @@ -329,16 +323,21 @@ function createVideoBidResponses(response, {bid, startTime}) { response.colo = vastQueryParams.colo; response.ts = vastQueryParams.ts; - if (shouldSendBoPixel && response.ts) { - registerBeacon(VIDEO, response, startTime) - } bidResponses.push(bidResponse); + + registerBeacon(VIDEO, response, startTime) } return bidResponses; } function registerBeacon(mediaType, adUnit, startTime) { + // only register beacon once + if (!shouldSendBoPixel) { + return; + } + shouldSendBoPixel = false; + let bt = config.getConfig('bidderTimeout'); let beaconUrl; if (window.PREBID_TIMEOUT) { diff --git a/test/spec/modules/openxBidAdapter_spec.js b/test/spec/modules/openxBidAdapter_spec.js index b763c111998..e4a1c9a979d 100644 --- a/test/spec/modules/openxBidAdapter_spec.js +++ b/test/spec/modules/openxBidAdapter_spec.js @@ -1,5 +1,5 @@ import {expect} from 'chai'; -import {spec} from 'modules/openxBidAdapter'; +import {spec, resetBoPixel} from 'modules/openxBidAdapter'; import {newBidder} from 'src/adapters/bidderFactory'; import {userSync} from 'src/userSync'; import * as utils from 'src/utils'; @@ -586,6 +586,7 @@ describe('OpenxAdapter', () => { }); it('should register a beacon', () => { + resetBoPixel(); spec.interpretResponse({body: bidResponse}, bidRequest); sinon.assert.calledWith(userSync.registerSync, 'image', 'openx', sinon.match(new RegExp(`\/\/openx-d\.openx\.net.*\/bo\?.*ts=${adUnitOverride.ts}`))); }); @@ -882,6 +883,7 @@ describe('OpenxAdapter', () => { }); it('should register a beacon', () => { + resetBoPixel(); spec.interpretResponse({body: bidResponse}, bidRequestsWithMediaTypes); sinon.assert.calledWith(userSync.registerSync, 'image', 'openx', sinon.match(/^\/\/test-colo\.com/)) sinon.assert.calledWith(userSync.registerSync, 'image', 'openx', sinon.match(/ph=test-ph/));