datahub-web-react/src/app/analytics/README.md
The DataHub React application can be configured to emit a set of standardized product analytics events to multiple backend providers including
This provides operators of DataHub with visibility into how their users are engaging with the platform, allowing them to answer questions around weekly active users, the most used features, the least used features, and more.
To accomplish this, we have built a small extension on top of the popular Analytics npm package. This package was chosen because it offers a clear pathway to extending support to many other providers, all of which you can find listed here.
Currently, configuring an analytics provider requires that you fork DataHub & modify code. As described in 'Coming Soon', we intend to improve this process by implementing no-code configuration.
datahub-web-react/src/conf/analytics.tsmixpanel field within the config object.token with the API token provided by Mixpanel.datahub-frontend-react to start tracking.const config: any = {
mixpanel: {
token: 'fad1285da4e618b618973cacf6565e61',
},
};
datahub-web-react/src/conf/analytics.tsamplitude field within the config object.apiKey with the key provided by Amplitude.datahub-frontend-react to start tracking.const config: any = {
amplitude: {
apiKey: 'c5c212632315d19c752ab083bc7c92ff',
},
};
datahub-web-react/src/conf/analytics.tsgoogleAnalytics field within the config.measurementIds with the one provided by Google Analytics.datahub-frontend-react to start tracking.Example:
const config: any = {
googleAnalytics: {
measurementIds: ['G-ATV123'],
},
};
To verify that analytics are being sent to your provider, you can inspect the networking tab of a Google Chrome inspector window:
With DataHub open on Google Chrome
To add a new plugin from the Analytics library:
src/app/analytics/plugin named based on the pluginsrc/app/analytics/plugin/index.jsIf you're unsure, check out the existing plugin implements as examples. Before contributing a plugin, please be sure to verify the integration by viewing the product metrics in the new analytics provider.
To add a new DataHub analytics event, make the following changes to src/app/analytics/event.ts:
EventType enum export enum EventType {
LogInEvent,
LogOutEvent,
...,
MyNewEvent
}
BaseEventexport interface MyNewEvent extends BaseEvent {
type: EventType.MyNewEvent; // must be the type you just added
... your event's custom fields
}
Event type.export type Event =
| LogInEvent
| LogOutEvent
....
| MyNewEvent
Emitting a tracking DataHub analytics event is a 2-step process:
analytics moduleimport analytics, { EventType } from '../analytics';
event method, passing in an event object of the appropriate typeanalytics.event({ type: EventType.MyNewEvent, ...my event fields });
To log events to the console for debugging / verification purposes
datahub-web-react/src/conf/analytics.tslogging: true within the config object.datahub-frontend-react to start logging all events to your browser's console.In the near future, we intend to