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;
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)

View File

@ -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;
}
}

View File

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

View File

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