Kaynağa Gözat

Adds analytics events for connection times.

Moves render time calculations in the library.
master
damencho 9 yıl önce
ebeveyn
işleme
2f93ae15e1

+ 14
- 0
JitsiConferenceEventManager.js Dosyayı Görüntüle

@@ -93,6 +93,19 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
93 93
 
94 94
     this.chatRoomForwarder.forward(XMPPEvents.MUC_JOINED,
95 95
         JitsiConferenceEvents.CONFERENCE_JOINED);
96
+    // send some analytics events
97
+    chatRoom.addListener(XMPPEvents.MUC_JOINED,
98
+        function ()
99
+        {
100
+            for (var ckey in chatRoom.connectionTimes){
101
+                var cvalue = chatRoom.connectionTimes[ckey];
102
+                AnalyticsAdapter.sendEvent('conference.' + ckey, cvalue);
103
+            }
104
+            for (var xkey in chatRoom.xmpp.connectionTimes){
105
+                var xvalue = chatRoom.xmpp.connectionTimes[xkey];
106
+                AnalyticsAdapter.sendEvent('xmpp.' + xkey, xvalue);
107
+            }
108
+        });
96 109
 
97 110
     this.chatRoomForwarder.forward(XMPPEvents.ROOM_JOIN_ERROR,
98 111
         JitsiConferenceEvents.CONFERENCE_FAILED,
@@ -438,6 +451,7 @@ JitsiConferenceEventManager.prototype.setupRTCListeners = function () {
438 451
         var now = window.performance.now();
439 452
         logger.log("(TIME) data channel opened ", now);
440 453
         conference.room.connectionTimes["data.channel.opened"] = now;
454
+        AnalyticsAdapter.sendEvent('conference.dataChannel.open', now);
441 455
     });
442 456
 
443 457
     this.rtcForwarder.forward(RTCEvents.LASTN_CHANGED,

+ 37
- 0
modules/RTC/JitsiRemoteTrack.js Dosyayı Görüntüle

@@ -1,5 +1,9 @@
1 1
 var JitsiTrack = require("./JitsiTrack");
2 2
 var JitsiTrackEvents = require("../../JitsiTrackEvents");
3
+var RTCBrowserType = require("./RTCBrowserType");
4
+
5
+var ttfmTrackerAudioAttached = false;
6
+var ttfmTrackerVideoAttached = false;
3 7
 
4 8
 /**
5 9
  * Represents a single media track (either audio or video).
@@ -84,4 +88,37 @@ JitsiRemoteTrack.prototype._setVideoType = function (type) {
84 88
     this.eventEmitter.emit(JitsiTrackEvents.TRACK_VIDEOTYPE_CHANGED, type);
85 89
 };
86 90
 
91
+/**
92
+ * Attach time to first media tracker only if there is conference and only
93
+ * for the first element.
94
+ * @param container the HTML container which can be 'video' or 'audio' element.
95
+ *        It can also be 'object' element if Temasys plugin is in use and this
96
+ *        method has been called previously on video or audio HTML element.
97
+ * @private
98
+ */
99
+JitsiRemoteTrack.prototype._attachTTFMTracker = function (container) {
100
+    if((ttfmTrackerAudioAttached && this.isAudioTrack())
101
+        || (ttfmTrackerVideoAttached && this.isVideoTrack()))
102
+        return;
103
+
104
+    if (this.isAudioTrack())
105
+        ttfmTrackerAudioAttached = true;
106
+    if (this.isVideoTrack())
107
+        ttfmTrackerVideoAttached = true;
108
+
109
+    // FIXME: this is not working for temasys
110
+    container.addEventListener("canplay", function () {
111
+        var type = (this.isVideoTrack() ? 'video' : 'audio');
112
+
113
+        var now = window.performance.now();
114
+        console.log("(TIME) Render " + type + ":\t", now);
115
+
116
+        var ttfm = now
117
+            - (this.conference.getConnectionTimes()["session.initiate"]
118
+            - this.conference.getConnectionTimes()["muc.joined"]);
119
+        this.conference.getConnectionTimes()[type + ".ttfm"] = ttfm;
120
+        console.log("(TIME) TTFM " + type + ":\t", ttfm);
121
+    }.bind(this));
122
+};
123
+
87 124
 module.exports = JitsiRemoteTrack;

+ 13
- 0
modules/RTC/JitsiTrack.js Dosyayı Görüntüle

@@ -189,6 +189,8 @@ JitsiTrack.prototype.attach = function (container) {
189 189
 
190 190
     this._maybeFireTrackAttached(container);
191 191
 
192
+    this._attachTTFMTracker(container);
193
+
192 194
     return container;
193 195
 };
194 196
 
@@ -216,6 +218,17 @@ JitsiTrack.prototype.detach = function (container) {
216 218
     }
217 219
 };
218 220
 
221
+/**
222
+ * Attach time to first media tracker only if there is conference and only
223
+ * for the first element.
224
+ * @param container the HTML container which can be 'video' or 'audio' element.
225
+ *        It can also be 'object' element if Temasys plugin is in use and this
226
+ *        method has been called previously on video or audio HTML element.
227
+ * @private
228
+ */
229
+JitsiTrack.prototype._attachTTFMTracker = function (container) {
230
+};
231
+
219 232
 /**
220 233
  * Removes attached event listeners.
221 234
  *

+ 3
- 0
modules/xmpp/JingleSessionPC.js Dosyayı Görüntüle

@@ -12,6 +12,7 @@ var XMPPEvents = require("../../service/xmpp/XMPPEvents");
12 12
 var RTCBrowserType = require("../RTC/RTCBrowserType");
13 13
 var RTC = require("../RTC/RTC");
14 14
 var GlobalOnErrorHandler = require("../util/GlobalOnErrorHandler");
15
+var AnalyticsAdapter = require("../statistics/AnalyticsAdapter");
15 16
 
16 17
 /**
17 18
  * Constant tells how long we're going to wait for IQ response, before timeout
@@ -132,6 +133,8 @@ JingleSessionPC.prototype.doInitialize = function () {
132 133
             self.peerconnection.iceConnectionState] = now;
133 134
         logger.log("(TIME) ICE " + self.peerconnection.iceConnectionState +
134 135
                     ":\t", now);
136
+        AnalyticsAdapter.sendEvent(
137
+            'ice.' + self.peerconnection.iceConnectionState, now);
135 138
         switch (self.peerconnection.iceConnectionState) {
136 139
             case 'connected':
137 140
 

+ 11
- 5
modules/xmpp/strophe.jingle.js Dosyayı Görüntüle

@@ -6,7 +6,7 @@ var JingleSession = require("./JingleSessionPC");
6 6
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
7 7
 var RTCBrowserType = require("../RTC/RTCBrowserType");
8 8
 var GlobalOnErrorHandler = require("../util/GlobalOnErrorHandler");
9
-
9
+var AnalyticsAdapter = require("../statistics/AnalyticsAdapter");
10 10
 
11 11
 module.exports = function(XMPP, eventEmitter) {
12 12
     Strophe.addConnectionPlugin('jingle', {
@@ -101,6 +101,7 @@ module.exports = function(XMPP, eventEmitter) {
101 101
                             .up();
102 102
                         this.terminate(sess.sid);
103 103
                     }
104
+                    AnalyticsAdapter.sendEvent('xmpp.session-initiate', now);
104 105
                     break;
105 106
                 case 'session-terminate':
106 107
                     logger.log('terminating...', sess.sid);
@@ -114,13 +115,18 @@ module.exports = function(XMPP, eventEmitter) {
114 115
                     this.terminate(sess.sid, reasonCondition, reasonText);
115 116
                     break;
116 117
                 case 'transport-replace':
117
-                    logger.info("(TIME) Start transport replace",
118
-                                window.performance.now());
118
+                    var now = window.performance.now();
119
+                    logger.info("(TIME) Start transport replace", now);
120
+                    AnalyticsAdapter.sendEvent(
121
+                        'xmpp.transport-replace.start', now);
122
+
119 123
                     sess.replaceTransport($(iq).find('>jingle'),
120 124
                         function () {
125
+                            var now = window.performance.now();
121 126
                             logger.info(
122
-                                "(TIME) Transport replace success!",
123
-                                window.performance.now());
127
+                                "(TIME) Transport replace success!", now);
128
+                            AnalyticsAdapter.sendEvent(
129
+                                'xmpp.transport-replace.success', now);
124 130
                         },
125 131
                         function(error) {
126 132
                             GlobalOnErrorHandler.callErrorHandler(error);

Loading…
İptal
Kaydet