Browse Source

fix(screenshare) Add timestamp to desktop track

Send screenshare duration to analytics
master
robertpin 2 years ago
parent
commit
92c6324ff3

+ 5
- 1
conference.js View File

@@ -107,6 +107,7 @@ import {
107 107
     getLocalJitsiAudioTrack,
108 108
     getLocalJitsiVideoTrack,
109 109
     getLocalTracks,
110
+    getLocalVideoTrack,
110 111
     isLocalCameraTrackMuted,
111 112
     isLocalTrackMuted,
112 113
     isUserInteractionRequiredForUnmute,
@@ -1549,6 +1550,8 @@ export default {
1549 1550
         if (config.enableScreenshotCapture) {
1550 1551
             APP.store.dispatch(toggleScreenshotCaptureSummary(false));
1551 1552
         }
1553
+        const tracks = APP.store.getState()['features/base/tracks'];
1554
+        const timestamp = getLocalVideoTrack(tracks)?.timestamp ?? 0;
1552 1555
 
1553 1556
         // It can happen that presenter GUM is in progress while screensharing is being turned off. Here it needs to
1554 1557
         // wait for that GUM to be resolved in order to prevent leaking the presenter track(this.localPresenterVideo
@@ -1610,7 +1613,8 @@ export default {
1610 1613
         return promise.then(
1611 1614
             () => {
1612 1615
                 this.videoSwitchInProgress = false;
1613
-                sendAnalytics(createScreenSharingEvent('stopped'));
1616
+                sendAnalytics(createScreenSharingEvent('stopped',
1617
+                    timestamp === 0 ? null : (Date.now() / 1000) - timestamp));
1614 1618
                 logger.info('Screen sharing stopped.');
1615 1619
             },
1616 1620
             error => {

+ 6
- 2
react/features/analytics/AnalyticsEvents.js View File

@@ -602,13 +602,17 @@ export function createVideoBlurEvent(action) {
602 602
  * occurred (e.g. It was started or stopped).
603 603
  *
604 604
  * @param {string} action - The action which occurred.
605
+ * @param {number?} value - The screenshare duration in seconds.
605 606
  * @returns {Object} The event in a format suitable for sending via
606 607
  * sendAnalytics.
607 608
  */
608
-export function createScreenSharingEvent(action) {
609
+export function createScreenSharingEvent(action, value = null) {
609 610
     return {
610 611
         action,
611
-        actionSubject: 'screen.sharing'
612
+        actionSubject: 'screen.sharing',
613
+        attributes: {
614
+            value
615
+        }
612 616
     };
613 617
 }
614 618
 

+ 1
- 0
react/features/base/tracks/middleware.js View File

@@ -57,6 +57,7 @@ MiddlewareRegistry.register(store => next => action => {
57 57
         // The devices list needs to be refreshed when no initial video permissions
58 58
         // were granted and a local video track is added by umuting the video.
59 59
         if (action.track.local) {
60
+            action.track.timestamp = Date.now() / 1000;
60 61
             store.dispatch(getAvailableDevices());
61 62
         }
62 63
 

Loading…
Cancel
Save