Skip to content
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

docs(flutter): Document beforeCapture function customization #12190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

denrase
Copy link
Collaborator

@denrase denrase commented Dec 19, 2024

DESCRIBE YOUR PR

Adds docs for using the before capture callbacks for screenshots and view hierarchy.

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

  • Urgent deadline (GA date, etc.):
  • Other deadline:
  • None: Not urgent, can wait up to 1 week+

EXTRA RESOURCES

Copy link

vercel bot commented Dec 19, 2024

@denrase is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

@denrase denrase requested a review from buenaflor December 19, 2024 14:29
Copy link

vercel bot commented Dec 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Dec 19, 2024 7:32pm


<Note>

Requires SDK version `8.12.0` or higher.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we released 8.12.0 already

Suggested change
Requires SDK version `8.12.0` or higher.
Requires SDK version `8.13.0` or higher.

Comment on lines +41 to +43
if (debounce) {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc that means that users can also skip debouncing if they return true anyway, right?


</Note>

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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`.


</Note>

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`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```java
```dart

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also please add line highlighting


```java
await SentryFlutter.init((options) {
options.attachScreenshot = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options.attachScreenshot = true;

I guess we can remove this as we can assume screenshots are already in place


```java
await SentryFlutter.init((options) {
options.attachViewHierarchy = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options.attachViewHierarchy = true;


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```java
```dart

pls add line highlighting


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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants