Browse Source

Merge pull request #208 from jitsi/analytics-update

Analytics update
master
hristoterezov 9 years ago
parent
commit
870a608a0d
3 changed files with 84 additions and 16 deletions
  1. 48
    0
      JitsiMeetJS.js
  2. 35
    15
      modules/RTC/JitsiRemoteTrack.js
  3. 1
    1
      modules/statistics/statistics.js

+ 48
- 0
JitsiMeetJS.js View File

41
     return resName;
41
     return resName;
42
 }
42
 }
43
 
43
 
44
+/**
45
+ * Checks the available devices in options and concatenate the data to the
46
+ * name, which will be used as analytics event name. Adds resolution for the
47
+ * devices.
48
+ * @param name name of event
49
+ * @param options gum options
50
+ * @returns {*}
51
+ */
52
+function addDeviceTypeToAnalyticsEvent(name, options) {
53
+    if (options.devices.indexOf("audio") !== -1) {
54
+        name += ".audio";
55
+    }
56
+    if (options.devices.indexOf("desktop") !== -1) {
57
+        name += ".desktop";
58
+    }
59
+    if (options.devices.indexOf("video") !== -1) {
60
+        // we have video add resolution
61
+        name += ".video." + options.resolution;
62
+    }
63
+
64
+    return name;
65
+}
66
+
44
 /**
67
 /**
45
  * Namespace for the interface of Jitsi Meet Library.
68
  * Namespace for the interface of Jitsi Meet Library.
46
  */
69
  */
164
             }, USER_MEDIA_PERMISSION_PROMPT_TIMEOUT);
187
             }, USER_MEDIA_PERMISSION_PROMPT_TIMEOUT);
165
         }
188
         }
166
 
189
 
190
+        if(!window.connectionTimes)
191
+            window.connectionTimes = {};
192
+        window.connectionTimes["obtainPermissions.start"] =
193
+            window.performance.now();
194
+
167
         return RTC.obtainAudioAndVideoPermissions(options || {})
195
         return RTC.obtainAudioAndVideoPermissions(options || {})
168
             .then(function(tracks) {
196
             .then(function(tracks) {
169
                 promiseFulfilled = true;
197
                 promiseFulfilled = true;
170
 
198
 
199
+                window.connectionTimes["obtainPermissions.end"] =
200
+                    window.performance.now();
201
+
202
+                Statistics.analytics.sendEvent(addDeviceTypeToAnalyticsEvent(
203
+                    "getUserMedia.success", options), options);
204
+
171
                 if(!RTC.options.disableAudioLevels)
205
                 if(!RTC.options.disableAudioLevels)
172
                     for(var i = 0; i < tracks.length; i++) {
206
                     for(var i = 0; i < tracks.length; i++) {
173
                         var track = tracks[i];
207
                         var track = tracks[i];
197
                         logger.debug("Retry createLocalTracks with resolution",
231
                         logger.debug("Retry createLocalTracks with resolution",
198
                             newResolution);
232
                             newResolution);
199
 
233
 
234
+                        Statistics.analytics.sendEvent(
235
+                            "getUserMedia.fail.resolution." + oldResolution);
236
+
200
                         return LibJitsiMeet.createLocalTracks(options);
237
                         return LibJitsiMeet.createLocalTracks(options);
201
                     }
238
                     }
202
                 }
239
                 }
211
                         message: error.message
248
                         message: error.message
212
                     };
249
                     };
213
                     Statistics.sendLog(JSON.stringify(logObject));
250
                     Statistics.sendLog(JSON.stringify(logObject));
251
+                    Statistics.analytics.sendEvent(
252
+                        "getUserMedia.userCancel.extensionInstall");
214
                 } else {
253
                 } else {
215
                     // Report gUM failed to the stats
254
                     // Report gUM failed to the stats
216
                     Statistics.sendGetUserMediaFailed(error);
255
                     Statistics.sendGetUserMediaFailed(error);
217
                 }
256
                 }
218
 
257
 
258
+                window.connectionTimes["obtainPermissions.end"] =
259
+                    window.performance.now();
260
+
261
+
262
+                Statistics.analytics.sendEvent(
263
+                    addDeviceTypeToAnalyticsEvent(
264
+                        "getUserMedia.failed", options) + '.' + error.name,
265
+                    options);
266
+
219
                 return Promise.reject(error);
267
                 return Promise.reject(error);
220
             }.bind(this));
268
             }.bind(this));
221
     },
269
     },

+ 35
- 15
modules/RTC/JitsiRemoteTrack.js View File

2
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
2
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
3
 var RTCBrowserType = require("./RTCBrowserType");
3
 var RTCBrowserType = require("./RTCBrowserType");
4
 var Statistics = require("../statistics/statistics");
4
 var Statistics = require("../statistics/statistics");
5
+var AdapterJS = require("./adapter.screenshare");
5
 
6
 
6
 var ttfmTrackerAudioAttached = false;
7
 var ttfmTrackerAudioAttached = false;
7
 var ttfmTrackerVideoAttached = false;
8
 var ttfmTrackerVideoAttached = false;
25
     this.conference = conference;
26
     this.conference = conference;
26
     this.peerjid = ownerJid;
27
     this.peerjid = ownerJid;
27
     this.muted = muted;
28
     this.muted = muted;
29
+    // we want to mark whether the track has been ever muted
30
+    // to detect ttfm events for startmuted conferences, as it can significantly
31
+    // increase ttfm values
32
+    this.hasBeenMuted = muted;
28
 }
33
 }
29
 
34
 
30
 JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
35
 JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
38
     if(this.muted === value)
43
     if(this.muted === value)
39
         return;
44
         return;
40
 
45
 
46
+    if(value)
47
+        this.hasBeenMuted = true;
48
+
41
     // we can have a fake video stream
49
     // we can have a fake video stream
42
     if(this.stream)
50
     if(this.stream)
43
         this.stream.muted = value;
51
         this.stream.muted = value;
89
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
97
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
90
 };
98
 };
91
 
99
 
100
+JitsiRemoteTrack.prototype._playCallback = function () {
101
+    var type = (this.isVideoTrack() ? 'video' : 'audio');
102
+
103
+    var now = window.performance.now();
104
+    console.log("(TIME) Render " + type + ":\t", now);
105
+    this.conference.getConnectionTimes()[type + ".render"] = now;
106
+
107
+    var ttfm = now
108
+        - (this.conference.getConnectionTimes()["session.initiate"]
109
+        - this.conference.getConnectionTimes()["muc.joined"])
110
+        - (window.connectionTimes["obtainPermissions.end"]
111
+        - window.connectionTimes["obtainPermissions.start"]);
112
+    this.conference.getConnectionTimes()[type + ".ttfm"] = ttfm;
113
+    console.log("(TIME) TTFM " + type + ":\t", ttfm);
114
+    var eventName = type +'.ttfm';
115
+    if(this.hasBeenMuted)
116
+        eventName += '.muted';
117
+    Statistics.analytics.sendEvent(eventName, ttfm);
118
+};
119
+
92
 /**
120
 /**
93
  * Attach time to first media tracker only if there is conference and only
121
  * Attach time to first media tracker only if there is conference and only
94
  * for the first element.
122
  * for the first element.
107
     if (this.isVideoTrack())
135
     if (this.isVideoTrack())
108
         ttfmTrackerVideoAttached = true;
136
         ttfmTrackerVideoAttached = true;
109
 
137
 
110
-    // FIXME: this is not working for temasys
111
-    container.addEventListener("canplay", function () {
112
-        var type = (this.isVideoTrack() ? 'video' : 'audio');
113
-
114
-        var now = window.performance.now();
115
-        console.log("(TIME) Render " + type + ":\t", now);
116
-        this.conference.getConnectionTimes()[type + ".render"] = now;
117
-
118
-        var ttfm = now
119
-            - (this.conference.getConnectionTimes()["session.initiate"]
120
-            - this.conference.getConnectionTimes()["muc.joined"]);
121
-        this.conference.getConnectionTimes()[type + ".ttfm"] = ttfm;
122
-        console.log("(TIME) TTFM " + type + ":\t", ttfm);
123
-        Statistics.analytics.sendEvent(type +'.ttfm', ttfm);
124
-    }.bind(this));
138
+    if (RTCBrowserType.isTemasysPluginUsed()) {
139
+        // FIXME: this is not working for IE11
140
+        AdapterJS.addEvent(container, 'play', this._playCallback.bind(this));
141
+    }
142
+    else {
143
+        container.addEventListener("canplay", this._playCallback.bind(this));
144
+    }
125
 };
145
 };
126
 
146
 
127
 module.exports = JitsiRemoteTrack;
147
 module.exports = JitsiRemoteTrack;

+ 1
- 1
modules/statistics/statistics.js View File

44
 function loadAnalytics(customScriptUrl) {
44
 function loadAnalytics(customScriptUrl) {
45
     // if we have a custom script url passed as parameter we don't want to
45
     // if we have a custom script url passed as parameter we don't want to
46
     // search it relatively near the library
46
     // search it relatively near the library
47
-    JitsiMeetJS.util.ScriptUtil.loadScript(
47
+    ScriptUtil.loadScript(
48
         customScriptUrl ? customScriptUrl : 'analytics.js',
48
         customScriptUrl ? customScriptUrl : 'analytics.js',
49
         /* async */ true,
49
         /* async */ true,
50
         /* prepend */ false,
50
         /* prepend */ false,

Loading…
Cancel
Save