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

NextMillennium Bid Adapter : fix imp.video.mimes #11216

Merged
merged 27 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7fc2b34
added support for gpp consent string
mhlm Nov 22, 2023
72e2101
changed test for nextMillenniumBidAdapter
mhlm Nov 23, 2023
d897b6b
Merge pull request #4 from nextmillenniummedia/PB-1373-feature/add-su…
mhlm Nov 23, 2023
93f578e
added some tests
mhlm Nov 24, 2023
bd51f48
Merge branch 'master' of github.com:nextmillenniummedia/Prebid.js
mhlm Nov 24, 2023
97396e2
added site.pagecat, site.content.cat and site.content.language to req…
mhlm Nov 25, 2023
a108dad
lint fix
mhlm Nov 25, 2023
b6865e7
formated code
mhlm Nov 25, 2023
763721a
formated code
mhlm Nov 25, 2023
03ffd76
formated code
mhlm Nov 27, 2023
9b7c16b
pachage-lock with prebid
mhlm Dec 1, 2023
281dd54
pachage-lock with prebid
mhlm Dec 1, 2023
d33f078
formatted code
mhlm Dec 1, 2023
c54ffca
Merge branch 'prebid:master' into master
mhlm Dec 4, 2023
28ccc93
added device.sua, user.eids
mhlm Dec 9, 2023
66f0bfb
Merge branch 'prebid:master' into master
mhlm Dec 9, 2023
ca85907
formatted
mhlm Dec 11, 2023
5577fdf
Merge branch 'master' of github.com:nextmillenniummedia/Prebid.js
mhlm Dec 11, 2023
6c1be2d
fixed tests
mhlm Dec 11, 2023
19b4db5
fixed bug functio getSua
mhlm Dec 11, 2023
ade3d69
Merge branch 'prebid:master' into master
mhlm Dec 12, 2023
f0df78e
Merge branch 'prebid:master' into master
mhlm Dec 22, 2023
2199ee2
Merge branch 'prebid:master' into master
mhlm Jan 31, 2024
0cab253
Merge branch 'prebid:master' into master
mhlm Feb 23, 2024
43ee73d
Merge branch 'prebid:master' into master
mhlm Mar 14, 2024
b64f5e8
fixed bug imp.video.mimes
mhlm Mar 14, 2024
a931741
fixed bug imp.video.mimes - 2
mhlm Mar 14, 2024
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
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