You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/apple/guides/ios/session-replay/customredact.mdx
+41-3Lines changed: 41 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,6 @@ If you choose to use custom masking in your Session Replays, you may accidentall
14
14
15
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
16
17
-
18
17
## Mask by View Class
19
18
20
19
You can choose which type of view you want to mask or unmask by using the `maskedViewClasses` or `unmaskedViewClasses` options.
@@ -34,6 +33,7 @@ You can also choose to mask or unmask a specific view instance by using the repl
34
33
SentrySDK.replay.maskView(view: view)
35
34
SentrySDK.replay.unmaskView(view: label)
36
35
```
36
+
37
37
or
38
38
39
39
```swift
@@ -44,9 +44,10 @@ or
44
44
## SwiftUI
45
45
46
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.
47
+
In order to control the SwiftUI masking process, you need to use the `sentryReplayUnmask` and/or `sentryReplayMask` modifiers.
48
48
49
49
In this example we want to show the message, but not the user name.
50
+
50
51
```swift
51
52
@Bindingvar user: String
52
53
@@ -72,6 +73,43 @@ To hide the username, we need to mask it.
72
73
.sentryReplayMask()
73
74
}
74
75
.background(.blue)
75
-
.sentryReplayUnmask()
76
+
.sentryReplayUnmask()
77
+
}
78
+
```
79
+
80
+
## Debugging Session Replay masking
81
+
82
+
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.
83
+
84
+
```swift
85
+
SentrySDK.replay.showMaskPreview()
86
+
```
87
+
88
+
By default, the overlay will be opaque. To configure the opacity, pass the desired opacity as a parameter:
89
+
90
+
```swift
91
+
SentrySDK.replay.showMaskPreview(0.5) // 0.5 opacity to render the preview semi-transparent
92
+
```
93
+
94
+
Make sure not accidentally include this in your release build by e.g. wrapping it in a `#if DEBUG` block.
95
+
96
+
```swift
97
+
#if DEBUG
98
+
SentrySDK.replay.showMaskPreview()
99
+
#endif
100
+
```
101
+
102
+
To preview masking during the design phase of your SwiftUI views, use the `sentryReplayPreviewMask` modifier.
103
+
104
+
This view modifier works on the simulator and on device, as well as within Xcode Preview. Therefore we recommend to apply the modifier only in your preview code, to ensure proper masking without affecting the final release build.
105
+
106
+
Note that when you apply this modifier to a view, it will show the masking preview for the entire window containing that view, not just the view itself.
0 commit comments