Skip to content

Commit

Permalink
Supporting battr param to pubmaticBidAdapter in banner requests (preb…
Browse files Browse the repository at this point in the history
…id#11917)

* Implement functionality for deal priority

* Update test cases

* kick off test manually

* Added support of GPP to PubMatic adapter

* gpp_sid in user syncs supposed to encode as a string, not an array

* Remove extra space

* Remove trailing spaces

* Remove the placement parameter and update test cases accordingly, Add plcmt parameter.

* Supporting placement parameter and logging warning message, for the plcmt parameter, if it is missing.

* Remove commented code

* Added plcmt in the pubmaticBidAdapter.md file

* Adding support for Banner battr object

* reading battr from ortb2Imp.banner

---------

Co-authored-by: Chris Huie <phoenixtechnerd@gmail.com>
  • Loading branch information
2 people authored and DecayConstant committed Jul 18, 2024
1 parent 263bcd3 commit 120a449
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
12 changes: 12 additions & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ const NATIVE_ASSET_IMAGE_TYPE = {
'IMAGE': 3
}

const BANNER_CUSTOM_PARAMS = {
'battr': DATA_TYPES.ARRAY
}

const NET_REVENUE = true;
const dealChannelValues = {
1: 'PMP',
Expand Down Expand Up @@ -551,6 +555,14 @@ function _createBannerRequest(bid) {
}
bannerObj.pos = 0;
bannerObj.topframe = inIframe() ? 0 : 1;

// Adding Banner custom params
const bannerCustomParams = {...deepAccess(bid, 'ortb2Imp.banner')};
for (let key in BANNER_CUSTOM_PARAMS) {
if (bannerCustomParams.hasOwnProperty(key)) {
bannerObj[key] = _checkParamDataType(key, bannerCustomParams[key], BANNER_CUSTOM_PARAMS[key]);
}
}
} else {
logWarn(LOG_WARN_PREFIX + 'Error: mediaTypes.banner.size missing for adunit: ' + bid.params.adUnit + '. Ignoring the banner impression in the adunit.');
bannerObj = UNDEFINED;
Expand Down
40 changes: 40 additions & 0 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4084,6 +4084,46 @@ describe('PubMatic adapter', function () {
})
});
}

describe('Banner Request param battr checking', function() {
it('should add battr params to bannerObj if present in ortb2Imp.banner', function() {
let originalBidRequests = utils.deepClone(bidRequests);
let bannerObj = utils.deepClone(originalBidRequests[0].ortb2Imp.banner);
originalBidRequests[0].ortb2Imp.banner = Object.assign(bannerObj, {
battr: [1, 2]
});

const req = spec.buildRequests(originalBidRequests, {
auctionId: 'new-auction-id'
});
let data = JSON.parse(req.data);
expect(data.imp[0]['banner']['battr']).to.exist.and.to.be.an('array');
expect(data.imp[0]['banner']['battr'][0]).to.equal(originalBidRequests[0].ortb2Imp.banner['battr'][0]);
expect(data.imp[0]['banner']['battr'][1]).to.equal(originalBidRequests[0].ortb2Imp.banner['battr'][1]);
});

it('should not add battr params to bannerObj if not present in ortb2Imp.banner', function() {
const req = spec.buildRequests(bidRequests, {
auctionId: 'new-auction-id'
});
let data = JSON.parse(req.data);
expect(data.imp[0]['banner']['battr']).to.equal(undefined);
});

it('should not add battr params if _checkParamDataType returns undefined (Mismatch data type)', function() {
let originalBidRequests = utils.deepClone(bidRequests);
let bannerObj = utils.deepClone(originalBidRequests[0].ortb2Imp.banner);
originalBidRequests[0].ortb2Imp.banner = Object.assign(bannerObj, {
battr: 1
});

const req = spec.buildRequests(originalBidRequests, {
auctionId: 'new-auction-id'
});
let data = JSON.parse(req.data);
expect(data.imp[0]['banner']['battr']).to.equal(undefined);
});
});
});

if (FEATURES.VIDEO) {
Expand Down

0 comments on commit 120a449

Please sign in to comment.