Skip to main content

herald_firebase 1.2.0 copy "herald_firebase: ^1.2.0" to clipboard
herald_firebase: ^1.2.0 copied to clipboard

A Herald vendor adapter that sends to Firebase Analytics (GA4).

Herald for Firebase #

Sends Herald events and properties to Firebase Analytics (GA4), over firebase_analytics.

final analytics = FirebaseAnalytics.instance; // after Firebase.initializeApp()
final tracker = FirebaseAnalyticsTrackerService(
  eventTrackerFactory: CompositeFirebaseEventTrackerFactory([
    ScreenViewFirebaseEventTrackerFactory(analytics), // GA4's reserved screen_view
    GenericFirebaseEventTrackerFactory(analytics), // everything else, as-is
  ]),
  propertySetterFactory: CompositeFirebasePropertySetterFactory([
    GenericFirebasePropertySetterFactory(analytics),
  ]),
);
final service = FirebaseAnalyticsService(analytics);

final provider = HeraldProvider(
  name: 'firebase',
  events: tracker,
  properties: tracker,
  identity: service,
  lifecycle: service,
  consent: service,
);
Herald Firebase
an event logEvent, with numbers as numbers and flags as 'true'/'false'
a ScreenViewEvent logScreenView(screenName: name)
a property setUserProperty, in its string form
identify / reset setUserId(id: ...) / setUserId()
setEnabled setAnalyticsCollectionEnabled

Herald's error reporter can send vendor failures to Crashlytics, with a one-line reason:

final herald = Herald(
  providers: [provider],
  errorReporter: (failure) => FirebaseCrashlytics.instance.recordError(
    failure.error,
    failure.stackTrace,
    reason: '$failure', // firebase failed on Track(checkout_started): ...
  ),
);

Firebase collects before consent unless its native flags turn collection off: firebase_analytics_collection_enabled=false in the Android manifest and FIREBASE_ANALYTICS_COLLECTION_ENABLED=NO in Info.plist.

Documentation #

It works with herald, the core, whose page lists every Herald package. The Herald website has the guides, and the repository has an example app.

0
likes
160
points
563
downloads

Documentation

Documentation
API reference

Publisher

unverified uploader

Weekly Downloads

A Herald vendor adapter that sends to Firebase Analytics (GA4).

Repository (GitHub)
View/report issues
Contributing

Topics

#analytics #firebase #google-analytics #tracking

License

Apache-2.0 (license)

Dependencies

firebase_analytics, flutter, herald

More

Packages that depend on herald_firebase