Parcourir la source

Merge pull request #208 from jitsi/analytics-update

Analytics update
master
hristoterezov il y a 9 ans
Parent
révision
870a608a0d
3 fichiers modifiés avec 84 ajouts et 16 suppressions
  1. 48
    0
      JitsiMeetJS.js
  2. 35
    15
      modules/RTC/JitsiRemoteTrack.js
  3. 1
    1
      modules/statistics/statistics.js

+ 48
- 0
JitsiMeetJS.js Voir le fichier

@@ -41,6 +41,29 @@ function getLowerResolution(resolution) {
41 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 68
  * Namespace for the interface of Jitsi Meet Library.
46 69
  */
@@ -164,10 +187,21 @@ var LibJitsiMeet = {
164 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 195
         return RTC.obtainAudioAndVideoPermissions(options || {})
168 196
             .then(function(tracks) {
169 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 205
                 if(!RTC.options.disableAudioLevels)
172 206
                     for(var i = 0; i < tracks.length; i++) {
173 207
                         var track = tracks[i];
@@ -197,6 +231,9 @@ var LibJitsiMeet = {
197 231
                         logger.debug("Retry createLocalTracks with resolution",
198 232
                             newResolution);
199 233
 
234
+                        Statistics.analytics.sendEvent(
235
+                            "getUserMedia.fail.resolution." + oldResolution);
236
+
200 237
                         return LibJitsiMeet.createLocalTracks(options);
201 238
                     }
202 239
                 }
@@ -211,11 +248,22 @@ var LibJitsiMeet = {
211 248
                         message: error.message
212 249
                     };
213 250
                     Statistics.sendLog(JSON.stringify(logObject));
251
+                    Statistics.analytics.sendEvent(
252
+                        "getUserMedia.userCancel.extensionInstall");
214 253
                 } else {
215 254
                     // Report gUM failed to the stats
216 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 267
                 return Promise.reject(error);
220 268
             }.bind(this));
221 269
     },

+ 35
- 15
modules/RTC/JitsiRemoteTrack.js Voir le fichier

@@ -2,6 +2,7 @@ var JitsiTrack = require("./JitsiTrack");
2 2
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
3 3
 var RTCBrowserType = require("./RTCBrowserType");
4 4
 var Statistics = require("../statistics/statistics");
5
+var AdapterJS = require("./adapter.screenshare");
5 6
 
6 7
 var ttfmTrackerAudioAttached = false;
7 8
 var ttfmTrackerVideoAttached = false;
@@ -25,6 +26,10 @@ function JitsiRemoteTrack(conference, ownerJid, stream, track, mediaType, videoT
25 26
     this.conference = conference;
26 27
     this.peerjid = ownerJid;
27 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 35
 JitsiRemoteTrack.prototype = Object.create(JitsiTrack.prototype);
@@ -38,6 +43,9 @@ JitsiRemoteTrack.prototype.setMute = function (value) {
38 43
     if(this.muted === value)
39 44
         return;
40 45
 
46
+    if(value)
47
+        this.hasBeenMuted = true;
48
+
41 49
     // we can have a fake video stream
42 50
     if(this.stream)
43 51
         this.stream.muted = value;
@@ -89,6 +97,26 @@ JitsiRemoteTrack.prototype._setVideoType = function (type) {
89 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 121
  * Attach time to first media tracker only if there is conference and only
94 122
  * for the first element.
@@ -107,21 +135,13 @@ JitsiRemoteTrack.prototype._attachTTFMTracker = function (container) {
107 135
     if (this.isVideoTrack())
108 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 147
 module.exports = JitsiRemoteTrack;

+ 1
- 1
modules/statistics/statistics.js Voir le fichier

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

Chargement…
Annuler
Enregistrer