Firebase Analytics Implementation
What you'll learn
- Generating the Firebase Analytics vendor implementation
- Wiring native config files (no runtime API keys)
- Registering the module so the analytics orchestrator picks it up automatically
Prerequisites
- Analytics SDK installed in your monorepo
- A Firebase project created at console.firebase.google.com
google-services.json(Android) andGoogleService-Info.plist(iOS) downloaded from the Firebase console
Step 1: Generate the Brick
archipelago generate firebase_analytics_implYou will be prompted for:
- appName —
MyApp(must match your monorepo app name) - isForMonorepo —
true
The brick is generated into infrastructure/firebase_analytics_impl/.
Step 2: Add Native Config Files
Firebase reads credentials from platform config files — there are no runtime API keys to set in app_config.
Android — place google-services.json in android/app/:
android/
└── app/
└── google-services.json ← downloaded from Firebase consoleiOS — place GoogleService-Info.plist in ios/Runner/:
ios/
└── Runner/
└── GoogleService-Info.plist ← downloaded from Firebase consoleFollow the FlutterFire setup guide if you haven't already initialised Firebase in your app.
Step 3: Register the Module
The generated package uses @InjectableInit.microPackage(). Import its module in your shell app's DI setup and call the initialiser:
import 'package:firebase_analytics_impl/firebase_analytics_impl.dart';
// In your configureDependencies() call:
await initFirebaseAnalyticsImplModule(getIt);The implementation is registered as @Named(AnalyticInjectorKey.firebaseImpl) and implements AnalyticVendor. The analytics_sdk orchestrator calls getIt.getAll<AnalyticVendor>(), so no further wiring is required — registering the module is enough for events to flow.
Step 4: Verify Events Flow
Run the app and trigger a tracked event. Open the Firebase console → DebugView to confirm events arrive in real time.
Event names and parameter keys are automatically sanitised (alphanumeric + underscore, max 40 chars). String values are truncated to 100 chars. Null values are dropped. You do not need to handle these constraints manually.
Next Steps
- Set up the Analytics SDK for the full multi-vendor architecture
- Configure monitoring to track analytics failures