From 858dedb6023c19ab4af411e46b5bacda02bc0563 Mon Sep 17 00:00:00 2001
From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com>
Date: Fri, 16 Jun 2023 09:06:58 +0200
Subject: [PATCH] Enable source code context for Flutter (#7157)
---
src/platform-includes/capture-error/dart.mdx | 3 ++-
.../getting-started-primer/flutter.mdx | 1 +
.../common/data-management/debug-files/index.mdx | 1 +
.../debug-files/source-context.mdx | 14 +++++++++++---
src/platforms/flutter/migration.mdx | 2 +-
src/platforms/flutter/native-init.mdx | 2 +-
src/platforms/flutter/troubleshooting.mdx | 2 +-
src/platforms/flutter/upload-debug.mdx | 12 +++++++++---
src/wizard/flutter/index.md | 16 +++++++++++++++-
9 files changed, 42 insertions(+), 11 deletions(-)
diff --git a/src/platform-includes/capture-error/dart.mdx b/src/platform-includes/capture-error/dart.mdx
index 150d5519b4908a..5fa74e00c20ebd 100644
--- a/src/platform-includes/capture-error/dart.mdx
+++ b/src/platform-includes/capture-error/dart.mdx
@@ -18,4 +18,5 @@ try {
- Use a `try/catch` block
- Use a `catchError` block for `Futures`
- `Isolate` errors on the `current` Isolate which is the equivalent of a main/UI thread, e.g. using `Isolate.current.addErrorListener`, are captured automatically (Only for non-Web Apps).
-- For your own `Isolates`, add an `ErrorListener` and call `Sentry.captureException`
+- Add an [Error Listener](https://api.flutter.dev/flutter/dart-isolate/Isolate/addErrorListener.html) to your `Isolates` argument by calling `isolate.addSentryErrorListener()`.
+- Use `await` when calling `Sentry.captureMessage` or `Sentry.captureException`. Alternatively, you can pass the `stackTrace` parameter via `Sentry.captureException(exception, stackTrace: stackTrace)` to get the correct stack trace.
diff --git a/src/platform-includes/getting-started-primer/flutter.mdx b/src/platform-includes/getting-started-primer/flutter.mdx
index 5677e21aa17fb5..5e3f4c31bb5c0f 100644
--- a/src/platform-includes/getting-started-primer/flutter.mdx
+++ b/src/platform-includes/getting-started-primer/flutter.mdx
@@ -14,6 +14,7 @@ Features:
- Android: Offline caching when a device is offline; we send a report once the application is restarted
- iOS: Offline caching when a device is unable to connect; we send a report once we receive another event
- Events [enriched](/platforms/flutter/enriching-events/context/) with device data
+- [Source Context](/platforms/flutter/data-management/debug-files/source-context/) show snippets of code around the location of stack frames
- Breadcrumbs automatically captured:
- by the [Dart SDK](/platforms/dart/enriching-events/breadcrumbs/#automatic-breadcrumbs)
- by the [Flutter SDK](/platforms/flutter/enriching-events/breadcrumbs/#automatic-breadcrumbs)
diff --git a/src/platforms/common/data-management/debug-files/index.mdx b/src/platforms/common/data-management/debug-files/index.mdx
index 1b76a0621b050e..7ffaf0d4893304 100644
--- a/src/platforms/common/data-management/debug-files/index.mdx
+++ b/src/platforms/common/data-management/debug-files/index.mdx
@@ -12,6 +12,7 @@ supported:
- unity
- unreal
- dotnet
+ - flutter
description: "Learn about how debug information files allow Sentry to extract stack traces and provide more information about crash reports for most compiled platforms."
---
diff --git a/src/platforms/common/data-management/debug-files/source-context.mdx b/src/platforms/common/data-management/debug-files/source-context.mdx
index 1d1ba071841ab3..0eb97bd7ea1ac3 100644
--- a/src/platforms/common/data-management/debug-files/source-context.mdx
+++ b/src/platforms/common/data-management/debug-files/source-context.mdx
@@ -4,9 +4,7 @@ sidebar_order: 5
description: "Learn about setting up source bundles to show source code in stack traces on the Issue Details page."
---
-If Sentry has access to application source code, it can show snippets of code
-around the location of stack frames. We refer to these snippets as _source context_.
-Source context can be very useful for quickly identify problematic code.
+If Sentry has access to your application's source code, it can show snippets of code (_source context_) around the location of stack frames, which helps to quickly pinpoint problematic code.
For example, here's a stack trace from a .NET application. The source context contains
the original C# source code of the application, with the location of the frame highlighted.
@@ -50,6 +48,16 @@ in the future. Referer to [this issue](https://github.com/getsentry/symbolic/iss
+
+
+
+
+For Flutter Android, iOS, and macOS, follow the instructions in the [Debug Symbols](/platforms/flutter/upload-debug/#uploading-source-code-context-for-flutter-android-ios-and-macos) guide.
+
+
+
+
+
After they've been uploaded you can review and manage source bundles the same as
any other debug information file. See [Managing Debug Information Files](../#managing-debug-information-files).
Source bundles will be tagged with `sources`, and will carry the same filename as the
diff --git a/src/platforms/flutter/migration.mdx b/src/platforms/flutter/migration.mdx
index 36bcd85169a83b..6ceee318c7dccc 100644
--- a/src/platforms/flutter/migration.mdx
+++ b/src/platforms/flutter/migration.mdx
@@ -1,6 +1,6 @@
---
title: Migration Guide
-sidebar_order: 1000
+sidebar_order: 13
---
## Migrating From `sentry_flutter` `6.18.x` to `sentry` `7.0.0`
diff --git a/src/platforms/flutter/native-init.mdx b/src/platforms/flutter/native-init.mdx
index cd3be85e98d8d7..772115a1583554 100644
--- a/src/platforms/flutter/native-init.mdx
+++ b/src/platforms/flutter/native-init.mdx
@@ -1,6 +1,6 @@
---
title: Native Initialization
-sidebar_order: 900
+sidebar_order: 12
description: "Learn how to manually initialize the native SDKs."
---
diff --git a/src/platforms/flutter/troubleshooting.mdx b/src/platforms/flutter/troubleshooting.mdx
index 05f161bf9118b0..56ac60564dc15c 100644
--- a/src/platforms/flutter/troubleshooting.mdx
+++ b/src/platforms/flutter/troubleshooting.mdx
@@ -1,6 +1,6 @@
---
title: Troubleshooting
-sidebar_order: 100
+sidebar_order: 14
redirect_from:
- /platforms/flutter/usage/advanced-usage/
description: "Troubleshoot and resolve edge cases regarding known limitations and bundling."
diff --git a/src/platforms/flutter/upload-debug.mdx b/src/platforms/flutter/upload-debug.mdx
index 64bbbc4e1d7426..9d9da1d1adaf2e 100644
--- a/src/platforms/flutter/upload-debug.mdx
+++ b/src/platforms/flutter/upload-debug.mdx
@@ -1,10 +1,10 @@
---
title: Debug Symbols
-sidebar_order: 2
+sidebar_order: 11
description: "Learn more about uploading debug symbols for both Android and iOS/macOS."
---
-Debug symbols provide information that Sentry displays on the **Issue Details** page to help you triage an issue. We offer a range of methods to provide Sentry with debug symbols.
+We offer a range of methods to provide Sentry with debug symbols so that you can see symbolicated stack traces and triage issues faster.
## When to Upload
@@ -46,4 +46,10 @@ To use ProGuard with Sentry, upload the [Android Proguard/R8 mapping files](/pla
## Uploading Source Maps for Flutter Web
-You can also use our CLI to [upload source maps for Flutter Web](/product/cli/releases/#managing-release-artifacts).
+You can also use our CLI to [upload source maps for Flutter Web](/product/cli/releases/#managing-release-artifacts). This will automatically enable Source Context as well.
+
+## Uploading Source Context for Flutter Android, iOS, and macOS
+
+Use the [`upload_sources`](/platforms/flutter/upload-debug/#sentry-dart-plugin) option to enable [Source Context](/platforms/flutter/data-management/debug-files/source-context/).
+
+For more information, check out the [Native Symbolication on iOS/macOS](/platforms/flutter/troubleshooting/#native-symbolication-on-iosmacos) and [Source Context](/platforms/flutter/troubleshooting/#source-context) troubleshooting guides.
diff --git a/src/wizard/flutter/index.md b/src/wizard/flutter/index.md
index e22b2a138b6720..317ffd7cd1ec02 100644
--- a/src/wizard/flutter/index.md
+++ b/src/wizard/flutter/index.md
@@ -88,4 +88,18 @@ Future processOrderBatch(ISentrySpan span) async {
}
```
-Check out [the documentation](https://docs.sentry.io/platforms/flutter/performance/instrumentation/) to learn more about the API and automatic instrumentations.
+To learn more about the API and automatic instrumentations, check out the [performance documentation](/platforms/flutter/performance/instrumentation/) .
+
+## Debug Symbols
+
+We offer a range of methods to provide Sentry with debug symbols so that you can see symbolicated stack traces and triage issues faster.
+
+Complete stack traces will be shown for your Dart error by default, but if you use [`split-debug-info`](https://flutter.dev/docs/perf/app-size#reducing-app-size) and [`obfuscate`](https://flutter.dev/docs/deployment/obfuscate), you'll need to [upload the debug information files](/platforms/flutter/upload-debug/) generated by the `flutter` build.
+
+You'll also need to [upload the debug information files](/platforms/flutter/upload-debug/) generated by the `flutter` build for iOS, macOS, and Android NDK native crashes.
+
+## Source Context
+
+If Sentry has access to your application's source code, it can show snippets of code (_source context_) around the location of stack frames, which helps to quickly pinpoint problematic code.
+
+To enable source context, you'll need to upload debug symbols to Sentry by following the [Uploading Source Code Context for Flutter Android, iOS, and macOS](/platforms/flutter/upload-debug/#uploading-source-code-context-for-flutter-android-ios-and-macos) guide.