Sentry Dart Plugin

Learn how to use the Sentry Dart Plugin to automatically upload debug symbols for your Dart application.

The Sentry Dart Plugin is the recommended way to upload debug symbols for Dart applications. It automates the upload process for Android, iOS, macOS, and Web, making it seamless to provide Sentry with the necessary files for symbolication.

In your pubspec.yaml, add sentry_dart_plugin as a new dev dependency:

pubspec.yaml
Copied
dev_dependencies:
  sentry_dart_plugin: ^2.4.1

The Sentry Dart Plugin requires basic configuration in your pubspec.yaml file:

pubspec.yaml
Copied
sentry:
  project: example-project
  org: example-org
  auth_token: sntrys_YOUR_TOKEN_HERE
  # Disable automatic upload of debug symbols
  # upload_debug_symbols: false
  # Enable source context
  upload_source_context: true
  # Enable source maps
  upload_source_maps: true

The upload_debug_symbols option defaults to true when not specified.

In addition to configuring the plugin in pubspec.yaml, you can use:

  • Environment variables
  • Properties file

For more information, read the Sentry Dart Plugin README.

Before running the plugin, build your Flutter application with one of the following commands. Obfuscated is encouraged for production builds, and will make uploading debug symbols necessary to get readable stack traces.

Copied
flutter build apk --obfuscate --split-debug-info=<output-directory>
flutter build ios --obfuscate --split-debug-info=<output-directory>
flutter build macos --obfuscate --split-debug-info=<output-directory>
flutter build windows --obfuscate --split-debug-info=<output-directory>
flutter build linux --obfuscate --split-debug-info=<output-directory>

After building your application, run the plugin to upload debug symbols:

Copied
flutter pub run sentry_dart_plugin

If you have ProGuard (minifyEnabled) enabled and you want to see proper native Android stacktraces, you must upload Android Proguard/R8 mapping files. You have two options:

  1. Use the Sentry Android Gradle Plugin (Recommended)

    After installing the Sentry Android Gradle Plugin, set autoInstallation to false in your app/build.gradle file:

    app/build.gradle
    Copied
    sentry {
        autoInstallation {
          enabled = false
        }
    }
    

    This is necessary because Sentry Flutter already ships with a compatible Sentry Android SDK, so we need to avoid conflicts.

    Follow the Android Gradle Plugin guide to complete the ProGuard mapping setup.

  2. Use the Sentry CLI

    Alternatively, you can use the Sentry CLI to manually upload mapping files.

The following table lists all available configuration options for the Sentry Dart Plugin:

OptionTypeDefaultDescriptionEnvironment Variable
projectstringRequired. Your project's name (e.g., sentry-flutter)SENTRY_PROJECT
orgstringRequired. Your organization's slug (e.g., sentry-sdks)SENTRY_ORG
auth_tokenstringRequired. The Sentry auth tokenSENTRY_AUTH_TOKEN
upload_debug_symbolsbooleantrueEnables or disables automatic upload of debug symbols
upload_source_mapsbooleanfalseEnables or disables automatic upload of source maps
upload_sourcesbooleanfalseEnables or disables source code upload
urlstringThe URL of your Sentry instanceSENTRY_URL
wait_for_processingbooleanfalseWhether to wait for server-side processing of uploaded files
log_levelstringwarnConfigures the log level for sentry-cli (trace, debug, info, warn, error)SENTRY_LOG_LEVEL
releasestringname@version from pubspecThe release version for source mapsSENTRY_RELEASE
diststringCustom distribution identifierSENTRY_DIST
web_build_pathstringbuild/webThe web build folder path
commitsstringautoRelease commits integration
ignore_missingbooleanfalseIgnore missing commits previously used in the release
bin_dirstring.dart_tool/pub/bin/sentry_dart_pluginThe folder where the plugin downloads the sentry-cli binary
bin_pathstringPath to a sentry-cli binary to use instead of downloading
sentry_cli_cdn_urlstringhttps://downloads.sentry-cdn.com/sentry-cliAlternative place to download sentry-cliSENTRYCLI_CDNURL

If you encounter any issues with the Sentry Dart Plugin, refer to Troubleshooting - Sentry Dart Plugin for solutions to common problems.

Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").