This library is deprecated and will be archived.
Its functionality has been moved into frontend-platform, which should be used for frontend development going forward. Please contact @edx/fedx-team with any questions.
frontend-analytics contains a shared interface for tracking events. At this time, it supports Segment and the Tracking Log API (hosted in LMS).
To install frontend-analytics into your project:
npm i --save @edx/frontend-analytics
Add the following configuration code to your app:
import { configureAnalytics, initializeSegment } from '@edx/analytics';
import LoggingService from '@edx/frontend-logging';
// Example of a configured frontend-auth api client
import apiClient from '../config/apiClient';
// Sample object containing app configuration
import { configuration } from '../config/environment';
initializeSegment(configuration.SEGMENT_KEY);
configureAnalytics({
loggingService: LoggingService,
authApiClient: apiClient,
analyticsApiBaseUrl: configuration.LMS_BASE_URL,
});