Skip to content

Commit 6bbddbe

Browse files
feat(apple): Add docs for beforeCaptureScreenshot (#10152)
Adds docs for the beforeCaptureScreenshot callback for the Cocoa SDK.
1 parent 2124f68 commit 6bbddbe

File tree

1 file changed

+35
-0
lines changed
  • platform-includes/enriching-events/attach-screenshots

1 file changed

+35
-0
lines changed

platform-includes/enriching-events/attach-screenshots/apple.mdx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,38 @@ SentrySDK.start { options in
1313
options.attachScreenshot = YES;
1414
}];
1515
```
16+
17+
### Customize Screenshot Capturing
18+
19+
<Note>
20+
21+
Requires Cocoa SDK version `8.27.0` or higher.
22+
23+
</Note>
24+
25+
26+
The `beforeCaptureScreenshot` also allows you to customize the behavior based on event data, so you can decide when to capture a screenshot and when not to. The callback doesn't work for crash events.
27+
28+
```swift {tabTitle:Swift}
29+
import Sentry
30+
31+
SentrySDK.start { options in
32+
options.dsn = "___PUBLIC_DSN___"
33+
options.beforeCaptureScreenshot = { event in
34+
// Return false to not capture a screenshot for the event.
35+
return false
36+
}
37+
}
38+
```
39+
40+
```objc {tabTitle:Objective-C}
41+
@import Sentry;
42+
43+
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) {
44+
options.dsn = @"___PUBLIC_DSN___";
45+
options.beforeCaptureScreenshot = ^BOOL(SentryEvent * _Nonnull event) {
46+
// Return NO to not capture a screenshot for the event.
47+
return NO;
48+
};
49+
}];
50+
```

0 commit comments

Comments
 (0)