From 7f316159ea802aa16157080a695d47ce99635f3e Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Thu, 19 Dec 2024 15:22:13 +0100 Subject: [PATCH 1/2] 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 33d9c37ccd1b0..5206bd629fc01 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/2] 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 a16296f3d0f1a..bd7997e070c93 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.