FirebaseTrackerMixin mixin
Mixin that adds action tracking (→ Firebase Analytics) and error reporting
(→ Firebase Crashlytics) to any class via a Logger backed by
FirebaseTransport.
The default transport and logger are shared singletons. Override firebaseTransport and logger together to inject custom instances.
Example:
class CheckoutService with FirebaseTrackerMixin {
@override
FirebaseTransport get firebaseTransport => _myTransport;
@override
Logger get logger => Logger([_myTransport]);
Future<void> purchase(Item item) {
return withTracking(
'purchase',
() async { /* ... */ },
params: {'item_id': item.id},
);
}
}
Properties
- firebaseTransport → FirebaseTransport
-
The FirebaseTransport backing the logger.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger → Logger
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- trackerContext → String
-
Context label embedded in log events. Defaults to the runtime type name.
no setter
Methods
-
guarded<
T> (Future< T> body(), {bool fatal = false}) → Future<T> -
Runs
bodyand automatically records any thrown error to Crashlytics. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setupFlutterErrorTracking(
) → void - Installs global Flutter error handlers that forward all uncaught errors to Firebase Crashlytics via firebaseTransport.
-
toString(
) → String -
A string representation of this object.
inherited
-
trackAction(
String action, {Map< String, dynamic> ? params}) → Future<void> - Records a user action to Firebase Analytics.
-
trackError(
Object error, {StackTrace? stackTrace, String? message, bool fatal = false}) → Future< void> - Records an error to Firebase Crashlytics (via logger).
-
withTracking<
T> (String action, Future< T> body(), {Map<String, dynamic> ? params}) → Future<T> -
Runs
body, loggingactionon entry.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited