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

pubmaticBidAdapter: battr in in banner requests #11917

Merged
merged 30 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d8c3dcc
Merge pull request #1 from prebid/master
pm-nitin-shirsat Oct 11, 2022
2dedab6
Implement functionality for deal priority
pm-nitin-shirsat Oct 12, 2022
afae888
Update test cases
pm-nitin-shirsat Oct 12, 2022
9447e84
kick off test manually
ChrisHuie Oct 13, 2022
400af75
Merge branch 'master' of https://github.com/prebid/Prebid.js into pre…
pm-nitin-shirsat May 3, 2023
5896b10
Merge branch 'prebid-master'
pm-nitin-shirsat May 3, 2023
ade41d3
Added support of GPP to PubMatic adapter
pm-nitin-shirsat May 3, 2023
7d0b86d
Merge pull request #3 from prebid/master
pm-nitin-shirsat May 12, 2023
caeae1a
Merge branch 'prebid-master-new' into master
pm-nitin-shirsat Jun 29, 2023
f21764b
Merge pull request #5 from pm-nitin-shirsat/master
pm-nitin-shirsat Jun 29, 2023
826e6e7
Merge pull request #6 from pm-nitin-shirsat/prebid-master-new
pm-nitin-shirsat Jun 29, 2023
92846e9
gpp_sid in user syncs supposed to encode as a string, not an array
pm-nitin-shirsat Jun 30, 2023
f92818a
Remove extra space
pm-nitin-shirsat Jul 5, 2023
fcb0dde
Remove trailing spaces
pm-nitin-shirsat Jul 5, 2023
51fc097
Merge pull request #7 from prebid/master
pm-nitin-shirsat Jul 31, 2023
6a72e8c
Merge pull request #8 from prebid/master
pm-nitin-shirsat Aug 25, 2023
2432d2f
Merge pull request #9 from prebid/master
pm-nitin-shirsat Sep 12, 2023
9fc89c6
Merge pull request #10 from prebid/master
pm-nitin-shirsat May 22, 2024
70b6e36
Remove the placement parameter and update test cases accordingly, Add…
pm-nitin-shirsat May 23, 2024
a3667c1
Supporting placement parameter and logging warning message, for the p…
pm-nitin-shirsat May 24, 2024
484c691
Remove commented code
pm-nitin-shirsat May 28, 2024
39af04f
Merge pull request #11 from prebid/master
pm-nitin-shirsat May 30, 2024
415037f
Merge pull request #12 from prebid/master
pm-nitin-shirsat May 31, 2024
14db919
Added plcmt in the pubmaticBidAdapter.md file
pm-nitin-shirsat May 31, 2024
8761239
Merge pull request #13 from prebid/master
pm-nitin-shirsat Jun 27, 2024
6cfb9be
Adding support for Banner battr object
pm-nitin-shirsat Jul 1, 2024
74330a8
Merge pull request #15 from prebid/master
pm-nitin-shirsat Jul 3, 2024
26a9bde
Merge pull request #16 from prebid/master
pm-nitin-shirsat Jul 4, 2024
cb85e20
reading battr from ortb2Imp.banner
pm-nitin-shirsat Jul 4, 2024
11e3c90
Merge branch 'UOE-10758' of https://github.com/pm-nitin-shirsat/Prebi…
pm-nitin-shirsat Jul 4, 2024
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
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