Skip to content

Commit 7d0ebfe

Browse files
committed
update code snippets
1 parent 4dd9ec2 commit 7d0ebfe

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

platform-includes/configuration/auto-session-tracking/flutter.mdx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ To benefit from the health data, you must use at least version 4.0.0 of the Flut
44

55
By default, the session is terminated once the application is in the background for more than `30 seconds`. You can change this default by setting the `autoSessionTrackingInterval` option to a `Duration` of your choosing.
66

7-
```dart
7+
```dart {2}
88
SentryFlutter.init((options) {
9-
// Change timeout duration until session is terminated in background
109
options.autoSessionTrackingInterval = const Duration(seconds: 60)
1110
});
1211
```
@@ -15,9 +14,8 @@ SentryFlutter.init((options) {
1514

1615
If you'd like to opt out of capturing sessions, set the `enableAutoSessionTracking` option to `false`. If you disable this feature, release health will not be available.
1716

18-
```dart
17+
```dart {2}
1918
SentryFlutter.init((options) {
20-
// Disable auto session tracking
2119
options.enableAutoSessionTracking = false;
2220
});
2321
```
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
Enable screenshots by setting the `attachScreenshot` option to `true` and wrap your root widget with `SentryWidget`.
22

3-
```dart
3+
```dart {3, 6-8}
44
await SentryFlutter.init(
55
(options) {
6-
// Set the option to true to enable capturing screenshots
76
options.attachScreenshot = true;
87
},
98
appRunner: () => runApp(
10-
// Wrap your root widget with the [SentryWidget] widget.
119
SentryWidget(
1210
child: MyApp(),
1311
),
@@ -21,14 +19,22 @@ You can filter your screenshots by using the `beforeScreenshot` callback, which
2119

2220
If the callback returns `false`, the screenshot will not be attached.
2321

24-
```dart
25-
await SentryFlutter.init((options) {
26-
options.beforeScreenshot = (event, {hint}) {
27-
// Example: based on some condition you can decide to attach the screenshot or drop it
22+
```dart {4-10}
23+
await SentryFlutter.init(
24+
(options) {
25+
options.attachScreenshot = true;
26+
options.beforeScreenshot = (event, {hint}) {
27+
// Based on some condition you can decide to attach the screenshot or drop it
2828
if (event.throwable is MyImportantException) {
2929
return true;
3030
}
31-
return false;
32-
};
33-
});
31+
return false;
32+
};
33+
},
34+
appRunner: () => runApp(
35+
SentryWidget(
36+
child: MyApp(),
37+
),
38+
),
39+
);
3440
```

0 commit comments

Comments
 (0)