Skip to content

Commit a03716d

Browse files
authored
feat(apple): Replay Redact (#11418)
Adding instructions on how to use custom redact APIs for Apple SDK
1 parent 32edc7e commit a03716d

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
title: Using Custom Masking for Session Replay
3+
sidebar_order: 5501
4+
notSupported:
5+
description: "Learn how to mask parts of your app's data in Session Replay."
6+
---
7+
8+
<Alert>
9+
Before publising an App with Session Replay enabled, make sure to test it thoroughly to ensure that no sensitive data is exposed.
10+
11+
If you choose to use custom masking in your Session Replays, you may accidentally expose sensitive customer data. Be sure to double-check what you choose to expose.
12+
13+
</Alert>
14+
15+
By default, our Session Replay SDK masks all text content, images, and user input. This helps ensure that no sensitive data will be exposed. You can also manually choose which parts of your app's data you want to mask by using the different options listed below.
16+
17+
18+
## Mask by View Class
19+
20+
You can choose which type of view you want to mask or unmask by using the `maskedViewClasses` or `unmaskedViewClasses` options.
21+
22+
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:
23+
24+
```swift
25+
options.experimental.sessionReplay.maskedViewClasses = [MyCustomView.self]
26+
options.experimental.sessionReplay.unmaskedViewClasses = [MyCustomLabel.self]
27+
```
28+
29+
## Mask by View Instance
30+
31+
You can also choose to mask or unmask a specific view instance by using the replay API (`SentrySDK.replay`) or view extensions like this:
32+
33+
```swift
34+
SentrySDK.replay.maskView(view: view)
35+
SentrySDK.replay.unmaskView(view: label)
36+
```
37+
or
38+
39+
```swift
40+
view.sentryReplayMask()
41+
label.sentryReplayUnmask()
42+
```
43+
44+
## SwiftUI
45+
46+
Because of the way SwiftUI is transformed into UIKit, it will often be over-masked. A modifier like `background` uses the same element as an `Image`.
47+
In order to control the SwiftUI masking process, you need to use the `sentryReplayUnmask` and/or `sentryReplayMask` modifiers.
48+
49+
In this example we want to show the message, but not the user name.
50+
```swift
51+
@Binding var user: String
52+
53+
var body: some View {
54+
VStack {
55+
Text("Hello")
56+
.sentryReplayUnmask()
57+
Text("\(user)")
58+
}
59+
}
60+
```
61+
62+
In this example, we need to unmask the VStack because its background element will be masked by default.
63+
To hide the username, we need to mask it.
64+
65+
```swift
66+
@Binding var user: String
67+
68+
var body: some View {
69+
VStack {
70+
Text("Hello")
71+
Text("\(user)")
72+
.sentrtReplayMask()
73+
}
74+
.background(.blue)
75+
.sentryReplayUnmask()
76+
}
77+
```

docs/platforms/apple/guides/ios/session-replay/index.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ Sampling begins as soon as a session starts. `sessionSampleRate` is evaluated fi
7373

7474
## Privacy
7575

76-
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.
76+
The SDK aggressively records the app and masks all text and images.
77+
Please don't turn it off if you have sensitive data in your app.
78+
If you want to manually mask parts of your app's data, read our guide on [custom masking](/platforms/apple/guides/ios/session-replay/customredact).
7779

7880
<Note>
7981

0 commit comments

Comments
 (0)