Bläddra i källkod

callstats

master
hristoterezov 9 år sedan
förälder
incheckning
0d03a4fceb

+ 21
- 7
conference.js Visa fil

@@ -230,7 +230,26 @@ export default {
230 230
     get startVideoMuted () {
231 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 253
     // used by torture currently
235 254
     isJoined () {
236 255
         return this._room
@@ -292,10 +311,7 @@ export default {
292 311
         this._setupListeners();
293 312
     },
294 313
     _getConferenceOptions() {
295
-        let options = {
296
-            openSctp: config.openSctp,
297
-            disableAudioLevels: config.disableAudioLevels
298
-        };
314
+        let options = config;
299 315
         if(config.enableRecording) {
300 316
             options.recordingType = (config.hosts &&
301 317
                 (typeof config.hosts.jirecon != "undefined"))?
@@ -359,10 +375,8 @@ export default {
359 375
             if(track.isLocal()){
360 376
                 id = this.localId;
361 377
                 if(track.getType() === "audio") {
362
-                    APP.statistics.onAudioMute(mute);
363 378
                     this.audioMuted = mute;
364 379
                 } else {
365
-                    APP.statistics.onVideoMute(mute);
366 380
                     this.videoMuted = mute;
367 381
                 }
368 382
             } else {

+ 0
- 1
index.html Visa fil

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

+ 5
- 6
modules/UI/Feedback.js Visa fil

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

+ 3
- 1
modules/UI/UI.js Visa fil

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

+ 0
- 19
modules/settings/Settings.js Visa fil

@@ -4,8 +4,6 @@ var email = '';
4 4
 var displayName = '';
5 5
 var userId;
6 6
 var language = null;
7
-var callStatsUserName;
8
-
9 7
 
10 8
 function supportsLocalStorage() {
11 9
     try {
@@ -30,22 +28,13 @@ if (supportsLocalStorage()) {
30 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 31
     userId = window.localStorage.jitsiMeetId || '';
41
-    callStatsUserName = window.localStorage.callStatsUserName;
42 32
     email = window.localStorage.email || '';
43 33
     displayName = window.localStorage.displayname || '';
44 34
     language = window.localStorage.language;
45 35
 } else {
46 36
     console.log("local storage is not supported");
47 37
     userId = generateUniqueId();
48
-    callStatsUserName = generateUsername();
49 38
 }
50 39
 
51 40
 export default {
@@ -73,14 +62,6 @@ export default {
73 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 65
     setEmail: function (newEmail) {
85 66
         email = newEmail;
86 67
         window.localStorage.email = newEmail;

+ 0
- 218
modules/statistics/CallStats.js Visa fil

@@ -1,218 +0,0 @@
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 Visa fil

@@ -6,7 +6,6 @@ var RTPStats = require("./RTPStatsCollector.js");
6 6
 var EventEmitter = require("events");
7 7
 var StreamEventTypes = require("../../service/RTC/StreamEventTypes.js");
8 8
 var XMPPEvents = require("../../service/xmpp/XMPPEvents");
9
-var CallStats = require("./CallStats");
10 9
 var RTCEvents = require("../../service/RTC/RTCEvents");
11 10
 var StatisticsEvents = require("../../service/statistics/Events");
12 11
 
@@ -32,7 +31,6 @@ function startRemoteStats (peerconnection) {
32 31
 }
33 32
 
34 33
 function onDisposeConference(onUnload) {
35
-    CallStats.sendTerminateEvent();
36 34
     stopRemote();
37 35
     if (onUnload) {
38 36
         eventEmitter.removeAllListeners();
@@ -58,15 +56,6 @@ export default {
58 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 59
     start: function () {
71 60
         const xmpp = APP.conference._room.xmpp;
72 61
         xmpp.addListener(
@@ -77,41 +66,6 @@ export default {
77 66
         // onnegotiationneeded
78 67
         xmpp.addListener(XMPPEvents.CALL_INCOMING, function (event) {
79 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
 };

Laddar…
Avbryt
Spara