Skip to content

sentry_monitoring_impl Free

Sentry vendor implementation for monitoring_api with full error tracking and performance tracing.

Version: 1.0.0

Variables

VariableTypeDefaultDescription
appNamestringThe name of your application
isForMonorepobooleantrueWhether 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 initinitialize(enable:) calls SentryFlutter.init with all options from SentryConfig; no-ops if enable is false
  • Scoped user identitysetUserId uses Sentry.configureScope to attach a SentryUser with optional email and token data; removeUser sets scope user to null
  • Breadcrumbslog(message:, tag:, level:) maps to Sentry.addBreadcrumb with category and level translation
  • Level mappingMonitoringLevel values map 1:1 to SentryLevel (debug → debug, info → info, warning → warning, error → error, fatal → fatal)
  • Exception capturerecordError calls Sentry.captureException; fatal errors set scope level to SentryLevel.fatal
  • Performance transactionsrecordTransaction wraps Sentry.startTransaction, attaches data entries as span data, marks status as ok or internalError, and always calls transaction.finish()

Dependencies

PackageVersionPurpose
sentry_flutter^9.10.0Sentry Flutter SDK
monitoring_apipathAppMonitoring contract
dependenciespathinjectable / get_it re-export

Configuration

Override SentryRegisterModule in your app DI module to supply the DSN and any other settings:

dart
@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

FieldTypeDefaultDescription
dsnStringrequiredSentry project DSN
environmentString'production'Environment label
releaseString?nullRelease string e.g. my-app@1.0.0
tracesSampleRatedouble1.0Performance trace sample rate (0.0–1.0)
enableAutoPerformanceTracingbooltrueAutomatic route/widget tracing
enableAutoSessionTrackingbooltrueSession tracking
attachStacktracebooltrueAttach stack traces to all events

The DSN is found in Sentry Dashboard → Project → Settings → Client Keys (DSN).

Built by Banua Coder