Browse Source

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

j8
Saúl Ibarra Corretgé 4 years ago
parent
commit
919be21912
2 changed files with 24 additions and 2 deletions
  1. 21
    0
      react/features/rtcstats/functions.js
  2. 3
    2
      react/features/rtcstats/middleware.js

+ 21
- 0
react/features/rtcstats/functions.js View File

1
+// @flow
2
+
3
+import { toState } from '../base/redux';
4
+
5
+/**
6
+ * Checks whether rtcstats is enabled or not.
7
+ *
8
+ * @param {Function|Object} stateful - The redux store or {@code getState} function.
9
+ * @returns {boolean}
10
+ */
11
+export function isRtcstatsEnabled(stateful: Function | Object) {
12
+    // TODO: Remove when rtcstats is fully cimpatible with mobile.
13
+    if (navigator.product === 'ReactNative') {
14
+        return false;
15
+    }
16
+
17
+    const state = toState(stateful);
18
+    const config = state['features/base/config'];
19
+
20
+    return config?.analytics?.rtcstatsEnabled ?? false;
21
+}

+ 3
- 2
react/features/rtcstats/middleware.js View File

9
 import { MiddlewareRegistry } from '../base/redux';
9
 import { MiddlewareRegistry } from '../base/redux';
10
 
10
 
11
 import RTCStats from './RTCStats';
11
 import RTCStats from './RTCStats';
12
+import { isRtcstatsEnabled } from './functions';
12
 import logger from './logger';
13
 import logger from './logger';
13
 
14
 
14
 /**
15
 /**
25
 
26
 
26
     switch (action.type) {
27
     switch (action.type) {
27
     case LIB_WILL_INIT: {
28
     case LIB_WILL_INIT: {
28
-        if (analytics.rtcstatsEnabled) {
29
+        if (isRtcstatsEnabled(state)) {
29
             // RTCStats "proxies" WebRTC functions such as GUM and RTCPeerConnection by rewriting the global
30
             // RTCStats "proxies" WebRTC functions such as GUM and RTCPeerConnection by rewriting the global
30
             // window functions. Because lib-jitsi-meet uses references to those functions that are taken on
31
             // window functions. Because lib-jitsi-meet uses references to those functions that are taken on
31
             // init, we need to add these proxies before it initializes, otherwise lib-jitsi-meet will use the
32
             // init, we need to add these proxies before it initializes, otherwise lib-jitsi-meet will use the
47
         break;
48
         break;
48
     }
49
     }
49
     case CONFERENCE_JOINED: {
50
     case CONFERENCE_JOINED: {
50
-        if (analytics.rtcstatsEnabled && RTCStats.isInitialized()) {
51
+        if (isRtcstatsEnabled(state) && RTCStats.isInitialized()) {
51
             // Once the conference started connect to the rtcstats server and send data.
52
             // Once the conference started connect to the rtcstats server and send data.
52
             try {
53
             try {
53
                 RTCStats.connect();
54
                 RTCStats.connect();

Loading…
Cancel
Save