Skip to content

firebase_analytics_impl Free

Firebase Analytics vendor implementation for the analytics_api contract.

Version: 1.0.0

Variables

VariableTypeDefaultDescription
appNamestringThe name of your application
isForMonorepobooleantrueWhether this is being generated as part of a monorepo

Architecture

This brick generates a single vendor implementation package that plugs into the analytics_sdk orchestration layer:

  • FirebaseAnalyticsVendor — Implements AnalyticVendor using FirebaseAnalytics, registered as @Named(AnalyticInjectorKey.firebaseImpl)
  • FirebaseAnalyticsRegisterModule — Injectable module that provides the FirebaseAnalytics.instance singleton
  • MicroPackage DI@InjectableInit.microPackage() on initFirebaseAnalyticsImplModule() for modular registration into the root DI graph

Unlike other vendor bricks, this implementation does not depend on app_config because FirebaseAnalytics.instance is configured via the google-services.json / GoogleService-Info.plist files placed in the native project.

Generated Structure

infrastructure/
└── firebase_analytics_impl/
    ├── lib/
    │   ├── firebase_analytics_impl.dart   # Package barrel export
    │   └── src/
    │       ├── firebase_analytics_vendor.dart  # AnalyticVendor impl
    │       └── di/
    │           ├── injector.dart               # microPackage DI entry
    │           └── register_module.dart        # FirebaseAnalytics provider
    └── pubspec.yaml

Key Features

  • Event name sanitization — Event names are cleaned to alphanumeric + underscore characters, collapsed to single underscores, and truncated to Firebase's 40-character maximum
  • Parameter key sanitization — Parameter keys receive the same treatment (alphanumeric + underscore, max 40 chars)
  • Parameter value coercion — Values are coerced to Firebase-compatible types: strings are truncated at 100 chars; lists and maps are converted via toString(); null values are dropped
  • User identificationsetUserId maps to FirebaseAnalytics.setUserId
  • User propertiessetUserProperty maps to FirebaseAnalytics.setUserProperty
  • Reset — Full data reset via FirebaseAnalytics.resetAnalyticsData()
  • Named DI — Registered under AnalyticInjectorKey.firebaseImpl for unambiguous resolution alongside other vendors

Configuration

Firebase Analytics is configured through native project files — no runtime API keys are read from app_config:

FilePlatformPurpose
google-services.jsonAndroidFirebase project configuration
GoogleService-Info.plistiOSFirebase project configuration

Follow the FlutterFire setup guide to generate and place these files.

Firebase Constraints

Firebase Analytics enforces strict limits that this vendor handles automatically:

ConstraintLimitHandled by
Event name length40 characters_sanitizeEventName truncation
Parameter key length40 characters_sanitizeParameterKey truncation
String value length100 characters_sanitizeParameterValue truncation
Allowed characters[a-zA-Z0-9_]regex replacement with _

Dependencies

PackageVersionPurpose
firebase_analytics^12.1.1Firebase Analytics Flutter SDK
analytics_apiworkspaceVendor contract (AnalyticVendor, TrackData)
dependenciesworkspaceShared DI annotations (injectable)

Built by Banua Coder