fix(analytics) make sure rtcstats is not enabled on mobile
This commit is contained in:
parent
1a339100ab
commit
919be21912
|
@ -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;
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ import { getLocalParticipant } from '../base/participants';
|
||||||
import { MiddlewareRegistry } from '../base/redux';
|
import { MiddlewareRegistry } from '../base/redux';
|
||||||
|
|
||||||
import RTCStats from './RTCStats';
|
import RTCStats from './RTCStats';
|
||||||
|
import { isRtcstatsEnabled } from './functions';
|
||||||
import logger from './logger';
|
import logger from './logger';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,7 +26,7 @@ MiddlewareRegistry.register(store => next => action => {
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case LIB_WILL_INIT: {
|
case LIB_WILL_INIT: {
|
||||||
if (analytics.rtcstatsEnabled) {
|
if (isRtcstatsEnabled(state)) {
|
||||||
// RTCStats "proxies" WebRTC functions such as GUM and RTCPeerConnection by rewriting the global
|
// 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
|
// 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
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
case CONFERENCE_JOINED: {
|
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.
|
// Once the conference started connect to the rtcstats server and send data.
|
||||||
try {
|
try {
|
||||||
RTCStats.connect();
|
RTCStats.connect();
|
||||||
|
|
Loading…
Reference in New Issue