fix(analytics) make sure rtcstats is not enabled on mobile

This commit is contained in:
Saúl Ibarra Corretgé 2020-09-24 11:53:31 +02:00 committed by Saúl Ibarra Corretgé
parent 1a339100ab
commit 919be21912
2 changed files with 24 additions and 2 deletions

View File

@ -0,0 +1,21 @@
// @flow
import { toState } from '../base/redux';
/**
* Checks whether rtcstats is enabled or not.
*
* @param {Function|Object} stateful - The redux store or {@code getState} function.
* @returns {boolean}
*/
export function isRtcstatsEnabled(stateful: Function | Object) {
// TODO: Remove when rtcstats is fully cimpatible with mobile.
if (navigator.product === 'ReactNative') {
return false;
}
const state = toState(stateful);
const config = state['features/base/config'];
return config?.analytics?.rtcstatsEnabled ?? false;
}

View File

@ -9,6 +9,7 @@ import { getLocalParticipant } from '../base/participants';
import { MiddlewareRegistry } from '../base/redux';
import RTCStats from './RTCStats';
import { isRtcstatsEnabled } from './functions';
import logger from './logger';
/**
@ -25,7 +26,7 @@ MiddlewareRegistry.register(store => next => action => {
switch (action.type) {
case LIB_WILL_INIT: {
if (analytics.rtcstatsEnabled) {
if (isRtcstatsEnabled(state)) {
// RTCStats "proxies" WebRTC functions such as GUM and RTCPeerConnection by rewriting the global
// window functions. Because lib-jitsi-meet uses references to those functions that are taken on
// init, we need to add these proxies before it initializes, otherwise lib-jitsi-meet will use the
@ -47,7 +48,7 @@ MiddlewareRegistry.register(store => next => action => {
break;
}
case CONFERENCE_JOINED: {
if (analytics.rtcstatsEnabled && RTCStats.isInitialized()) {
if (isRtcstatsEnabled(state) && RTCStats.isInitialized()) {
// Once the conference started connect to the rtcstats server and send data.
try {
RTCStats.connect();