瀏覽代碼

callstats

j8
hristoterezov 9 年之前
父節點
當前提交
0d03a4fceb
共有 7 個文件被更改,包括 29 次插入298 次删除
  1. 21
    7
      conference.js
  2. 0
    1
      index.html
  3. 5
    6
      modules/UI/Feedback.js
  4. 3
    1
      modules/UI/UI.js
  5. 0
    19
      modules/settings/Settings.js
  6. 0
    218
      modules/statistics/CallStats.js
  7. 0
    46
      modules/statistics/statistics.js

+ 21
- 7
conference.js 查看文件

230
     get startVideoMuted () {
230
     get startVideoMuted () {
231
         return room && room.getStartMutedPolicy().video;
231
         return room && room.getStartMutedPolicy().video;
232
     },
232
     },
233
-
233
+    /**
234
+     * Returns true if the callstats integration is enabled, otherwise returns
235
+     * false.
236
+     *
237
+     * @returns true if the callstats integration is enabled, otherwise returns
238
+     * false.
239
+     */
240
+    isCallstatsEnabled () {
241
+        return room.isCallstatsEnabled();
242
+    },
243
+    /**
244
+     * Sends the given feedback through CallStats if enabled.
245
+     *
246
+     * @param overallFeedback an integer between 1 and 5 indicating the
247
+     * user feedback
248
+     * @param detailedFeedback detailed feedback from the user. Not yet used
249
+     */
250
+    sendFeedback (overallFeedback, detailedFeedback) {
251
+        return room.sendFeedback (overallFeedback, detailedFeedback);
252
+    },
234
     // used by torture currently
253
     // used by torture currently
235
     isJoined () {
254
     isJoined () {
236
         return this._room
255
         return this._room
292
         this._setupListeners();
311
         this._setupListeners();
293
     },
312
     },
294
     _getConferenceOptions() {
313
     _getConferenceOptions() {
295
-        let options = {
296
-            openSctp: config.openSctp,
297
-            disableAudioLevels: config.disableAudioLevels
298
-        };
314
+        let options = config;
299
         if(config.enableRecording) {
315
         if(config.enableRecording) {
300
             options.recordingType = (config.hosts &&
316
             options.recordingType = (config.hosts &&
301
                 (typeof config.hosts.jirecon != "undefined"))?
317
                 (typeof config.hosts.jirecon != "undefined"))?
359
             if(track.isLocal()){
375
             if(track.isLocal()){
360
                 id = this.localId;
376
                 id = this.localId;
361
                 if(track.getType() === "audio") {
377
                 if(track.getType() === "audio") {
362
-                    APP.statistics.onAudioMute(mute);
363
                     this.audioMuted = mute;
378
                     this.audioMuted = mute;
364
                 } else {
379
                 } else {
365
-                    APP.statistics.onVideoMute(mute);
366
                     this.videoMuted = mute;
380
                     this.videoMuted = mute;
367
                 }
381
                 }
368
             } else {
382
             } else {

+ 0
- 1
index.html 查看文件

245
     <script type="text/javascript">
245
     <script type="text/javascript">
246
       if (!config.disableThirdPartyRequests) {
246
       if (!config.disableThirdPartyRequests) {
247
         [
247
         [
248
-          'https://api.callstats.io/static/callstats.min.js',
249
           'analytics.js?v=1'
248
           'analytics.js?v=1'
250
         ].forEach(function(extSrc) {
249
         ].forEach(function(extSrc) {
251
           var extScript = document.createElement('script');
250
           var extScript = document.createElement('script');

+ 5
- 6
modules/UI/Feedback.js 查看文件

4
  * Created by Yana Stamcheva on 2/10/15.
4
  * Created by Yana Stamcheva on 2/10/15.
5
  */
5
  */
6
 var messageHandler = require("./util/MessageHandler");
6
 var messageHandler = require("./util/MessageHandler");
7
-var callStats = require("../statistics/CallStats");
8
 
7
 
9
 /**
8
 /**
10
  * Constructs the html for the overall feedback window.
9
  * Constructs the html for the overall feedback window.
78
     init: function () {
77
     init: function () {
79
         // CallStats is the way we send feedback, so we don't have to initialise
78
         // CallStats is the way we send feedback, so we don't have to initialise
80
         // if callstats isn't enabled.
79
         // if callstats isn't enabled.
81
-        if (!callStats.isEnabled())
80
+        if (!APP.conference.isCallstatsEnabled())
82
             return;
81
             return;
83
 
82
 
84
         $("div.feedbackButton").css("display", "block");
83
         $("div.feedbackButton").css("display", "block");
92
      * @return true if the feedback functionality is enabled, false otherwise.
91
      * @return true if the feedback functionality is enabled, false otherwise.
93
      */
92
      */
94
     isEnabled: function() {
93
     isEnabled: function() {
95
-        return callStats.isEnabled();
94
+        return APP.conference.isCallstatsEnabled();
96
     },
95
     },
97
     /**
96
     /**
98
      * Opens the feedback window.
97
      * Opens the feedback window.
118
                     // If the feedback is less than 3 stars we're going to
117
                     // If the feedback is less than 3 stars we're going to
119
                     // ask the user for more information.
118
                     // ask the user for more information.
120
                     if (Feedback.feedbackScore > 3) {
119
                     if (Feedback.feedbackScore > 3) {
121
-                        callStats.sendFeedback(Feedback.feedbackScore, "");
120
+                        APP.conference.sendFeedback(Feedback.feedbackScore, "");
122
                         if (feedbackWindowCallback)
121
                         if (feedbackWindowCallback)
123
                             feedbackWindowCallback();
122
                             feedbackWindowCallback();
124
                         else
123
                         else
160
                             = document.getElementById("feedbackTextArea").value;
159
                             = document.getElementById("feedbackTextArea").value;
161
 
160
 
162
                         if (feedbackDetails && feedbackDetails.length > 0)
161
                         if (feedbackDetails && feedbackDetails.length > 0)
163
-                            callStats.sendFeedback( Feedback.feedbackScore,
162
+                            APP.conference.sendFeedback( Feedback.feedbackScore,
164
                                                     feedbackDetails);
163
                                                     feedbackDetails);
165
 
164
 
166
                         if (feedbackWindowCallback)
165
                         if (feedbackWindowCallback)
233
 };
232
 };
234
 
233
 
235
 // Exports the Feedback class.
234
 // Exports the Feedback class.
236
-module.exports = Feedback;
235
+module.exports = Feedback;

+ 3
- 1
modules/UI/UI.js 查看文件

177
     UI.setUserAvatar(id, settings.email);
177
     UI.setUserAvatar(id, settings.email);
178
 
178
 
179
     Toolbar.checkAutoEnableDesktopSharing();
179
     Toolbar.checkAutoEnableDesktopSharing();
180
+    if(!interfaceConfig.filmStripOnly) {
181
+        Feedback.init();
182
+    }
180
 };
183
 };
181
 
184
 
182
 UI.mucJoined = function () {
185
 UI.mucJoined = function () {
282
             // dump(event.target);
285
             // dump(event.target);
283
             // FIXME integrate logs
286
             // FIXME integrate logs
284
         });
287
         });
285
-        Feedback.init();
286
     } else {
288
     } else {
287
         $("#header").css("display", "none");
289
         $("#header").css("display", "none");
288
         $("#bottomToolbar").css("display", "none");
290
         $("#bottomToolbar").css("display", "none");

+ 0
- 19
modules/settings/Settings.js 查看文件

4
 var displayName = '';
4
 var displayName = '';
5
 var userId;
5
 var userId;
6
 var language = null;
6
 var language = null;
7
-var callStatsUserName;
8
-
9
 
7
 
10
 function supportsLocalStorage() {
8
 function supportsLocalStorage() {
11
     try {
9
     try {
30
         console.log("generated id", window.localStorage.jitsiMeetId);
28
         console.log("generated id", window.localStorage.jitsiMeetId);
31
     }
29
     }
32
 
30
 
33
-    if (!window.localStorage.callStatsUserName) {
34
-        window.localStorage.callStatsUserName
35
-            = generateUsername();
36
-        console.log('generated callstats uid',
37
-            window.localStorage.callStatsUserName);
38
-
39
-    }
40
     userId = window.localStorage.jitsiMeetId || '';
31
     userId = window.localStorage.jitsiMeetId || '';
41
-    callStatsUserName = window.localStorage.callStatsUserName;
42
     email = window.localStorage.email || '';
32
     email = window.localStorage.email || '';
43
     displayName = window.localStorage.displayname || '';
33
     displayName = window.localStorage.displayname || '';
44
     language = window.localStorage.language;
34
     language = window.localStorage.language;
45
 } else {
35
 } else {
46
     console.log("local storage is not supported");
36
     console.log("local storage is not supported");
47
     userId = generateUniqueId();
37
     userId = generateUniqueId();
48
-    callStatsUserName = generateUsername();
49
 }
38
 }
50
 
39
 
51
 export default {
40
 export default {
73
         return displayName;
62
         return displayName;
74
     },
63
     },
75
 
64
 
76
-    /**
77
-     * Returns fake username for callstats
78
-     * @returns {string} fake username for callstats
79
-     */
80
-    getCallStatsUserName: function () {
81
-        return callStatsUserName;
82
-    },
83
-
84
     setEmail: function (newEmail) {
65
     setEmail: function (newEmail) {
85
         email = newEmail;
66
         email = newEmail;
86
         window.localStorage.email = newEmail;
67
         window.localStorage.email = newEmail;

+ 0
- 218
modules/statistics/CallStats.js 查看文件

1
-/* global config, $, APP, Strophe, callstats */
2
-
3
-var Settings = require('../settings/Settings');
4
-var jsSHA = require('jssha');
5
-var io = require('socket.io-client');
6
-var callStats = null;
7
-
8
-/**
9
- * @const
10
- * @see http://www.callstats.io/api/#enumeration-of-wrtcfuncnames
11
- */
12
-var wrtcFuncNames = {
13
-    createOffer:          "createOffer",
14
-    createAnswer:         "createAnswer",
15
-    setLocalDescription:  "setLocalDescription",
16
-    setRemoteDescription: "setRemoteDescription",
17
-    addIceCandidate:      "addIceCandidate",
18
-    getUserMedia:         "getUserMedia"
19
-};
20
-
21
-// some errors may happen before CallStats init
22
-// in this case we accumulate them in this array
23
-// and send them to callstats on init
24
-var pendingErrors = [];
25
-
26
-function initCallback (err, msg) {
27
-    console.log("CallStats Status: err=" + err + " msg=" + msg);
28
-}
29
-
30
-var callStatsIntegrationEnabled = config.callStatsID && config.callStatsSecret;
31
-
32
-var CallStats = {
33
-    init: function (jingleSession) {
34
-        if(!callStatsIntegrationEnabled || callStats !== null) {
35
-            return;
36
-        }
37
-
38
-        callStats = new callstats($, io, jsSHA);
39
-
40
-        this.session = jingleSession;
41
-        this.peerconnection = jingleSession.peerconnection.peerconnection;
42
-
43
-        this.userID = Settings.getCallStatsUserName();
44
-
45
-        var location = window.location;
46
-        this.confID = location.hostname + location.pathname;
47
-
48
-        //userID is generated or given by the origin server
49
-        callStats.initialize(config.callStatsID,
50
-            config.callStatsSecret,
51
-            this.userID,
52
-            initCallback);
53
-
54
-        var usage = callStats.fabricUsage.multiplex;
55
-
56
-        callStats.addNewFabric(this.peerconnection,
57
-            Strophe.getResourceFromJid(jingleSession.peerjid),
58
-            usage,
59
-            this.confID,
60
-            this.pcCallback.bind(this));
61
-
62
-        // notify callstats about failures if there were any
63
-        if (pendingErrors.length) {
64
-            pendingErrors.forEach(function (error) {
65
-                this._reportError(error.type, error.error, error.pc);
66
-            }, this);
67
-            pendingErrors.length = 0;
68
-        }
69
-    },
70
-    /**
71
-     * Returns true if the callstats integration is enabled, otherwise returns
72
-     * false.
73
-     *
74
-     * @returns true if the callstats integration is enabled, otherwise returns
75
-     * false.
76
-     */
77
-    isEnabled: function() {
78
-        return callStatsIntegrationEnabled;
79
-    },
80
-    pcCallback: function (err, msg) {
81
-        if (!callStats) {
82
-            return;
83
-        }
84
-        console.log("Monitoring status: "+ err + " msg: " + msg);
85
-        callStats.sendFabricEvent(this.peerconnection,
86
-            callStats.fabricEvent.fabricSetup, this.confID);
87
-    },
88
-    sendMuteEvent: function (mute, type) {
89
-        if (!callStats) {
90
-            return;
91
-        }
92
-        var event = null;
93
-        if (type === "video") {
94
-            event = (mute? callStats.fabricEvent.videoPause :
95
-                callStats.fabricEvent.videoResume);
96
-        }
97
-        else {
98
-            event = (mute? callStats.fabricEvent.audioMute :
99
-                callStats.fabricEvent.audioUnmute);
100
-        }
101
-        callStats.sendFabricEvent(this.peerconnection, event, this.confID);
102
-    },
103
-    sendTerminateEvent: function () {
104
-        if(!callStats) {
105
-            return;
106
-        }
107
-        callStats.sendFabricEvent(this.peerconnection,
108
-            callStats.fabricEvent.fabricTerminated, this.confID);
109
-    },
110
-    sendSetupFailedEvent: function () {
111
-        if(!callStats) {
112
-            return;
113
-        }
114
-        callStats.sendFabricEvent(this.peerconnection,
115
-            callStats.fabricEvent.fabricSetupFailed, this.confID);
116
-    },
117
-
118
-   /**
119
-     * Sends the given feedback through CallStats.
120
-     *
121
-     * @param overallFeedback an integer between 1 and 5 indicating the
122
-     * user feedback
123
-     * @param detailedFeedback detailed feedback from the user. Not yet used
124
-     */
125
-    sendFeedback: function(overallFeedback, detailedFeedback) {
126
-        if(!callStats) {
127
-            return;
128
-        }
129
-        var feedbackString =    '{"userID":"' + this.userID + '"' +
130
-                                ', "overall":' + overallFeedback +
131
-                                ', "comment": "' + detailedFeedback + '"}';
132
-
133
-        var feedbackJSON = JSON.parse(feedbackString);
134
-
135
-        callStats.sendUserFeedback(
136
-            this.confID, feedbackJSON);
137
-    },
138
-    /**
139
-     * Reports an error to callstats.
140
-     *
141
-     * @param type the type of the error, which will be one of the wrtcFuncNames
142
-     * @param e the error
143
-     * @param pc the peerconnection
144
-     * @private
145
-     */
146
-    _reportError: function (type, e, pc) {
147
-        if (callStats) {
148
-            callStats.reportError(pc, this.confID, type, e);
149
-        } else if (callStatsIntegrationEnabled) {
150
-            pendingErrors.push({
151
-                type: type,
152
-                error: e,
153
-                pc: pc
154
-            });
155
-        }
156
-        // else just ignore it
157
-    },
158
-
159
-    /**
160
-     * Notifies CallStats that getUserMedia failed.
161
-     *
162
-     * @param {Error} e error to send
163
-     */
164
-    sendGetUserMediaFailed: function (e) {
165
-        this._reportError(wrtcFuncNames.getUserMedia, e, null);
166
-    },
167
-
168
-    /**
169
-     * Notifies CallStats that peer connection failed to create offer.
170
-     *
171
-     * @param {Error} e error to send
172
-     * @param {RTCPeerConnection} pc connection on which failure occured.
173
-     */
174
-    sendCreateOfferFailed: function (e, pc) {
175
-        this._reportError(wrtcFuncNames.createOffer, e, pc);
176
-    },
177
-
178
-    /**
179
-     * Notifies CallStats that peer connection failed to create answer.
180
-     *
181
-     * @param {Error} e error to send
182
-     * @param {RTCPeerConnection} pc connection on which failure occured.
183
-     */
184
-    sendCreateAnswerFailed: function (e, pc) {
185
-        this._reportError(wrtcFuncNames.createAnswer, e, pc);
186
-    },
187
-
188
-    /**
189
-     * Notifies CallStats that peer connection failed to set local description.
190
-     *
191
-     * @param {Error} e error to send
192
-     * @param {RTCPeerConnection} pc connection on which failure occured.
193
-     */
194
-    sendSetLocalDescFailed: function (e, pc) {
195
-        this._reportError(wrtcFuncNames.setLocalDescription, e, pc);
196
-    },
197
-
198
-    /**
199
-     * Notifies CallStats that peer connection failed to set remote description.
200
-     *
201
-     * @param {Error} e error to send
202
-     * @param {RTCPeerConnection} pc connection on which failure occured.
203
-     */
204
-    sendSetRemoteDescFailed: function (e, pc) {
205
-        this._reportError(wrtcFuncNames.setRemoteDescription, e, pc);
206
-    },
207
-
208
-    /**
209
-     * Notifies CallStats that peer connection failed to add ICE candidate.
210
-     *
211
-     * @param {Error} e error to send
212
-     * @param {RTCPeerConnection} pc connection on which failure occured.
213
-     */
214
-    sendAddIceCandidateFailed: function (e, pc) {
215
-        this._reportError(wrtcFuncNames.addIceCandidate, e, pc);
216
-    }
217
-};
218
-module.exports = CallStats;

+ 0
- 46
modules/statistics/statistics.js 查看文件

6
 var EventEmitter = require("events");
6
 var EventEmitter = require("events");
7
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
7
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
8
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
8
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
9
-var CallStats = require("./CallStats");
10
 var RTCEvents = require("../../service/RTC/RTCEvents");
9
 var RTCEvents = require("../../service/RTC/RTCEvents");
11
 var StatisticsEvents = require("../../service/statistics/Events");
10
 var StatisticsEvents = require("../../service/statistics/Events");
12
 
11
 
32
 }
31
 }
33
 
32
 
34
 function onDisposeConference(onUnload) {
33
 function onDisposeConference(onUnload) {
35
-    CallStats.sendTerminateEvent();
36
     stopRemote();
34
     stopRemote();
37
     if (onUnload) {
35
     if (onUnload) {
38
         eventEmitter.removeAllListeners();
36
         eventEmitter.removeAllListeners();
58
             eventEmitter.removeAllListeners();
56
             eventEmitter.removeAllListeners();
59
         }
57
         }
60
     },
58
     },
61
-    onAudioMute (mute) {
62
-        CallStats.sendMuteEvent(mute, "audio");
63
-    },
64
-    onVideoMute (mute) {
65
-        CallStats.sendMuteEvent(mute, "video");
66
-    },
67
-    onGetUserMediaFailed (e) {
68
-       CallStats.sendGetUserMediaFailed(e);
69
-    },
70
     start: function () {
59
     start: function () {
71
         const xmpp = APP.conference._room.xmpp;
60
         const xmpp = APP.conference._room.xmpp;
72
         xmpp.addListener(
61
         xmpp.addListener(
77
         // onnegotiationneeded
66
         // onnegotiationneeded
78
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function (event) {
67
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function (event) {
79
             startRemoteStats(event.peerconnection);
68
             startRemoteStats(event.peerconnection);
80
-            // CallStats.init(event);
81
-        });
82
-        xmpp.addListener(
83
-            XMPPEvents.PEERCONNECTION_READY,
84
-            function (session) {
85
-                CallStats.init(session);
86
-            }
87
-        );
88
-        xmpp.addListener(XMPPEvents.CONFERENCE_SETUP_FAILED, function () {
89
-            CallStats.sendSetupFailedEvent();
90
-        });
91
-
92
-        xmpp.addListener(RTCEvents.CREATE_OFFER_FAILED, function (e, pc) {
93
-            CallStats.sendCreateOfferFailed(e, pc);
94
         });
69
         });
95
-        xmpp.addListener(RTCEvents.CREATE_ANSWER_FAILED, function (e, pc) {
96
-            CallStats.sendCreateAnswerFailed(e, pc);
97
-        });
98
-        xmpp.addListener(
99
-            RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
100
-            function (e, pc) {
101
-                CallStats.sendSetLocalDescFailed(e, pc);
102
-            }
103
-        );
104
-        xmpp.addListener(
105
-            RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
106
-            function (e, pc) {
107
-                CallStats.sendSetRemoteDescFailed(e, pc);
108
-            }
109
-        );
110
-        xmpp.addListener(
111
-            RTCEvents.ADD_ICE_CANDIDATE_FAILED,
112
-            function (e, pc) {
113
-                CallStats.sendAddIceCandidateFailed(e, pc);
114
-            }
115
-        );
116
     }
70
     }
117
 };
71
 };

Loading…
取消
儲存