瀏覽代碼

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

j8
Saúl Ibarra Corretgé 4 年之前
父節點
當前提交
919be21912
共有 2 個文件被更改,包括 24 次插入2 次删除
  1. 21
    0
      react/features/rtcstats/functions.js
  2. 3
    2
      react/features/rtcstats/middleware.js

+ 21
- 0
react/features/rtcstats/functions.js 查看文件

@@ -0,0 +1,21 @@
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 查看文件

@@ -9,6 +9,7 @@ import { getLocalParticipant } from '../base/participants';
9 9
 import { MiddlewareRegistry } from '../base/redux';
10 10
 
11 11
 import RTCStats from './RTCStats';
12
+import { isRtcstatsEnabled } from './functions';
12 13
 import logger from './logger';
13 14
 
14 15
 /**
@@ -25,7 +26,7 @@ MiddlewareRegistry.register(store => next => action => {
25 26
 
26 27
     switch (action.type) {
27 28
     case LIB_WILL_INIT: {
28
-        if (analytics.rtcstatsEnabled) {
29
+        if (isRtcstatsEnabled(state)) {
29 30
             // RTCStats "proxies" WebRTC functions such as GUM and RTCPeerConnection by rewriting the global
30 31
             // window functions. Because lib-jitsi-meet uses references to those functions that are taken on
31 32
             // 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 => {
47 48
         break;
48 49
     }
49 50
     case CONFERENCE_JOINED: {
50
-        if (analytics.rtcstatsEnabled && RTCStats.isInitialized()) {
51
+        if (isRtcstatsEnabled(state) && RTCStats.isInitialized()) {
51 52
             // Once the conference started connect to the rtcstats server and send data.
52 53
             try {
53 54
                 RTCStats.connect();

Loading…
取消
儲存