firebase_analytics_impl Free
Firebase Analytics vendor implementation for the analytics_api contract.
Version: 1.0.0
Variables
| Variable | Type | Default | Description |
|---|---|---|---|
| appName | string | — | The name of your application |
| isForMonorepo | boolean | true | Whether 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— ImplementsAnalyticVendorusingFirebaseAnalytics, registered as@Named(AnalyticInjectorKey.firebaseImpl)FirebaseAnalyticsRegisterModule— Injectable module that provides theFirebaseAnalytics.instancesingleton- MicroPackage DI —
@InjectableInit.microPackage()oninitFirebaseAnalyticsImplModule()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.yamlKey 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();nullvalues are dropped - User identification —
setUserIdmaps toFirebaseAnalytics.setUserId - User properties —
setUserPropertymaps toFirebaseAnalytics.setUserProperty - Reset — Full data reset via
FirebaseAnalytics.resetAnalyticsData() - Named DI — Registered under
AnalyticInjectorKey.firebaseImplfor unambiguous resolution alongside other vendors
Configuration
Firebase Analytics is configured through native project files — no runtime API keys are read from app_config:
| File | Platform | Purpose |
|---|---|---|
google-services.json | Android | Firebase project configuration |
GoogleService-Info.plist | iOS | Firebase 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:
| Constraint | Limit | Handled by |
|---|---|---|
| Event name length | 40 characters | _sanitizeEventName truncation |
| Parameter key length | 40 characters | _sanitizeParameterKey truncation |
| String value length | 100 characters | _sanitizeParameterValue truncation |
| Allowed characters | [a-zA-Z0-9_] | regex replacement with _ |
Dependencies
| Package | Version | Purpose |
|---|---|---|
firebase_analytics | ^12.1.1 | Firebase Analytics Flutter SDK |
analytics_api | workspace | Vendor contract (AnalyticVendor, TrackData) |
dependencies | workspace | Shared DI annotations (injectable) |