feat(analytics):Add white/black list functionality

This commit is contained in:
Hristo Terezov 2019-08-30 16:16:05 +01:00
parent 0c042b4078
commit bd99108e8e
4 changed files with 33 additions and 10 deletions

View File

@ -63,12 +63,15 @@ export function initAnalytics({ getState }: { getState: Function }) {
} = config; } = config;
const { const {
amplitudeAPPKey, amplitudeAPPKey,
blackListedEvents,
scriptURLs, scriptURLs,
googleAnalyticsTrackingId googleAnalyticsTrackingId,
whiteListedEvents
} = analyticsConfig; } = analyticsConfig;
const { group, server, user } = state['features/base/jwt']; const { group, server, user } = state['features/base/jwt'];
const handlerConstructorOptions = { const handlerConstructorOptions = {
amplitudeAPPKey, amplitudeAPPKey,
blackListedEvents,
envType: (deploymentInfo && deploymentInfo.envType) || 'dev', envType: (deploymentInfo && deploymentInfo.envType) || 'dev',
googleAnalyticsTrackingId, googleAnalyticsTrackingId,
group, group,
@ -76,7 +79,8 @@ export function initAnalytics({ getState }: { getState: Function }) {
product: deploymentInfo && deploymentInfo.product, product: deploymentInfo && deploymentInfo.product,
subproduct: deploymentInfo && deploymentInfo.environment, subproduct: deploymentInfo && deploymentInfo.environment,
user: user && user.id, user: user && user.id,
version: JitsiMeetJS.version version: JitsiMeetJS.version,
whiteListedEvents
}; };
_loadHandlers(scriptURLs, handlerConstructorOptions) _loadHandlers(scriptURLs, handlerConstructorOptions)

View File

@ -4,12 +4,22 @@
export default class AbstractHandler { export default class AbstractHandler {
/** /**
* Creates new instance. * Creates new instance.
*
* @param {Object} options - Optional parameters.
*/ */
constructor() { constructor(options = {}) {
this._enabled = false; this._enabled = false;
this._ignoredEvents this._whiteListedEvents = options.whiteListedEvents;
= [ 'e2e_rtt', 'rtp.stats', 'rtt.by.region', 'available.device',
'stream.switch.delay', 'ice.state.changed', 'ice.duration' ]; // 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; return true;
} }
// Temporary removing some of the events that are too noisy. const name = this._extractName(event);
return this._ignoredEvents.indexOf(event.action) !== -1;
if (Array.isArray(this._whiteListedEvents)) {
return this._whiteListedEvents.indexOf(name) === -1;
}
if (Array.isArray(this._blackListedEvents)) {
return this._blackListedEvents.indexOf(name) !== -1;
}
return false;
} }
} }

View File

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

View File

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