Ver código fonte

feat(recording): Add analytics.

master
hristoterezov 7 anos atrás
pai
commit
d3bf0b7862

+ 21
- 0
react/features/analytics/AnalyticsEvents.js Ver arquivo

@@ -350,6 +350,27 @@ export function createRecordingDialogEvent(dialogName, buttonName) {
350 350
     };
351 351
 }
352 352
 
353
+/**
354
+ * Creates an event which indicates that an action related to recording has
355
+ * occured.
356
+ *
357
+ * @param {string} action - The action (e.g. 'start' or 'stop').
358
+ * @param {string} type - The recording type (e.g. 'file' or 'live').
359
+ * @param {number} value - The duration of the recording in seconds (for stop
360
+ * action).
361
+ * @returns {Object} The event in a format suitable for sending via
362
+ * sendAnalytics.
363
+ */
364
+export function createRecordingEvent(action, type, value) {
365
+    return {
366
+        action,
367
+        actionSubject: `recording.${type}`,
368
+        attributes: {
369
+            value
370
+        }
371
+    };
372
+}
373
+
353 374
 /**
354 375
  * Creates an event which specifies that the "confirm" button on the remote
355 376
  * mute dialog has been clicked.

+ 9
- 3
react/features/recording/actions.js Ver arquivo

@@ -1,7 +1,6 @@
1 1
 // @flow
2 2
 
3
-import JitsiMeetJS from '../base/lib-jitsi-meet';
4
-
3
+import JitsiMeetJS, { JitsiRecordingConstants } from '../base/lib-jitsi-meet';
5 4
 import {
6 5
     hideNotification,
7 6
     showErrorNotification,
@@ -138,6 +137,12 @@ export function showStoppedRecordingNotification(streamType: string) {
138 137
  * }}
139 138
  */
140 139
 export function updateRecordingSessionData(session: Object) {
140
+    const status = session.getStatus();
141
+    const timestamp
142
+        = status === JitsiRecordingConstants.status.ON
143
+            ? Date.now() / 1000
144
+            : undefined;
145
+
141 146
     return {
142 147
         type: RECORDING_SESSION_UPDATED,
143 148
         sessionData: {
@@ -145,7 +150,8 @@ export function updateRecordingSessionData(session: Object) {
145 150
             id: session.getID(),
146 151
             liveStreamViewURL: session.getLiveStreamViewURL(),
147 152
             mode: session.getMode(),
148
-            status: session.getStatus()
153
+            status,
154
+            timestamp
149 155
         }
150 156
     };
151 157
 }

+ 15
- 0
react/features/recording/middleware.js Ver arquivo

@@ -1,5 +1,10 @@
1 1
 /* @flow */
2 2
 
3
+
4
+import {
5
+    createRecordingEvent,
6
+    sendAnalytics
7
+} from '../analytics';
3 8
 import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../base/app';
4 9
 import { CONFERENCE_WILL_JOIN, getCurrentConference } from '../base/conference';
5 10
 import JitsiMeetJS, {
@@ -117,6 +122,7 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
117 122
                 && (!oldSessionData || oldSessionData.status !== ON)
118 123
                 && updatedSessionData.mode
119 124
                     === JitsiRecordingConstants.mode.FILE) {
125
+                sendAnalytics(createRecordingEvent('start', 'file'));
120 126
                 dispatch(playSound(RECORDING_ON_SOUND_ID));
121 127
             } else if (updatedSessionData.status === OFF
122 128
                 && (!oldSessionData || oldSessionData.status !== OFF)) {
@@ -126,6 +132,15 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
126 132
 
127 133
                 if (updatedSessionData.mode
128 134
                         === JitsiRecordingConstants.mode.FILE) {
135
+                    let duration = 0;
136
+
137
+                    // eslint-disable-next-line max-depth
138
+                    if (oldSessionData && oldSessionData.timestamp) {
139
+                        duration
140
+                            = (Date.now() / 1000) - oldSessionData.timestamp;
141
+                    }
142
+                    sendAnalytics(
143
+                        createRecordingEvent('stop', 'file', duration));
129 144
                     dispatch(stopSound(RECORDING_ON_SOUND_ID));
130 145
                     dispatch(playSound(RECORDING_OFF_SOUND_ID));
131 146
                 }

Carregando…
Cancelar
Salvar