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
+26-26Lines changed: 26 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -21,24 +21,24 @@ You can choose which type of view you want to mask or unmask by using the `maske
21
21
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:
You can also choose to mask or unmask a specific view instance by using the replay API (`SentrySDK.replay`) or view extensions like this:
31
31
32
32
```swift
33
-
SentrySDK.replay.maskView(view: view)
34
-
SentrySDK.replay.unmaskView(view: label)
33
+
SentrySDK.replay.maskView(view: view)
34
+
SentrySDK.replay.unmaskView(view: label)
35
35
```
36
36
37
37
or
38
38
39
39
```swift
40
-
view.sentryReplayMask()
41
-
label.sentryReplayUnmask()
40
+
view.sentryReplayMask()
41
+
label.sentryReplayUnmask()
42
42
```
43
43
44
44
## SwiftUI
@@ -49,46 +49,46 @@ In order to control the SwiftUI masking process, you need to use the `sentryRepl
49
49
In this example we want to show the message, but not the user name.
50
50
51
51
```swift
52
-
@Bindingvar user: String
53
-
54
-
var body: some View {
55
-
VStack {
56
-
Text("Hello")
57
-
.sentryReplayUnmask()
58
-
Text("\(user)")
59
-
}
52
+
@Bindingvar user: String
53
+
54
+
var body: some View {
55
+
VStack {
56
+
Text("Hello")
57
+
.sentryReplayUnmask()
58
+
Text("\(user)")
60
59
}
60
+
}
61
61
```
62
62
63
63
In this example, we need to unmask the VStack because its background element will be masked by default.
64
64
To hide the username, we need to mask it.
65
65
66
66
```swift
67
-
@Bindingvar user: String
68
-
69
-
var body: some View {
70
-
VStack {
71
-
Text("Hello")
72
-
Text("\(user)")
73
-
.sentryReplayMask()
74
-
}
75
-
.background(.blue)
76
-
.sentryReplayUnmask()
67
+
@Bindingvar user: String
68
+
69
+
var body: some View {
70
+
VStack {
71
+
Text("Hello")
72
+
Text("\(user)")
73
+
.sentryReplayMask()
77
74
}
75
+
.background(.blue)
76
+
.sentryReplayUnmask()
77
+
}
78
78
```
79
79
80
80
## Debugging Session Replay masking
81
81
82
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
83
84
84
```swift
85
-
SentrySDK.replay.showMaskPreview()
85
+
SentrySDK.replay.showMaskPreview()
86
86
```
87
87
88
88
By default, the overlay will be opaque. To configure the opacity, pass the desired opacity as a parameter:
89
89
90
90
```swift
91
-
SentrySDK.replay.showMaskPreview(0.5) // 0.5 opacity to render the preview semi-transparent
91
+
SentrySDK.replay.showMaskPreview(0.5) // 0.5 opacity to render the preview semi-transparent
92
92
```
93
93
94
94
Make sure not accidentally include this in your release build by e.g. wrapping it in a `#if DEBUG` block.
0 commit comments