diff --git a/modules/pubmaticBidAdapter.js b/modules/pubmaticBidAdapter.js index 6297bd7c066..eb2ad8ccb03 100644 --- a/modules/pubmaticBidAdapter.js +++ b/modules/pubmaticBidAdapter.js @@ -630,7 +630,7 @@ function _addJWPlayerSegmentData(imp, bid) { ext && ext.key_val === undefined ? ext.key_val = jwPlayerData : ext.key_val += '|' + jwPlayerData; } -function _createImpressionObject(bid) { +function _createImpressionObject(bid, bidderRequest) { var impObj = {}; var bannerObj; var videoObj; @@ -638,6 +638,7 @@ function _createImpressionObject(bid) { var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : []; var mediaTypes = ''; var format = []; + var isFledgeEnabled = bidderRequest?.fledgeEnabled; impObj = { id: bid.bidId, @@ -708,11 +709,26 @@ function _createImpressionObject(bid) { _addFloorFromFloorModule(impObj, bid); + _addFledgeflag(impObj, bid, isFledgeEnabled) + return impObj.hasOwnProperty(BANNER) || impObj.hasOwnProperty(NATIVE) || (FEATURES.VIDEO && impObj.hasOwnProperty(VIDEO)) ? impObj : UNDEFINED; } +function _addFledgeflag(impObj, bid, isFledgeEnabled) { + if (isFledgeEnabled) { + impObj.ext = impObj.ext || {}; + if (bid?.ortb2Imp?.ext?.ae !== undefined) { + impObj.ext.ae = bid.ortb2Imp.ext.ae; + } + } else { + if (impObj.ext?.ae) { + delete impObj.ext.ae; + } + } +} + function _addImpressionFPD(imp, bid) { const ortb2 = {...deepAccess(bid, 'ortb2Imp.ext.data')}; Object.keys(ortb2).forEach(prop => { @@ -1095,7 +1111,7 @@ export const spec = { if (bid.params.hasOwnProperty('acat') && isArray(bid.params.acat)) { allowedIabCategories = allowedIabCategories.concat(bid.params.acat); } - var impObj = _createImpressionObject(bid); + var impObj = _createImpressionObject(bid, bidderRequest); if (impObj) { payload.imp.push(impObj); } diff --git a/test/spec/modules/pubmaticBidAdapter_spec.js b/test/spec/modules/pubmaticBidAdapter_spec.js index 12805c7786d..5d8d762e793 100644 --- a/test/spec/modules/pubmaticBidAdapter_spec.js +++ b/test/spec/modules/pubmaticBidAdapter_spec.js @@ -3056,6 +3056,31 @@ describe('PubMatic adapter', function () { expect(data.imp[0]['video']['h']).to.equal(videoBidRequests[0].mediaTypes.video.playerSize[1]); }); } + + describe('Fledge', function() { + it('should not send imp.ext.ae when FLEDGE is disabled, ', function () { + let bidRequest = Object.assign([], bidRequests); + bidRequest[0].ortb2Imp = { + ext: { ae: 1 } + }; + const req = spec.buildRequests(bidRequest, { ...bidRequest, fledgeEnabled: false }); + let data = JSON.parse(req.data); + if (data.imp[0].ext) { + expect(data.imp[0].ext).to.not.have.property('ae'); + } + }); + + it('when FLEDGE is enabled, should send whatever is set in ortb2imp.ext.ae in all bid requests', function () { + let bidRequest = Object.assign([], bidRequests); + delete bidRequest[0].params.test; + bidRequest[0].ortb2Imp = { + ext: { ae: 1 } + }; + const req = spec.buildRequests(bidRequest, { ...bidRequest, fledgeEnabled: true }); + let data = JSON.parse(req.data); + expect(data.imp[0].ext.ae).to.equal(1); + }); + }); }); it('Request params dctr check', function () {