Browse Source

feat(rtcstats): switch to rtcstats v3 protocol (#8989)

* use new rtcstats clinet

* add room name to identity

* update rtcstats version
factor2
Andrei Gavrilescu 4 years ago
parent
commit
96e886d306
No account linked to committer's email address
4 changed files with 36 additions and 14 deletions
  1. 4
    3
      package-lock.json
  2. 1
    1
      package.json
  3. 22
    6
      react/features/rtcstats/RTCStats.js
  4. 9
    4
      react/features/rtcstats/middleware.js

+ 4
- 3
package-lock.json View File

@@ -15059,10 +15059,11 @@
15059 15059
       }
15060 15060
     },
15061 15061
     "rtcstats": {
15062
-      "version": "github:jitsi/rtcstats#0597c6a928f321d3cdec947d877012b7e8c2f1dc",
15063
-      "from": "github:jitsi/rtcstats#v6.2.0",
15062
+      "version": "github:jitsi/rtcstats#7593044b35b46881fb88af9b20db0f9b660f5752",
15063
+      "from": "github:jitsi/rtcstats#v8.0.1",
15064 15064
       "requires": {
15065
-        "@jitsi/js-utils": "1.0.0"
15065
+        "@jitsi/js-utils": "1.0.0",
15066
+        "uuid": "3.1.0"
15066 15067
       },
15067 15068
       "dependencies": {
15068 15069
         "@jitsi/js-utils": {

+ 1
- 1
package.json View File

@@ -92,7 +92,7 @@
92 92
     "redux": "4.0.4",
93 93
     "redux-thunk": "2.2.0",
94 94
     "rnnoise-wasm": "github:jitsi/rnnoise-wasm#566a16885897704d6e6d67a1d5ac5d39781db2af",
95
-    "rtcstats": "github:jitsi/rtcstats#v6.2.0",
95
+    "rtcstats": "github:jitsi/rtcstats#v8.0.1",
96 96
     "styled-components": "3.4.9",
97 97
     "util": "0.12.1",
98 98
     "uuid": "3.1.0",

+ 22
- 6
react/features/rtcstats/RTCStats.js View File

@@ -37,14 +37,30 @@ class RTCStats {
37 37
      * loaded before it does.
38 38
      *
39 39
      * @param {Object} options -.
40
-     * @param {string} options.rtcstatsEndpoint - The Amplitude app key required.
41
-     * @param {number} options.rtcstatsPollInterval - The getstats poll interval in ms.
40
+     * @param {string} options.endpoint - The Amplitude app key required.
41
+     * @param {string} options.useLegacy - Switch to legacy chrome webrtc statistics. Parameter will only have
42
+     * an effect on chrome based applications.
43
+     * @param {number} options.pollInterval - The getstats poll interval in ms.
42 44
      * @returns {void}
43 45
      */
44 46
     init(options) {
45
-        this.handleTraceWSClose = this.handleTraceWSClose.bind(this);
46
-        this.trace = traceInit(options.rtcstatsEndpoint, this.handleTraceWSClose);
47
-        rtcstatsInit(this.trace, options.rtcstatsPollInterval, [ '' ], connectionFilter);
47
+
48
+        const { endpoint, useLegacy, pollInterval } = options;
49
+
50
+        const traceOptions = {
51
+            endpoint,
52
+            onCloseCallback: this.handleTraceWSClose.bind(this),
53
+            useLegacy
54
+        };
55
+
56
+        const rtcstatsOptions = {
57
+            connectionFilter,
58
+            pollInterval,
59
+            useLegacy
60
+        };
61
+
62
+        this.trace = traceInit(traceOptions);
63
+        rtcstatsInit(this.trace, rtcstatsOptions);
48 64
         this.initialized = true;
49 65
     }
50 66
 
@@ -66,7 +82,7 @@ class RTCStats {
66 82
      * @returns {void}
67 83
      */
68 84
     sendIdentityData(identityData) {
69
-        this.trace && this.trace('identity', null, identityData);
85
+        this.trace && this.trace.identity('identity', null, identityData);
70 86
     }
71 87
 
72 88
     /**

+ 9
- 4
react/features/rtcstats/middleware.js View File

@@ -1,7 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import { getAmplitudeIdentity } from '../analytics';
4
-import { CONFERENCE_UNIQUE_ID_SET } from '../base/conference';
4
+import { CONFERENCE_UNIQUE_ID_SET, getRoomName } from '../base/conference';
5 5
 import { LIB_WILL_INIT } from '../base/lib-jitsi-meet';
6 6
 import { getLocalParticipant } from '../base/participants';
7 7
 import { MiddlewareRegistry } from '../base/redux';
@@ -22,6 +22,7 @@ MiddlewareRegistry.register(store => next => action => {
22 22
     const config = state['features/base/config'];
23 23
     const { analytics } = config;
24 24
 
25
+
25 26
     switch (action.type) {
26 27
     case LIB_WILL_INIT: {
27 28
         if (isRtcstatsEnabled(state)) {
@@ -30,14 +31,17 @@ MiddlewareRegistry.register(store => next => action => {
30 31
             // init, we need to add these proxies before it initializes, otherwise lib-jitsi-meet will use the
31 32
             // original non proxy versions of these functions.
32 33
             try {
33
-                // Default poll interval is 1000ms if not provided in the config.
34
+                // Default poll interval is 1000ms and standard stats will be used, if not provided in the config.
34 35
                 const pollInterval = analytics.rtcstatsPollInterval || 1000;
36
+                const useLegacy = analytics.rtcstatsUseLegacy || false;
37
+
35 38
 
36 39
                 // Initialize but don't connect to the rtcstats server wss, as it will start sending data for all
37 40
                 // media calls made even before the conference started.
38 41
                 RTCStats.init({
39
-                    rtcstatsEndpoint: analytics.rtcstatsEndpoint,
40
-                    rtcstatsPollInterval: pollInterval
42
+                    endpoint: analytics.rtcstatsEndpoint,
43
+                    useLegacy,
44
+                    pollInterval
41 45
                 });
42 46
             } catch (error) {
43 47
                 logger.error('Failed to initialize RTCStats: ', error);
@@ -68,6 +72,7 @@ MiddlewareRegistry.register(store => next => action => {
68 72
                 RTCStats.sendIdentityData({
69 73
                     ...getAmplitudeIdentity(),
70 74
                     ...config,
75
+                    confName: getRoomName(state),
71 76
                     displayName: localParticipant?.name,
72 77
                     meetingUniqueId
73 78
                 });

Loading…
Cancel
Save