-
Notifications
You must be signed in to change notification settings - Fork 1
Player integration for Freewheel video ad server #177
base: master
Are you sure you want to change the base?
Changes from 5 commits
cc9115f
fa3aeeb
57f4d6c
01e1e8f
67940ab
80ff21e
b5e393b
1889522
74f7633
12d2e85
54018d8
c7c7150
2d9ea9a
16c0d31
de5e7a2
197df85
b6f5c0c
b716fdd
e8acadb
aeca9b9
4f97e9b
fe7e831
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,10 @@ import Comscore from '../plugins/comscore'; | |
|
||
import React, { PropTypes } from 'react'; | ||
import invariant from 'invariant'; | ||
import SETTINGS from 'bulbs-elements/settings'; | ||
|
||
// FIXME: where should this be defined? Per-app? | ||
// Or in some better sort of settings file here? | ||
global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = 'UA-223393-14'; | ||
global.BULBS_ELEMENTS_COMSCORE_ID = '6036328'; | ||
global.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID = SETTINGS.BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID; | ||
global.BULBS_ELEMENTS_COMSCORE_ID = SETTINGS.BULBS_ELEMENTS_COMSCORE_ID; | ||
|
||
let prefixCount = 0; | ||
function makeGaPrefix () { | ||
|
@@ -40,6 +39,11 @@ export default class Revealed extends React.Component { | |
'`<bulbs-video>` requires `jwplayer` to be in global scope.' | ||
); | ||
|
||
invariant( | ||
window.isMobile, | ||
'`<bulbs-video>` requires `isMobile()` to be set on window.' | ||
); | ||
|
||
let gaPrefix = makeGaPrefix(); | ||
ga('create', BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID, 'auto', { name: gaPrefix }); | ||
|
||
|
@@ -156,13 +160,54 @@ export default class Revealed extends React.Component { | |
return false; | ||
} | ||
|
||
vastUrl (videoMeta) { | ||
let baseUrl = 'http://us-theonion.videoplaza.tv/proxy/distributor/v2?rt=vast_2.0'; | ||
getProfValue () { | ||
if (window.isMobile.any) { | ||
return 'theonion_mobileweb_html5'; | ||
} else { | ||
return 'theonion_desktop_html5'; | ||
} | ||
} | ||
|
||
setDeviceAcronym () { | ||
if (window.isMobile.any) { | ||
return 'm'; | ||
} else { | ||
return 'd'; | ||
} | ||
} | ||
|
||
getSiteName () { | ||
return window.location.host.split('.')[1]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We actually want this to be the I'm not sure we actually need this method at all, since we should be able to pull this value direct from the video props There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. some videos have their |
||
} | ||
|
||
getDfpSection () { | ||
if (window.TARGETING.dfp_section) { | ||
return window.TARGETING.dfp_section; | ||
} else if (window.TARGETING.dfp_specialcoverage) { | ||
let slug = window.TARGETING.dfp_specialcoverage; | ||
return `specialcoverage_${slug}`; | ||
} else { | ||
return 'video'; | ||
} | ||
} | ||
|
||
getCsidValue (videoMeta) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should try to make the method name for this much more descriptive than |
||
let deviceAcronym = this.setDeviceAcronym(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to differentiate from values we are pulling in from other places the vs values we are setting. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but I suppose its really 6 of one half a dozen of the other |
||
let siteName = this.getSiteName(); | ||
let dfpSection = this.getDfpSection(); | ||
|
||
|
||
return `${deviceAcronym}.${siteName}_${dfpSection}_${videoMeta.hostChannel}`; | ||
} | ||
|
||
vastUrl (videoMeta) { | ||
let baseUrl = `http://${SETTINGS.FREEWHEEL_NETWORK_ID}.v.fwmrm.net/ad/g/1?`; | ||
let vastTestId = this.vastTest(window.location.search); | ||
|
||
// AD_TYPE: one of p (preroll), m (midroll), po (postroll), o (overlay) | ||
baseUrl += '&tt=p'; | ||
let prof = this.getProfValue(); | ||
baseUrl += '&resp=' + 'vmap1'; | ||
baseUrl += '&prof=' + prof; | ||
|
||
videoMeta.tags.push('html5'); // Force HTML 5 | ||
// Tags | ||
baseUrl += '&t=' + videoMeta.tags; | ||
|
@@ -184,6 +229,8 @@ export default class Revealed extends React.Component { | |
return baseUrl; | ||
} | ||
|
||
|
||
|
||
extractTrackCaptions (sources, defaultCaptions) { | ||
let captions = []; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
let settings = { | ||
base: { | ||
BULBS_ELEMENTS_ONIONSTUDIOS_GA_ID: 'UA-223393-14', | ||
BULBS_ELEMENTS_COMSCORE_ID: '6036328', | ||
}, | ||
development: { | ||
FREEWHEEL_NETWORK_ID: '111976', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these network IDs should actually be stored in each property's python settings and then passed into the the bulbs-element somehow, maybe even as a namespaced variable on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. my logic behind it was that they were the same for each site, so we wouldn't have to repeat them. And I just felt weird about putting them on the window. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So far we've been kicking the can down the road on some of these bulbs-elements settings. I think this is a good step to have a module that exports settings. Maybe we could add a settings object to the properties header (before bulbs-elements is loaded). <script>
window.BULBS_ELEMENTS_SETTINGS = {};
</script> And in if (window.BULBS_ELEMENTS_SETTINGS) {
Object.assign(settings, window.BULBS_ELEMENTS_SETTINGS);
} Then we can decide where a setting should live on a case-by-case basis. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the long-term I'd like to get But 1 settings.py location and 1 settings.js location beats having these settings strewn about the individual js files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if the end goal is to have all the settings in one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
}, | ||
test: { | ||
FREEWHEEL_NETWORK_ID: '111976', | ||
}, | ||
production: { | ||
FREEWHEEL_NETWORK_ID: '112214', | ||
} | ||
} | ||
|
||
function getEnvironment () { | ||
let envValues; | ||
if (process.env.NODE_ENV === 'production') { | ||
envValues = settings.production; | ||
} else if ( process.env.NODE_ENV === 'test') { | ||
envValues = settings.test; | ||
} else { | ||
envValues = settings.development; | ||
} | ||
return Object.assign(settings.base, envValues); | ||
}; | ||
|
||
let SETTINGS = getEnvironment(); | ||
export default SETTINGS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than dump this on settings, I think we should just read it from
SETTINGS
every time we use these values.