improving documentation
This commit is contained in:
parent
26fc53bb4d
commit
3afee8e5c9
3 changed files with 35 additions and 13 deletions
|
@ -240,7 +240,7 @@ const analytics: Analytics = {
|
|||
startWatchmanIntervalIfNotRunning();
|
||||
}
|
||||
},
|
||||
videoStartEvent: (claimId, duration, poweredBy, passedUserId, canonicalUrl, passedPlayer) => {
|
||||
videoStartEvent: (claimId, timeToStartVideo, poweredBy, passedUserId, canonicalUrl, passedPlayer) => {
|
||||
// populate values for watchman when video starts
|
||||
userId = passedUserId;
|
||||
claimUrl = canonicalUrl;
|
||||
|
@ -249,8 +249,8 @@ const analytics: Analytics = {
|
|||
videoType = passedPlayer.currentSource().type;
|
||||
videoPlayer = passedPlayer;
|
||||
|
||||
sendPromMetric('time_to_start', duration);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, duration);
|
||||
sendPromMetric('time_to_start', timeToStartVideo);
|
||||
sendMatomoEvent('Media', 'TimeToStart', claimId, timeToStartVideo);
|
||||
},
|
||||
error: (message) => {
|
||||
return new Promise((resolve) => {
|
||||
|
@ -319,6 +319,7 @@ const analytics: Analytics = {
|
|||
|
||||
apiLogView: (uri, outpoint, claimId, timeToStart) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
if (internalAnalyticsEnabled && (isProduction || devInternalApis)) {
|
||||
const params: {
|
||||
uri: string,
|
||||
|
|
|
@ -31,11 +31,14 @@ const VERSION = '0.0.1';
|
|||
// live channel
|
||||
// b354389c7adb506d0bd9a4
|
||||
|
||||
// ford ad
|
||||
// 612fb75a42715a07645a614c
|
||||
|
||||
// Modified to work with IMA
|
||||
const macroUrl =
|
||||
`https://vast.aniview.com/api/adserver61/vast/` +
|
||||
`?AV_PUBLISHERID=60afcbc58cfdb065440d2426` +
|
||||
`&AV_CHANNELID=612fb75a42715a07645a614c` +
|
||||
`&AV_CHANNELID=b354389c7adb506d0bd9a4` +
|
||||
`&AV_URL=[URL]` +
|
||||
`&cb=[CACHEBUSTING]` +
|
||||
`&AV_WIDTH=[WIDTH]` +
|
||||
|
@ -44,11 +47,11 @@ const macroUrl =
|
|||
// `&AV_CCPA=[CCPA_MACRO]` +
|
||||
// `&AV_GDPR=[GDPR_MACRO]` +
|
||||
// `&AV_CONSENT=[CONSENT_MACRO]` +
|
||||
`&skip=true` +
|
||||
`&skiptimer=5` +
|
||||
`&skip=false` +
|
||||
`&skiptimer=2` +
|
||||
`&logo=true` +
|
||||
`&usevslot=true` +
|
||||
`&vastretry=5` +
|
||||
`&vastretry=2` +
|
||||
`&hidecontrols=false`;
|
||||
|
||||
const defaults = {
|
||||
|
|
|
@ -152,6 +152,7 @@ function VideoViewer(props: Props) {
|
|||
};
|
||||
}, [embedded, videoPlaybackRate]);
|
||||
|
||||
// TODO: analytics functionality
|
||||
function doTrackingBuffered(e: Event, data: any) {
|
||||
fetch(source, { method: 'HEAD', cache: 'no-store' }).then((response) => {
|
||||
data.playerPoweredBy = response.headers.get('x-powered-by');
|
||||
|
@ -159,21 +160,37 @@ function VideoViewer(props: Props) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Analytics functionality that is run on first video start
|
||||
* @param e - event from videojs (from the plugin?)
|
||||
* @param data - only has secondsToLoad property
|
||||
*/
|
||||
function doTrackingFirstPlay(e: Event, data: any) {
|
||||
let timeToStart = data.secondsToLoad;
|
||||
// how long until the video starts
|
||||
let timeToStartVideo = data.secondsToLoad;
|
||||
|
||||
if (desktopPlayStartTime !== undefined) {
|
||||
const differenceToAdd = Date.now() - desktopPlayStartTime;
|
||||
timeToStart += differenceToAdd;
|
||||
// TODO: what's happening here briefly?
|
||||
if (!IS_WEB) {
|
||||
if (desktopPlayStartTime !== undefined) {
|
||||
const differenceToAdd = Date.now() - desktopPlayStartTime;
|
||||
timeToStartVideo += differenceToAdd;
|
||||
}
|
||||
}
|
||||
|
||||
// send matomo event (embedded is boolean)
|
||||
analytics.playerStartedEvent(embedded);
|
||||
|
||||
// figure out what server the video is served from and then run start analytic event
|
||||
fetch(source, { method: 'HEAD', cache: 'no-store' }).then((response) => {
|
||||
// server string such as 'eu-p6'
|
||||
let playerPoweredBy = response.headers.get('x-powered-by') || '';
|
||||
analytics.videoStartEvent(claimId, timeToStart, playerPoweredBy, userId, claim.canonical_url, this);
|
||||
|
||||
// populates data for watchman, sends prom and matomo event
|
||||
analytics.videoStartEvent(claimId, timeToStartVideo, playerPoweredBy, userId, claim.canonical_url, this);
|
||||
});
|
||||
|
||||
doAnalyticsView(uri, timeToStart).then(() => {
|
||||
// hit backend to mark a view
|
||||
doAnalyticsView(uri, timeToStartVideo).then(() => {
|
||||
claimRewards();
|
||||
});
|
||||
}
|
||||
|
@ -256,6 +273,7 @@ function VideoViewer(props: Props) {
|
|||
clearPosition(uri);
|
||||
}, [adUrl, autoplayNext, clearPosition, collectionId, embedded, ended, setAdUrl, uri]);
|
||||
|
||||
// MORE ON PLAY STUFF
|
||||
function onPlay(player) {
|
||||
setEnded(false);
|
||||
setIsLoading(false);
|
||||
|
|
Loading…
Reference in a new issue