Skip to content

Commit

Permalink
PubMatic Bid Adapter - Fledge Support (Added support for sending AE:1…
Browse files Browse the repository at this point in the history
… in bidrequest if slot is fledge enabled) (#9942)

* Added support for sending AE:1 in bidrequest if slot is fledge enabled

* PubMatic bid Adapter - Lint issue resolved
  • Loading branch information
pm-nitin-nimbalkar authored Jun 19, 2023
1 parent 6027de5 commit a35cda0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
20 changes: 18 additions & 2 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,14 +630,15 @@ 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;
var nativeObj = {};
var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : [];
var mediaTypes = '';
var format = [];
var isFledgeEnabled = bidderRequest?.fledgeEnabled;

impObj = {
id: bid.bidId,
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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);
}
Expand Down
25 changes: 25 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit a35cda0

Please sign in to comment.