sentry_monitoring_impl Free
Sentry vendor implementation for
monitoring_apiwith full error tracking and performance tracing.
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
sentry_monitoring_impl is a vendor brick that implements the AppMonitoring 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.sentryImpl and bound to the AppMonitoring 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. The host app imports SentryMonitoringImplPackageModule and calls initSentryMonitoringImplModule() during DI bootstrap, then overrides 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(enable:)callsSentryFlutter.initwith all options fromSentryConfig; no-ops ifenableis false - Scoped user identity —
setUserIdusesSentry.configureScopeto attach aSentryUserwith optional email and token data;removeUsersets scope user to null - Breadcrumbs —
log(message:, tag:, level:)maps toSentry.addBreadcrumbwith category 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 - Performance transactions —
recordTransactionwrapsSentry.startTransaction, attaches data entries as span data, marks status asokorinternalError, and always callstransaction.finish()
Dependencies
| Package | Version | Purpose |
|---|---|---|
sentry_flutter | ^9.10.0 | Sentry Flutter SDK |
monitoring_api | path | AppMonitoring contract |
dependencies | path | injectable / get_it re-export |
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).