sentry-cocoa
sentry-cocoa copied to clipboard
Add `setBeforeViewHierarchyCaptureCallback` to Cocoa SDK
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
Yes, that makes sense. Thanks for opening the issue, @narlei. This is related to https://github.com/getsentry/sentry-cocoa/issues/3007.