Browse Source

Adds confID to JitsiConference option and enables callstats siteID. (#934)

* Adds confID to JitsiConference option and enables callstats siteID.

* Simplifies siteID logic and use '/' as default when there is no tenant.
master
Дамян Минков 5 years ago
parent
commit
24bda8e941
No account linked to committer's email address
4 changed files with 17 additions and 35 deletions
  1. 1
    13
      JitsiConference.js
  2. 1
    1
      doc/API.md
  3. 8
    0
      modules/statistics/CallStats.js
  4. 7
    21
      modules/statistics/statistics.js

+ 1
- 13
JitsiConference.js View File

@@ -295,14 +295,6 @@ JitsiConference.prototype._init = function(options = {}) {
295 295
     this.participantConnectionStatus.init();
296 296
 
297 297
     if (!this.statistics) {
298
-        // XXX The property location on the global variable window is not
299
-        // defined in all execution environments (e.g. react-native). While
300
-        // jitsi-meet may polyfill it when executing on react-native, it is
301
-        // better for the cross-platform support to not require window.location
302
-        // especially when there is a worthy alternative (as demonstrated
303
-        // bellow).
304
-        const windowLocation = window.location;
305
-
306 298
         let callStatsAliasName = this.myUserId();
307 299
 
308 300
         if (config.enableDisplayNameInStats && config.displayName) {
@@ -311,14 +303,10 @@ JitsiConference.prototype._init = function(options = {}) {
311 303
 
312 304
         this.statistics = new Statistics(this.xmpp, {
313 305
             callStatsAliasName,
314
-            callStatsConfIDNamespace:
315
-                config.callStatsConfIDNamespace
316
-                    || (windowLocation && windowLocation.hostname)
317
-                    || (config.hosts && config.hosts.domain),
306
+            confID: config.confID || `${config.hosts.domain}/${this.options.name}`,
318 307
             customScriptUrl: config.callStatsCustomScriptUrl,
319 308
             callStatsID: config.callStatsID,
320 309
             callStatsSecret: config.callStatsSecret,
321
-            roomName: this.options.name,
322 310
             swapUserNameAndAlias: config.enableStatsID,
323 311
             applicationName: config.applicationName,
324 312
             getWiFiStatsMethod: config.getWiFiStatsMethod

+ 1
- 1
doc/API.md View File

@@ -50,7 +50,6 @@ The ```options``` parameter is JS object with the following properties:
50 50
     - `disableThirdPartyRequests` - if true - callstats will be disabled and the callstats API won't be included.
51 51
     - `enableAnalyticsLogging` - boolean property (default false). Enables/disables analytics logging.
52 52
     - `callStatsCustomScriptUrl` - (optional) custom url to access callstats client script
53
-    - `callStatsConfIDNamespace` - (optional) a namespace to prepend the callstats conference ID with. Defaults to the window.location.hostname
54 53
     - `disableRtx` - (optional) boolean property (default to false).  Enables/disable the use of RTX.
55 54
     - `disableH264` - (optional) boolean property (default to false).  If enabled, strips the H.264 codec from the local SDP.
56 55
     - `preferH264` - (optional) boolean property (default to false).  Enables/disable preferring the first instance of an h264 codec in an offer by moving it to the front of the codec list.
@@ -228,6 +227,7 @@ This objects represents the server connection. You can create new ```JitsiConnec
228 227
         8. enableStatsID - enables sending callStatsUsername as stats-id in presence, jicofo and videobridge will use it as endpointID to report stats
229 228
         9. enableDisplayNameInStats - enables sending the users display name, if set, to callstats as alias of the endpointID stats
230 229
         10. startSilent - enables silent mode, will mark audio as inactive will not send/receive audio
230
+        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.
231 231
 
232 232
         **NOTE: if 4 and 5 are set the library is going to send events to callstats. Otherwise the callstats integration will be disabled.**
233 233
 

+ 8
- 0
modules/statistics/CallStats.js View File

@@ -371,6 +371,14 @@ export default class CallStats {
371 371
                 };
372 372
             }
373 373
 
374
+            if (options.confID) {
375
+                // we first check is there a tenant in the confID
376
+                const match = options.confID.match(/.*\/(.*)\/.*/);
377
+
378
+                // if there is no tenant, we will just set '/'
379
+                configParams.siteID = (match && match[1]) || '/';
380
+            }
381
+
374 382
             // userID is generated or given by the origin server
375 383
             CallStats.backend.initialize(
376 384
                 CallStats.callStatsID,

+ 7
- 21
modules/statistics/statistics.js View File

@@ -73,7 +73,8 @@ function _initCallStatsBackend(options) {
73 73
         aliasName: options.swapUserNameAndAlias
74 74
             ? userName : options.callStatsAliasName,
75 75
         applicationName: options.applicationName,
76
-        getWiFiStatsMethod: options.getWiFiStatsMethod
76
+        getWiFiStatsMethod: options.getWiFiStatsMethod,
77
+        confID: options.confID
77 78
     })) {
78 79
         logger.error('CallStats Backend initialization failed bad');
79 80
     }
@@ -129,13 +130,11 @@ Statistics.init = function(options) {
129 130
  * callstats.
130 131
  * @property {string} callStatsAliasName - The alias name to use when
131 132
  * initializing callstats.
132
- * @property {string} callStatsConfIDNamespace - A namespace to prepend the
133
- * callstats conference ID with.
133
+ * @property {string} confID - The callstats conference ID to use.
134 134
  * @property {string} callStatsID - Callstats credentials - the id.
135 135
  * @property {string} callStatsSecret - Callstats credentials - the secret.
136 136
  * @property {string} customScriptUrl - A custom lib url to use when downloading
137 137
  * callstats library.
138
- * @property {string} roomName - The room name we are currently in.
139 138
  * @property {boolean} swapUserNameAndAlias - Whether to swap the places of
140 139
  * username and alias when initiating callstats.
141 140
  */
@@ -170,8 +169,8 @@ export default function Statistics(xmpp, options) {
170 169
             loadCallStatsAPI(this.options);
171 170
         }
172 171
 
173
-        if (!this.options.callStatsConfIDNamespace) {
174
-            logger.warn('"callStatsConfIDNamespace" is not defined');
172
+        if (!this.options.confID) {
173
+            logger.warn('"confID" is not defined');
175 174
         }
176 175
     }
177 176
 
@@ -368,7 +367,7 @@ Statistics.prototype.startCallStats = function(tpc, remoteUserID) {
368 367
         = new CallStats(
369 368
             tpc,
370 369
             {
371
-                confID: this._getCallStatsConfID(),
370
+                confID: this.options.confID,
372 371
                 remoteUserID
373 372
             });
374 373
 
@@ -393,19 +392,6 @@ Statistics._getAllCallStatsInstances = function() {
393 392
     return csInstances;
394 393
 };
395 394
 
396
-/**
397
- * Constructs the CallStats conference ID based on the options currently
398
- * configured in this instance.
399
- * @return {string}
400
- * @private
401
- */
402
-Statistics.prototype._getCallStatsConfID = function() {
403
-    // The conference ID is case sensitive!!!
404
-    return this.options.callStatsConfIDNamespace
405
-        ? `${this.options.callStatsConfIDNamespace}/${this.options.roomName}`
406
-        : this.options.roomName;
407
-};
408
-
409 395
 /**
410 396
  * Removes the callstats.io instances.
411 397
  */
@@ -686,7 +672,7 @@ Statistics.sendLog = function(m) {
686 672
  * @param comment the comment from the user.
687 673
  */
688 674
 Statistics.prototype.sendFeedback = function(overall, comment) {
689
-    CallStats.sendFeedback(this._getCallStatsConfID(), overall, comment);
675
+    CallStats.sendFeedback(this.options.confID, overall, comment);
690 676
     Statistics.analytics.sendEvent(
691 677
         FEEDBACK,
692 678
         {

Loading…
Cancel
Save