Skip to content

Commit

Permalink
Added logic to send pos to pubmatic adapter (#12768)
Browse files Browse the repository at this point in the history
Added logic to send pos to pubmatic adapter

1st draft Changes

change in pos logic

Update pubmaticBidAdapter.js

updated test case for pos

Update pubmaticAnalyticsAdapter.js

changes sending pos in translator and test cases fix

Update pubmaticBidAdapter.js
  • Loading branch information
pm-asit-sahoo authored Feb 18, 2025
1 parent aa7fc97 commit 0d60466
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
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

0 comments on commit 0d60466

Please # to comment.