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

appnexusBidAdapter - fix video params #5394

Merged
merged 2 commits into from Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 32 additions & 2 deletions modules/appnexusBidAdapter.js
Expand Up @@ -12,10 +12,28 @@ 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'];
'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,19 @@ 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) {
// may change mimes in the future
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
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
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