Skip to content

Fix iOS SR Custom Redact whitespace prefix in code snippets #13806

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 26 additions & 26 deletions docs/platforms/apple/guides/ios/session-replay/customredact.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ You can choose which type of view you want to mask or unmask by using the `maske
Let's say you have a custom view that you want to mask and a `UILabel` subclass (which normally would be masked) that you don't want to mask. You can set the options like this:

```swift
options.sessionReplay.maskedViewClasses = [MyCustomView.self]
options.sessionReplay.unmaskedViewClasses = [MyCustomLabel.self]
options.sessionReplay.maskedViewClasses = [MyCustomView.self]
options.sessionReplay.unmaskedViewClasses = [MyCustomLabel.self]
```

## Mask by View Instance

You can also choose to mask or unmask a specific view instance by using the replay API (`SentrySDK.replay`) or view extensions like this:

```swift
SentrySDK.replay.maskView(view: view)
SentrySDK.replay.unmaskView(view: label)
SentrySDK.replay.maskView(view: view)
SentrySDK.replay.unmaskView(view: label)
```

or

```swift
view.sentryReplayMask()
label.sentryReplayUnmask()
view.sentryReplayMask()
label.sentryReplayUnmask()
```

## SwiftUI
Expand All @@ -49,46 +49,46 @@ In order to control the SwiftUI masking process, you need to use the `sentryRepl
In this example we want to show the message, but not the user name.

```swift
@Binding var user: String

var body: some View {
VStack {
Text("Hello")
.sentryReplayUnmask()
Text("\(user)")
}
@Binding var user: String

var body: some View {
VStack {
Text("Hello")
.sentryReplayUnmask()
Text("\(user)")
}
}
```

In this example, we need to unmask the VStack because its background element will be masked by default.
To hide the username, we need to mask it.

```swift
@Binding var user: String

var body: some View {
VStack {
Text("Hello")
Text("\(user)")
.sentryReplayMask()
}
.background(.blue)
.sentryReplayUnmask()
@Binding var user: String

var body: some View {
VStack {
Text("Hello")
Text("\(user)")
.sentryReplayMask()
}
.background(.blue)
.sentryReplayUnmask()
}
```

## Debugging Session Replay masking

To see how elements are being masked, enable the masking preview from anywhere in your app. It will display an overlay on top of the masked elements. This works on the simulator and on device, as well as within Xcode Preview.

```swift
SentrySDK.replay.showMaskPreview()
SentrySDK.replay.showMaskPreview()
```

By default, the overlay will be opaque. To configure the opacity, pass the desired opacity as a parameter:

```swift
SentrySDK.replay.showMaskPreview(0.5) // 0.5 opacity to render the preview semi-transparent
SentrySDK.replay.showMaskPreview(0.5) // 0.5 opacity to render the preview semi-transparent
```

Make sure not accidentally include this in your release build by e.g. wrapping it in a `#if DEBUG` block.
Expand Down