浏览代码

feat(analytics):Add white/black list functionality

master
Hristo Terezov 6 年前
父节点
当前提交
bd99108e8e

+ 6
- 2
react/features/analytics/functions.js 查看文件

63
     } = config;
63
     } = config;
64
     const {
64
     const {
65
         amplitudeAPPKey,
65
         amplitudeAPPKey,
66
+        blackListedEvents,
66
         scriptURLs,
67
         scriptURLs,
67
-        googleAnalyticsTrackingId
68
+        googleAnalyticsTrackingId,
69
+        whiteListedEvents
68
     } = analyticsConfig;
70
     } = analyticsConfig;
69
     const { group, server, user } = state['features/base/jwt'];
71
     const { group, server, user } = state['features/base/jwt'];
70
     const handlerConstructorOptions = {
72
     const handlerConstructorOptions = {
71
         amplitudeAPPKey,
73
         amplitudeAPPKey,
74
+        blackListedEvents,
72
         envType: (deploymentInfo && deploymentInfo.envType) || 'dev',
75
         envType: (deploymentInfo && deploymentInfo.envType) || 'dev',
73
         googleAnalyticsTrackingId,
76
         googleAnalyticsTrackingId,
74
         group,
77
         group,
76
         product: deploymentInfo && deploymentInfo.product,
79
         product: deploymentInfo && deploymentInfo.product,
77
         subproduct: deploymentInfo && deploymentInfo.environment,
80
         subproduct: deploymentInfo && deploymentInfo.environment,
78
         user: user && user.id,
81
         user: user && user.id,
79
-        version: JitsiMeetJS.version
82
+        version: JitsiMeetJS.version,
83
+        whiteListedEvents
80
     };
84
     };
81
 
85
 
82
     _loadHandlers(scriptURLs, handlerConstructorOptions)
86
     _loadHandlers(scriptURLs, handlerConstructorOptions)

+ 25
- 6
react/features/analytics/handlers/AbstractHandler.js 查看文件

4
 export default class AbstractHandler {
4
 export default class AbstractHandler {
5
     /**
5
     /**
6
      * Creates new instance.
6
      * Creates new instance.
7
+     *
8
+     * @param {Object} options - Optional parameters.
7
      */
9
      */
8
-    constructor() {
10
+    constructor(options = {}) {
9
         this._enabled = false;
11
         this._enabled = false;
10
-        this._ignoredEvents
11
-            = [ 'e2e_rtt', 'rtp.stats', 'rtt.by.region', 'available.device',
12
-                'stream.switch.delay', 'ice.state.changed', 'ice.duration' ];
12
+        this._whiteListedEvents = options.whiteListedEvents;
13
+
14
+        // FIXME:
15
+        // Keeping the list with the very noisy events so that we don't flood with events whoever hasn't configured
16
+        // white/black lists yet. We need to solve this issue properly by either making these events not so noisy or
17
+        // by removing them completely from the code.
18
+        this._blackListedEvents = [
19
+            ...(options.blackListedEvents || []), // eslint-disable-line no-extra-parens
20
+            'e2e_rtt', 'rtp.stats', 'rtt.by.region', 'available.device', 'stream.switch.delay', 'ice.state.changed',
21
+            'ice.duration'
22
+        ];
13
     }
23
     }
14
 
24
 
15
     /**
25
     /**
60
             return true;
70
             return true;
61
         }
71
         }
62
 
72
 
63
-        // Temporary removing some of the events that are too noisy.
64
-        return this._ignoredEvents.indexOf(event.action) !== -1;
73
+        const name = this._extractName(event);
74
+
75
+        if (Array.isArray(this._whiteListedEvents)) {
76
+            return this._whiteListedEvents.indexOf(name) === -1;
77
+        }
78
+
79
+        if (Array.isArray(this._blackListedEvents)) {
80
+            return this._blackListedEvents.indexOf(name) !== -1;
81
+        }
82
+
83
+        return false;
65
     }
84
     }
66
 }
85
 }

+ 1
- 1
react/features/analytics/handlers/AmplitudeHandler.js 查看文件

13
      * by the Amplitude API.
13
      * by the Amplitude API.
14
      */
14
      */
15
     constructor(options) {
15
     constructor(options) {
16
-        super();
16
+        super(options);
17
 
17
 
18
         const { amplitudeAPPKey, host, user } = options;
18
         const { amplitudeAPPKey, host, user } = options;
19
 
19
 

+ 1
- 1
react/features/analytics/handlers/GoogleAnalyticsHandler.js 查看文件

17
      * required by the GA API.
17
      * required by the GA API.
18
      */
18
      */
19
     constructor(options) {
19
     constructor(options) {
20
-        super();
20
+        super(options);
21
 
21
 
22
         this._userProperties = {};
22
         this._userProperties = {};
23
 
23
 

正在加载...
取消
保存