Browse Source

Simplifies logic around userID and callstatsUsername in callstats.

dev1
damencho 6 years ago
parent
commit
dd31f0aff0
2 changed files with 24 additions and 52 deletions
  1. 14
    40
      JitsiConference.js
  2. 10
    12
      doc/API.md

+ 14
- 40
JitsiConference.js View File

@@ -285,19 +285,13 @@ JitsiConference.prototype._init = function(options = {}) {
285 285
     }
286 286
 
287 287
     const { config } = this.options;
288
-    const statsCurrentId = config.enableEmailInStats && config.email
289
-        ? config.email : Settings.callStatsUserName;
290
-    const createRoomOptions = {
291
-        ...config
292
-    };
293
-
294
-    if (config.enableStatsID) {
295
-        createRoomOptions.statsId = statsCurrentId;
296
-    }
288
+    const statsCurrentId = config.statisticsId ? config.statisticsId : Settings.callStatsUserName;
297 289
 
298 290
     this.room = this.xmpp.createRoom(
299
-        this.options.name,
300
-        createRoomOptions,
291
+        this.options.name, {
292
+            ...config,
293
+            statsId: statsCurrentId
294
+        },
301 295
         JitsiConference.resourceCreator
302 296
     );
303 297
 
@@ -354,25 +348,9 @@ JitsiConference.prototype._init = function(options = {}) {
354 348
     this.participantConnectionStatus.init();
355 349
 
356 350
     if (!this.statistics) {
357
-        let aliasName = this.myUserId();
358
-        let userName = statsCurrentId;
359
-
360
-        if (config.enableDisplayNameInStats && config.displayName) {
361
-            aliasName = config.displayName;
362
-        }
363
-
364
-        if (config.enableStatsID) {
365
-            // let's swap the values, as instead of components to report
366
-            // the xmpp resource as id will use the supplied statsId
367
-            const newAlias = userName;
368
-
369
-            userName = aliasName;
370
-            aliasName = newAlias;
371
-        }
372
-
373 351
         this.statistics = new Statistics(this.xmpp, {
374
-            aliasName,
375
-            userName,
352
+            aliasName: statsCurrentId,
353
+            userName: config.statisticsDisplayName ? config.statisticsDisplayName : this.myUserId(),
376 354
             callStatsConfIDNamespace: this.connection.options.hosts.domain,
377 355
             confID: config.confID || `${this.connection.options.hosts.domain}/${this.options.name}`,
378 356
             customScriptUrl: config.callStatsCustomScriptUrl,
@@ -383,7 +361,7 @@ JitsiConference.prototype._init = function(options = {}) {
383 361
             getWiFiStatsMethod: config.getWiFiStatsMethod
384 362
         });
385 363
         Statistics.analytics.addPermanentProperties({
386
-            'callstats_name': aliasName
364
+            'callstats_name': statsCurrentId
387 365
         });
388 366
     }
389 367
 
@@ -2553,12 +2531,10 @@ JitsiConference.prototype._acceptP2PIncomingCall = function(
2553 2531
 
2554 2532
     let remoteID = Strophe.getResourceFromJid(this.p2pJingleSession.remoteJid);
2555 2533
 
2556
-    if (this.options.config.enableStatsID) {
2557
-        const participant = this.participants[remoteID];
2534
+    const participant = this.participants[remoteID];
2558 2535
 
2559
-        if (participant) {
2560
-            remoteID = participant.getStatsID() || remoteID;
2561
-        }
2536
+    if (participant) {
2537
+        remoteID = participant.getStatsID() || remoteID;
2562 2538
     }
2563 2539
 
2564 2540
     this.statistics.startCallStats(
@@ -2903,12 +2879,10 @@ JitsiConference.prototype._startP2PSession = function(remoteJid) {
2903 2879
 
2904 2880
     let remoteID = Strophe.getResourceFromJid(this.p2pJingleSession.remoteJid);
2905 2881
 
2906
-    if (this.options.config.enableStatsID) {
2907
-        const participant = this.participants[remoteID];
2882
+    const participant = this.participants[remoteID];
2908 2883
 
2909
-        if (participant) {
2910
-            remoteID = participant.getStatsID() || remoteID;
2911
-        }
2884
+    if (participant) {
2885
+        remoteID = participant.getStatsID() || remoteID;
2912 2886
     }
2913 2887
 
2914 2888
     this.statistics.startCallStats(

+ 10
- 12
doc/API.md View File

@@ -218,18 +218,16 @@ This objects represents the server connection. You can create new ```JitsiConnec
218 218
 4. initJitsiConference(name, options) - creates new ```JitsiConference``` object.
219 219
     - name - the name of the conference
220 220
     - options - JS object with configuration options for the conference. You can change the following properties there:
221
-        1. openBridgeChannel - Enables/disables bridge channel. Values can be "datachannel", "websocket", true (treat it as "datachannel"), undefined (treat it as "datachannel") and false (don't open any channel). **NOTE: we recommend to set that option to true**
222
-        2. recordingType - the type of recording to be used
223
-        3. jirecon
224
-        4. callStatsID - callstats credentials
225
-        5. callStatsSecret - callstats credentials
226
-        6. enableTalkWhileMuted - boolean property. Enables/disables talk while muted detection, by default the value is false/disabled.
227
-        7. ignoreStartMuted - ignores start muted events coming from jicofo.
228
-        8. enableStatsID - enables sending callStatsUsername as stats-id in presence, jicofo and videobridge will use it as endpointID to report stats
229
-        9. enableDisplayNameInStats - enables sending the users display name, if set, to callstats as alias of the endpointID stats
230
-        10. startSilent - enables silent mode, will mark audio as inactive will not send/receive audio
231
-        11. confID - Used for statistics to identify conference, if tenants are supported will contain tenant and the non lower case variant for the room name.
232
-        12. enableEmailInStats - enables sending the users emails to callstats as id of the endpointID stats, set as presence so it can reach jicofo and jvb to use it when reporting, set as id to the anlytics
221
+        - openBridgeChannel - Enables/disables bridge channel. Values can be "datachannel", "websocket", true (treat it as "datachannel"), undefined (treat it as "datachannel") and false (don't open any channel). **NOTE: we recommend to set that option to true**
222
+        - recordingType - the type of recording to be used
223
+        - callStatsID - callstats credentials
224
+        - callStatsSecret - callstats credentials
225
+        - enableTalkWhileMuted - boolean property. Enables/disables talk while muted detection, by default the value is false/disabled.
226
+        - ignoreStartMuted - ignores start muted events coming from jicofo.
227
+        - startSilent - enables silent mode, will mark audio as inactive will not send/receive audio
228
+        - confID - Used for statistics to identify conference, if tenants are supported will contain tenant and the non lower case variant for the room name.
229
+        - statisticsId - The id to be used as stats instead of default callStatsUsername.
230
+        - statisticsDisplayName - The display name to be used for stats, used for callstats.
233 231
 
234 232
         **NOTE: if 4 and 5 are set the library is going to send events to callstats. Otherwise the callstats integration will be disabled.**
235 233
 

Loading…
Cancel
Save