|
| 1 | +## Installation |
| 2 | + |
| 3 | +In your `pubspec.yaml`, add `sentry_dart_plugin` as a new dev dependency: |
| 4 | + |
| 5 | +```yaml {filename: pubspec.yaml} |
| 6 | +dev_dependencies: |
| 7 | + sentry_dart_plugin: ^{{@inject packages.version('sentry.dart.plugin', '2.0.0') }} |
| 8 | +``` |
| 9 | +
|
| 10 | +## Configuration |
| 11 | +
|
| 12 | +The Sentry Dart Plugin requires basic configuration in your `pubspec.yaml` file: |
| 13 | + |
| 14 | +<DebugSymbolConfig /> |
| 15 | + |
| 16 | +### Alternative Configuration Methods |
| 17 | + |
| 18 | +In addition to configuring the plugin in `pubspec.yaml`, you can use: |
| 19 | +- Environment variables |
| 20 | +- Properties file |
| 21 | + |
| 22 | +For more information, read the [Sentry Dart Plugin README](https://github.com/getsentry/sentry-dart-plugin/tree/main?tab=readme-ov-file#configuration-optional). |
| 23 | + |
| 24 | +## Building Your Application |
| 25 | + |
| 26 | +Before running the plugin, build your Flutter application with one of the following commands: |
| 27 | + |
| 28 | +### Standard Build |
| 29 | + |
| 30 | +```bash |
| 31 | +flutter build apk |
| 32 | +flutter build ios |
| 33 | +flutter build macos |
| 34 | +flutter build windows |
| 35 | +flutter build linux |
| 36 | +``` |
| 37 | + |
| 38 | +### Obfuscated Build (Recommended for Production) |
| 39 | + |
| 40 | +Include the `--obfuscate` flag with the `--split-debug-info` option: |
| 41 | + |
| 42 | +```bash |
| 43 | +flutter build apk --obfuscate --split-debug-info=<output-directory> |
| 44 | +flutter build ios --obfuscate --split-debug-info=<output-directory> |
| 45 | +flutter build macos --obfuscate --split-debug-info=<output-directory> |
| 46 | +flutter build windows --obfuscate --split-debug-info=<output-directory> |
| 47 | +flutter build linux --obfuscate --split-debug-info=<output-directory> |
| 48 | +``` |
| 49 | + |
| 50 | +### Flutter Web |
| 51 | + |
| 52 | +For Flutter Web, generate source maps: |
| 53 | + |
| 54 | +```bash |
| 55 | +flutter build web --release --source-maps |
| 56 | +``` |
| 57 | + |
| 58 | +## Running the Plugin |
| 59 | + |
| 60 | +After building your application, run the plugin to upload debug symbols: |
| 61 | + |
| 62 | +```bash |
| 63 | +flutter pub run sentry_dart_plugin |
| 64 | +``` |
| 65 | + |
| 66 | +<Alert> |
| 67 | + |
| 68 | +If you don't obfuscate your build, the plugin won't upload debug symbols but will still configure source context if enabled. |
| 69 | + |
| 70 | +</Alert> |
| 71 | + |
| 72 | +## Android ProGuard Integration |
| 73 | + |
| 74 | +If you have ProGuard (`minifyEnabled`) enabled, you must upload Android Proguard/R8 mapping files. You have two options: |
| 75 | + |
| 76 | +1. **Use the Sentry Android Gradle Plugin (Recommended)** |
| 77 | + |
| 78 | + After installing the [Sentry Android Gradle Plugin](/platforms/android/configuration/gradle/), set `autoInstallation` to `false` in your `app/build.gradle` file: |
| 79 | + |
| 80 | + ```groovy {filename: app/build.gradle} |
| 81 | + sentry { |
| 82 | + autoInstallation { |
| 83 | + enabled = false |
| 84 | + } |
| 85 | + } |
| 86 | + ``` |
| 87 | + |
| 88 | + This is necessary because Sentry Flutter already ships with a compatible Sentry Android SDK, so we need to avoid conflicts. |
| 89 | + |
| 90 | + Follow the [Android Gradle Plugin guide](/platforms/android/configuration/gradle/#proguardr8--dexguard) to complete the ProGuard mapping setup. |
| 91 | + |
| 92 | +2. **Use the Sentry CLI** |
| 93 | + |
| 94 | + Alternatively, you can use the [Sentry CLI](/cli/dif/#uploading-files) to manually upload mapping files. |
| 95 | + |
| 96 | +<Alert> |
| 97 | + |
| 98 | +Sentry's Flutter SDK doesn't currently support the `uploadNativeSymbols` flag from the Sentry Gradle Plugin. |
| 99 | + |
| 100 | +</Alert> |
| 101 | + |
| 102 | +## iOS and macOS dSYM Uploads |
| 103 | + |
| 104 | +For iOS and macOS applications, you need to upload dSYM files. The Sentry Dart Plugin will automatically handle this when you build with the `--obfuscate` flag. |
| 105 | + |
| 106 | +For non-obfuscated builds or additional configuration options, you can: |
| 107 | + |
| 108 | +1. **Use the Sentry Cocoa script** |
| 109 | + |
| 110 | + Follow the [Sentry Cocoa debug symbols guide](/platforms/apple/guides/ios/dsym/) to set up automatic dSYM uploads with the script. |
| 111 | + |
| 112 | +2. **Use the Sentry CLI** |
| 113 | + |
| 114 | + Use the [Sentry CLI](/platforms/apple/guides/ios/dsym/#upload-dsyms-with-cli) to manually upload dSYM files. |
| 115 | + |
| 116 | +## Configuration Reference |
| 117 | + |
| 118 | +The following table lists all available configuration options for the Sentry Dart Plugin: |
| 119 | + |
| 120 | +<div style={{overflowX: 'auto', display: 'block', width: '100%'}}> |
| 121 | + |
| 122 | +| Option | Type | Default | Description | Environment Variable | |
| 123 | +|--------|------|---------|-------------|---------------------| |
| 124 | +| `project` | string | | **Required.** Your project's name (e.g., `sentry-flutter`) | `SENTRY_PROJECT` | |
| 125 | +| `org` | string | | **Required.** Your organization's slug (e.g., `sentry-sdks`) | `SENTRY_ORG` | |
| 126 | +| `auth_token` | string | | **Required.** The Sentry auth token | `SENTRY_AUTH_TOKEN` | |
| 127 | +| `upload_debug_symbols` | boolean | `true` | Enables or disables automatic upload of debug symbols | | |
| 128 | +| `upload_source_maps` | boolean | `false` | Enables or disables automatic upload of source maps | | |
| 129 | +| `upload_sources` | boolean | `false` | Enables or disables source code upload | | |
| 130 | +| `url` | string | | The URL of your Sentry instance | `SENTRY_URL` | |
| 131 | +| `wait_for_processing` | boolean | `false` | Whether to wait for server-side processing of uploaded files | | |
| 132 | +| `log_level` | string | `warn` | Configures the log level for sentry-cli (`trace`, `debug`, `info`, `warn`, `error`) | `SENTRY_LOG_LEVEL` | |
| 133 | +| `release` | string | `name@version` from pubspec | The release version for source maps | `SENTRY_RELEASE` | |
| 134 | +| `dist` | string | | Custom distribution identifier | `SENTRY_DIST` | |
| 135 | +| `web_build_path` | string | `build/web` | The web build folder path | | |
| 136 | +| `commits` | string | `auto` | Release commits integration | | |
| 137 | +| `ignore_missing` | boolean | `false` | Ignore missing commits previously used in the release | | |
| 138 | +| `bin_dir` | string | `.dart_tool/pub/bin/sentry_dart_plugin` | The folder where the plugin downloads the sentry-cli binary | | |
| 139 | +| `bin_path` | string | | Path to a sentry-cli binary to use instead of downloading | | |
| 140 | +| `sentry_cli_cdn_url` | string | `https://downloads.sentry-cdn.com/sentry-cli` | Alternative place to download sentry-cli | `SENTRYCLI_CDNURL` | |
| 141 | + |
| 142 | +</div> |
| 143 | + |
| 144 | +## Troubleshooting |
| 145 | + |
| 146 | +If you encounter any issues with the Sentry Dart Plugin, refer to [Troubleshooting - Sentry Dart Plugin](/platforms/dart/guides/flutter/troubleshooting#sentry-dart-plugin) for solutions to common problems. |
0 commit comments