Procházet zdrojové kódy

feat(analytics):Add white/black list functionality

j8
Hristo Terezov před 5 roky
rodič
revize
bd99108e8e

+ 6
- 2
react/features/analytics/functions.js Zobrazit soubor

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

+ 25
- 6
react/features/analytics/handlers/AbstractHandler.js Zobrazit soubor

@@ -4,12 +4,22 @@
4 4
 export default class AbstractHandler {
5 5
     /**
6 6
      * Creates new instance.
7
+     *
8
+     * @param {Object} options - Optional parameters.
7 9
      */
8
-    constructor() {
10
+    constructor(options = {}) {
9 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,7 +70,16 @@ export default class AbstractHandler {
60 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 Zobrazit soubor

@@ -13,7 +13,7 @@ export default class AmplitudeHandler extends AbstractHandler {
13 13
      * by the Amplitude API.
14 14
      */
15 15
     constructor(options) {
16
-        super();
16
+        super(options);
17 17
 
18 18
         const { amplitudeAPPKey, host, user } = options;
19 19
 

+ 1
- 1
react/features/analytics/handlers/GoogleAnalyticsHandler.js Zobrazit soubor

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

Načítá se…
Zrušit
Uložit