Skip to content

Commit 78d5117

Browse files
jsalisJohn Salis
and
John Salis
authored
Add skip params to Beachfront adapter (#5847)
* feat: add skip params and standard params to video bid request * refactor: add props to exclude list * refactor: bump adapter version Co-authored-by: John Salis <[email protected]>
1 parent 640a3cd commit 78d5117

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

modules/beachfrontBidAdapter.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ import { VIDEO, BANNER } from '../src/mediaTypes.js';
66
import find from 'core-js-pure/features/array/find.js';
77
import includes from 'core-js-pure/features/array/includes.js';
88

9-
const ADAPTER_VERSION = '1.11';
9+
const ADAPTER_VERSION = '1.12';
1010
const ADAPTER_NAME = 'BFIO_PREBID';
1111
const OUTSTREAM = 'outstream';
1212

1313
export const VIDEO_ENDPOINT = 'https://reachms.bfmio.com/bid.json?exchange_id=';
1414
export const BANNER_ENDPOINT = 'https://display.bfmio.com/prebid_display';
1515
export const OUTSTREAM_SRC = 'https://player-cdn.beachfrontmedia.com/playerapi/loader/outstream.js';
1616

17-
export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement'];
17+
export const VIDEO_TARGETING = ['mimes', 'playbackmethod', 'maxduration', 'placement', 'skip', 'skipmin', 'skipafter'];
1818
export const DEFAULT_MIMES = ['video/mp4', 'application/javascript'];
1919

2020
let appId = '';
@@ -258,12 +258,19 @@ function getTopWindowReferrer() {
258258
}
259259

260260
function getVideoTargetingParams(bid) {
261-
return Object.keys(Object(bid.params.video))
262-
.filter(param => includes(VIDEO_TARGETING, param))
263-
.reduce((obj, param) => {
264-
obj[ param ] = bid.params.video[ param ];
265-
return obj;
266-
}, {});
261+
const result = {};
262+
const excludeProps = ['playerSize', 'context', 'w', 'h'];
263+
Object.keys(Object(bid.mediaTypes.video))
264+
.filter(key => !includes(excludeProps, key))
265+
.forEach(key => {
266+
result[ key ] = bid.mediaTypes.video[ key ];
267+
});
268+
Object.keys(Object(bid.params.video))
269+
.filter(key => includes(VIDEO_TARGETING, key))
270+
.forEach(key => {
271+
result[ key ] = bid.params.video[ key ];
272+
});
273+
return result;
267274
}
268275

269276
function createVideoRequestData(bid, bidderRequest) {

test/spec/modules/beachfrontBidAdapter_spec.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,17 +223,33 @@ describe('BeachfrontAdapter', function () {
223223
expect(data.imp[0].video).to.deep.contain({ w: width, h: height });
224224
});
225225

226-
it('must override video targeting params', function () {
226+
it('must set video params from the standard object', function () {
227227
const bidRequest = bidRequests[0];
228228
const mimes = ['video/webm'];
229229
const playbackmethod = 2;
230230
const maxduration = 30;
231231
const placement = 4;
232-
bidRequest.mediaTypes = { video: {} };
233-
bidRequest.params.video = { mimes, playbackmethod, maxduration, placement };
232+
const skip = 1;
233+
bidRequest.mediaTypes = {
234+
video: { mimes, playbackmethod, maxduration, placement, skip }
235+
};
236+
const requests = spec.buildRequests([ bidRequest ]);
237+
const data = requests[0].data;
238+
expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement, skip });
239+
});
240+
241+
it('must override video params from the bidder object', function () {
242+
const bidRequest = bidRequests[0];
243+
const mimes = ['video/webm'];
244+
const playbackmethod = 2;
245+
const maxduration = 30;
246+
const placement = 4;
247+
const skip = 1;
248+
bidRequest.mediaTypes = { video: { placement: 3, skip: 0 } };
249+
bidRequest.params.video = { mimes, playbackmethod, maxduration, placement, skip };
234250
const requests = spec.buildRequests([ bidRequest ]);
235251
const data = requests[0].data;
236-
expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement });
252+
expect(data.imp[0].video).to.deep.contain({ mimes, playbackmethod, maxduration, placement, skip });
237253
});
238254

239255
it('must add US privacy data to the request', function () {

0 commit comments

Comments
 (0)