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

[pull] master from prebid:master #18

Merged
merged 7 commits into from
Mar 15, 2024
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
15 changes: 15 additions & 0 deletions modules/jixieBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,21 @@ export const spec = {
}
return bidResponses;
} else { return []; }
},

getUserSyncs: function(syncOptions, serverResponses) {
if (!serverResponses.length || !serverResponses[0].body || !serverResponses[0].body.userSyncs) {
return false;
}
let syncs = [];
serverResponses[0].body.userSyncs.forEach(function(sync) {
if (syncOptions.iframeEnabled) {
syncs.push(sync.uf ? { url: sync.uf, type: 'iframe' } : { url: sync.up, type: 'image' });
} else if (syncOptions.pixelEnabled && sync.up) {
syncs.push({url: sync.up, type: 'image'})
}
})
return syncs;
}
}

Expand Down
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
2 changes: 1 addition & 1 deletion modules/userId/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1096,7 +1096,7 @@ export function init(config, {delay = GreedyPromise.timeout} = {}) {
// init config update listener to start the application
init(config);

module('userId', attachIdSystem);
module('userId', attachIdSystem, { postInstallAllowed: true });

export function setOrtbUserExtEids(ortbRequest, bidderRequest, context) {
const eids = deepAccess(context, 'bidRequests.0.userIdAsEids');
Expand Down
8 changes: 0 additions & 8 deletions modules/yieldmoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,14 +654,6 @@ function validateVideoParams(bid) {
}

validate('video.protocols', val => isDefined(val), paramRequired);
validate(
'video.protocols',
(val) =>
isArrayOfNums(val) &&
val.every((v) => v >= 1 && v <= 12 && v != 9 && v != 10), // 9 and 10 are for DAST which are not supported.
paramInvalid,
'array of numbers between 1 and 12 except for 9 or 10 , ex: [2,3, 7, 11]'
);

validate('video.api', val => isDefined(val), paramRequired);
validate('video.api', val => isArrayOfNums(val) && val.every(v => (v >= 1 && v <= 6)),
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "prebid.js",
"version": "8.41.0-pre",
"version": "8.42.0-pre",
"description": "Header Bidding Management Library",
"main": "src/prebid.js",
"scripts": {
Expand Down
63 changes: 63 additions & 0 deletions test/spec/modules/jixieBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,4 +707,67 @@ describe('jixie Adapter', function () {
expect(jixieaux.ajax.calledWith(TRACKINGURL_)).to.equal(true);
})
}); // describe

describe('getUserSyncs', function () {
it('it should favour iframe over pixel if publisher allows iframe usersync', function () {
const syncOptions = {
'iframeEnabled': true,
'pixelEnabled': true,
}
const response = {
'userSyncs': [
{
'uf': 'https://syncstuff.jixie.io/',
'up': 'https://syncstuff.jixie.io/image.gif'
},
{
'up': 'https://syncstuff.jixie.io/image1.gif'
}
]
}
let result = spec.getUserSyncs(syncOptions, [{ body: response }]);
expect(result[0].type).to.equal('iframe')
expect(result[1].type).to.equal('image')
})

it('it should pick pixel if publisher not allow iframe', function () {
const syncOptions = {
'iframeEnabled': false,
'pixelEnabled': true,
}
const response = {
'userSyncs': [
{
'uf': 'https://syncstuff.jixie.io/',
'up': 'https://syncstuff.jixie.io/image.gif'
},
{
'up': 'https://syncstuff.jixie.io/image1.gif'
}
]
}
let result = spec.getUserSyncs(syncOptions, [{ body: response }]);
expect(result[0].type).to.equal('image')
expect(result[1].type).to.equal('image')
})

it('it should return nothing if pub only allow pixel but all usersyncs are iframe only', function () {
const syncOptions = {
'iframeEnabled': false,
'pixelEnabled': true,
}
const response = {
'userSyncs': [
{
'uf': 'https://syncstuff.jixie.io/',
},
{
'uf': 'https://syncstuff2.jixie.io/',
}
]
}
let result = spec.getUserSyncs(syncOptions, [{ body: response }]);
expect(result.length).to.equal(0)
})
})
});
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
14 changes: 0 additions & 14 deletions test/spec/modules/yieldmoBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,20 +512,6 @@ describe('YieldmoAdapter', function () {
expect(buildVideoBidAndGetVideoParam().mimes).to.deep.equal(['video/mkv']);
});

it('should validate protocol in video bid request', function () {
expect(
spec.isBidRequestValid(
mockVideoBid({}, {}, { protocols: [2, 3, 11] })
)
).to.be.true;

expect(
spec.isBidRequestValid(
mockVideoBid({}, {}, { protocols: [2, 3, 10] })
)
).to.be.false;
});

describe('video.skip state check', () => {
it('should not set video.skip if neither *.video.skip nor *.video.skippable is present', function () {
utils.deepAccess(videoBid, 'mediaTypes.video')['skippable'] = false;
Expand Down
Loading