Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flutter: improve session and screenshots docs #11708

Merged
merged 14 commits into from
Nov 11, 2024
11 changes: 11 additions & 0 deletions docs/platforms/dart/configuration/releases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,14 @@ Setting the release name tags each event with that release name. We recommend th
If you don't tell Sentry about a new release, Sentry will automatically create a release entity in the system the first time it sees an event with that release ID.

After configuring your SDK, you can install a repository integration or manually supply Sentry with your own commit metadata. Read our documentation about [setting up releases](/product/releases/setup/) for further information about integrations, associating commits, and telling Sentry when deploying releases.

## Release Health

<Note>

Looking for Flutter release health? [See the Flutter documentation](/platforms/flutter/configuration/releases/#release-health).

</Note>

Monitoring release health is currently not supported for pure Dart applications.

1 change: 1 addition & 0 deletions docs/platforms/flutter/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ This option can be overridden using <PlatformIdentifier name="in-app-include" />
<ConfigKey name="attach-screenshot">

Takes a screenshot of the application when an error happens and includes it as an attachment.
Enable this feature by setting <PlatformIdentifier name="attach-screenshot" /> to `true` and wrapping your root widget with `SentryWidget(child: MyApp())`.
buenaflor marked this conversation as resolved.
Show resolved Hide resolved
Learn more about enriching events with screenshots in our <PlatformLink to="/enriching-events/screenshots/">Screenshots documentation</PlatformLink>.

</ConfigKey>
Expand Down
6 changes: 3 additions & 3 deletions docs/platforms/flutter/configuration/releases.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ After configuring your SDK, you can install a repository integration or manually

Monitor the [health of releases](/product/releases/health/) by observing user adoption, usage of the application, percentage of [crashes](/product/releases/health/#crash), and [session data](/product/releases/health/#session). Release health will provide insight into the impact of crashes and bugs as it relates to user experience, and reveal trends with each new issue through the [Release Details](/product/releases/release-details/) graphs and filters.

In order to monitor release health, the SDK sends session data.

<Note>

Crash reporting and app hang detection are not available for watchOS.
Release health in Flutter is only available for Android, iOS and macOS.
buenaflor marked this conversation as resolved.
Show resolved Hide resolved

</Note>

In order to monitor release health, the SDK sends session data.

### Sessions

A session represents the interaction between the user and the application. Sessions contain a timestamp, a status (if the session was OK or if it crashed), and are always linked to a release. Most Sentry SDKs can manage sessions automatically.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This feature is only available for SDKs with a user interface, like the ones for

## Enabling Screenshots

Because screenshots may contain <PlatformLink to="/data-management/sensitive-data/">PII</PlatformLink>, they are an opt-in feature. You can enable screenshots as shown below:
Because screenshots may contain <PlatformLink to="/data-management/sensitive-data/">PII</PlatformLink>, they are an opt-in feature.

<PlatformContent includePath="enriching-events/attach-screenshots" />

Expand Down
34 changes: 14 additions & 20 deletions platform-includes/configuration/auto-session-tracking/flutter.mdx
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
To benefit from the health data, you must use at least version 4.0.0 of the Flutter SDK.

By default, the session is terminated once the application is in the background for more than 30 seconds. You can change the time out with the option named `sessionTrackingIntervalMillis`. It takes the amount in milliseconds. For example, to configure it to be 60 seconds:
#### Session Timeout

```dart
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
By default, the session is terminated once the application is in the background for more than `30 seconds`. You can change the default timeout with the option `autoSessionTrackingInterval` to a `Duration` of your choosing.
buenaflor marked this conversation as resolved.
Show resolved Hide resolved

Future<void> main() async {
await SentryFlutter.init(
(options) => options.autoSessionTrackingInterval = const Duration(milliseconds: 60000)
appRunner: () => runApp(MyApp()),
);
}
```dart
SentryFlutter.init((options) {
// Change timeout duration until session is terminated in background
options.autoSessionTrackingInterval = const Duration(seconds: 60)
});
```

If you'd like to opt out of this feature, you can do so using options.
#### Disable Auto Session Tracking

```dart
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
If you'd like to opt out of capturing sessions, set the option `enableAutoSessionTracking` to `false`. If you disable this feature, release health will not be available.
buenaflor marked this conversation as resolved.
Show resolved Hide resolved

Future<void> main() async {
await SentryFlutter.init(
(options) => options.enableAutoSessionTracking = true, // it's enabled by default
appRunner: () => runApp(MyApp()),
);
}
```dart
SentryFlutter.init((options) {
// Disable auto session tracking
options.enableAutoSessionTracking = false;
});
```
66 changes: 26 additions & 40 deletions platform-includes/enriching-events/attach-screenshots/flutter.mdx
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
```dart
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
Enable screenshots by setting the `attachScreenshot` option to `true` and wrap your root widget with `SentryWidget`.

Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = '___PUBLIC_DSN___';
options.attachScreenshot = true;
},
appRunner: () => runApp(
// Wrap your app widget with the [SentryWidget] widget.
SentryWidget(
child: MyApp(),
),
```dart
await SentryFlutter.init(
(options) {
// Set the option to true to enable capturing screenshots
options.attachScreenshot = true;
},
appRunner: () => runApp(
// Wrap your root widget with the [SentryWidget] widget.
SentryWidget(
child: MyApp(),
),
);
}
),
);
```

### Filtering Screenshots
## Filtering Screenshots

You can filter your screenshots by using the `beforeScreenshot` callback.
It is called before taking a screenshot and if the callback returns `false`, the screenshot will not be attached.
You can filter your screenshots by using the `beforeScreenshot` callback which is called before attaching a screenshot to an event. By default, the callback returns `true` which means that all screenshots are attached.

buenaflor marked this conversation as resolved.
Show resolved Hide resolved
```dart
import 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
If the callback returns `false`, the screenshot will not be attached.

Future<void> main() async {
await SentryFlutter.init(
(options) {
options.dsn = '___PUBLIC_DSN___';
options.attachScreenshot = true;
options.beforeScreenshot = (event, {hint}) {
// Return false if you don't want to attach the screenshot based on some condition.
return true;
};
},
appRunner: () => runApp(
// Wrap your app widget with the [SentryWidget] widget.
SentryWidget(
child: MyApp(),
),
),
);
}
```dart
await SentryFlutter.init((options) {
options.beforeScreenshot = (event, {hint}) {
// Example: based on some condition you can decide to attach the screenshot or drop it
if (event.throwable is MyImportantException) {
return true;
}
return false;
};
});
```
Loading