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

Add setBeforeViewHierarchyCaptureCallback to Cocoa SDK #4004

Closed
narlei opened this issue May 22, 2024 · 1 comment · Fixed by #4210
Closed

Add setBeforeViewHierarchyCaptureCallback to Cocoa SDK #4004

narlei opened this issue May 22, 2024 · 1 comment · Fixed by #4210

Comments

@narlei
Copy link

narlei commented May 22, 2024

Problem Statement

If we enable the attachViewHierarchy option, we're sending too much attachments, including events that I don't want to get ViewHierarchy, like HTTP request erros.

Solution Brainstorm

The Android SDK contains an interceptor:
https://docs.sentry.io/platforms/android/enriching-events/viewhierarchy/#customize-view-hierarchy-capturing

SentryAndroid.init(this, options -> {
    options.setBeforeViewHierarchyCaptureCallback((event, hint, debounce) -> {
        // always capture crashed events
        if (event.isCrashed()) {
            return true;
        }

        // if debounce is active, skip capturing
        if (debounce) {
            return false;
        } else {
            // also capture fatal events
            return event.getLevel() == SentryLevel.FATAL;
        }
    });
});

It allows to customize the ViewHierarchy and send when we want. Another option is allowing to get the event attachments on beforeSend.

Are you willing to submit a PR?

No response

@philipphofmann
Copy link
Member

Yes, that makes sense. Thanks for opening the issue, @narlei. This is related to #3007.

@philipphofmann philipphofmann moved this from Needs Discussion to Todo in Mobile & Cross Platform SDK Jun 5, 2024
@philipphofmann philipphofmann self-assigned this Jul 30, 2024
@philipphofmann philipphofmann moved this from Todo to In Progress in Mobile & Cross Platform SDK Jul 30, 2024
philipphofmann added a commit that referenced this issue Jul 30, 2024
Add a callback to the options to decide if the SDK should capture a view
hierarchy or not.

Fixes GH-4004
@philipphofmann philipphofmann moved this from In Progress to Needs Review in Mobile & Cross Platform SDK Jul 30, 2024
@github-project-automation github-project-automation bot moved this from Needs Review to Done in Mobile & Cross Platform SDK Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants