From 7f316159ea802aa16157080a695d47ce99635f3e Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Thu, 19 Dec 2024 15:22:13 +0100 Subject: [PATCH 1/4] document debounce ob beforeCaptureScreenshot --- .../attach-screenshots/flutter.mdx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 33d9c37ccd1b08..5206bd629fc010 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -13,6 +13,32 @@ await SentryFlutter.init( ); ``` +### Customize Screenshot Capturing + + + +Requires SDK version `8.11.0` or higher. + + + +Because capturing screenshots can be a resource-intensive operation on Flutter, it's limited to one screenshot every 2 seconds using a debouncing mechanism. This behavior can be overruled if you supply a `BeforeCaptureCallback` for screenshots in the `SentryFlutterOptions`. + +The `BeforeCaptureCallback` also allows you to customize the behavior based on event data, so you can decide when to capture a screenshot and when not to. For example, you can decide to only capture screenshots of fatal events: + +```java +await SentryFlutter.init((options) { + options.attachScreenshot = true; + options.beforeCaptureScreenshot = (event, hint, debounce) async { + // If debounce is active, skip capturing + if (debounce) { + return false; + } + // Capture if it's a fatal event + return event.level == SentryLevel.fatal; + }; +}); +``` + ## Redact Screenshots via `masking` The masking feature is by default disabled for Screenshots. To enable masking, use the `options.experimental.privacy` parameter. @@ -26,7 +52,7 @@ The masking feature is by default disabled for Screenshots. To enable masking, u ## 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 `beforeCaptureScreenshot` 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 f617617d0f7d8097a288501c2df8793e43aa064c Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Thu, 19 Dec 2024 15:26:32 +0100 Subject: [PATCH 2/4] document for viewHierarchy --- .../enriching-events/viewhierarchy/index.mdx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx index a16296f3d0f1a5..bd7997e070c93b 100644 --- a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx +++ b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx @@ -21,6 +21,32 @@ View hierarchy debugging is an opt-in feature. You can enable it as shown below: +### Customize View Hierarchy Capturing + + + +Requires SDK version `8.12.0` or higher. + + + +Because capturing view hierarchy can be a resource-intensive operation on Flutter, it's limited to one view hierarchy every 2 seconds using a debouncing mechanism. This behavior can be overruled if you supply a `BeforeCaptureCallback` for view hierarchies in the `SentryFlutterOptions`. + +The `BeforeCaptureCallback` also allows you to customize behavior based on event data so you can decide when to capture view hierarchy and when not to. For example, you can decide to only capture view hierarchy for fatal events: + +```java +await SentryFlutter.init((options) { + options.attachViewHierarchy = true; + options.beforeCaptureViewHierarchy = (event, hint, debounce) async { + // If debounce is active, skip capturing + if (debounce) { + return false; + } + // Capture if it's a fatal event + return event.level == SentryLevel.fatal; + }; +}); +``` + ## Viewing View Hierarchy Attachments View hierarchies appear in the "Attachments" tab, where you can view all attachments, as well as associated events. Click the event ID to open the [Issue Details](/product/issues/issue-details) page of that specific event. From 940b7ddb35df31398cd2cffea26f86fdf719dfa7 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 7 Jan 2025 11:14:44 +0100 Subject: [PATCH 3/4] incorp feedback --- .../flutter/enriching-events/viewhierarchy/index.mdx | 8 ++++---- .../enriching-events/attach-screenshots/flutter.mdx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx index bd7997e070c93b..bcd982c4fac720 100644 --- a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx +++ b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx @@ -25,15 +25,15 @@ View hierarchy debugging is an opt-in feature. You can enable it as shown below: -Requires SDK version `8.12.0` or higher. +Requires SDK version `8.13.0` or higher. -Because capturing view hierarchy can be a resource-intensive operation on Flutter, it's limited to one view hierarchy every 2 seconds using a debouncing mechanism. This behavior can be overruled if you supply a `BeforeCaptureCallback` for view hierarchies in the `SentryFlutterOptions`. +Capturing view hierarchies on Flutter is limited to once every 2 seconds by default to minimize performance impact. While this debounce interval is fixed, you can override individual capture decisions by implementing the `beforeCaptureViewHierarchy` option in your `SentryFlutterOptions`. -The `BeforeCaptureCallback` also allows you to customize behavior based on event data so you can decide when to capture view hierarchy and when not to. For example, you can decide to only capture view hierarchy for fatal events: +The `beforeCaptureViewHierarchy` option allows you to customize behavior based on event data so you can decide when to capture view hierarchy and when not to. For example, you can decide to only capture view hierarchy for fatal events: -```java +```flutter {2-10} await SentryFlutter.init((options) { options.attachViewHierarchy = true; options.beforeCaptureViewHierarchy = (event, hint, debounce) async { diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 5206bd629fc010..4bd58ae8a14b6a 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -21,11 +21,11 @@ Requires SDK version `8.11.0` or higher. -Because capturing screenshots can be a resource-intensive operation on Flutter, it's limited to one screenshot every 2 seconds using a debouncing mechanism. This behavior can be overruled if you supply a `BeforeCaptureCallback` for screenshots in the `SentryFlutterOptions`. +Capturing screenshots on Flutter is limited to once every 2 seconds by default to minimize performance impact. While this debounce interval is fixed, you can override individual capture decisions by implementing the `beforeCaptureScreenshot` option in your `SentryFlutterOptions`. The `BeforeCaptureCallback` also allows you to customize the behavior based on event data, so you can decide when to capture a screenshot and when not to. For example, you can decide to only capture screenshots of fatal events: -```java +```flutter {2-10} await SentryFlutter.init((options) { options.attachScreenshot = true; options.beforeCaptureScreenshot = (event, hint, debounce) async { From d5ad4ecccf66176840c6d0cb512ab1992ddd8676 Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Tue, 7 Jan 2025 17:23:56 +0100 Subject: [PATCH 4/4] remove options.attachScreenshot and options.attachViewHierarchy in snippet --- .../platforms/flutter/enriching-events/viewhierarchy/index.mdx | 3 +-- .../enriching-events/attach-screenshots/flutter.mdx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx index bcd982c4fac720..ba601c80a9b085 100644 --- a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx +++ b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx @@ -33,9 +33,8 @@ Capturing view hierarchies on Flutter is limited to once every 2 seconds by defa The `beforeCaptureViewHierarchy` option allows you to customize behavior based on event data so you can decide when to capture view hierarchy and when not to. For example, you can decide to only capture view hierarchy for fatal events: -```flutter {2-10} +```flutter {2-9} await SentryFlutter.init((options) { - options.attachViewHierarchy = true; options.beforeCaptureViewHierarchy = (event, hint, debounce) async { // If debounce is active, skip capturing if (debounce) { diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 4bd58ae8a14b6a..70bb59631aba6e 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -25,9 +25,8 @@ Capturing screenshots on Flutter is limited to once every 2 seconds by default t The `BeforeCaptureCallback` also allows you to customize the behavior based on event data, so you can decide when to capture a screenshot and when not to. For example, you can decide to only capture screenshots of fatal events: -```flutter {2-10} +```flutter {2-9} await SentryFlutter.init((options) { - options.attachScreenshot = true; options.beforeCaptureScreenshot = (event, hint, debounce) async { // If debounce is active, skip capturing if (debounce) {