Skip to content

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

Step 1: Generate the Brick

bash
archipelago generate firebase_analytics_impl

You will be prompted for:

  • appNameMyApp (must match your monorepo app name)
  • isForMonorepotrue

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 console

iOS — place GoogleService-Info.plist in ios/Runner/:

ios/
└── Runner/
    └── GoogleService-Info.plist   ← downloaded from Firebase console

Follow 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:

dart
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

Built by Banua Coder