AnalyticsService class

This service allows interacting with the integrated trackers (Firebase Analytics, Amplitude, etc).

Constructors

AnalyticsService({List<Tracker>? trackers})
Public constructor to allow direct instantiability for dependency injection and testing.

Properties

enabled ↔ bool
Global toggle to enable or disable all analytics tracking (for GDPR/privacy compliance). If set to false, all tracking, userId, and user property updates are ignored.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

init(List<Tracker> trackers) → void
Init each Tracker.
isTrackerEnabled(Type trackerType) → bool
Returns whether a specific tracker type is enabled.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setTrackerEnabled(Type trackerType, {required bool enabled}) → void
Sets whether a specific tracker type is enabled or disabled.
setUserId(String? userId) → void
Set user id for each Tracker.
setUserProperties(Map<String, dynamic> properties) → void
Set user properties for each Tracker.
toString() → String
A string representation of this object.
inherited
track(Event event) → void
Log event in each Tracker.

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

instance → AnalyticsService
Returns the default global instance of AnalyticsService.
no setter

Static Methods

reset() → void
Resets the global instance of AnalyticsService. Useful for unit tests.