Skip to content

Commit

Permalink
NextMillennium Bid Adapter : fix imp.video.mimes (prebid#11216)
Browse files Browse the repository at this point in the history
* added support for gpp consent string

* changed test for nextMillenniumBidAdapter

* added some tests

* added site.pagecat, site.content.cat and site.content.language to request

* lint fix

* formated code

* formated code

* formated code

* pachage-lock with prebid

* pachage-lock with prebid

* formatted code

* added device.sua, user.eids

* formatted

* fixed tests

* fixed bug functio getSua

* fixed bug imp.video.mimes

* fixed bug imp.video.mimes - 2
  • Loading branch information
mhlm authored Mar 15, 2024
1 parent 9a978bd commit 44717bc
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 36 deletions.
85 changes: 52 additions & 33 deletions modules/nextMillenniumBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,24 @@ const REPORT_ENDPOINT = 'https://report2.hb.brainlyads.com/statistics/metric';
const TIME_TO_LIVE = 360;
const DEFAULT_CURRENCY = 'USD';

const VIDEO_PARAMS = [
'api',
'linearity',
'maxduration',
'mimes',
'minduration',
'placement',
'playbackmethod',
'protocols',
'startdelay',
];
const VIDEO_PARAMS_DEFAULT = {
api: undefined,
linearity: undefined,
maxduration: undefined,
mimes: [
'video/mp4',
'video/x-ms-wmv',
'application/javascript',
],

minduration: undefined,
placement: undefined,
playbackmethod: undefined,
protocols: undefined,
startdelay: undefined,
};

const VIDEO_PARAMS = Object.keys(VIDEO_PARAMS_DEFAULT);
const ALLOWED_ORTB2_PARAMETERS = [
'site.pagecat',
'site.content.cat',
Expand Down Expand Up @@ -267,33 +273,46 @@ export function getImp(bid, id, mediaTypes) {
},
};

if (banner) {
if (banner.bidfloorcur) imp.bidfloorcur = banner.bidfloorcur;
if (banner.bidfloor) imp.bidfloor = banner.bidfloor;
getImpBanner(imp, banner);
getImpVideo(imp, video);

const format = (banner.data?.sizes || []).map(s => { return {w: s[0], h: s[1]} })
const {w, h} = (format[0] || {})
imp.banner = {
w,
h,
format,
};
};
return imp;
};

if (video) {
if (video.bidfloorcur) imp.bidfloorcur = video.bidfloorcur;
if (video.bidfloor) imp.bidfloor = video.bidfloor;
export function getImpBanner(imp, banner) {
if (!banner) return;

imp.video = getDefinedParams(video, VIDEO_PARAMS);
if (video.data.playerSize) {
imp.video = Object.assign(imp.video, parseGPTSingleSizeArrayToRtbSize(video.data.playerSize) || {});
} else if (video.w && video.h) {
imp.video.w = video.w;
imp.video.h = video.h;
};
if (banner.bidfloorcur) imp.bidfloorcur = banner.bidfloorcur;
if (banner.bidfloor) imp.bidfloor = banner.bidfloor;

const format = (banner.data?.sizes || []).map(s => { return {w: s[0], h: s[1]} })
const {w, h} = (format[0] || {})
imp.banner = {
w,
h,
format,
};
};

return imp;
export function getImpVideo(imp, video) {
if (!video) return;

if (video.bidfloorcur) imp.bidfloorcur = video.bidfloorcur;
if (video.bidfloor) imp.bidfloor = video.bidfloor;

imp.video = getDefinedParams(video.data, VIDEO_PARAMS);
Object.keys(VIDEO_PARAMS_DEFAULT)
.filter(videoParamName => VIDEO_PARAMS_DEFAULT[videoParamName])
.forEach(videoParamName => {
if (typeof imp.video[videoParamName] === 'undefined') imp.video[videoParamName] = VIDEO_PARAMS_DEFAULT[videoParamName];
});

if (video.data.playerSize) {
imp.video = Object.assign(imp.video, parseGPTSingleSizeArrayToRtbSize(video.data?.playerSize) || {});
} else if (video.data.w && video.data.h) {
imp.video.w = video.data.w;
imp.video.h = video.data.h;
};
};

export function setConsentStrings(postBody = {}, bidderRequest) {
Expand Down
37 changes: 34 additions & 3 deletions test/spec/modules/nextMillenniumBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ describe('nextMillenniumBidAdapterTests', () => {
data: {
id: '234',
bid: {
mediaTypes: {video: {playerSize: [400, 300]}},
mediaTypes: {video: {playerSize: [400, 300], api: [2], placement: 1, plcmt: 1}},
adUnitCode: 'test-video-1',
},

mediaTypes: {
video: {
data: {playerSize: [400, 300]},
data: {playerSize: [400, 300], api: [2], placement: 1, plcmt: 1},
bidfloorcur: 'USD',
},
},
Expand All @@ -59,7 +59,38 @@ describe('nextMillenniumBidAdapterTests', () => {
id: 'test-video-1',
bidfloorcur: 'USD',
ext: {prebid: {storedrequest: {id: '234'}}},
video: {w: 400, h: 300},
video: {
mimes: ['video/mp4', 'video/x-ms-wmv', 'application/javascript'],
api: [2],
placement: 1,
w: 400,
h: 300,
},
},
},

{
title: 'imp - mediaTypes.video is empty',
data: {
id: '234',
bid: {
mediaTypes: {video: {w: 640, h: 480}},
adUnitCode: 'test-video-2',
},

mediaTypes: {
video: {
data: {w: 640, h: 480},
bidfloorcur: 'USD',
},
},
},

expected: {
id: 'test-video-2',
bidfloorcur: 'USD',
ext: {prebid: {storedrequest: {id: '234'}}},
video: {w: 640, h: 480, mimes: ['video/mp4', 'video/x-ms-wmv', 'application/javascript']},
},
},
];
Expand Down

0 comments on commit 44717bc

Please sign in to comment.