Monitoring Implementations
sentry_monitoring_impl Free
- Tier
- Freeversion 1.2.7
- Command
archipelago generate sentry_monitoring_impl- Generates
infrastructure/sentry_monitoring_impl
- Depends on
- monitoring_sdkgenerate these first
Sentry vendor implementation for
monitoring_apiwith full error tracking and performance tracing.
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 |
Install
Interactive
archipelago generate sentry_monitoring_implNon-interactive (CI)
archipelago generate sentry_monitoring_impl --config my_config.jsonGenerate monitoring_sdk first — this brick depends on its monitoring_api package.
Public API
final vendor = getIt<AppMonitoringVendor>(instanceName: MonitoringInjectorKey.sentry);
await vendor.initialize(); // calls SentryFlutter.init(...)
await vendor.setUserContext(userId, extras: {'plan': 'pro'});
vendor.log('checkout opened', level: MonitoringLevel.info); // Sentry breadcrumb
await vendor.recordError(exception, stackTrace, fatal: false);
await vendor.recordTransaction('checkout', () => api.submitOrder());Architecture
sentry_monitoring_impl is a vendor brick that implements the AppMonitoringVendor contract from monitoring_api using the Sentry Flutter SDK. It is selected during flutter_modular_monorepo generation when the user picks sentry from the monitoringVendors multi-select.
SentryMonitoringImpl is registered as a @LazySingleton named MonitoringInjectorKey.sentry (not sentryImpl) and bound to the AppMonitoringVendor interface. It receives a SentryConfig instance via constructor injection. The config is provided by SentryRegisterModule, which the host app must override to supply the real DSN.
DI Registration
The package uses @InjectableInit.microPackage() for modular registration. post_gen.dart adds the package to the host app's pubspec.yaml and registers SentryMonitoringImplPackageModule 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. You then override SentryRegisterModule to provide the project DSN.
Generated Structure
infrastructure/
└── sentry_monitoring_impl/
├── pubspec.yaml
└── lib/
├── sentry_monitoring_impl.dart # Barrel export
└── src/
├── sentry_monitoring_impl.dart # AppMonitoring impl
├── config/
│ └── sentry_config.dart # SentryConfig data class
└── di/
├── injector.dart # microPackage init
├── injector.module.dart # Generated DI module
└── register_module.dart # SentryConfig provider (override required)Key Features
- Full SDK init —
initialize()callsSentryFlutter.initwith every option fromSentryConfig(dsn,environment,tracesSampleRate,enableAutoPerformanceTracing,enableAutoSessionTracking,attachStacktrace, optionalrelease) - Scoped user identity —
setUserContext(userId, {extras})usesSentry.configureScopeto attach aSentryUser(id:, data:);clearUserContext()sets scope user tonull - Breadcrumbs —
log(message, {tag, level})andbreadcrumb(message, {category, data, level})both map toSentry.addBreadcrumbwith category/data and level translation - Level mapping —
MonitoringLevelvalues map 1:1 toSentryLevel(debug → debug, info → info, warning → warning, error → error, fatal → fatal) - Exception capture —
recordErrorcallsSentry.captureException; fatal errors set scope level toSentryLevel.fatal, andcontextis attached viascope.setContexts('context', context) - Performance transactions —
recordTransactionwrapsSentry.startTransaction(name, operation ?? 'task', bindToScope: true), attachesdataentries viatransaction.setData, marks statusok/internalError, and always callstransaction.finish()in afinallyblock
Dependencies
| Package | Version | Purpose |
|---|---|---|
sentry_flutter | ^9.26.0 | Sentry Flutter SDK |
monitoring_api | path | AppMonitoringVendor contract |
dependencies | path | injectable / get_it re-export |
Platform Setup
None required beyond sentry_flutter's own defaults — no native symbol upload or manifest changes are generated by this brick.
Limitations
- No
enable/kill-switch parameter oninitialize()— call it conditionally in your own bootstrap code if you need to skip Sentry entirely (e.g. local dev). recordTransaction'soperationargument maps directly to Sentry's ownoperationparameter (Sentry.startTransaction(name, operation ?? 'task', ...)) — unlikegrafana_monitoring_impl, which instead foldsoperationinto the span name as'$name:$operation'. The two vendors are not interchangeable in how they label spans.
Changelog
Run archipelago brick info sentry_monitoring_impl to see the latest published version. Enterprise customers can read the full CHANGELOG.md in the brick source repository.
Configuration
Override SentryRegisterModule in your app DI module to supply the DSN and any other settings:
@module
abstract class AppSentryModule extends SentryRegisterModule {
@override
@lazySingleton
SentryConfig get sentryConfig => SentryConfig(
dsn: Env.sentryDsn, // required — from your .env / build config
environment: Flavor.status.name, // 'production', 'staging', etc.
release: '${Env.appName}@${Env.version}',
tracesSampleRate: 1.0,
enableAutoPerformanceTracing: true,
enableAutoSessionTracking: true,
attachStacktrace: true,
);
}SentryConfig Fields
| Field | Type | Default | Description |
|---|---|---|---|
dsn | String | required | Sentry project DSN |
environment | String | 'production' | Environment label |
release | String? | null | Release string e.g. my-app@1.0.0 |
tracesSampleRate | double | 1.0 | Performance trace sample rate (0.0–1.0) |
enableAutoPerformanceTracing | bool | true | Automatic route/widget tracing |
enableAutoSessionTracking | bool | true | Session tracking |
attachStacktrace | bool | true | Attach stack traces to all events |
The DSN is found in Sentry Dashboard → Project → Settings → Client Keys (DSN).