Skip to content
66 changes: 66 additions & 0 deletions docs/platforms/apple/guides/ios/session-replay/customredact.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Using custom redact for Session Replay
sidebar_order: 5501
notSupported:
description: "Learn how to choose which part of your app's data to redact in Session Replay."
---

<Note>

Using custom redaction for Session Replay can expose sensitive data. Make sure to double-check every part of your app's data that you choose to redact or not.

</Note>

By default, our Session Replay SDK masks all text content, images, and user input, giving you heightened confidence that no sensitive data will leave the device. However, you can choose which parts of your app's data to redact or not by using some different options.


## Redact by View class

You can choose which type of view you want to redact or ignore by using the `redactViewClasses` or `ignoreViewClasses` options.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

h: After reading this and the whole document, I'm still unsure of the difference between redact and ignore. Can we add a short explanation, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document was updated. Please take another look


Let's say you have a custom view that you want to redact and a UILabel subclass (which normally would be redacted) that you want to ignore. You can set the options like this:

```swift
options.experimental.sessionReplay.redactViewClasses = [MyCustomView.self]
options.experimental.sessionReplay.ignoreViewClasses = [MyCustomLabel.self]
```

## Redact View by instance

You can also choose to redact or ignore a specific view instance by using the replay API or view extensions like this:

```swift
SentrySDK.replay.redactView(view: view)
SentrySDK.replay.ignoreView(view: label)
```
or

```swift
view.sentryReplayRedact()
label.sentryReplayIgnore()
```

## SwiftUI

Because of the way SwiftUI is transformed into UIKit, it will be often over-redacted. Modifier like `background` use the same element as an `Image`.
In order to be able to control SwiftUI redact process, first you need to disable the default redaction options:

```swift
options.experimental.sessionReplay.redactAllText = false
options.experimental.sessionReplay.redactAllImages = false
```

Then you can manually choose which `View` you want to redact with the `replayRedact` modifier

```swift
var body: some View {
Text("Hello, World!")
.sentryReplayRedact()
}
```

<Note>
Dissabling the default redaction options will expose all text and images in the session replay.
Make sure to redact them manually.
</Note>

4 changes: 3 additions & 1 deletion docs/platforms/apple/guides/ios/session-replay/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ Sampling begins as soon as a session starts. `sessionSampleRate` is evaluated fi

## Privacy

The SDK is recording and aggressively redacting all text and images. We plan to add fine controls for redacting, but in this version, we just allow either on or off. The default is on. Please don’t turn it off if you have sensitive data in your app. Before the Beta is complete, we'll give you the controls you need.
The SDK is recording and aggressively redacting all text and images.
Please don't turn it off if you have sensitive data in your app.
If you want to manually choose which part of your app's data to redact, read our guide on [custom redaction](/platforms/apple/guides/ios/session-replay/customredact).

<Note>

Expand Down