Skip to content
New issue

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

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

Already on GitHub? # to your account

PubMatic Bid Adapter : passing POS value from mediaType #12768

Merged
merged 1 commit into from
Feb 18, 2025
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
6 changes: 4 additions & 2 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ const VIDEO_CUSTOM_PARAMS = {
'plcmt': DATA_TYPES.NUMBER,
'minbitrate': DATA_TYPES.NUMBER,
'maxbitrate': DATA_TYPES.NUMBER,
'skip': DATA_TYPES.NUMBER
'skip': DATA_TYPES.NUMBER,
'pos': DATA_TYPES.NUMBER
}

const NATIVE_ASSET_IMAGE_TYPE = {
Expand All @@ -70,7 +71,8 @@ const NATIVE_ASSET_IMAGE_TYPE = {
}

const BANNER_CUSTOM_PARAMS = {
'battr': DATA_TYPES.ARRAY
'battr': DATA_TYPES.ARRAY,
'pos': DATA_TYPES.NUMBER,
}

const NET_REVENUE = true;
Expand Down
20 changes: 15 additions & 5 deletions test/spec/modules/pubmaticBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,20 @@ describe('PubMatic adapter', function () {
bannerAndVideoBidRequests = [
{
code: 'div-banner-video',
ortb2Imp: {
banner: {
pos: 1
}
},
mediaTypes: {
video: {
playerSize: [640, 480],
context: 'instream'
context: 'instream',
pos: 2
},
banner: {
sizes: [[300, 250], [300, 600]]
sizes: [[300, 250], [300, 600]],
pos: 1
}
},
bidder: 'pubmatic',
Expand Down Expand Up @@ -2556,9 +2563,9 @@ describe('PubMatic adapter', function () {
expect(data.user.yob).to.equal(parseInt(multipleMediaRequests[0].params.yob)); // YOB
expect(data.user.gender).to.equal(multipleMediaRequests[0].params.gender); // Gender
expect(data.device.geo.lat).to.equal('36.5189'); // Latitude
expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude
expect(data.user.geo.lat).to.equal('26.8915'); // Latitude
expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude
expect(data.device.geo.lon).to.equal('-76.4063'); // Lognitude
expect(data.user.geo.lat).to.equal('26.8915'); // Latitude
expect(data.user.geo.lon).to.equal('-56.6340'); // Lognitude
expect(data.ext.wrapper.wv).to.equal($$REPO_AND_VERSION$$); // Wrapper Version
expect(data.ext.wrapper.transactionId).to.equal(multipleMediaRequests[0].transactionId); // Prebid TransactionId
expect(data.ext.wrapper.wiid).to.equal(multipleMediaRequests[0].params.wiid); // OpenWrap: Wrapper Impression ID
Expand Down Expand Up @@ -2621,6 +2628,7 @@ describe('PubMatic adapter', function () {
expect(data.banner.h).to.equal(250);
expect(data.banner.format).to.exist;
expect(data.banner.format.length).to.equal(bannerAndVideoBidRequests[0].mediaTypes.banner.sizes.length);
expect(data.banner.pos).to.equal(1);

// Case: when size is not present in adslo
bannerAndVideoBidRequests[0].params.adSlot = '/15671365/DMDemo';
Expand All @@ -2638,6 +2646,7 @@ describe('PubMatic adapter', function () {
expect(data.video).to.exist;
expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]);
expect(data.video.h).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[1]);
expect(data.video.pos).to.equal(2);
});

it('Request params - should handle banner, video and native format in single adunit', function() {
Expand All @@ -2652,6 +2661,7 @@ describe('PubMatic adapter', function () {
expect(data.banner.h).to.equal(250);
expect(data.banner.format).to.exist;
expect(data.banner.format.length).to.equal(bannerAndNativeBidRequests[0].mediaTypes.banner.sizes.length);
expect(data.banner.pos).to.equal(0);

expect(data.video).to.exist;
expect(data.video.w).to.equal(bannerAndVideoBidRequests[0].mediaTypes.video.playerSize[0]);
Expand Down