sentry-flutter-sdk by getsentry/sentry-for-ai
npx skills add https://github.com/getsentry/sentry-for-ai --skill sentry-flutter-sdk一个智能向导,用于扫描您的 Flutter 或 Dart 项目,并指导您完成完整的 Sentry 设置——错误监控、追踪、会话回放、日志记录、性能剖析以及生态系统集成。
sentry_flutter、sentry_dart、移动端错误追踪或 Flutter 版 Sentry注意: 下面的 SDK 版本和 API 反映了
sentry_flutter≥9.14.0(当前稳定版,2026年2月)。在实施前,请务必对照 docs.sentry.io/platforms/flutter/ 进行验证。
在提出任何建议之前,运行以下命令来了解项目:
# 检测 Flutter 项目类型和现有 Sentry
cat pubspec.yaml | grep -E '(sentry|flutter|dart)'
# 检查 SDK 版本
cat pubspec.yaml | grep -A2 'environment:'
# 检查现有的 Sentry 初始化
grep -r "SentryFlutter.init\|Sentry.init" lib/ 2>/dev/null | head -5
# 检测导航库
grep -E '(go_router|auto_route|get:|beamer|routemaster)' pubspec.yaml
# 检测 HTTP 客户端
grep -E '(dio:|http:|chopper:)' pubspec.yaml
# 检测数据库包
grep -E '(sqflite|drift|hive|isar|floor)' pubspec.yaml
# 检测状态管理(用于集成模式)
grep -E '(flutter_bloc|riverpod|provider:|get:)' pubspec.yaml
# 检测 GraphQL
grep -E '(graphql|ferry|gql)' pubspec.yaml
# 检测 Firebase
grep -E '(firebase_core|supabase)' pubspec.yaml
# 检测后端以进行交叉链接
ls ../backend/ ../server/ ../api/ 2>/dev/null
find .. -maxdepth 3 \( -name "go.mod" -o -name "requirements.txt" -o -name "Gemfile" -o -name "*.csproj" \) 2>/dev/null | grep -v flutter | head -10
# 检测平台目标
ls android/ ios/ macos/ linux/ windows/ web/ 2>/dev/null
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
需要确定的内容:
| 问题 | 影响 |
|---|---|
pubspec.yaml 中是否已存在 sentry_flutter? | 跳过安装,跳转到功能配置 |
Dart SDK 是否 >=3.5? | sentry_flutter ≥9.0.0 所需 |
是否存在 go_router 或 auto_route? | 使用 SentryNavigatorObserver —— 需应用特定模式 |
是否存在 dio? | 推荐 sentry_dio 集成 |
是否存在 sqflite、drift、hive、isar? | 推荐匹配的 sentry_* 数据库包 |
是否有 android/ 和 ios/ 目录? | 完整的移动端功能集可用 |
是否仅有 web/ 目录? | 会话回放和性能剖析不可用 |
是否有 macos/ 目录? | 性能剖析可用(Alpha 阶段) |
| 是否检测到后端目录? | 触发阶段 4 的交叉链接 |
根据您的发现提出具体建议。不要问开放式问题——直接提出方案:
推荐(核心覆盖范围——始终设置这些):
可选(增强可观测性):
Sentry.logger.* 和 sentry_logging 集成实现结构化日志平台限制——请事先说明:
| 功能 | 平台 | 备注 |
|---|---|---|
| 会话回放 | iOS, Android | 在 macOS、Linux、Windows、Web 上不可用 |
| 性能剖析 | iOS, macOS | Alpha 状态;在 Android、Linux、Windows、Web 上不可用 |
| 原生崩溃 | iOS, Android, macOS | NDK/信号处理;Linux/Windows/Web:仅限 Dart 异常 |
| 应用启动指标 | iOS, Android | 在桌面/web 上不可用 |
| 慢/冻结帧 | iOS, Android, macOS | 在 Linux、Windows、Web 上不可用 |
| Crons | N/A | 不可用于 Flutter/Dart SDK |
建议:“针对您的 iOS/Android Flutter 应用,我推荐错误监控 + 追踪 + 会话回放。您是否也希望我添加日志记录和性能剖析(iOS/macOS Alpha 阶段)?”
| 项目类型 | 推荐设置 |
|---|---|
| 任何 Flutter 应用 | 向导 CLI(处理 pubspec、初始化、符号上传) |
| 偏好手动 | 下面的路径 B —— pubspec.yaml + main.dart |
| 仅限 Dart(CLI、服务器) | 下面的路径 C —— 纯 sentry 包 |
您需要自己运行此命令 —— 向导会打开浏览器进行登录,并需要交互式输入,这是代理无法处理的。请复制粘贴到您的终端:
brew install getsentry/tools/sentry-wizard && sentry-wizard -i flutter它会处理组织/项目选择,将
sentry_flutter添加到pubspec.yaml,更新main.dart,为调试符号上传配置sentry_dart_plugin,并添加构建脚本。以下是它创建/修改的内容:
文件 操作 目的 pubspec.yaml添加 sentry_flutter依赖项和sentry:配置块SDK + 符号上传配置 lib/main.dart用 SentryFlutter.init()包装main()SDK 初始化 android/app/build.gradle添加 Proguard 配置引用 Android 混淆支持 .sentryclirc认证令牌和组织/项目配置 符号上传凭据 完成后,请返回并跳转到验证。
如果用户跳过向导,请继续下面的路径 B(手动设置)。
步骤 1 —— 安装
flutter pub add sentry_flutter
或手动添加到 pubspec.yaml:
dependencies:
flutter:
sdk: flutter
sentry_flutter: ^9.14.0
然后运行:
flutter pub get
步骤 2 —— 在 lib/main.dart 中初始化 Sentry
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = 'YOUR_SENTRY_DSN';
options.sendDefaultPii = true;
// 追踪
options.tracesSampleRate = 1.0; // 生产环境中降低到 0.1–0.2
// 性能剖析(仅限 iOS 和 macOS —— Alpha 阶段)
options.profilesSampleRate = 1.0;
// 会话回放(仅限 iOS 和 Android)
options.replay.sessionSampleRate = 0.1;
options.replay.onErrorSampleRate = 1.0;
// 结构化日志记录(SDK ≥9.5.0)
options.enableLogs = true;
options.environment = const bool.fromEnvironment('dart.vm.product')
? 'production'
: 'development';
},
// 必需:包装根小部件以启用截图、回放、用户交互追踪
appRunner: () => runApp(SentryWidget(child: MyApp())),
);
}
步骤 3 —— 添加导航观察器
将 SentryNavigatorObserver 添加到您的 MaterialApp 或 CupertinoApp:
import 'package:flutter/material.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [
SentryNavigatorObserver(),
],
// 始终为您的路由命名,以便 Sentry 追踪它们
routes: {
'/': (context) => HomeScreen(),
'/profile': (context) => ProfileScreen(),
],
);
}
}
对于 GoRouter:
import 'package:go_router/go_router.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
final GoRouter router = GoRouter(
observers: [SentryNavigatorObserver()],
routes: [
GoRoute(
path: '/',
name: 'home', // name 是 Sentry 路由追踪所必需的
builder: (context, state) => const HomeScreen(),
routes: [
GoRoute(
path: 'profile/:id',
name: 'profile', // name 是必需的
builder: (context, state) => ProfileScreen(
id: state.pathParameters['id']!,
),
),
],
),
],
);
步骤 4 —— 配置调试符号上传
在 Sentry 中获得可读的堆栈跟踪需要在构建时使用 --obfuscate 上传调试符号。
添加到 pubspec.yaml:
dev_dependencies:
sentry_dart_plugin: ^3.2.1
sentry:
project: YOUR_PROJECT_SLUG
org: YOUR_ORG_SLUG
auth_token: YOUR_AUTH_TOKEN # 建议使用 SENTRY_AUTH_TOKEN 环境变量替代
upload_debug_symbols: true
upload_sources: true
upload_source_maps: true # 用于 Web
构建并上传:
# Android
flutter build apk \
--release \
--obfuscate \
--split-debug-info=build/debug-info \
--extra-gen-snapshot-options=--save-obfuscation-map=build/app/obfuscation.map.json
dart run sentry_dart_plugin
# iOS
flutter build ipa \
--release \
--obfuscate \
--split-debug-info=build/debug-info \
--extra-gen-snapshot-options=--save-obfuscation-map=build/app/obfuscation.map.json
dart run sentry_dart_plugin
# Web
flutter build web --release --source-maps
dart run sentry_dart_plugin
# pubspec.yaml
dependencies:
sentry: ^9.14.0
import 'package:sentry/sentry.dart';
Future<void> main() async {
await Sentry.init(
(options) {
options.dsn = 'YOUR_SENTRY_DSN';
options.tracesSampleRate = 1.0;
options.enableLogs = true;
},
appRunner: myApp,
);
}
SentryFlutter.init()import 'package:sentry_flutter/sentry_flutter.dart';
Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = 'YOUR_SENTRY_DSN';
options.sendDefaultPii = true;
// 环境 —— 通过 dart.vm.product 检测发布构建
options.environment = const bool.fromEnvironment('dart.vm.product')
? 'production'
: 'development';
// 在 iOS/Android 上,Release 自动设置为 "packageName@version+build"
// 如果需要,可以覆盖:
// options.release = 'my-app@1.0.0+42';
// 错误采样 —— 在高流量生产环境中降低以丢弃部分错误
options.sampleRate = 1.0;
// 追踪 —— 在高流量生产环境中降低到 0.1–0.2
options.tracesSampleRate = 1.0;
// 性能剖析 —— 仅限 iOS 和 macOS(Alpha 阶段);相对于 tracesSampleRate
options.profilesSampleRate = 1.0;
// 会话回放 —— 仅限 iOS 和 Android(SDK ≥9.0.0)
options.replay.sessionSampleRate = 0.1; // 记录 10% 的所有会话
options.replay.onErrorSampleRate = 1.0; // 始终记录错误会话
// 隐私默认设置 —— 所有文本和图像都被屏蔽
options.privacy.maskAllText = true;
options.privacy.maskAllImages = true;
// 结构化日志记录(SDK ≥9.5.0)
options.enableLogs = true;
// 附件
options.attachScreenshot = true; // 错误时截图
options.attachViewHierarchy = true; // 错误时小部件树
// HTTP 客户端
options.captureFailedRequests = true; // 自动捕获 HTTP 错误
options.maxRequestBodySize = MaxRequestBodySize.small;
// Android 特定设置
options.anrEnabled = true; // ANR 检测
options.enableNdkScopeSync = true; // 同步作用域到原生层
options.enableTombstone = false; // Android 12+ 墓碑信息(需手动启用)
// 导航(完全显示时间 —— 需手动启用)
options.enableTimeToFullDisplayTracing = true;
},
appRunner: () => runApp(SentryWidget(child: MyApp())),
);
}
初始显示时间始终启用。完全显示时间需要手动启用:
// 在选项中启用:
options.enableTimeToFullDisplayTracing = true;
然后在您的屏幕加载完数据后报告:
// 选项 1:小部件包装器(当子部件首次渲染时标记 TTFD)
SentryDisplayWidget(child: MyWidget())
// 选项 2:手动 API 调用(在异步数据加载后)
await _loadData();
SentryFlutter.currentDisplay()?.reportFullyDisplayed();
逐一介绍功能。为每个功能加载参考文件,按照其步骤操作,然后在继续之前进行验证:
| 功能 | 参考 | 何时加载 |
|---|---|---|
| 错误监控 | ${SKILL_ROOT}/references/error-monitoring.md | 始终(基线) |
| 追踪与性能 | ${SKILL_ROOT}/references/tracing.md | 始终 —— 导航、HTTP、数据库跨度 |
| 会话回放 | ${SKILL_ROOT}/references/session-replay.md | iOS/Android 面向用户的应用 |
| 性能剖析 | ${SKILL_ROOT}/references/profiling.md | iOS/macOS 性能敏感型应用 |
| 日志记录 | ${SKILL_ROOT}/references/logging.md | 结构化日志记录 / 日志-追踪关联 |
| 指标 | ${SKILL_ROOT}/references/metrics.md | 自定义业务指标(公开测试版) |
对于每个功能:读取 ${SKILL_ROOT}/references/<功能>.md,严格按照步骤操作,验证其是否正常工作。
SentryFlutter.init() 选项| 选项 | 类型 | 默认值 | 目的 |
|---|---|---|---|
dsn | string | — | 必需。 项目 DSN。环境变量:通过 --dart-define 设置 SENTRY_DSN |
environment | string | — | 例如,"production"、"staging"。环境变量:SENTRY_ENVIRONMENT |
release | string | iOS/Android 上自动设置 | "packageName@version+build"。环境变量:SENTRY_RELEASE |
dist | string | — | 分发标识符;最多 64 个字符。环境变量:SENTRY_DIST |
sendDefaultPii | bool | false | 包含 PII:IP 地址、用户标签、回放中的小部件文本 |
sampleRate | double | 1.0 | 错误事件采样率(0.0–1.0) |
maxBreadcrumbs | int | 100 | 每个事件的最大面包屑数量 |
attachStacktrace | bool | true | 自动附加堆栈跟踪到消息 |
attachScreenshot | bool | false | 错误时捕获截图(仅限移动端/桌面端) |
screenshotQuality | enum | high | 截图质量:full、high、medium、low |
attachViewHierarchy | bool | false | 错误时将 JSON 小部件树作为附件附加 |
debug | bool | debug 模式下为 true | 详细 SDK 输出。切勿在生产环境中强制设为 true |
diagnosticLevel | enum | warning | 日志详细程度:debug、info、warning、error、fatal |
enabled | bool | true | 完全禁用 SDK(例如,用于测试) |
maxCacheItems | int | 30 | 最大离线缓存信封数(Web 上不支持) |
sendClientReports | bool | true | 发送 SDK 健康报告(丢弃的事件等) |
reportPackages | bool | true | 报告 pubspec.yaml 依赖项列表 |
reportSilentFlutterErrors | bool | false | 捕获 FlutterErrorDetails.silent 错误 |
idleTimeout | Duration | 3000ms | 自动完成空闲用户交互事务 |
| 选项 | 类型 | 默认值 | 目的 |
|---|---|---|---|
tracesSampleRate | double | — | 事务采样率(0–1)。通过设置 >0 来启用 |
tracesSampler | function | — | 每个事务的采样;覆盖 tracesSampleRate |
tracePropagationTargets | List | — | 附加 sentry-trace + baggage 头的 URL |
propagateTraceparent | bool | false | 同时发送 W3C traceparent 头(SDK ≥9.7.0) |
enableTimeToFullDisplayTracing | bool | false | 按屏幕选择启用 TTFD 追踪 |
enableAutoPerformanceTracing | bool | true | 自动启用性能监控 |
enableUserInteractionTracing | bool | true | 为点击/长按事件创建事务 |
enableUserInteractionBreadcrumbs | bool | true | 为每个追踪的用户交互记录面包屑 |
| 选项 | 类型 | 默认值 | 目的 |
|---|---|---|---|
profilesSampleRate | double | — | 相对于 tracesSampleRate 的性能剖析率。仅限 iOS/macOS |
| 选项 | 类型 | 默认值 | 目的 |
|---|---|---|---|
autoInitializeNativeSdk | bool | true | 自动初始化原生 Android/iOS SDK 层 |
enableNativeCrashHandling | bool | true | 捕获原生崩溃(NDK、信号、Mach 异常) |
enableNdkScopeSync | bool | true | 将 Dart 作用域同步到 Android NDK |
enableScopeSync | bool | true | 将作用域数据同步到原生 SDK |
anrEnabled | bool | true | ANR 检测(Android) |
anrTimeoutInterval | int | 5000 | ANR 超时时间(毫秒)(Android) |
enableWatchdogTerminationTracking | bool | true | OOM 终止追踪(iOS) |
enableTombstone | bool | false | 通过 ApplicationExitInfo 获取 Android 12+ 原生崩溃信息 |
attachThreads | bool | false | 崩溃时附加所有线程(Android) |
captureNativeFailedRequests | bool | — | 原生 HTTP 错误捕获,独立于 Dart 客户端(iOS/macOS,v9.11.0+) |
enableAutoNativeAppStart | bool | true | 应用启动时间检测(iOS/Android) |
enableFramesTracking | bool | true | 慢/冻结帧监控(iOS/Android/macOS) |
proguardUuid | string | — | 用于 Android 混淆映射的 Proguard UUID |
| 选项 | 类型 | 默认值 | 目的 |
|---|---|---|---|
enableAutoSessionTracking | bool | true | 用于无崩溃用户/会话指标的会话追踪 |
autoSessionTrackingInterval | Duration | 30s | 会话结束前的后台不活动时间 |
options.replay)| 选项 | 类型 | 默认值 | 目的 |
|---|---|---|---|
replay.sessionSampleRate | double | 0.0 | 记录所有会话的比例 |
replay.onErrorSampleRate | double | 0.0 | 记录错误会话的比例 |
options.privacy)| 选项 / 方法 | 默认值 | 目的 |
|---|---|---|
privacy.maskAllText | true | 屏蔽所有文本小部件内容 |
privacy.maskAllImages | true | 屏蔽所有图像小部件 |
privacy.maskAssetImages | true | 屏蔽来自根资源包的图像 |
privacy.mask<T>() | — | 屏蔽特定小部件类型及其所有子类 |
privacy.unmask<T>() | — | 取消屏蔽特定小部件类型 |
privacy.maskCallback<T>() | — | 按小部件实例自定义屏蔽决策 |
| 选项 | 类型 | 默认值 | 目的 |
|---|---|---|---|
captureFailedRequests | bool | true (Flutter) | 自动捕获 HTTP 错误 |
maxRequestBodySize | enum | never | 请求体捕获:never、small、medium、always |
failedRequestStatusCodes | List | [500–599] | 被视为失败的状态码 |
failedRequestTargets | List | ['.*'] | 要监控的 URL 模式 |
| 选项 | 类型 | 目的 |
|---|---|---|
beforeSend | (SentryEvent, Hint) → SentryEvent? | 修改或丢弃错误事件。返回 null 以丢弃 |
beforeSendTransaction | (SentryEvent) → SentryEvent? | 修改或丢弃事务事件 |
beforeBreadcrumb | (Breadcrumb, Hint) → Breadcrumb? | 在存储前处理面包屑 |
beforeSendLog | (SentryLog) → SentryLog? | 在发送前过滤结构化日志 |
在构建时通过 --dart-define 传递:
| 变量 | 目的 | 备注 |
|---|---|---|
SENTRY_DSN | 数据源名称 | 从 options.dsn 回退 |
SENTRY_ENVIRONMENT | 部署环境 | 从 options.environment 回退 |
SENTRY_RELEASE | 发布标识符 | 从 options.release 回退 |
SENTRY_DIST | 构建分发 | 从 options.dist 回退 |
SENTRY_AUTH_TOKEN | 上传调试符号 | 切勿嵌入应用中 —— 仅用于构建工具 |
SENTRY_ORG | 组织标识 | 由 sentry_dart_plugin 使用 |
SENTRY_PROJECT | 项目标识 | 由 sentry_dart_plugin 使用 |
用法:
flutter build apk --release \
--dart-define=SENTRY_DSN=https://xxx@sentry.io/123 \
--dart-define=SENTRY_ENVIRONMENT=production
然后在代码中:
options.dsn = const String.fromEnvironment('SENTRY_DSN');
options.environment = const String.fromEnvironment('SENTRY_ENVIRONMENT', defaultValue: 'development');
将这些包与 sentry_flutter 一起添加,以实现更深入的检测:
标准 http 包 —— 内置于 sentry_flutter,无需额外安装:
import 'package:sentry/sentry.dart';
// 包装您的 http 客户端
final client = SentryHttpClient(
captureFailedRequests: true,
failedRequestStatusCodes: [SentryStatusCode.range(400, 599)],
);
try {
final response = await client.get(Uri.parse('https://api.example.com/users'));
} finally {
client.close();
}
Dio —— 安装 sentry_dio:
flutter pub add sentry_dio
import 'package:dio/dio.dart';
import 'package:sentry_dio/sentry_dio.dart';
final dio = Dio();
// 首先添加您的拦截器,然后最后添加 addSentry()
dio.addSentry(
captureFailedRequests: true,
failedRequestStatusCodes: [SentryStatusCode.range(400, 599)],
);
| 包 | 安装 | 设置 |
|---|---|---|
sentry_sqflite | flutter pub add sentry_sqflite | databaseFactory = SentrySqfliteDatabaseFactory(); |
sentry_drift | flutter pub add sentry_drift | .interceptWith(SentryQueryInterceptor(databaseName: 'db')) |
sentry_hive | flutter pub add sentry_hive | 使用 SentryHive 替代 Hive |
sentry_isar | flutter pub add sentry_isar | 使用 SentryIsar.open() 替代 Isar.open() |
| 包 | 安装 | 目的 |
|---|---|---|
sentry_logging | flutter pub add sentry_logging | Dart logging 包 → Sentry 面包屑/事件 |
sentry_link | flutter pub add sentry_link | GraphQL(gql、graphql_flutter、ferry)追踪 |
sentry_supabase | flutter pub add sentry_supabase | Supabase 查询追踪(SDK ≥9.9.0) |
sentry_firebase_remote_config | flutter pub add sentry_firebase_remote_config | 功能标志追踪 |
sentry_file | flutter pub add sentry_file | 通过 .sentryTrace() 扩展进行文件 I/O 追踪 |
没有官方包 —— 通过观察者 API 连接 Sentry:
| 框架 | 钩子点 | 模式 |
|---|---|---|
| BLoC/Cubit | BlocObserver.onError | 在 onError 内部调用 Sentry.captureException(error, stackTrace: stackTrace);在初始化前设置 Bloc.observer = SentryBlocObserver() |
| Riverpod | ProviderObserver.providerDidFail | 在 FutureProvider/StreamProvider 失败时触发;用 ProviderScope(observers: [SentryProviderObserver()]) 包装应用 |
| Provider/ChangeNotifier | notifyListeners 调用者中的 try/catch | 在 catch 块中手动调用 Sentry.captureException(e, stackTrace: stack) |
| GetX | GetMaterialApp.onError | GetMaterialApp(onError: (details) => Sentry.captureException(...)) |
在发布前降低采样率并强化配置:
Future<void> main() async {
final isProduction = const bool.fromEnvironment('dart.vm.product');
await SentryFlutter.init(
(options) {
options.dsn = const String.fromEnvironment('SENTRY_DSN');
options.environment = isProduction ? 'production' : 'development';
// 在高流量生产环境中追踪 10% 的事务
options.tracesSampleRate = isProduction ? 0.1 : 1.0;
// 对 100% 的已追踪事务进行性能剖析(性能剖析始终是子集)
options.profilesSampleRate = 1.0;
// 回放所有错误会话,采样 5% 的正常会话
options.replay.onErrorSampleRate = 1.0;
options.replay.sessionSampleRate = isProduction ? 0.05 : 1.0;
// 在生产环境中禁用调试日志记录
options.debug = !isProduction;
},
appRunner: () => runApp(SentryWidget(child: MyApp())),
);
}
设置完成后,测试 Sentry 是否正在接收事件:
// 在开发期间,在某个可见位置添加一个测试按钮:
ElevatedButton(
onPressed: () {
throw Exception('Sentry 测试错误!');
},
child: const Text('测试 Sentry 错误'),
)
// 或者手动捕获:
ElevatedButton(
onPressed: () {
Sentry.captureMessage('Sentry 测试消息', level: SentryLevel.info);
},
child: const Text('测试 Sentry 消息'),
)
// 测试结构化日志记录:
ElevatedButton(
onPressed: () {
Sentry.logger.info('来自 Flutter 应用的测试日志');
},
child: const Text('测试 Sentry 日志'),
)
检查 Sentry 仪表板:
enableLogs: true,则显示结构化日志条目⚠️ 调试模式下的平台限制:
- 原生崩溃、会话回放、慢/冻结帧和应用启动指标仅在 iOS/Android 的发布构建中完全工作
- 运行
flutter run --release或使用真实设备/模拟器来测试原生功能- 调试模式使用带有 JIT 编译的 Dart VM —— 某些原生集成行为不同
当您调用 SentryFlutter.init() 时,这些集成会自动启用,无需额外配置:
| 集成 | 功能 |
|---|---|
FlutterErrorIntegration | 捕获 FlutterError.onError 框架错误 |
RunZonedGuardedIntegration | 捕获 runZonedGuarded 中未处理的 Dart 异常 |
NativeAppStartIntegration | 应用启动时间(iOS/Android) |
FramesTrackingIntegration | 慢/冻结帧(iOS/Android/macOS) |
NativeUserInteractionIntegration | 来自原生层的用户交互面包屑 |
UserInteractionIntegration | Dart 层点击/点击事务(需要 SentryWidget) |
DeviceContextIntegration | 设备型号、操作系统版本、屏幕分辨率 |
AppContextIntegration | 应用版本、构建号、包 ID |
ConnectivityIntegration | 网络连接变更面包屑 |
HttpClientIntegration | 自动检测 Dart http 请求 |
SdkIntegration | SDK 元数据标记 |
ReleaseIntegration | 从包信息自动设置 iOS/Android 上的发布版本 |
完成 Flutter 设置后,检查是否有缺少 Sentry 覆盖的后端:
# 相邻的后端目录
ls ../backend ../server ../api 2>/dev/null
cat ../go.mod 2>/dev/null | head -3
cat ../requirements.txt ../pyproject.toml 2>/dev/null | head -3
cat ../Gemfile 2>/dev/null | head -3
ls ../backend/package.json ../server/package.json 2>/dev/null
如果存在没有 Sentry 的后端,建议使用匹配的技能:
| 检测到 | 建议技能 |
|---|---|
Go 后端 (go.mod) | sentry-go-sdk |
Python 后端 (requirements.txt, pyproject.toml) | sentry-python-sdk |
Ruby 后端 (Gemfile) | sentry-ruby-sdk |
| Node.js 后端 | sentry-node-sdk |
.NET 后端 (*.csproj) | sentry-dotnet-sdk |
| React / Next.js web | sentry-react-sdk / sentry-nextjs-sdk |
分布式追踪 —— 如果添加了后端技能,请在 Flutter 中配置 tracePropagationTargets,以将追踪上下文传播到您的 API:
options.tracePropagationTargets = ['api.myapp.com', 'localhost'];
options.propagateTraceparent = true; // 同时发送 W3C traceparent 头
这将在 Sentry 瀑布视图中将移动端事务链接到后端追踪。
| 问题 | 解决方案 |
|---|---|
| 事件未出现在 Sentry 中 | 设置 options.debug = true —— SDK 将日志输出到 Flutter 控制台;验证 DSN 是否正确 |
SentryFlutter.init 抛出异常 | 确保 main() 是 async 并且您 await SentryFlutter.init(...) |
| Sentry 中的堆栈跟踪不可读 | 使用 sentry_dart_plugin 上传调试符号;使用 --obfuscate --split-debug-info 构建 |
| Web 上缺少堆栈跟踪 | 使用 --source-maps 构建并运行 dart run sentry_dart_plugin 上传 |
| 未捕获原生崩溃 | 确认 enableNativeCrashHandling: true;在发布模式下测试,而非调试模式 |
| 会话回放未记录 | 仅限 iOS/Android;确认 SentryWidget 包装了根部件;检查 replay.onErrorSampleRate |
| 回放显示空白屏幕 | 确认 SentryWidget(child: MyApp()) 是最外层小部件;不在导航器内部 |
| 性能剖析不工作 | 仅限 iOS 和 macOS(Alpha 阶段);确认首先设置了 tracesSampleRate > 0 |
All Skills > SDK Setup > Flutter SDK
Opinionated wizard that scans your Flutter or Dart project and guides you through complete Sentry setup — error monitoring, tracing, session replay, logging, profiling, and ecosystem integrations.
sentry_flutter, sentry_dart, mobile error tracking, or Sentry for FlutterNote: SDK versions and APIs below reflect
sentry_flutter≥9.14.0 (current stable, February 2026). Always verify against docs.sentry.io/platforms/flutter/ before implementing.
Run these commands to understand the project before making any recommendations:
# Detect Flutter project type and existing Sentry
cat pubspec.yaml | grep -E '(sentry|flutter|dart)'
# Check SDK version
cat pubspec.yaml | grep -A2 'environment:'
# Check for existing Sentry initialization
grep -r "SentryFlutter.init\|Sentry.init" lib/ 2>/dev/null | head -5
# Detect navigation library
grep -E '(go_router|auto_route|get:|beamer|routemaster)' pubspec.yaml
# Detect HTTP client
grep -E '(dio:|http:|chopper:)' pubspec.yaml
# Detect database packages
grep -E '(sqflite|drift|hive|isar|floor)' pubspec.yaml
# Detect state management (for integration patterns)
grep -E '(flutter_bloc|riverpod|provider:|get:)' pubspec.yaml
# Detect GraphQL
grep -E '(graphql|ferry|gql)' pubspec.yaml
# Detect Firebase
grep -E '(firebase_core|supabase)' pubspec.yaml
# Detect backend for cross-link
ls ../backend/ ../server/ ../api/ 2>/dev/null
find .. -maxdepth 3 \( -name "go.mod" -o -name "requirements.txt" -o -name "Gemfile" -o -name "*.csproj" \) 2>/dev/null | grep -v flutter | head -10
# Detect platform targets
ls android/ ios/ macos/ linux/ windows/ web/ 2>/dev/null
What to determine:
| Question | Impact |
|---|---|
sentry_flutter already in pubspec.yaml? | Skip install, jump to feature config |
Dart SDK >=3.5? | Required for sentry_flutter ≥9.0.0 |
go_router or auto_route present? | Use SentryNavigatorObserver — specific patterns apply |
dio present? |
Present a concrete recommendation based on what you found. Don't ask open-ended questions — lead with a proposal:
Recommended (core coverage — always set up these):
Optional (enhanced observability):
Sentry.logger.* and sentry_logging integrationPlatform limitations — be upfront:
| Feature | Platforms | Notes |
|---|---|---|
| Session Replay | iOS, Android | Not available on macOS, Linux, Windows, Web |
| Profiling | iOS, macOS | Alpha status; not available on Android, Linux, Windows, Web |
| Native crashes | iOS, Android, macOS | NDK/signal handling; Linux/Windows/Web: Dart exceptions only |
| App Start metrics | iOS, Android | Not available on desktop/web |
| Slow/frozen frames | iOS, Android, macOS | Not available on Linux, Windows, Web |
| Crons | N/A | Not available in the Flutter/Dart SDK |
Propose: "For your Flutter app targeting iOS/Android, I recommend Error Monitoring + Tracing + Session Replay. Want me to also add Logging and Profiling (iOS/macOS alpha)?"
| Project type | Recommended setup |
|---|---|
| Any Flutter app | Wizard CLI (handles pubspec, init, symbol upload) |
| Manual preferred | Path B below — pubspec.yaml + main.dart |
| Dart-only (CLI, server) | Path C below — pure sentry package |
You need to run this yourself — the wizard opens a browser for login and requires interactive input that the agent can't handle. Copy-paste into your terminal:
brew install getsentry/tools/sentry-wizard && sentry-wizard -i flutterIt handles org/project selection, adds
sentry_fluttertopubspec.yaml, updatesmain.dart, configuressentry_dart_pluginfor debug symbol upload, and adds build scripts. Here's what it creates/modifies:
File Action Purpose pubspec.yamlAdds sentry_flutterdependency and config block
If the user skips the wizard, proceed with Path B (Manual Setup) below.
Step 1 — Install
flutter pub add sentry_flutter
Or add to pubspec.yaml manually:
dependencies:
flutter:
sdk: flutter
sentry_flutter: ^9.14.0
Then run:
flutter pub get
Step 2 — Initialize Sentry inlib/main.dart
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = 'YOUR_SENTRY_DSN';
options.sendDefaultPii = true;
// Tracing
options.tracesSampleRate = 1.0; // lower to 0.1–0.2 in production
// Profiling (iOS and macOS only — alpha)
options.profilesSampleRate = 1.0;
// Session Replay (iOS and Android only)
options.replay.sessionSampleRate = 0.1;
options.replay.onErrorSampleRate = 1.0;
// Structured Logging (SDK ≥9.5.0)
options.enableLogs = true;
options.environment = const bool.fromEnvironment('dart.vm.product')
? 'production'
: 'development';
},
// REQUIRED: wrap root widget to enable screenshots, replay, user interaction tracing
appRunner: () => runApp(SentryWidget(child: MyApp())),
);
}
Step 3 — Add Navigation Observer
Add SentryNavigatorObserver to your MaterialApp or CupertinoApp:
import 'package:flutter/material.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorObservers: [
SentryNavigatorObserver(),
],
// Always name your routes for Sentry to track them
routes: {
'/': (context) => HomeScreen(),
'/profile': (context) => ProfileScreen(),
},
);
}
}
For GoRouter :
import 'package:go_router/go_router.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
final GoRouter router = GoRouter(
observers: [SentryNavigatorObserver()],
routes: [
GoRoute(
path: '/',
name: 'home', // name is REQUIRED for Sentry route tracking
builder: (context, state) => const HomeScreen(),
routes: [
GoRoute(
path: 'profile/:id',
name: 'profile', // name is REQUIRED
builder: (context, state) => ProfileScreen(
id: state.pathParameters['id']!,
),
),
],
),
],
);
Step 4 — Configure Debug Symbol Upload
Readable stack traces in Sentry require uploading debug symbols when building with --obfuscate.
Add to pubspec.yaml:
dev_dependencies:
sentry_dart_plugin: ^3.2.1
sentry:
project: YOUR_PROJECT_SLUG
org: YOUR_ORG_SLUG
auth_token: YOUR_AUTH_TOKEN # prefer SENTRY_AUTH_TOKEN env var instead
upload_debug_symbols: true
upload_sources: true
upload_source_maps: true # for Web
Build and upload:
# Android
flutter build apk \
--release \
--obfuscate \
--split-debug-info=build/debug-info \
--extra-gen-snapshot-options=--save-obfuscation-map=build/app/obfuscation.map.json
dart run sentry_dart_plugin
# iOS
flutter build ipa \
--release \
--obfuscate \
--split-debug-info=build/debug-info \
--extra-gen-snapshot-options=--save-obfuscation-map=build/app/obfuscation.map.json
dart run sentry_dart_plugin
# Web
flutter build web --release --source-maps
dart run sentry_dart_plugin
# pubspec.yaml
dependencies:
sentry: ^9.14.0
import 'package:sentry/sentry.dart';
Future<void> main() async {
await Sentry.init(
(options) {
options.dsn = 'YOUR_SENTRY_DSN';
options.tracesSampleRate = 1.0;
options.enableLogs = true;
},
appRunner: myApp,
);
}
SentryFlutter.init()import 'package:sentry_flutter/sentry_flutter.dart';
Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = 'YOUR_SENTRY_DSN';
options.sendDefaultPii = true;
// Environment — detect release builds via dart.vm.product
options.environment = const bool.fromEnvironment('dart.vm.product')
? 'production'
: 'development';
// Release is auto-set on iOS/Android as "packageName@version+build"
// Override if needed:
// options.release = 'my-app@1.0.0+42';
// Error sampling — reduce to drop a fraction of errors in high-volume production
options.sampleRate = 1.0;
// Tracing — lower to 0.1–0.2 in high-traffic production
options.tracesSampleRate = 1.0;
// Profiling — iOS and macOS only (alpha); relative to tracesSampleRate
options.profilesSampleRate = 1.0;
// Session Replay — iOS and Android only (SDK ≥9.0.0)
options.replay.sessionSampleRate = 0.1; // record 10% of all sessions
options.replay.onErrorSampleRate = 1.0; // always record error sessions
// Privacy defaults — all text and images masked
options.privacy.maskAllText = true;
options.privacy.maskAllImages = true;
// Structured logging (SDK ≥9.5.0)
options.enableLogs = true;
// Attachments
options.attachScreenshot = true; // screenshot on error
options.attachViewHierarchy = true; // widget tree on error
// HTTP client
options.captureFailedRequests = true; // auto-capture HTTP errors
options.maxRequestBodySize = MaxRequestBodySize.small;
// Android specifics
options.anrEnabled = true; // ANR detection
options.enableNdkScopeSync = true; // sync scope to native
options.enableTombstone = false; // Android 12+ tombstone (opt-in)
// Navigation (Time to Full Display — opt-in)
options.enableTimeToFullDisplayTracing = true;
},
appRunner: () => runApp(SentryWidget(child: MyApp())),
);
}
TTID (Time to Initial Display) is always enabled. TTFD is opt-in:
// Enable in options:
options.enableTimeToFullDisplayTracing = true;
Then report when your screen has loaded its data:
// Option 1: Widget wrapper (marks TTFD when child first renders)
SentryDisplayWidget(child: MyWidget())
// Option 2: Manual API call (after async data loads)
await _loadData();
SentryFlutter.currentDisplay()?.reportFullyDisplayed();
Walk through features one at a time. Load the reference file for each, follow its steps, then verify before moving on:
| Feature | Reference | Load when... |
|---|---|---|
| Error Monitoring | ${SKILL_ROOT}/references/error-monitoring.md | Always (baseline) |
| Tracing & Performance | ${SKILL_ROOT}/references/tracing.md | Always — navigation, HTTP, DB spans |
| Session Replay | ${SKILL_ROOT}/references/session-replay.md | iOS/Android user-facing apps |
| Profiling | ${SKILL_ROOT}/references/profiling.md | iOS/macOS performance-sensitive apps |
| Logging | ${SKILL_ROOT}/references/logging.md |
For each feature: Read ${SKILL_ROOT}/references/<feature>.md, follow steps exactly, verify it works.
SentryFlutter.init() Options| Option | Type | Default | Purpose |
|---|---|---|---|
dsn | string | — | Required. Project DSN. Env: SENTRY_DSN via --dart-define |
environment | string | — | e.g., "production", . Env: |
| Option | Type | Default | Purpose |
|---|---|---|---|
tracesSampleRate | double | — | Transaction sample rate (0–1). Enable by setting >0 |
tracesSampler | function | — | Per-transaction sampling; overrides tracesSampleRate |
tracePropagationTargets |
| Option | Type | Default | Purpose |
|---|---|---|---|
profilesSampleRate | double | — | Profiling rate relative to tracesSampleRate. iOS/macOS only |
| Option | Type | Default | Purpose |
|---|---|---|---|
autoInitializeNativeSdk | bool | true | Auto-initialize native Android/iOS SDK layer |
enableNativeCrashHandling | bool | true | Capture native crashes (NDK, signal, Mach exception) |
enableNdkScopeSync |
| Option | Type | Default | Purpose |
|---|---|---|---|
enableAutoSessionTracking | bool | true | Session tracking for crash-free user/session metrics |
autoSessionTrackingInterval | Duration | 30s | Background inactivity before session ends |
options.replay)| Option | Type | Default | Purpose |
|---|---|---|---|
replay.sessionSampleRate | double | 0.0 | Fraction of all sessions recorded |
replay.onErrorSampleRate | double | 0.0 | Fraction of error sessions recorded |
options.privacy)| Option / Method | Default | Purpose |
|---|---|---|
privacy.maskAllText | true | Mask all text widget content |
privacy.maskAllImages | true | Mask all image widgets |
privacy.maskAssetImages | true | Mask images from root asset bundle |
privacy.mask<T>() |
| Option | Type | Default | Purpose |
|---|---|---|---|
captureFailedRequests | bool | true (Flutter) | Auto-capture HTTP errors |
maxRequestBodySize | enum | never | Body capture: never, small, , |
| Option | Type | Purpose |
|---|---|---|
beforeSend | (SentryEvent, Hint) → SentryEvent? | Modify or drop error events. Return null to drop |
beforeSendTransaction | (SentryEvent) → SentryEvent? | Modify or drop transaction events |
beforeBreadcrumb | (Breadcrumb, Hint) → Breadcrumb? |
Pass via --dart-define at build time:
| Variable | Purpose | Notes |
|---|---|---|
SENTRY_DSN | Data Source Name | Falls back from options.dsn |
SENTRY_ENVIRONMENT | Deployment environment | Falls back from options.environment |
SENTRY_RELEASE | Release identifier | Falls back from options.release |
SENTRY_DIST |
Usage:
flutter build apk --release \
--dart-define=SENTRY_DSN=https://xxx@sentry.io/123 \
--dart-define=SENTRY_ENVIRONMENT=production
Then in code:
options.dsn = const String.fromEnvironment('SENTRY_DSN');
options.environment = const String.fromEnvironment('SENTRY_ENVIRONMENT', defaultValue: 'development');
Add these packages alongside sentry_flutter for deeper instrumentation:
Standardhttp package — built into sentry_flutter, no extra install:
import 'package:sentry/sentry.dart';
// Wrap your http client
final client = SentryHttpClient(
captureFailedRequests: true,
failedRequestStatusCodes: [SentryStatusCode.range(400, 599)],
);
try {
final response = await client.get(Uri.parse('https://api.example.com/users'));
} finally {
client.close();
}
Dio — install sentry_dio:
flutter pub add sentry_dio
import 'package:dio/dio.dart';
import 'package:sentry_dio/sentry_dio.dart';
final dio = Dio();
// Add your interceptors first, THEN addSentry() last
dio.addSentry(
captureFailedRequests: true,
failedRequestStatusCodes: [SentryStatusCode.range(400, 599)],
);
| Package | Install | Setup |
|---|---|---|
sentry_sqflite | flutter pub add sentry_sqflite | databaseFactory = SentrySqfliteDatabaseFactory(); |
sentry_drift | flutter pub add sentry_drift | .interceptWith(SentryQueryInterceptor(databaseName: 'db')) |
sentry_hive |
| Package | Install | Purpose |
|---|---|---|
sentry_logging | flutter pub add sentry_logging | Dart logging package → Sentry breadcrumbs/events |
sentry_link | flutter pub add sentry_link | GraphQL (gql, graphql_flutter, ferry) tracing |
sentry_supabase | flutter pub add sentry_supabase |
No official packages — wire Sentry via observer APIs:
| Framework | Hook point | Pattern |
|---|---|---|
| BLoC/Cubit | BlocObserver.onError | Sentry.captureException(error, stackTrace: stackTrace) inside onError; set Bloc.observer = SentryBlocObserver() before init |
| Riverpod | ProviderObserver.providerDidFail | Fires for FutureProvider/StreamProvider failures; wrap app with |
Lower sample rates and harden config before shipping:
Future<void> main() async {
final isProduction = const bool.fromEnvironment('dart.vm.product');
await SentryFlutter.init(
(options) {
options.dsn = const String.fromEnvironment('SENTRY_DSN');
options.environment = isProduction ? 'production' : 'development';
// Trace 10% of transactions in high-traffic production
options.tracesSampleRate = isProduction ? 0.1 : 1.0;
// Profile 100% of traced transactions (profiling is always a subset)
options.profilesSampleRate = 1.0;
// Replay all error sessions, sample 5% of normal sessions
options.replay.onErrorSampleRate = 1.0;
options.replay.sessionSampleRate = isProduction ? 0.05 : 1.0;
// Disable debug logging in production
options.debug = !isProduction;
},
appRunner: () => runApp(SentryWidget(child: MyApp())),
);
}
After setup, test that Sentry is receiving events:
// Add a test button somewhere visible during development:
ElevatedButton(
onPressed: () {
throw Exception('Sentry test error!');
},
child: const Text('Test Sentry Error'),
)
// Or capture manually:
ElevatedButton(
onPressed: () {
Sentry.captureMessage('Sentry test message', level: SentryLevel.info);
},
child: const Text('Test Sentry Message'),
)
// Test structured logging:
ElevatedButton(
onPressed: () {
Sentry.logger.info('Test log from Flutter app');
},
child: const Text('Test Sentry Log'),
)
Check the Sentry dashboard:
enableLogs: true⚠️ Platform limitations in debug mode:
- Native crashes, session replay, slow/frozen frames, and app start metrics only fully work in release builds on iOS/Android
- Run
flutter run --releaseor use a real device/emulator to test native features- Debug mode uses the Dart VM with JIT compilation — some native integrations behave differently
These are active with no extra config when you call SentryFlutter.init():
| Integration | What it does |
|---|---|
FlutterErrorIntegration | Captures FlutterError.onError framework errors |
RunZonedGuardedIntegration | Catches unhandled Dart exceptions in runZonedGuarded |
NativeAppStartIntegration | App start timing (iOS/Android) |
FramesTrackingIntegration | Slow/frozen frames (iOS/Android/macOS) |
NativeUserInteractionIntegration | User interaction breadcrumbs from native layer |
After completing Flutter setup, check for a backend missing Sentry coverage:
# Adjacent backend directories
ls ../backend ../server ../api 2>/dev/null
cat ../go.mod 2>/dev/null | head -3
cat ../requirements.txt ../pyproject.toml 2>/dev/null | head -3
cat ../Gemfile 2>/dev/null | head -3
ls ../backend/package.json ../server/package.json 2>/dev/null
If a backend exists without Sentry, suggest the matching skill:
| Detected | Suggest skill |
|---|---|
Go backend (go.mod) | sentry-go-sdk |
Python backend (requirements.txt, pyproject.toml) | sentry-python-sdk |
Ruby backend (Gemfile) | sentry-ruby-sdk |
| Node.js backend | sentry-node-sdk |
Distributed tracing — if a backend skill is added, configure tracePropagationTargets in Flutter to propagate trace context to your API:
options.tracePropagationTargets = ['api.myapp.com', 'localhost'];
options.propagateTraceparent = true; // also send W3C traceparent header
This links mobile transactions to backend traces in the Sentry waterfall view.
| Issue | Solution |
|---|---|
| Events not appearing in Sentry | Set options.debug = true — SDK logs to Flutter console; verify DSN is correct |
SentryFlutter.init throws | Ensure main() is async and you await SentryFlutter.init(...) |
| Stack traces unreadable in Sentry | Upload debug symbols with sentry_dart_plugin; build with --obfuscate --split-debug-info |
| Stack traces missing on Web |
Weekly Installs
161
Repository
GitHub Stars
83
First Seen
Mar 6, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli160
codex160
cursor160
kimi-cli159
amp159
cline159
Electron应用自动化指南:使用agent-browser通过CDP实现桌面应用自动化
13,200 周安装
Recommend sentry_dio integration |
sqflite, drift, hive, isar present? | Recommend matching sentry_* DB package |
Has android/ and ios/ directories? | Full mobile feature set available |
Has web/ directory only? | Session Replay and Profiling unavailable |
Has macos/ directory? | Profiling available (alpha) |
| Backend directory detected? | Trigger Phase 4 cross-link |
sentry:| SDK + symbol upload config |
lib/main.dart | Wraps main() with SentryFlutter.init() | SDK initialization |
android/app/build.gradle | Adds Proguard config reference | Android obfuscation support |
.sentryclirc | Auth token and org/project config | Symbol upload credentials |
Once it finishes, come back and skip toVerification.
| Structured logging / log-trace correlation |
| Metrics | ${SKILL_ROOT}/references/metrics.md | Custom business metrics (open beta) |
"staging"SENTRY_ENVIRONMENTrelease | string | Auto on iOS/Android | "packageName@version+build". Env: SENTRY_RELEASE |
dist | string | — | Distribution identifier; max 64 chars. Env: SENTRY_DIST |
sendDefaultPii | bool | false | Include PII: IP address, user labels, widget text in replay |
sampleRate | double | 1.0 | Error event sampling (0.0–1.0) |
maxBreadcrumbs | int | 100 | Max breadcrumbs per event |
attachStacktrace | bool | true | Auto-attach stack traces to messages |
attachScreenshot | bool | false | Capture screenshot on error (mobile/desktop only) |
screenshotQuality | enum | high | Screenshot quality: full, high, medium, low |
attachViewHierarchy | bool | false | Attach JSON widget tree as attachment on error |
debug | bool | true in debug | Verbose SDK output. Never forcetrue in production |
diagnosticLevel | enum | warning | Log verbosity: debug, info, warning, error, fatal |
enabled | bool | true | Disable SDK entirely (e.g., for testing) |
maxCacheItems | int | 30 | Max offline-cached envelopes (not supported on Web) |
sendClientReports | bool | true | Send SDK health reports (dropped events, etc.) |
reportPackages | bool | true | Report pubspec.yaml dependency list |
reportSilentFlutterErrors | bool | false | Capture FlutterErrorDetails.silent errors |
idleTimeout | Duration | 3000ms | Auto-finish idle user interaction transactions |
List| — |
URLs to attach sentry-trace + baggage headers |
propagateTraceparent | bool | false | Also send W3C traceparent header (SDK ≥9.7.0) |
enableTimeToFullDisplayTracing | bool | false | Opt-in TTFD tracking per screen |
enableAutoPerformanceTracing | bool | true | Auto-enable performance monitoring |
enableUserInteractionTracing | bool | true | Create transactions for tap/click/long-press events |
enableUserInteractionBreadcrumbs | bool | true | Breadcrumbs for every tracked user interaction |
bool |
true |
| Sync Dart scope to Android NDK |
enableScopeSync | bool | true | Sync scope data to native SDKs |
anrEnabled | bool | true | ANR detection (Android) |
anrTimeoutInterval | int | 5000 | ANR timeout in milliseconds (Android) |
enableWatchdogTerminationTracking | bool | true | OOM kill tracking (iOS) |
enableTombstone | bool | false | Android 12+ native crash info via ApplicationExitInfo |
attachThreads | bool | false | Attach all threads on crash (Android) |
captureNativeFailedRequests | bool | — | Native HTTP error capture, independent of Dart client (iOS/macOS, v9.11.0+) |
enableAutoNativeAppStart | bool | true | App start timing instrumentation (iOS/Android) |
enableFramesTracking | bool | true | Slow/frozen frame monitoring (iOS/Android/macOS) |
proguardUuid | string | — | Proguard UUID for Android obfuscation mapping |
| — |
| Mask a specific widget type and all subclasses |
privacy.unmask<T>() | — | Unmask a specific widget type |
privacy.maskCallback<T>() | — | Custom masking decision per widget instance |
mediumalwaysfailedRequestStatusCodes | List | [500–599] | Status codes treated as failures |
failedRequestTargets | List | ['.*'] | URL patterns to monitor |
| Process breadcrumbs before storage |
beforeSendLog | (SentryLog) → SentryLog? | Filter structured logs before sending |
| Build distribution |
Falls back from options.dist |
SENTRY_AUTH_TOKEN | Upload debug symbols | Never embed in app — build tool only |
SENTRY_ORG | Organization slug | Used by sentry_dart_plugin |
SENTRY_PROJECT | Project slug | Used by sentry_dart_plugin |
flutter pub add sentry_hive |
Use SentryHive instead of Hive |
sentry_isar | flutter pub add sentry_isar | Use SentryIsar.open() instead of Isar.open() |
| Supabase query tracing (SDK ≥9.9.0) |
sentry_firebase_remote_config | flutter pub add sentry_firebase_remote_config | Feature flag tracking |
sentry_file | flutter pub add sentry_file | File I/O tracing via .sentryTrace() extension |
ProviderScope(observers: [SentryProviderObserver()])| Provider/ChangeNotifier | try/catch in notifyListeners callers | Manually call Sentry.captureException(e, stackTrace: stack) in catch blocks |
| GetX | GetMaterialApp.onError | GetMaterialApp(onError: (details) => Sentry.captureException(...)) |
UserInteractionIntegration | Dart-layer tap/click transactions (requires SentryWidget) |
DeviceContextIntegration | Device model, OS version, screen resolution |
AppContextIntegration | App version, build number, bundle ID |
ConnectivityIntegration | Network connectivity change breadcrumbs |
HttpClientIntegration | Auto-instrument Dart http requests |
SdkIntegration | SDK metadata tagging |
ReleaseIntegration | Auto-set release on iOS/Android from package info |
.NET backend (*.csproj) | sentry-dotnet-sdk |
| React / Next.js web | sentry-react-sdk / sentry-nextjs-sdk |
Build with --source-maps and run dart run sentry_dart_plugin to upload |
| Native crashes not captured | Confirm enableNativeCrashHandling: true; test in release mode, not debug |
| Session replay not recording | iOS/Android only; confirm SentryWidget wraps root; check replay.onErrorSampleRate |
| Replay shows blank screens | Confirm SentryWidget(child: MyApp()) is outermost widget; not inside navigator |
| Profiling not working | iOS and macOS only (alpha); confirm tracesSampleRate > 0 is set first |
| Navigation not tracked | Add SentryNavigatorObserver() to navigatorObservers; name all routes |
| GoRouter routes unnamed | Add name: to all GoRoute entries — unnamed routes are tracked as null |
| TTFD never reports | Call SentryFlutter.currentDisplay()?.reportFullyDisplayed() after data loads, or wrap with SentryDisplayWidget |
sentry_dart_plugin auth error | Set SENTRY_AUTH_TOKEN env var instead of hardcoding in pubspec.yaml |
| Android ProGuard mapping missing | Ensure --extra-gen-snapshot-options=--save-obfuscation-map=... flag is set |
| iOS dSYM not uploaded | sentry_dart_plugin handles this; check upload_debug_symbols: true in pubspec.yaml sentry: block |
pub get fails: Dart SDK too old | sentry_flutter ≥9.0.0 requires Dart ≥3.5.0; run flutter upgrade |
| Hot restart crashes on Android debug | Known issue (fixed in SDK ≥9.9.0); upgrade if on older version |
| ANR detection too aggressive | Increase anrTimeoutInterval (default: 5000ms) |
| Too many transactions in dashboard | Lower tracesSampleRate to 0.1 or use tracesSampler to drop health checks |
beforeSend not firing for native crashes | Expected — beforeSend intercepts only Dart-layer events; native crashes bypass it |
| Crons not available | The Flutter/Dart SDK does not support Sentry Crons; use a server-side SDK instead |
| Metrics marked as experimental | sentry_flutter Metrics API is open beta (SDK ≥9.11.0); stable on other SDKs |
SentryWidget warning in tests | Wrap test widget with SentryFlutter.init() in setUpAll, or use enabled: false |
| Firebase Remote Config: Linux/Windows | sentry_firebase_remote_config not supported on Linux/Windows (Firebase limitation) |
| Isar tracing on Web | sentry_isar does NOT support Web (Isar does not support Web) |