Skip to content

Commit

Permalink
feat(apple): beforeCaptureScreenshot callback (#10913)
Browse files Browse the repository at this point in the history
Adds docs for the beforeCaptureScreenshot callback for the Cocoa SDK;
see getsentry/sentry-cocoa#4210.
We have to wait until we release Cocoa 8.33.0 to merge this.
  • Loading branch information
philipphofmann authored Aug 8, 2024
1 parent 20f3e45 commit b577082
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions platform-includes/enriching-events/attach-viewhierarchy/apple.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,38 @@ SentrySDK.start { options in
options.attachViewHierarchy = YES;
}];
```
### Customize View Hierarchy Capturing
<Note>
Requires Cocoa SDK version `8.33.0` or higher.
</Note>
The `beforeCaptureViewHierarchy` also allows you to customize the behavior based on event data, so you can decide when to capture a view hierarchy and when not to. The callback doesn't work for crash events.
```swift {tabTitle:Swift}
import Sentry
SentrySDK.start { options in
options.dsn = "___PUBLIC_DSN___"
options.beforeCaptureViewHierarchy = { event in
// Return false to not capture a view hierarchy for the event.
return false
}
}
```

```objc {tabTitle:Objective-C}
@import Sentry;

[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
options.dsn = @"___PUBLIC_DSN___";
options.beforeCaptureViewHierarchy = ^BOOL(SentryEvent * _Nonnull event) {
// Return NO to not capture a view hierarchy for the event.
return NO;
};
}];
```

0 comments on commit b577082

Please sign in to comment.