From 3afee8e5c99f43727032bb875e79cacc41c92089 Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 8 Oct 2021 18:37:03 +0300 Subject: [PATCH] improving documentation --- ui/analytics.js | 7 +++-- .../plugins/videojs-aniview/plugin.js | 11 ++++--- ui/component/viewers/videoViewer/view.jsx | 30 +++++++++++++++---- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/ui/analytics.js b/ui/analytics.js index 495535dcc..8b0705304 100644 --- a/ui/analytics.js +++ b/ui/analytics.js @@ -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, diff --git a/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js b/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js index ffe30a867..45b7f043e 100644 --- a/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js +++ b/ui/component/viewers/videoViewer/internal/plugins/videojs-aniview/plugin.js @@ -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 = { diff --git a/ui/component/viewers/videoViewer/view.jsx b/ui/component/viewers/videoViewer/view.jsx index efe534dd1..d6dcf08c4 100644 --- a/ui/component/viewers/videoViewer/view.jsx +++ b/ui/component/viewers/videoViewer/view.jsx @@ -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);