Explorar el Código

Uses analytics from lib-jitsi-meet and adds new events.

Adds more analytics events for shortcuts, recording and shared video. Changes the way we calculate ttfm.
j8
damencho hace 8 años
padre
commit
6302e42229

+ 4
- 1
analytics.js Ver fichero

@@ -11,7 +11,10 @@
11 11
   }
12 12
 
13 13
   Analytics.prototype.sendEvent = function (action, data) {
14
-    ga('send', 'event', 'jit.si', action);
14
+    // empty label and add the value, the value should be integer or null
15
+    var value = parseInt(data);
16
+
17
+    ga('send', 'event', 'jit.si', action, "", value ? value : null);
15 18
   };
16 19
 
17 20
   ctx.Analytics = Analytics;

+ 16
- 3
modules/UI/recording/Recording.js Ver fichero

@@ -20,6 +20,7 @@ import VideoLayout from '../videolayout/VideoLayout';
20 20
 import Feedback from '../Feedback.js';
21 21
 import Toolbar from '../toolbars/Toolbar';
22 22
 import BottomToolbar from '../toolbars/BottomToolbar';
23
+import AnalyticsAdapter from '../../statistics/AnalyticsAdapter';
23 24
 
24 25
 /**
25 26
  * The dialog for user input.
@@ -306,13 +307,16 @@ var Recording = {
306 307
         selector.click(function () {
307 308
             if (dialog)
308 309
                 return;
309
-
310
+            AnalyticsAdapter.sendEvent('recording.clicked');
310 311
             switch (self.currentState) {
311 312
                 case Status.ON:
312 313
                 case Status.RETRYING:
313 314
                 case Status.PENDING: {
314
-                    _showStopRecordingPrompt(recordingType).then(() =>
315
-                        self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED),
315
+                    _showStopRecordingPrompt(recordingType).then(
316
+                        () => {
317
+                            self.eventEmitter.emit(UIEvents.RECORDING_TOGGLED);
318
+                            AnalyticsAdapter.sendEvent('recording.stopped');
319
+                        },
316 320
                         () => {});
317 321
                     break;
318 322
                 }
@@ -322,26 +326,35 @@ var Recording = {
322 326
                         _requestLiveStreamId().then((streamId) => {
323 327
                             self.eventEmitter.emit( UIEvents.RECORDING_TOGGLED,
324 328
                                 {streamId: streamId});
329
+                            AnalyticsAdapter.sendEvent('recording.started');
325 330
                         }).catch(
326 331
                             reason => {
327 332
                                 if (reason !== APP.UI.messageHandler.CANCEL)
328 333
                                     console.error(reason);
334
+                                else
335
+                                    AnalyticsAdapter.sendEvent(
336
+                                        'recording.canceled');
329 337
                             }
330 338
                         );
331 339
                     else {
332 340
                         if (self.predefinedToken) {
333 341
                             self.eventEmitter.emit( UIEvents.RECORDING_TOGGLED,
334 342
                                 {token: self.predefinedToken});
343
+                            AnalyticsAdapter.sendEvent('recording.started');
335 344
                             return;
336 345
                         }
337 346
 
338 347
                         _requestRecordingToken().then((token) => {
339 348
                             self.eventEmitter.emit( UIEvents.RECORDING_TOGGLED,
340 349
                                 {token: token});
350
+                            AnalyticsAdapter.sendEvent('recording.started');
341 351
                         }).catch(
342 352
                             reason => {
343 353
                                 if (reason !== APP.UI.messageHandler.CANCEL)
344 354
                                     console.error(reason);
355
+                                else
356
+                                    AnalyticsAdapter.sendEvent(
357
+                                        'recording.canceled');
345 358
                             }
346 359
                         );
347 360
                     }

+ 18
- 6
modules/UI/shared_video/SharedVideo.js Ver fichero

@@ -8,6 +8,7 @@ import LargeContainer from '../videolayout/LargeContainer';
8 8
 import SmallVideo from '../videolayout/SmallVideo';
9 9
 import FilmStrip from '../videolayout/FilmStrip';
10 10
 import ToolbarToggler from "../toolbars/ToolbarToggler";
11
+import AnalyticsAdapter from '../../statistics/AnalyticsAdapter';
11 12
 
12 13
 export const SHARED_VIDEO_CONTAINER_TYPE = "sharedvideo";
13 14
 
@@ -68,17 +69,25 @@ export default class SharedVideoManager {
68 69
 
69 70
         if(!this.isSharedVideoShown) {
70 71
             requestVideoLink().then(
71
-                    url => this.emitter.emit(
72
-                                UIEvents.UPDATE_SHARED_VIDEO, url, 'start'),
73
-                    err => console.log('SHARED VIDEO CANCELED', err)
72
+                    url => {
73
+                        this.emitter.emit(
74
+                            UIEvents.UPDATE_SHARED_VIDEO, url, 'start');
75
+                        AnalyticsAdapter.sendEvent('sharedvideo.started');
76
+                    },
77
+                    err => {
78
+                        console.log('SHARED VIDEO CANCELED', err);
79
+                        AnalyticsAdapter.sendEvent('sharedvideo.canceled');
80
+                    }
74 81
             );
75 82
             return;
76 83
         }
77 84
 
78 85
         if(APP.conference.isLocalId(this.from)) {
79
-            showStopVideoPropmpt().then(() =>
80
-                this.emitter.emit(
81
-                    UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop'),
86
+            showStopVideoPropmpt().then(() => {
87
+                    this.emitter.emit(
88
+                        UIEvents.UPDATE_SHARED_VIDEO, this.url, 'stop');
89
+                    AnalyticsAdapter.sendEvent('sharedvideo.stoped');
90
+                },
82 91
                 () => {});
83 92
         } else {
84 93
             dialog = APP.UI.messageHandler.openMessageDialog(
@@ -89,6 +98,7 @@ export default class SharedVideoManager {
89 98
                     dialog = null;
90 99
                 }
91 100
             );
101
+            AnalyticsAdapter.sendEvent('sharedvideo.alreadyshared');
92 102
         }
93 103
     }
94 104
 
@@ -192,6 +202,7 @@ export default class SharedVideoManager {
192 202
                 self.smartAudioMute();
193 203
             } else if (event.data == YT.PlayerState.PAUSED) {
194 204
                 self.smartAudioUnmute();
205
+                AnalyticsAdapter.sendEvent('sharedvideo.paused');
195 206
             }
196 207
             self.fireSharedVideoEvent(event.data == YT.PlayerState.PAUSED);
197 208
         };
@@ -221,6 +232,7 @@ export default class SharedVideoManager {
221 232
             else if (event.data.volume <=0 || event.data.muted) {
222 233
                 self.smartAudioUnmute();
223 234
             }
235
+            AnalyticsAdapter.sendEvent('sharedvideo.volumechanged');
224 236
         };
225 237
 
226 238
         window.onPlayerReady = function(event) {

+ 1
- 0
modules/UI/toolbars/Toolbar.js Ver fichero

@@ -82,6 +82,7 @@ const buttonHandlers = {
82 82
         }
83 83
     },
84 84
     "toolbar_button_security": function () {
85
+        AnalyticsAdapter.sendEvent('toolbar.lock.clicked');
85 86
         emitter.emit(UIEvents.ROOM_LOCK_CLICKED);
86 87
     },
87 88
     "toolbar_button_link": function () {

+ 1
- 1
modules/UI/videolayout/SmallVideo.js Ver fichero

@@ -173,7 +173,7 @@ SmallVideo.createStreamElement = function (stream) {
173 173
         // the rest participants. It subtracts the period of waiting for the
174 174
         // second participant to join (time between join and first
175 175
         // session initiate).
176
-        var ttfm = now - APP.connectionTimes["document.ready"]
176
+        var ttfm = now
177 177
             - (APP.conference.getConnectionTimes()["session.initiate"]
178 178
                 - APP.conference.getConnectionTimes()["muc.joined"]);
179 179
         console.log("(TIME) TTFM " + type + ":\t", ttfm);

+ 9
- 0
modules/keyboardshortcut/keyboardshortcut.js Ver fichero

@@ -1,4 +1,5 @@
1 1
 /* global APP, $ */
2
+import AnalyticsAdapter from '../statistics/AnalyticsAdapter';
2 3
 //maps keycode to character, id of popover for given function and function
3 4
 var shortcuts = {};
4 5
 function initShortcutHandlers() {
@@ -13,6 +14,7 @@ function initShortcutHandlers() {
13 14
             character: "C",
14 15
             id: "toggleChatPopover",
15 16
             function: function() {
17
+                AnalyticsAdapter.sendEvent('shortcut.chat.toggled');
16 18
                 APP.UI.toggleChat();
17 19
             }
18 20
         },
@@ -20,6 +22,7 @@ function initShortcutHandlers() {
20 22
             character: "D",
21 23
             id: "toggleDesktopSharingPopover",
22 24
             function: function () {
25
+                AnalyticsAdapter.sendEvent('shortcut.screen.toggled');
23 26
                 APP.conference.toggleScreenSharing();
24 27
             }
25 28
         },
@@ -27,6 +30,7 @@ function initShortcutHandlers() {
27 30
             character: "F",
28 31
             id: "filmstripPopover",
29 32
             function: function() {
33
+                AnalyticsAdapter.sendEvent('shortcut.film.toggled');
30 34
                 APP.UI.toggleFilmStrip();
31 35
             }
32 36
         },
@@ -34,12 +38,14 @@ function initShortcutHandlers() {
34 38
             character: "M",
35 39
             id: "mutePopover",
36 40
             function: function() {
41
+                AnalyticsAdapter.sendEvent('shortcut.audiomute.toggled');
37 42
                 APP.conference.toggleAudioMuted();
38 43
             }
39 44
         },
40 45
         "R": {
41 46
             character: "R",
42 47
             function: function() {
48
+                AnalyticsAdapter.sendEvent('shortcut.raisedhand.toggled');
43 49
                 APP.conference.maybeToggleRaisedHand();
44 50
             }
45 51
 
@@ -47,6 +53,7 @@ function initShortcutHandlers() {
47 53
         "T": {
48 54
             character: "T",
49 55
             function: function() {
56
+                AnalyticsAdapter.sendEvent('shortcut.talk.clicked');
50 57
                 APP.conference.muteAudio(true);
51 58
             }
52 59
         },
@@ -54,12 +61,14 @@ function initShortcutHandlers() {
54 61
             character: "V",
55 62
             id: "toggleVideoPopover",
56 63
             function: function() {
64
+                AnalyticsAdapter.sendEvent('shortcut.videomute.toggled');
57 65
                 APP.conference.toggleVideoMuted();
58 66
             }
59 67
         },
60 68
         "?": {
61 69
             character: "?",
62 70
             function: function(e) {
71
+                AnalyticsAdapter.sendEvent('shortcut.shortcut.help');
63 72
                 APP.UI.toggleKeyboardShortcutsPanel();
64 73
             }
65 74
         }

+ 1
- 29
modules/statistics/AnalyticsAdapter.js Ver fichero

@@ -15,32 +15,4 @@ if (config.disableThirdPartyRequests !== true) {
15 15
             /* prepend */ false);
16 16
 }
17 17
 
18
-class NoopAnalytics {
19
-    sendEvent () {}
20
-}
21
-
22
-// XXX Since we asynchronously load the integration of the analytics API and the
23
-// analytics API may asynchronously load its implementation (e.g. Google
24
-// Analytics), we cannot make the decision with respect to which analytics
25
-// implementation we will use here and we have to postpone it i.e. we will make
26
-// a lazy decision.
27
-
28
-class AnalyticsAdapter {
29
-    constructor () {
30
-    }
31
-
32
-    sendEvent (...args) {
33
-        var a = this.analytics;
34
-
35
-        if (a === null || typeof a === 'undefined') {
36
-            var AnalyticsImpl = window.Analytics || NoopAnalytics;
37
-
38
-            this.analytics = a = new AnalyticsImpl();
39
-        }
40
-        try {
41
-            a.sendEvent(...args);
42
-        } catch (ignored) {}
43
-    }
44
-}
45
-
46
-export default new AnalyticsAdapter();
18
+export default JitsiMeetJS.analytics;

Loading…
Cancelar
Guardar