Skip to content

Commit

Permalink
Enable source code context for Flutter (#7157)
Browse files Browse the repository at this point in the history
  • Loading branch information
marandaneto authored Jun 16, 2023
1 parent 8a7ce14 commit 858dedb
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/platform-includes/capture-error/dart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
1 change: 1 addition & 0 deletions src/platform-includes/getting-started-primer/flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/platforms/common/data-management/debug-files/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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."
---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -50,6 +48,16 @@ in the future. Referer to [this issue](https://github.com/getsentry/symbolic/iss

</PlatformSection>

<PlatformSection supported={["flutter"]}>

<Note>

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.

</Note>

</PlatformSection>

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
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/flutter/migration.mdx
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
2 changes: 1 addition & 1 deletion src/platforms/flutter/native-init.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Native Initialization
sidebar_order: 900
sidebar_order: 12
description: "Learn how to manually initialize the native SDKs."
---

Expand Down
2 changes: 1 addition & 1 deletion src/platforms/flutter/troubleshooting.mdx
Original file line number Diff line number Diff line change
@@ -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."
Expand Down
12 changes: 9 additions & 3 deletions src/platforms/flutter/upload-debug.mdx
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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.
16 changes: 15 additions & 1 deletion src/wizard/flutter/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,18 @@ Future<void> 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.

1 comment on commit 858dedb

@vercel
Copy link

@vercel vercel bot commented on 858dedb Jun 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs-git-master.sentry.dev
sentry-docs.sentry.dev
docs.sentry.io

Please sign in to comment.