From dd72b4476c38e83eab1c7d3ed665de4e85ff09f8 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 1 Nov 2024 09:49:02 +0000 Subject: [PATCH 01/14] improve docs --- .../flutter/configuration/releases.mdx | 2 +- .../auto-session-tracking/flutter.mdx | 34 ++++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/docs/platforms/flutter/configuration/releases.mdx b/docs/platforms/flutter/configuration/releases.mdx index 9452a9f9a258af..f5ff76a634e4bb 100644 --- a/docs/platforms/flutter/configuration/releases.mdx +++ b/docs/platforms/flutter/configuration/releases.mdx @@ -64,7 +64,7 @@ Monitor the [health of releases](/product/releases/health/) by observing user ad -Crash reporting and app hang detection are not available for watchOS. +Release health is only available for Android and iOS and macOS. diff --git a/platform-includes/configuration/auto-session-tracking/flutter.mdx b/platform-includes/configuration/auto-session-tracking/flutter.mdx index 61702e012fefbe..1aa0c114bfbf46 100644 --- a/platform-includes/configuration/auto-session-tracking/flutter.mdx +++ b/platform-includes/configuration/auto-session-tracking/flutter.mdx @@ -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. -Future 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) +}, appRunner: () => runApp(MyApp())); ``` -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`. -Future 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; +}, appRunner: () => runApp(MyApp())); ``` From d54177932708b95896605cef013dc06ccc89f541 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 1 Nov 2024 10:06:29 +0000 Subject: [PATCH 02/14] update --- .../platforms/dart/configuration/releases.mdx | 11 ++++ .../flutter/configuration/options.mdx | 1 + .../flutter/configuration/releases.mdx | 6 +-- .../auto-session-tracking/flutter.mdx | 6 +-- .../attach-screenshots/flutter.mdx | 54 ++++++------------- 5 files changed, 35 insertions(+), 43 deletions(-) diff --git a/docs/platforms/dart/configuration/releases.mdx b/docs/platforms/dart/configuration/releases.mdx index 35d472a60df93a..c25bf6ca359a08 100644 --- a/docs/platforms/dart/configuration/releases.mdx +++ b/docs/platforms/dart/configuration/releases.mdx @@ -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 + + + +Looking for Flutter release health? [See the Flutter documentation](/platforms/flutter/configuration/releases/#release-health). + + + +Monitoring release health is currently not supported for pure Dart applications. + diff --git a/docs/platforms/flutter/configuration/options.mdx b/docs/platforms/flutter/configuration/options.mdx index ac0234e0aa2771..d98a8571bf36b5 100644 --- a/docs/platforms/flutter/configuration/options.mdx +++ b/docs/platforms/flutter/configuration/options.mdx @@ -151,6 +151,7 @@ This option can be overridden using Takes a screenshot of the application when an error happens and includes it as an attachment. +Enable this feature by setting to `true` and wrapping your root widget with `SentryWidget(child: MyApp())`. Learn more about enriching events with screenshots in our Screenshots documentation. diff --git a/docs/platforms/flutter/configuration/releases.mdx b/docs/platforms/flutter/configuration/releases.mdx index f5ff76a634e4bb..d3071bf1e1bca7 100644 --- a/docs/platforms/flutter/configuration/releases.mdx +++ b/docs/platforms/flutter/configuration/releases.mdx @@ -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. + -Release health is only available for Android and iOS and macOS. +Release health in Flutter is only available for Android and iOS and macOS. -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. diff --git a/platform-includes/configuration/auto-session-tracking/flutter.mdx b/platform-includes/configuration/auto-session-tracking/flutter.mdx index 1aa0c114bfbf46..09ac5dbba4243f 100644 --- a/platform-includes/configuration/auto-session-tracking/flutter.mdx +++ b/platform-includes/configuration/auto-session-tracking/flutter.mdx @@ -1,8 +1,8 @@ To benefit from the health data, you must use at least version 4.0.0 of the Flutter SDK. -### Session Timeout +#### Session Timeout -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. +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. ```dart SentryFlutter.init((options) { @@ -11,7 +11,7 @@ SentryFlutter.init((options) { }, appRunner: () => runApp(MyApp())); ``` -### Disable Auto Session Tracking +#### Disable Auto Session Tracking If you'd like to opt out of capturing sessions, set the option `enableAutoSessionTracking` to `false`. diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index df8e38da76cebf..ee2687bf772fa3 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -1,21 +1,16 @@ ```dart -import 'package:flutter/widgets.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; - -Future 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(), - ), +await SentryFlutter.init( + (options) { + // Set the option to true to enable capturing screenshots + options.attachScreenshot = true; + }, + appRunner: () => runApp( + // Wrap your app widget with the [SentryWidget] widget. + SentryWidget( + child: MyApp(), ), - ); -} + ), +); ``` ### Filtering Screenshots @@ -24,25 +19,10 @@ 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. ```dart -import 'package:flutter/widgets.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; - -Future 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(), - ), - ), - ); -} +await SentryFlutter.init((options) { + options.beforeScreenshot = (event, {hint}) { + // Return false if you don't want to attach the screenshot based on some condition. + return true; + }; +}); ``` From 954778cd725d5ce34a58933b103ab9d528d6fe45 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 1 Nov 2024 10:14:47 +0000 Subject: [PATCH 03/14] update --- docs/platforms/flutter/enriching-events/screenshots/index.mdx | 2 +- .../enriching-events/attach-screenshots/flutter.mdx | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/platforms/flutter/enriching-events/screenshots/index.mdx b/docs/platforms/flutter/enriching-events/screenshots/index.mdx index 21b747ce283f31..95ef93f31c6567 100644 --- a/docs/platforms/flutter/enriching-events/screenshots/index.mdx +++ b/docs/platforms/flutter/enriching-events/screenshots/index.mdx @@ -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 PII, they are an opt-in feature. You can enable screenshots as shown below: +Because screenshots may contain PII, they are an opt-in feature. diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index ee2687bf772fa3..19c5b3c7585c44 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -1,3 +1,5 @@ +Enable screenshots by setting the `attachScreenshot` option to `true` and wrap your root widget with `SentryWidget(child: MyApp())`. + ```dart await SentryFlutter.init( (options) { From 1aec95a26dac38ed9a8496b938cc59d7c9c82e38 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 1 Nov 2024 10:41:01 +0000 Subject: [PATCH 04/14] update snippet --- .../attach-screenshots/flutter.mdx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 19c5b3c7585c44..4dc1e11dd14c06 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -1,4 +1,4 @@ -Enable screenshots by setting the `attachScreenshot` option to `true` and wrap your root widget with `SentryWidget(child: MyApp())`. +Enable screenshots by setting the `attachScreenshot` option to `true` and wrap your root widget with `SentryWidget`. ```dart await SentryFlutter.init( @@ -7,7 +7,7 @@ await SentryFlutter.init( options.attachScreenshot = true; }, appRunner: () => runApp( - // Wrap your app widget with the [SentryWidget] widget. + // Wrap your root widget with the [SentryWidget] widget. SentryWidget( child: MyApp(), ), @@ -17,14 +17,18 @@ await SentryFlutter.init( ### 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 adding a screenshot to an event. + +If the callback returns `false`, the screenshot will not be attached. ```dart await SentryFlutter.init((options) { options.beforeScreenshot = (event, {hint}) { - // Return false if you don't want to attach the screenshot based on some condition. - return true; + // Example: based on some condition you can decide to attach the screenshot or drop it + if (event.throwable is MyImportantException) { + return true; + } + return false; }; }); ``` From 2e8577660e9fa42c04d4af62d647cd0f959a4af5 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 1 Nov 2024 10:42:01 +0000 Subject: [PATCH 05/14] update doc --- .../enriching-events/attach-screenshots/flutter.mdx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 4dc1e11dd14c06..7f94105635224f 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -21,6 +21,8 @@ You can filter your screenshots by using the `beforeScreenshot` callback which i If the callback returns `false`, the screenshot will not be attached. +By default, the callback returns `true` which means that all screenshots are attached. + ```dart await SentryFlutter.init((options) { options.beforeScreenshot = (event, {hint}) { From 3715b226f921005fe87648cd8e1242e169835e82 Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Fri, 1 Nov 2024 10:53:51 +0000 Subject: [PATCH 06/14] update screenshots --- docs/platforms/flutter/configuration/releases.mdx | 2 +- .../configuration/auto-session-tracking/flutter.mdx | 6 +++--- .../enriching-events/attach-screenshots/flutter.mdx | 6 ++---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/platforms/flutter/configuration/releases.mdx b/docs/platforms/flutter/configuration/releases.mdx index d3071bf1e1bca7..6dd566d7f52874 100644 --- a/docs/platforms/flutter/configuration/releases.mdx +++ b/docs/platforms/flutter/configuration/releases.mdx @@ -66,7 +66,7 @@ In order to monitor release health, the SDK sends session data. -Release health in Flutter is only available for Android and iOS and macOS. +Release health in Flutter is only available for Android, iOS and macOS. diff --git a/platform-includes/configuration/auto-session-tracking/flutter.mdx b/platform-includes/configuration/auto-session-tracking/flutter.mdx index 09ac5dbba4243f..57119a36b34910 100644 --- a/platform-includes/configuration/auto-session-tracking/flutter.mdx +++ b/platform-includes/configuration/auto-session-tracking/flutter.mdx @@ -8,16 +8,16 @@ By default, the session is terminated once the application is in the background SentryFlutter.init((options) { // Change timeout duration until session is terminated in background options.autoSessionTrackingInterval = const Duration(seconds: 60) -}, appRunner: () => runApp(MyApp())); +}); ``` #### Disable Auto Session Tracking -If you'd like to opt out of capturing sessions, set the option `enableAutoSessionTracking` to `false`. +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. ```dart SentryFlutter.init((options) { // Disable auto session tracking options.enableAutoSessionTracking = false; -}, appRunner: () => runApp(MyApp())); +}); ``` diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 7f94105635224f..5133088f2db4b2 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -15,14 +15,12 @@ await SentryFlutter.init( ); ``` -### Filtering Screenshots +## Filtering Screenshots -You can filter your screenshots by using the `beforeScreenshot` callback which is called before adding a screenshot to an event. +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. If the callback returns `false`, the screenshot will not be attached. -By default, the callback returns `true` which means that all screenshots are attached. - ```dart await SentryFlutter.init((options) { options.beforeScreenshot = (event, {hint}) { From 9cc1a66e6cb38251df21eaf6c7884a39879c4562 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 11 Nov 2024 16:09:35 +0100 Subject: [PATCH 07/14] Update docs/platforms/flutter/configuration/options.mdx Co-authored-by: Alex Krawiec --- docs/platforms/flutter/configuration/options.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/flutter/configuration/options.mdx b/docs/platforms/flutter/configuration/options.mdx index d98a8571bf36b5..ef94188d858a05 100644 --- a/docs/platforms/flutter/configuration/options.mdx +++ b/docs/platforms/flutter/configuration/options.mdx @@ -151,7 +151,7 @@ This option can be overridden using Takes a screenshot of the application when an error happens and includes it as an attachment. -Enable this feature by setting to `true` and wrapping your root widget with `SentryWidget(child: MyApp())`. +Enable this option by setting to `true` and wrapping your root widget with `SentryWidget(child: MyApp())`. Learn more about enriching events with screenshots in our Screenshots documentation. From 515585d791d4180bda396059ae6d4bb3b5ded7dc Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 11 Nov 2024 16:09:57 +0100 Subject: [PATCH 08/14] Update docs/platforms/flutter/configuration/releases.mdx Co-authored-by: Alex Krawiec --- docs/platforms/flutter/configuration/releases.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/flutter/configuration/releases.mdx b/docs/platforms/flutter/configuration/releases.mdx index 6dd566d7f52874..22093a18faee8e 100644 --- a/docs/platforms/flutter/configuration/releases.mdx +++ b/docs/platforms/flutter/configuration/releases.mdx @@ -66,7 +66,7 @@ In order to monitor release health, the SDK sends session data. -Release health in Flutter is only available for Android, iOS and macOS. +Release health in Flutter is only available for Android, iOS, and macOS. From fc2699f8d56c93599037f6e9dd39d94821d2426a Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 11 Nov 2024 16:10:12 +0100 Subject: [PATCH 09/14] Update platform-includes/configuration/auto-session-tracking/flutter.mdx Co-authored-by: Alex Krawiec --- .../configuration/auto-session-tracking/flutter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/configuration/auto-session-tracking/flutter.mdx b/platform-includes/configuration/auto-session-tracking/flutter.mdx index 57119a36b34910..f825e2bc160489 100644 --- a/platform-includes/configuration/auto-session-tracking/flutter.mdx +++ b/platform-includes/configuration/auto-session-tracking/flutter.mdx @@ -2,7 +2,7 @@ To benefit from the health data, you must use at least version 4.0.0 of the Flut #### Session Timeout -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. +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. ```dart SentryFlutter.init((options) { From 5d5a64cd63a4027e517b7c0576505cbcec3bc990 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 11 Nov 2024 16:10:20 +0100 Subject: [PATCH 10/14] Update platform-includes/enriching-events/attach-screenshots/flutter.mdx Co-authored-by: Alex Krawiec --- .../enriching-events/attach-screenshots/flutter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 5133088f2db4b2..fba16640e67d84 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -17,7 +17,7 @@ await SentryFlutter.init( ## Filtering Screenshots -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. +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. If the callback returns `false`, the screenshot will not be attached. From 4dd9ec20cffe65702b829dcba2033a86eed52194 Mon Sep 17 00:00:00 2001 From: Giancarlo Buenaflor Date: Mon, 11 Nov 2024 16:10:31 +0100 Subject: [PATCH 11/14] Update platform-includes/configuration/auto-session-tracking/flutter.mdx Co-authored-by: Alex Krawiec --- .../configuration/auto-session-tracking/flutter.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform-includes/configuration/auto-session-tracking/flutter.mdx b/platform-includes/configuration/auto-session-tracking/flutter.mdx index f825e2bc160489..ca8c89b5478221 100644 --- a/platform-includes/configuration/auto-session-tracking/flutter.mdx +++ b/platform-includes/configuration/auto-session-tracking/flutter.mdx @@ -13,7 +13,7 @@ SentryFlutter.init((options) { #### Disable Auto Session Tracking -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. +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. ```dart SentryFlutter.init((options) { From 7d0ebfe50fff354ea8d3915476000877af3719ff Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Mon, 11 Nov 2024 16:28:48 +0100 Subject: [PATCH 12/14] update code snippets --- .../auto-session-tracking/flutter.mdx | 6 ++--- .../attach-screenshots/flutter.mdx | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/platform-includes/configuration/auto-session-tracking/flutter.mdx b/platform-includes/configuration/auto-session-tracking/flutter.mdx index ca8c89b5478221..040243fbe23f11 100644 --- a/platform-includes/configuration/auto-session-tracking/flutter.mdx +++ b/platform-includes/configuration/auto-session-tracking/flutter.mdx @@ -4,9 +4,8 @@ To benefit from the health data, you must use at least version 4.0.0 of the Flut 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. -```dart +```dart {2} SentryFlutter.init((options) { - // Change timeout duration until session is terminated in background options.autoSessionTrackingInterval = const Duration(seconds: 60) }); ``` @@ -15,9 +14,8 @@ SentryFlutter.init((options) { 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. -```dart +```dart {2} SentryFlutter.init((options) { - // Disable auto session tracking options.enableAutoSessionTracking = false; }); ``` diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index fba16640e67d84..c17ce7d836ddf7 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -1,13 +1,11 @@ Enable screenshots by setting the `attachScreenshot` option to `true` and wrap your root widget with `SentryWidget`. -```dart +```dart {3, 6-8} 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(), ), @@ -21,14 +19,22 @@ You can filter your screenshots by using the `beforeScreenshot` callback, which If the callback returns `false`, the screenshot will not be attached. -```dart -await SentryFlutter.init((options) { - options.beforeScreenshot = (event, {hint}) { - // Example: based on some condition you can decide to attach the screenshot or drop it +```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; - }; -}); + return false; + }; + }, + appRunner: () => runApp( + SentryWidget( + child: MyApp(), + ), + ), +); ``` From 14aacaa9a31e87ebd804f23660b52500b54aac8a Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Mon, 11 Nov 2024 16:30:48 +0100 Subject: [PATCH 13/14] update code snippets --- docs/platforms/dart/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/dart/index.mdx b/docs/platforms/dart/index.mdx index ce68a6968e154e..cf6509d20dff5b 100644 --- a/docs/platforms/dart/index.mdx +++ b/docs/platforms/dart/index.mdx @@ -68,7 +68,7 @@ Verify that your app is sending events to Sentry by adding the following snippet import 'package:sentry/sentry.dart'; try { - aMethodThatMightFail(); + throw Exception('Sentry Test Error'); } catch (exception, stackTrace) { await Sentry.captureException( exception, From a56109d0b8495da620e891f35eb50106ea45279a Mon Sep 17 00:00:00 2001 From: GIancarlo Buenaflor Date: Mon, 11 Nov 2024 16:43:44 +0100 Subject: [PATCH 14/14] update code snippets --- .../integrations/routing-instrumentation.mdx | 46 ++++--------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/docs/platforms/flutter/integrations/routing-instrumentation.mdx b/docs/platforms/flutter/integrations/routing-instrumentation.mdx index c8509722d9c912..8b47a07166ac60 100644 --- a/docs/platforms/flutter/integrations/routing-instrumentation.mdx +++ b/docs/platforms/flutter/integrations/routing-instrumentation.mdx @@ -30,7 +30,7 @@ Before starting, ensure: Add an instance of `SentryNavigationObserver` to your application's `navigatorObservers`. -```dart {tabTitle: Flutter Routing} +```dart {8} {tabTitle: Flutter Routing} import 'package:flutter/material.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; @@ -43,7 +43,7 @@ return MaterialApp( ); ``` -```dart {tabTitle: GoRouter} +```dart {6} {tabTitle: GoRouter} import 'package:go_router/go_router.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; @@ -62,10 +62,7 @@ For transactions to be created when navigation changes, you need to provide rout - Flutter routing: use `RouteSettings` and set the name in the constructor. - GoRouter: use the `name` parameter to set the route name. -```dart {tabTitle: Flutter Routing} -import 'package:flutter/material.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; - +```dart {4} {tabTitle: Flutter Routing} /// Setting the route name is required MaterialPageRoute( builder: (BuildContext context) => MyWidget(), @@ -73,10 +70,7 @@ MaterialPageRoute( ) ``` -```dart {tabTitle: GoRouter} -import 'package:go_router/go_router.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; - +```dart {13} {tabTitle: GoRouter} final GoRouter _router = GoRouter( observers: [SentryNavigatorObserver()], routes: [ @@ -110,8 +104,6 @@ There are two ways to set up TTID: The default setup is enabled automatically, but only provides an approximation of TTID. To set a more accurate TTID, manually wrap the desired widget with `SentryDisplayWidget`, as shown below: ```dart -import 'package:sentry_flutter/sentry_flutter.dart'; - SentryDisplayWidget( child: MyWidget(), ) @@ -129,23 +121,17 @@ TTFD is disabled by default. To enable TTFD measurements, follow these steps: 1. Enable the `enableTimeToFullDisplayTracing` option in the SDK configuration: -```dart -import 'package:flutter/widgets.dart'; -import 'package:sentry_flutter/sentry_flutter.dart'; - -Future main() async { - await SentryFlutter.init( - (options) => options.enableTimeToFullDisplayTracing = true, - appRunner: () => runApp(MyApp()), - ); -} +```dart {3} +await SentryFlutter.init( + (options) { + options.enableTimeToFullDisplayTracing = true; + }, appRunner: () => runApp(MyApp()), +); ``` 2. Report the span manually: ```dart -import 'package:sentry_flutter/sentry_flutter.dart'; - SentryFlutter.reportFullyDisplayed(); ``` @@ -231,9 +217,6 @@ Log into [sentry.io](https://sentry.io) and open your project's performance page Adjust the duration before a routing transaction automatically finishes. The default is 3 seconds. ```dart -import 'package:sentry_flutter/sentry_flutter.dart'; - -/// Change how long navigation transactions idle before being finished SentryNavigatorObserver( autoFinishAfter: Duration(seconds: 5) ) @@ -251,9 +234,6 @@ Set `enableAutoTransactions` to `false` if you only want to track navigation bre Enabled by default. ```dart -import 'package:sentry_flutter/sentry_flutter.dart'; - -/// Only track navigation breadcrumbs SentryNavigatorObserver( enableAutoTransactions: false, ) @@ -265,9 +245,6 @@ Set `ignoreRoutes` if you want routes to be ignored and not processed by the nav Empty by default. ```dart -import 'package:sentry_flutter/sentry_flutter.dart'; - -/// Ignore matching routes SentryNavigatorObserver( ignoreRoutes: ["/ignoreThisRoute", "/my/ignored/route"], ) @@ -280,9 +257,6 @@ An existing transaction in the scope 'CustomTransaction' will be renamed to 'MyW Disabled by default. ```dart -import 'package:sentry_flutter/sentry_flutter.dart'; - -/// Override transaction name with route name SentryNavigatorObserver( setRouteNameAsTransaction: true, )