Skip to content
This repository has been archived by the owner on Jun 2, 2021. It is now read-only.

edx/frontend-analytics

⛔️ DEPRECATION WARNING

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

Build Status Coveralls npm_version npm_downloads license semantic-release

frontend-analytics contains a shared interface for tracking events. At this time, it supports Segment and the Tracking Log API (hosted in LMS).

Usage

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