|
1 | 1 | To benefit from the health data, you must use at least version 4.0.0 of the Flutter SDK. |
2 | 2 |
|
3 | | -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: |
| 3 | +### Session Timeout |
4 | 4 |
|
5 | | -```dart |
6 | | -import 'package:flutter/widgets.dart'; |
7 | | -import 'package:sentry_flutter/sentry_flutter.dart'; |
| 5 | +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. |
8 | 6 |
|
9 | | -Future<void> main() async { |
10 | | - await SentryFlutter.init( |
11 | | - (options) => options.autoSessionTrackingInterval = const Duration(milliseconds: 60000) |
12 | | - appRunner: () => runApp(MyApp()), |
13 | | - ); |
14 | | -} |
| 7 | +```dart |
| 8 | +SentryFlutter.init((options) { |
| 9 | + // Change timeout duration until session is terminated in background |
| 10 | + options.autoSessionTrackingInterval = const Duration(seconds: 60) |
| 11 | +}, appRunner: () => runApp(MyApp())); |
15 | 12 | ``` |
16 | 13 |
|
17 | | -If you'd like to opt out of this feature, you can do so using options. |
| 14 | +### Disable Auto Session Tracking |
18 | 15 |
|
19 | | -```dart |
20 | | -import 'package:flutter/widgets.dart'; |
21 | | -import 'package:sentry_flutter/sentry_flutter.dart'; |
| 16 | +If you'd like to opt out of capturing sessions, set the option `enableAutoSessionTracking` to `false`. |
22 | 17 |
|
23 | | -Future<void> main() async { |
24 | | - await SentryFlutter.init( |
25 | | - (options) => options.enableAutoSessionTracking = true, // it's enabled by default |
26 | | - appRunner: () => runApp(MyApp()), |
27 | | - ); |
28 | | -} |
| 18 | +```dart |
| 19 | +SentryFlutter.init((options) { |
| 20 | + // Disable auto session tracking |
| 21 | + options.enableAutoSessionTracking = false; |
| 22 | +}, appRunner: () => runApp(MyApp())); |
29 | 23 | ``` |
0 commit comments