Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move content out of advanced usage to correct pages
  • Loading branch information
PeloWriter committed Mar 4, 2021
commit 315548f25336052c36019c2fbbc5582ff6dfd8c3
23 changes: 23 additions & 0 deletions src/includes/capture-error/flutter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
You can capture any exception object that you caught:

```dart
import 'package:sentry/sentry.dart';
try {
aMethodThatMightFail();
} catch (exception, stackTrace) {
await Sentry.captureException(
exception,
stackTrace: stackTrace,
);
}
```

## Tips for Catching Errors

- Use a `try/catch` block
- Use a `catchError` block for `Futures`
- The SDK already runs your init `callback` on an error handler, such as using `runZonedGuarded`, are captured automatically
- Flutter-specific errors, such as using `FlutterError.onError`, are captured automatically
- `Isolate` errors on the `current` Isolate which is the equivalent of a main/UI thread, such as using `Isolate.current.addErrorListener`, are captured automatically (only for non-Web Apps).
- For your own `Isolates`, add an `ErrorListener` and call `Sentry.captureException`
8 changes: 8 additions & 0 deletions src/includes/getting-started-config/flutter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ Future<void> main() async {
// or define SENTRY_DSN via Dart environment variable (--dart-define)
}
```

<Note>

Use the `SentryFlutter.init(...)` instead of `Sentry.init(...)` as it adds the Flutter integrations on top of the Dart SDK.

</Note>

You can configure the `SENTRY_DSN`, `SENTRY_RELEASE`, `SENTRY_DIST` and `SENTRY_ENVIRONMENT` via the Dart environment variables passing the `--dart-define` flag to the compiler as noted in the code sample.
36 changes: 6 additions & 30 deletions src/platforms/flutter/usage/advanced-usage.mdx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
---
title: Advanced Usage
sidebar_order: 2
description: "Learn about advanced uses of the Flutter SDK, including uploading debug symbols, known limitations, and bundling."
---

#

## Automatic Breadcrumbs



## Uploading Debug Symbols (Android and iOS)

Debug symbols provide information that Sentry displays on the Issue Details page to help you triage an issue.

- [iOS dSYM files](/platforms/apple/dsym/)
- [Android NDK](/product/cli/dif/#uploading-files), You've to do it manually, Do not use the `uploadNativeSymbols` flag from the [Sentry Gradle Plugin](/platforms/android/proguard/), it's not supported yet.
- [Android NDK](/product/cli/dif/#uploading-files) need to be done manually. Do not use the `uploadNativeSymbols` flag from the [Sentry Gradle Plugin](/platforms/android/proguard/) as it is not yet supported.
- [Android Proguard/R8 mapping file](/platforms/android/proguard/)
- [Source maps for Flutter Web](/product/cli/releases/#managing-release-artifacts)

Expand All @@ -23,33 +21,11 @@ sidebar_order: 2
- Also, Issue's titles might be obfuscated as we rely on the `runtimeType`, but they may not be human-readable, See: [Obfuscate Caveat](https://flutter.dev/docs/deployment/obfuscate#caveat)
- Layout related errors are only caught by [FlutterError.onError](https://api.flutter.dev/flutter/foundation/FlutterError/onError.html) in debug mode. In release mode, they are removed by the Flutter framework. See [Flutter build modes](https://flutter.dev/docs/testing/build-modes).

## Tips for Catching Errors

- Use a `try/catch` block
- Use a `catchError` block for `Futures`
- The SDK already runs your init `callback` on an error handler, e.g. using `runZonedGuarded`, are captured automatically
- Flutter-specific errors, e.g. using `FlutterError.onError`, are captured automatically
- `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`

## Caveat

Always prefer the `SentryFlutter.init(...)` instead of `Sentry.init(...)` as it adds the Flutter integrations on top of the Dart SDK.

## Advanced Usage (Android and iOS)

- [iOS Advanced Usage](/platforms/apple/usage/)
- [Android Advanced Usage](/platforms/android/usage/advanced-usage/)

## Dart environment variables

- You can configure the `SENTRY_DSN`, `SENTRY_RELEASE`, `SENTRY_DIST` and `SENTRY_ENVIRONMENT` via the Dart environment variables passing the `--dart-define` flag to the compiler.

## Building specific ABI on Android
## Building Specific ABI on Android

The Sentry Flutter SDK includes the Sentry Android SDK, which bundles multiple native libraries for multiple ABIs.
Building a Flutter app for a specific ABI using the `--target-platform` argument, for example an ARM 32bit apk, looks like this, which should also include the `--split-per-abi` flag:

```sh
```bash
flutter build apk --target-platform=android-arm --split-per-abi
```