Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubMatic Bid Adapter - Fledge Support (Added support for sending AE:1 in bidrequest if slot is fledge enabled) #9942

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -3047,6 +3047,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