Monitoring Implementations
crashlytics_monitoring_impl Free
- Tier
- Freeversion 1.2.8
- Command
archipelago generate crashlytics_monitoring_impl- Generates
infrastructure/crashlytics_monitoring_impl
- Depends on
- monitoring_sdkgenerate these first
Firebase Crashlytics vendor plugin for
monitoring_sdk— implementsAppMonitoringVendorand registers itself into theAppMonitoringfanout under the'crashlytics'key.
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 |
Selected during flutter_modular_monorepo generation via the monitoringVendors multi-select (crashlytics option) — see monitoring_sdk, not a variable of this brick itself.
Usage
Interactive
archipelago generate crashlytics_monitoring_implNon-interactive (CI)
archipelago generate crashlytics_monitoring_impl --config my_config.jsonGenerated Structure
infrastructure/
└── crashlytics_monitoring_impl/
├── pubspec.yaml
└── lib/
├── crashlytics_monitoring_impl.dart # Barrel export
└── src/
├── crashlytics_monitoring_impl.dart # CrashlyticsMonitoringVendor
└── di/
├── injector.dart # microPackage init
├── injector.module.dart # Generated DI module
└── register_module.dart # FirebaseCrashlytics providerAPI
@Named(MonitoringInjectorKey.crashlytics) // 'crashlytics'
@LazySingleton(as: AppMonitoringVendor)
class CrashlyticsMonitoringVendor
implements AppMonitoringVendor, FlutterAwareMonitoringVendor {
CrashlyticsMonitoringVendor(this._crashlytics);
Future<void> initialize(); // setCrashlyticsCollectionEnabled(true)
Future<void> dispose(); // setCrashlyticsCollectionEnabled(false)
Future<void> setUserContext(String userId, {Map<String, dynamic>? extras});
Future<void> clearUserContext();
void log(String message, {String? tag, MonitoringLevel level});
Future<void> recordError(Object exception, StackTrace? stackTrace, {bool fatal = false, Map<String, dynamic>? context});
Future<T> recordTransaction<T>(String name, Future<T> Function() action, {String? operation, Map<String, dynamic>? data});
void breadcrumb(String message, {String? category, Map<String, dynamic>? data, MonitoringLevel level});
Future<void> recordFlutterError(FlutterErrorDetails details);
}You never call this class directly — install the brick, and getIt<AppMonitoring>() (from monitoring_sdk) fans out to it automatically once monitoring.initialize() runs. Notes on the real implementation:
- When diagnostics consent is withdrawn, the vendor disables collection, calls
deleteUnsentReports()and clears the user id. initialize()/dispose()take no parameters — collection is toggled purely by callinginitialize()(enable) ordispose()(disable); there is noenable:bool argument.setUserContext(userId, extras)maps to CrashlyticssetUserIdentifier+ onesetCustomKeyperextrasentry (stringified).clearUserContext()resets the identifier to''.recordErrorforwards toFirebaseCrashlytics.recordError(fatal: ..., printDetails: kDebugMode); anycontextmap is written as custom keys first.recordTransactionis a pass-through — Crashlytics has no span/transaction concept, so it just awaits and returnsaction().- Implementing
FlutterAwareMonitoringVendormeansMonitoringFanoutImpl.recordFlutterError(reached from bootstrap'sFlutterError.onError) usesrecordFlutterError(Crashlytics' dedicated API, preserves widget-tree info) instead of the genericrecordError.
Dependency injection
register_module.dart provides the FirebaseCrashlytics singleton:
@module
abstract class CrashlyticsRegisterModule {
@lazySingleton
FirebaseCrashlytics get firebaseCrashlytics => FirebaseCrashlytics.instance;
}pubspec.yaml's archipelago: manifest declares the package's DI module for monorepo_toolkit generate host-registry:
archipelago:
di_modules:
- class: CrashlyticsMonitoringImplPackageModulepost_gen.dart adds the package to the host app's pubspec.yaml and registers CrashlyticsMonitoringImplPackageModule in the app's injector.dart. The monitoring_impl fanout builds its vendor list from the @Named registrations when AppMonitoring is first resolved, so every vendor module must run before that. Install order does not decide this. The hook rebuilds the injector entries from each package's archipelago: di_modules manifest in dependency order (the order monorepo_toolkit generate host-registry computes). Generate monitoring_sdk first when you install standalone, because the vendor imports monitoring_api. flutter_modular_monorepo generates the vendors first in one run, and both orders work. After you add a vendor, run flutter test test/di/injector_test.dart to confirm AppMonitoring resolves.
Dependencies
monitoring_api— theAppMonitoringVendor/FlutterAwareMonitoringVendorcontractsfirebase_crashlytics: ^5.2.7dependencies(shared workspaceinjectable/get_itre-export)
Platform Setup
Firebase Crashlytics needs native configuration independent of this brick. Firebase must be configured with flutterfire configure: see Firebase Setup. The brick wires a guarded Firebase.initializeApp() into bootstrap.dart (before initializeInjector()). Without Firebase config the app still boots and this vendor is skipped with a debug message.
- Add
google-services.json(Android) andGoogleService-Info.plist(iOS) to the respective platform directories. - Apply the Google Services / Crashlytics Gradle plugin on Android.
- Enable Crashlytics for the project in the Firebase console.
Known Limitations
- No performance-transaction support (see
recordTransactionabove) — pair with a tracing-capable vendor (Sentry, Grafana) if spans are needed.
Changelog
Run archipelago brick info crashlytics_monitoring_impl to see the latest published version. Enterprise customers can read the full CHANGELOG.md in the brick source repository.