-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
flutter: improve session and screenshots docs (#11708)
* improve docs * update * update * update snippet * update doc * update screenshots * Update docs/platforms/flutter/configuration/options.mdx Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io> * Update docs/platforms/flutter/configuration/releases.mdx Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io> * Update platform-includes/configuration/auto-session-tracking/flutter.mdx Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io> * Update platform-includes/enriching-events/attach-screenshots/flutter.mdx Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io> * Update platform-includes/configuration/auto-session-tracking/flutter.mdx Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io> * update code snippets * update code snippets * update code snippets --------- Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>
- Loading branch information
1 parent
d8dce06
commit 8ebae05
Showing
8 changed files
with
70 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 12 additions & 20 deletions
32
platform-includes/configuration/auto-session-tracking/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
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 this default by setting the `autoSessionTrackingInterval` option to a `Duration` of your choosing. | ||
|
||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) => options.autoSessionTrackingInterval = const Duration(milliseconds: 60000) | ||
appRunner: () => runApp(MyApp()), | ||
); | ||
} | ||
```dart {2} | ||
SentryFlutter.init((options) { | ||
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 `enableAutoSessionTracking` option to `false`. If you disable this feature, release health will not be available. | ||
|
||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) => options.enableAutoSessionTracking = true, // it's enabled by default | ||
appRunner: () => runApp(MyApp()), | ||
); | ||
} | ||
```dart {2} | ||
SentryFlutter.init((options) { | ||
options.enableAutoSessionTracking = false; | ||
}); | ||
``` |
70 changes: 31 additions & 39 deletions
70
platform-includes/enriching-events/attach-screenshots/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,40 @@ | ||
```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 {3, 6-8} | ||
await SentryFlutter.init( | ||
(options) { | ||
options.attachScreenshot = true; | ||
}, | ||
appRunner: () => runApp( | ||
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. | ||
|
||
```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 {4-10} | ||
await SentryFlutter.init( | ||
(options) { | ||
options.attachScreenshot = true; | ||
options.beforeScreenshot = (event, {hint}) { | ||
// Based on some condition you can decide to attach the screenshot or drop it | ||
if (event.throwable is MyImportantException) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
}, | ||
appRunner: () => runApp( | ||
SentryWidget( | ||
child: MyApp(), | ||
), | ||
); | ||
} | ||
), | ||
); | ||
``` |