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

Insticator: Update prebid-server bidder params for impressions #11982

Merged
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
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
Loading