Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

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

Andrei Gavrilescu96e886d30647
diff --git a/package-lock.json b/package-lock.json
index ba6add779d..2c14bcae27 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -15059,10 +15059,11 @@
}
},
"rtcstats": {
- "version": "github:jitsi/rtcstats#0597c6a928f321d3cdec947d877012b7e8c2f1dc",
- "from": "github:jitsi/rtcstats#v6.2.0",
+ "version": "github:jitsi/rtcstats#7593044b35b46881fb88af9b20db0f9b660f5752",
+ "from": "github:jitsi/rtcstats#v8.0.1",
"requires": {
- "@jitsi/js-utils": "1.0.0"
+ "@jitsi/js-utils": "1.0.0",
+ "uuid": "3.1.0"
},
"dependencies": {
"@jitsi/js-utils": {
diff --git a/package.json b/package.json
index d118d2100e..9c098cece6 100644
--- a/package.json
+++ b/package.json
@@ -92,7 +92,7 @@
"redux": "4.0.4",
"redux-thunk": "2.2.0",
"rnnoise-wasm": "github:jitsi/rnnoise-wasm#566a16885897704d6e6d67a1d5ac5d39781db2af",
- "rtcstats": "github:jitsi/rtcstats#v6.2.0",
+ "rtcstats": "github:jitsi/rtcstats#v8.0.1",
"styled-components": "3.4.9",
"util": "0.12.1",
"uuid": "3.1.0",
diff --git a/react/features/rtcstats/RTCStats.js b/react/features/rtcstats/RTCStats.js
index 14c915c009..714bde54be 100644
--- a/react/features/rtcstats/RTCStats.js
+++ b/react/features/rtcstats/RTCStats.js
@@ -37,14 +37,30 @@ class RTCStats {
* loaded before it does.
*
* @param {Object} options -.
- * @param {string} options.rtcstatsEndpoint - The Amplitude app key required.
- * @param {number} options.rtcstatsPollInterval - The getstats poll interval in ms.
+ * @param {string} options.endpoint - The Amplitude app key required.
+ * @param {string} options.useLegacy - Switch to legacy chrome webrtc statistics. Parameter will only have
+ * an effect on chrome based applications.
+ * @param {number} options.pollInterval - The getstats poll interval in ms.
* @returns {void}
*/
init(options) {
- this.handleTraceWSClose = this.handleTraceWSClose.bind(this);
- this.trace = traceInit(options.rtcstatsEndpoint, this.handleTraceWSClose);
- rtcstatsInit(this.trace, options.rtcstatsPollInterval, [ '' ], connectionFilter);
+
+ const { endpoint, useLegacy, pollInterval } = options;
+
+ const traceOptions = {
+ endpoint,
+ onCloseCallback: this.handleTraceWSClose.bind(this),
+ useLegacy
+ };
+
+ const rtcstatsOptions = {
+ connectionFilter,
+ pollInterval,
+ useLegacy
+ };
+
+ this.trace = traceInit(traceOptions);
+ rtcstatsInit(this.trace, rtcstatsOptions);
this.initialized = true;
}
@@ -66,7 +82,7 @@ class RTCStats {
* @returns {void}
*/
sendIdentityData(identityData) {
- this.trace && this.trace('identity', null, identityData);
+ this.trace && this.trace.identity('identity', null, identityData);
}
/**
diff --git a/react/features/rtcstats/middleware.js b/react/features/rtcstats/middleware.js
index 8623c13bf6..9b269bce0e 100644
--- a/react/features/rtcstats/middleware.js
+++ b/react/features/rtcstats/middleware.js
@@ -1,7 +1,7 @@
// @flow
import { getAmplitudeIdentity } from '../analytics';
-import { CONFERENCE_UNIQUE_ID_SET } from '../base/conference';
+import { CONFERENCE_UNIQUE_ID_SET, getRoomName } from '../base/conference';
import { LIB_WILL_INIT } from '../base/lib-jitsi-meet';
import { getLocalParticipant } from '../base/participants';
import { MiddlewareRegistry } from '../base/redux';
@@ -22,6 +22,7 @@ MiddlewareRegistry.register(store => next => action => {
const config = state['features/base/config'];
const { analytics } = config;
+
switch (action.type) {
case LIB_WILL_INIT: {
if (isRtcstatsEnabled(state)) {
@@ -30,14 +31,17 @@ MiddlewareRegistry.register(store => next => action => {
// init, we need to add these proxies before it initializes, otherwise lib-jitsi-meet will use the
// original non proxy versions of these functions.
try {
- // Default poll interval is 1000ms if not provided in the config.
+ // Default poll interval is 1000ms and standard stats will be used, if not provided in the config.
const pollInterval = analytics.rtcstatsPollInterval || 1000;
+ const useLegacy = analytics.rtcstatsUseLegacy || false;
+
// Initialize but don't connect to the rtcstats server wss, as it will start sending data for all
// media calls made even before the conference started.
RTCStats.init({
- rtcstatsEndpoint: analytics.rtcstatsEndpoint,
- rtcstatsPollInterval: pollInterval
+ endpoint: analytics.rtcstatsEndpoint,
+ useLegacy,
+ pollInterval
});
} catch (error) {
logger.error('Failed to initialize RTCStats: ', error);
@@ -68,6 +72,7 @@ MiddlewareRegistry.register(store => next => action => {
RTCStats.sendIdentityData({
...getAmplitudeIdentity(),
...config,
+ confName: getRoomName(state),
displayName: localParticipant?.name,
meetingUniqueId
});