-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
flutter: improve session and screenshots docs #11708
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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
dd72b44
improve docs
buenaflor d541779
update
buenaflor 954778c
update
buenaflor 1aec95a
update snippet
buenaflor 2e85776
update doc
buenaflor 3715b22
update screenshots
buenaflor 9cc1a66
Update docs/platforms/flutter/configuration/options.mdx
buenaflor 515585d
Update docs/platforms/flutter/configuration/releases.mdx
buenaflor fc2699f
Update platform-includes/configuration/auto-session-tracking/flutter.mdx
buenaflor 5d5a64c
Update platform-includes/enriching-events/attach-screenshots/flutter.mdx
buenaflor 4dd9ec2
Update platform-includes/configuration/auto-session-tracking/flutter.mdx
buenaflor 7d0ebfe
update code snippets
buenaflor 14aacaa
update code snippets
buenaflor a56109d
update code snippets
buenaflor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
34 changes: 14 additions & 20 deletions
34
platform-includes/configuration/auto-session-tracking/flutter.mdx
This file contains hidden or 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,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.
Outdated
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.
Outdated
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
66
platform-includes/enriching-events/attach-screenshots/flutter.mdx
This file contains hidden or 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,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.
Outdated
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; | ||
| }; | ||
| }); | ||
| ``` | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.