Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SDKs and their associated integrations will automatically record many types of breadcrumbs. For instance, the browser JavaScript SDK will automatically record all location changes.
20 changes: 20 additions & 0 deletions src/includes/breadcrumbs/automatic-breadcrumbs/flutter.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The Flutter SDK already captures breadcrumbs automatically via the Native SDKs.

- [Automatic Breadcrumbs for Android](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs)
- [Automatic Breadcrumbs for iOS](/platforms/apple/usage/#sentryautobreadcrumbtrackingintegration)

If you wish to add additional Navigation breadcrumbs for Flutter Apps, Add the `SentryNavigatorObserver` to your `MaterialApp`, `WidgetsApp` or `CupertinoApp`

```dart
import 'package:flutter/material.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

MaterialApp(
navigatorObservers: [
SentryNavigatorObserver(),
],
// other parameters
)
```

To track automatic Breadcrumbs for `HTTP` requests, Check out the [SentryHttpClient](/platforms/dart/usage/advanced-usage/#automatic-breadcrumbs) Wrapper for the [http](https://pub.dev/packages/http) library.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ SentryXamarin.Init(options =>
? null
: breadcrumb;
});
```
```
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.
2 changes: 2 additions & 0 deletions src/includes/getting-started-install/flutter.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Get the SDK from [pub.dev](https://pub.dev/packages/sentry_flutter) by adding the following to your `pubspec.yaml`:

```yml {filename:pubspec.yaml}
dependencies:
sentry_flutter: ^4.0.4
Expand Down
17 changes: 14 additions & 3 deletions src/includes/getting-started-primer/flutter.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<Note>

_Sentry's Flutter SDK enables capturing sessions for Release Health, offline caching as well as reporting messages and errors._

_Sentry's Flutter SDK depends on the [Dart SDK](/platforms/dart/) and includes support to native crashes through Sentry's native SDKs (Android and iOS), It'll capture errors in the native layer, including Java, Kotlin, C and C++ code for `Android` and ObjC, Swift and C for `iOS`._
_Sentry's Flutter SDK enables automatic reporting of errors, messages, and exceptions. The SDK is available on GitHub [`sentry-dart`](https://github.com/getsentry/sentry-dart/)._

</Note>

Features:

- Automatic native crash error tracking (using both [Android](/platforms/android/) and [iOS](/platforms/apple/)), including
Copy link
Contributor

Choose a reason for hiding this comment

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

we also Support Flutter Web, it's a bit limited compared to Android and iOS, of course.
Eg, events are not enriched with device context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added "Limited Support for Flutter Web" - LMK if there's a link to add or if that wording is quite what we want here @bruno-garcia

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good to me, so we don't create much expectations from Web devs as we didn't spend time on it

- Java, Kotlin, C, and C++ code for Android
- ObjC, Swift, and C for iOS
- Offline storage of events
- Events [enriched](/platforms/flutter/enriching-events/context/) with device data
- Breadcrumbs automatically captured via the Native SDKs.
- [Automatic Breadcrumbs for Android](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs)
- [Automatic Breadcrumbs for iOS](/platforms/apple/usage/#sentryautobreadcrumbtrackingintegration)
- [Release Health](/product/releases/health/) tracks crash free users and sessions
- Under the hood the SDK relies on the [Dart SDK](/platforms/dart/); the minimum required version is `2.8.0` and Flutter SDK version is `1.17.0`.
2 changes: 1 addition & 1 deletion src/platforms/common/configuration/filtering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ In this example, the fingerprint is forced to a common value if an exception of

</PlatformSection>

<PlatformSection supported={["javascript", "node", "python", "go", "dotnet"]} notSupported={["javascript.cordova"]}>
<PlatformSection supported={["node", "javascript", "python", "php", "dotnet", "java", "ruby", "go", "react-native", "android", "dotnet"]} notSupported={["javascript.cordova", "flutter"]}>

## Using Sampling to Filter Transaction Events

Expand Down
8 changes: 6 additions & 2 deletions src/platforms/common/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,20 @@ Controls how many seconds to wait before shutting down. Sentry SDKs send events

</PlatformSection>

<PlatformSection supported={["node", "javascript", "python", "php", "dotnet", "java", "ruby", "go", "react-native", "android", "dotnet"]}>

## Tracing Options

<ConfigKey name="traces-sample-rate" supported={["node", "javascript", "python", "php", "dotnet"]}>
<ConfigKey name="traces-sample-rate" supported={["node", "javascript", "python", "php", "dotnet", "java", "ruby", "go", "react-native", "android", "dotnet"]}>

A number between 0 and 1, controlling the percentage chance a given transaction will be sent to Sentry. (0 represents 0% while 1 represents 100%.) Applies equally to all transactions created in the app. Either this or <PlatformIdentifier name="traces-sampler" /> must be defined to enable tracing.

</ConfigKey>

<ConfigKey name="traces-sampler" supported={["node", "javascript", "python", "php", "dotnet"]}>
<ConfigKey name="traces-sampler" supported={["node", "javascript", "python", "php", "dotnet", "java", "ruby", "go", "react-native", "android", "dotnet"]}>

A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering transactions, by returning 0 for those that are unwanted. Either this or <PlatformIdentifier name="traces-sample-rate" /> must be defined to enable tracing.

</ConfigKey>

</PlatformSection>
6 changes: 3 additions & 3 deletions src/platforms/common/enriching-events/breadcrumbs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Developers who want to modify the breadcrumbs interface can read about this in d

You can manually add breadcrumbs whenever something interesting happens. For example, you might manually record a breadcrumb if the user authenticates or another state change happens.

<PlatformContent includePath="breadcrumbs-example" />
<PlatformContent includePath="breadcrumbs/breadcrumbs-example" />

<PlatformSection supported={["javascript", "node", "python", "php", "ruby", "elixir", "perl", "native"]}>

Expand All @@ -36,13 +36,13 @@ The available breadcrumb keys are `type`, `category`, `message`, `level`, `times

## Automatic Breadcrumbs

SDKs and their associated integrations will automatically record many types of breadcrumbs. For instance, the browser JavaScript SDK will automatically record all location changes.
<PlatformContent includePath="breadcrumbs/automatic-breadcrumbs" />

## Customize Breadcrumbs

SDKs allow you to customize breadcrumbs through the `before_breadcrumb` hook. This hook is passed an already assembled breadcrumb and, in some SDKs, an optional hint. The function can modify the breadcrumb or decide to discard it entirely by returning `null`:

<PlatformContent includePath="before-breadcrumb" />
<PlatformContent includePath="breadcrumbs/before-breadcrumb" />

For information about what can be done with the hint, see <PlatformLink to="/enriching-events/breadcrumbs/">Filtering Events</PlatformLink>.

Expand Down
23 changes: 0 additions & 23 deletions src/platforms/flutter/index.mdx

This file was deleted.

59 changes: 7 additions & 52 deletions src/platforms/flutter/usage/advanced-usage.mdx
Original file line number Diff line number Diff line change
@@ -1,39 +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."
---

## Requirements

For the usage of the Flutter SDK, the minimal required Dart SDK version is `2.8.0` and Flutter SDK version is `1.17.0`

## Automatic Breadcrumbs

The Flutter SDK already captures breadcrumbs automatically via the Native SDKs.

- [Automatic Breadcrumbs for Android](/platforms/android/enriching-events/breadcrumbs/#automatic-breadcrumbs)
- [Automatic Breadcrumbs for iOS](/platforms/apple/usage/#sentryautobreadcrumbtrackingintegration)

If you wish to add additional Navigation breadcrumbs for Flutter Apps, Add the `SentryNavigatorObserver` to your `MaterialApp`, `WidgetsApp` or `CupertinoApp`

```dart
import 'package:flutter/material.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

MaterialApp(
navigatorObservers: [
SentryNavigatorObserver(),
],
// other parameters
)
```

To track automatic Breadcrumbs for `HTTP` requests, Check out the [SentryHttpClient](/platforms/dart/usage/advanced-usage/#automatic-breadcrumbs) Wrapper for the [http](https://pub.dev/packages/http) library.

## 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 @@ -42,35 +19,13 @@ To track automatic Breadcrumbs for `HTTP` requests, Check out the [SentryHttpCli
- Flutter `split-debug-info` and `obfuscate` flags aren't yet supported on iOS; they are supported only on Android. If this feature is enabled, Dart stack traces are not human readable, this is a tooling limitation, See: [43612](https://github.com/dart-lang/sdk/issues/43612) and [43274](https://github.com/dart-lang/sdk/issues/43274).
- If you enable the `split-debug-info` feature, you must upload the Debug Symbols manually.
- 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.
- 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).

## 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
```