浏览代码

fix(screenshare) Add timestamp to desktop track

Send screenshare duration to analytics
master
robertpin 3 年前
父节点
当前提交
92c6324ff3
共有 3 个文件被更改,包括 12 次插入3 次删除
  1. 5
    1
      conference.js
  2. 6
    2
      react/features/analytics/AnalyticsEvents.js
  3. 1
    0
      react/features/base/tracks/middleware.js

+ 5
- 1
conference.js 查看文件

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

+ 6
- 2
react/features/analytics/AnalyticsEvents.js 查看文件

602
  * occurred (e.g. It was started or stopped).
602
  * occurred (e.g. It was started or stopped).
603
  *
603
  *
604
  * @param {string} action - The action which occurred.
604
  * @param {string} action - The action which occurred.
605
+ * @param {number?} value - The screenshare duration in seconds.
605
  * @returns {Object} The event in a format suitable for sending via
606
  * @returns {Object} The event in a format suitable for sending via
606
  * sendAnalytics.
607
  * sendAnalytics.
607
  */
608
  */
608
-export function createScreenSharingEvent(action) {
609
+export function createScreenSharingEvent(action, value = null) {
609
     return {
610
     return {
610
         action,
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 查看文件

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

正在加载...
取消
保存