diff --git a/react/features/analytics/functions.js b/react/features/analytics/functions.js index 339d5fa19..05a86f4f1 100644 --- a/react/features/analytics/functions.js +++ b/react/features/analytics/functions.js @@ -63,12 +63,15 @@ export function initAnalytics({ getState }: { getState: Function }) { } = config; const { amplitudeAPPKey, + blackListedEvents, scriptURLs, - googleAnalyticsTrackingId + googleAnalyticsTrackingId, + whiteListedEvents } = analyticsConfig; const { group, server, user } = state['features/base/jwt']; const handlerConstructorOptions = { amplitudeAPPKey, + blackListedEvents, envType: (deploymentInfo && deploymentInfo.envType) || 'dev', googleAnalyticsTrackingId, group, @@ -76,7 +79,8 @@ export function initAnalytics({ getState }: { getState: Function }) { product: deploymentInfo && deploymentInfo.product, subproduct: deploymentInfo && deploymentInfo.environment, user: user && user.id, - version: JitsiMeetJS.version + version: JitsiMeetJS.version, + whiteListedEvents }; _loadHandlers(scriptURLs, handlerConstructorOptions) diff --git a/react/features/analytics/handlers/AbstractHandler.js b/react/features/analytics/handlers/AbstractHandler.js index cc7c720d8..7d6881dbd 100644 --- a/react/features/analytics/handlers/AbstractHandler.js +++ b/react/features/analytics/handlers/AbstractHandler.js @@ -4,12 +4,22 @@ export default class AbstractHandler { /** * Creates new instance. + * + * @param {Object} options - Optional parameters. */ - constructor() { + constructor(options = {}) { this._enabled = false; - this._ignoredEvents - = [ 'e2e_rtt', 'rtp.stats', 'rtt.by.region', 'available.device', - 'stream.switch.delay', 'ice.state.changed', 'ice.duration' ]; + this._whiteListedEvents = options.whiteListedEvents; + + // FIXME: + // Keeping the list with the very noisy events so that we don't flood with events whoever hasn't configured + // white/black lists yet. We need to solve this issue properly by either making these events not so noisy or + // by removing them completely from the code. + this._blackListedEvents = [ + ...(options.blackListedEvents || []), // eslint-disable-line no-extra-parens + 'e2e_rtt', 'rtp.stats', 'rtt.by.region', 'available.device', 'stream.switch.delay', 'ice.state.changed', + 'ice.duration' + ]; } /** @@ -60,7 +70,16 @@ export default class AbstractHandler { return true; } - // Temporary removing some of the events that are too noisy. - return this._ignoredEvents.indexOf(event.action) !== -1; + const name = this._extractName(event); + + if (Array.isArray(this._whiteListedEvents)) { + return this._whiteListedEvents.indexOf(name) === -1; + } + + if (Array.isArray(this._blackListedEvents)) { + return this._blackListedEvents.indexOf(name) !== -1; + } + + return false; } } diff --git a/react/features/analytics/handlers/AmplitudeHandler.js b/react/features/analytics/handlers/AmplitudeHandler.js index 5e128bb49..ac576cfa6 100644 --- a/react/features/analytics/handlers/AmplitudeHandler.js +++ b/react/features/analytics/handlers/AmplitudeHandler.js @@ -13,7 +13,7 @@ export default class AmplitudeHandler extends AbstractHandler { * by the Amplitude API. */ constructor(options) { - super(); + super(options); const { amplitudeAPPKey, host, user } = options; diff --git a/react/features/analytics/handlers/GoogleAnalyticsHandler.js b/react/features/analytics/handlers/GoogleAnalyticsHandler.js index 50db3a286..bb79bfbfa 100644 --- a/react/features/analytics/handlers/GoogleAnalyticsHandler.js +++ b/react/features/analytics/handlers/GoogleAnalyticsHandler.js @@ -17,7 +17,7 @@ class GoogleAnalyticsHandler extends AbstractHandler { * required by the GA API. */ constructor(options) { - super(); + super(options); this._userProperties = {};