Analytics

Import members from @edx/frontend-platform/analytics

Contains a shared interface for tracking events. Has a default implementation of SegmentAnalyticsService, which supports Segment and the Tracking Log API (hosted in LMS).

The initialize function performs much of the analytics configuration for you. If, however, you're not using the initialize function, analytics can be configured via:

import { configure, SegmentAnalyticsService } from '@edx/frontend-platform/analytics';
import { getConfig } from '@edx/frontend-platform';
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { getLoggingService } from '@edx/frontend-platform/logging';

configure(SegmentAnalyticsService, {
  config: getConfig(),
  loggingService: getLoggingService(),
  httpClient: getAuthenticatedHttpClient(),
});

As shown in this example, analytics depends on the configuration document, logging, and having an authenticated HTTP client.

Source:

Classes

MockAnalyticsService
SegmentAnalyticsService

Interfaces

AnalyticsService

Methods

(inner) configure(AnalyticsService, options) → {AnalyticsService}

Parameters:
Name Type Description
AnalyticsService class
options *
Source:
Returns:
Type
AnalyticsService

(inner) getAnalyticsService() → {AnalyticsService}

Source:
Returns:
Type
AnalyticsService

(inner) identifyAnonymousUser(traits) → {Promise}

Parameters:
Name Type Description
traits *
Source:
Returns:
Type
Promise

(inner) identifyAuthenticatedUser(userId, traits)

Parameters:
Name Type Description
userId *
traits *
Source:

(inner) resetAnalyticsService()

Source:

(inner) sendPageEvent(category, name, properties)

Parameters:
Name Type Description
category *
name *
properties *
Source:

(inner) sendTrackEvent(eventName, properties)

Parameters:
Name Type Description
eventName *
properties *
Source:

(inner) sendTrackingLogEvent(eventName, properties) → {Promise}

Parameters:
Name Type Description
eventName *
properties *
Source:
Returns:
Type
Promise