Skip to content

Commit

Permalink
appnexusBidAdapter - fix video params (prebid#5394)
Browse files Browse the repository at this point in the history
* appnexusBidAdapter - fix video params

* remove mimes field
  • Loading branch information
jsnellbaker authored and iggyfisk committed Jun 22, 2020
1 parent 8a13aa6 commit 046cb20
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
35 changes: 32 additions & 3 deletions modules/appnexusBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,29 @@ import { getStorageManager } from '../src/storageManager.js';

const BIDDER_CODE = 'appnexus';
const URL = 'https://ib.adnxs.com/ut/v3/prebid';
const VIDEO_TARGETING = ['id', 'mimes', 'minduration', 'maxduration',
'startdelay', 'skippable', 'playback_method', 'frameworks'];
const VIDEO_TARGETING = ['id', 'minduration', 'maxduration',
'skippable', 'playback_method', 'frameworks', 'context', 'skipoffset'];
const USER_PARAMS = ['age', 'externalUid', 'segments', 'gender', 'dnt', 'language'];
const APP_DEVICE_PARAMS = ['geo', 'device_id']; // appid is collected separately
const DEBUG_PARAMS = ['enabled', 'dongle', 'member_id', 'debug_timeout'];
const VIDEO_MAPPING = {
playback_method: {
'unknown': 0,
'auto_play_sound_on': 1,
'auto_play_sound_off': 2,
'click_to_play': 3,
'mouse_over': 4,
'auto_play_sound_unknown': 5
},
context: {
'unknown': 0,
'pre_roll': 1,
'mid_roll': 2,
'post_roll': 3,
'outstream': 4,
'in-banner': 5
}
};
const NATIVE_MAPPING = {
body: 'description',
body2: 'desc2',
Expand Down Expand Up @@ -711,7 +729,18 @@ function bidToTag(bid) {
// place any valid video params on the tag
Object.keys(bid.params.video)
.filter(param => includes(VIDEO_TARGETING, param))
.forEach(param => tag.video[param] = bid.params.video[param]);
.forEach(param => {
switch (param) {
case 'context':
case 'playback_method':
let type = bid.params.video[param];
type = (utils.isArray(type)) ? type[0] : type;
tag.video[param] = VIDEO_MAPPING[param][type];
break;
default:
tag.video[param] = bid.params.video[param];
}
});
}

if (bid.renderer) {
Expand Down
2 changes: 1 addition & 1 deletion modules/appnexusBidAdapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var adUnits = [
placementId: 13232385,
video: {
skippable: true,
playback_method: ['auto_play_sound_off']
playback_method: 'auto_play_sound_off'
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/appnexusBidAdapter_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ describe('AppNexusAdapter', function () {
const payload = JSON.parse(request.data);
expect(payload.tags[0].video).to.deep.equal({
skippable: true,
playback_method: ['auto_play_sound_off'],
playback_method: 2,
custom_renderer_present: true
});
expect(payload.tags[1].video).to.deep.equal({
skippable: true,
playback_method: ['auto_play_sound_off']
playback_method: 2
});
});

Expand Down

0 comments on commit 046cb20

Please sign in to comment.