AnalyticsEngine
AnalyticsEngine
AnalyticsEngine class for managing analytics providers and tracking events. This class allows you to register a provider, set a filter for events, and track or identify events.
class AnalyticsEngine {
constructor(commandkit: CommandKit)
setFilter(filter: FilterFunction | null) => ;
registerProvider(provider: AnalyticsProvider) => ;
removeProvider(provider: AnalyticsProvider) => ;
getProvider() => AnalyticsProvider | null;
identify(event: IdentifyEvent) => ;
track(event: AnalyticsEvent) => ;
}
constructor
(commandkit: CommandKit) => AnalyticsEngine
Creates an instance of the AnalyticsEngine.
setFilter
(filter: FilterFunction | null) =>
Sets a filter function for analytics events.
This function will be called before tracking an event to determine if it should be tracked.
If the filter returns false
, the event will not be tracked.
If the filter is set to null
, all events will be tracked unless doNotTrack
is enabled.
registerProvider
(provider: AnalyticsProvider) =>
Registers an analytics provider. This provider will be used to track and identify events. If a provider is already registered, it will be replaced with the new one.
removeProvider
(provider: AnalyticsProvider) =>
Removes the currently registered analytics provider.
getProvider
() => AnalyticsProvider | null
Retrieves the currently registered analytics provider.
identify
(event: IdentifyEvent) =>
Identifies a user with the analytics provider. This method sends an identify event to the provider, which can be used to associate user data with events.
track
(event: AnalyticsEvent) =>
Tracks an analytics event with the registered provider.
This method sends the event to the provider, which can then process it as needed.
If the doNotTrack
setting is enabled or if the filter function returns false
, the event will not be tracked.