Skip to content

Commit

Permalink
update prebid-serer bidder params for impressions (prebid#11982)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamc-ins authored Jul 17, 2024
1 parent 730d679 commit cdd3b5a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 32 deletions.
66 changes: 35 additions & 31 deletions modules/insticatorBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,8 @@ function buildVideo(bidRequest) {
const playerSize = deepAccess(bidRequest, 'mediaTypes.video.playerSize');
const context = deepAccess(bidRequest, 'mediaTypes.video.context');

if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
w = parseInt(playerSize[0], 10);
}
}
if (!h && playerSize) {
if (Array.isArray(playerSize[0])) {
h = parseInt(playerSize[0][1], 10);
} else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
h = parseInt(playerSize[1], 10);
}
if (!h && !w && playerSize) {
({w, h} = parsePlayerSizeToWidthHeight(playerSize, w, h));
}

const bidRequestVideo = deepAccess(bidRequest, 'mediaTypes.video');
Expand Down Expand Up @@ -173,6 +162,14 @@ function buildImpression(bidRequest) {
},
}

if (bidRequest?.params?.adUnitId) {
deepSetValue(imp, 'ext.prebid.bidder.insticator.adUnitId', bidRequest.params.adUnitId);
}

if (bidRequest?.params?.publisherId) {
deepSetValue(imp, 'ext.prebid.bidder.insticator.publisherId', bidRequest.params.publisherId);
}

let bidFloor = parseFloat(deepAccess(bidRequest, 'params.floor'));

if (!isNaN(bidFloor)) {
Expand Down Expand Up @@ -247,7 +244,7 @@ function buildDevice(bidRequest) {
const device = {
w: window.innerWidth,
h: window.innerHeight,
js: true,
js: 1,
ext: {
localStorage: storage.localStorageIsEnabled(),
cookies: storage.cookiesAreEnabled(),
Expand Down Expand Up @@ -569,24 +566,12 @@ function validateVideo(bid) {
let w = deepAccess(bid, 'mediaTypes.video.w');
let h = deepAccess(bid, 'mediaTypes.video.h');
const playerSize = deepAccess(bid, 'mediaTypes.video.playerSize');
if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
w = parseInt(playerSize[0], 10);
}
}
if (!h && playerSize) {
if (Array.isArray(playerSize[0])) {
h = parseInt(playerSize[0][1], 10);
} else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
h = parseInt(playerSize[1], 10);
}

if (!h && !w && playerSize) {
({w, h} = parsePlayerSizeToWidthHeight(playerSize, w, h));
}
const videoSize = [
w,
h,
];

const videoSize = [w, h];

if (
!validateSize(videoSize)
Expand Down Expand Up @@ -625,6 +610,25 @@ function validateVideo(bid) {
return true;
}

function parsePlayerSizeToWidthHeight(playerSize, w, h) {
if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
w = parseInt(playerSize[0], 10);
}
}
if (!h && playerSize) {
if (Array.isArray(playerSize[0])) {
h = parseInt(playerSize[0][1], 10);
} else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
h = parseInt(playerSize[1], 10);
}
}

return { w, h };
}

export const spec = {
code: BIDDER_CODE,
gvlid: GVLID,
Expand Down
9 changes: 8 additions & 1 deletion test/spec/modules/insticatorBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ describe('InsticatorBidAdapter', function () {
expect(data.device).to.be.an('object');
expect(data.device.w).to.equal(window.innerWidth);
expect(data.device.h).to.equal(window.innerHeight);
expect(data.device.js).to.equal(true);
expect(data.device.js).to.equal(1);
expect(data.device.ext).to.be.an('object');
expect(data.device.ext.localStorage).to.equal(true);
expect(data.device.ext.cookies).to.equal(false);
Expand Down Expand Up @@ -439,6 +439,13 @@ describe('InsticatorBidAdapter', function () {
insticator: {
adUnitId: bidRequest.params.adUnitId,
},
prebid: {
bidder: {
insticator: {
adUnitId: bidRequest.params.adUnitId,
}
}
}
}
}]);
expect(data.ext).to.be.an('object');
Expand Down

0 comments on commit cdd3b5a

Please sign in to comment.