diff --git a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx index a16296f3d0f1a..ba601c80a9b08 100644 --- a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx +++ b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx @@ -21,6 +21,31 @@ View hierarchy debugging is an opt-in feature. You can enable it as shown below: +### Customize View Hierarchy Capturing + + + +Requires SDK version `8.13.0` or higher. + + + +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 `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-9} +await SentryFlutter.init((options) { + 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. diff --git a/platform-includes/enriching-events/attach-screenshots/flutter.mdx b/platform-includes/enriching-events/attach-screenshots/flutter.mdx index 33d9c37ccd1b0..70bb59631aba6 100644 --- a/platform-includes/enriching-events/attach-screenshots/flutter.mdx +++ b/platform-includes/enriching-events/attach-screenshots/flutter.mdx @@ -13,6 +13,31 @@ await SentryFlutter.init( ); ``` +### Customize Screenshot Capturing + + + +Requires SDK version `8.11.0` or higher. + + + +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: + +```flutter {2-9} +await SentryFlutter.init((options) { + 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 +51,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.