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
Screenshot masking allows you to mask sensitive data in screenshots before they are captured. You can customize this behavior to fit your application's needs.
22
+
23
+
<Alert>
24
+
25
+
Screenshot masking requires the `sentry-android-replay` module at runtime. This module is included by default if you use the `sentry-android` dependency. If you only depend on `sentry-android-core`, add the replay module explicitly:
If masking options are configured but the module is not available at runtime, the SDK will skip capturing screenshots entirely to avoid leaking sensitive data.
40
+
41
+
</Alert>
42
+
43
+
### Default Masking Behavior
44
+
45
+
Unlike Session Replay, screenshot masking is **disabled by default**. You can enable masking for all text and image content:
When `setMaskAllImages(true)` is set, the SDK will also mask `WebView`, `VideoView`, CameraX `PreviewView`, ExoPlayer, and Media3 player views in addition to `ImageView`.
75
+
76
+
</Alert>
77
+
78
+
### Mask by View Class
79
+
80
+
You can choose which type of view to mask or unmask by using `addMaskViewClass` or `addUnmaskViewClass`. These accept fully-qualified class names and apply to all subclasses of the specified class as well.
Alternatively, you can use the `android:tag` attribute with the `sentry-mask` or `sentry-unmask` string values:
130
+
131
+
```xml
132
+
<TextView
133
+
android:layout_width="wrap_content"
134
+
android:layout_height="wrap_content"
135
+
android:tag="sentry-mask"
136
+
android:text="Sensitive data" />
137
+
```
138
+
139
+
In Java, you can use view tags with the `sentry_privacy` resource ID:
140
+
141
+
```java
142
+
importio.sentry.android.replay.R;
143
+
144
+
view.setTag(R.id.sentry_privacy, "mask");
145
+
view.setTag(R.id.sentry_privacy, "unmask");
146
+
```
147
+
148
+
### Jetpack Compose
149
+
150
+
For Jetpack Compose, use the `sentryReplayMask()` and `sentryReplayUnmask()` modifiers:
151
+
152
+
```kotlin
153
+
importio.sentry.android.replay.sentryReplayMask
154
+
importio.sentry.android.replay.sentryReplayUnmask
155
+
156
+
@Composable
157
+
funMyScreen() {
158
+
Column {
159
+
Text(
160
+
text ="Sensitive info",
161
+
modifier =Modifier.sentryReplayMask()
162
+
)
163
+
Text(
164
+
text ="Public info",
165
+
modifier =Modifier.sentryReplayUnmask()
166
+
)
167
+
}
168
+
}
169
+
```
170
+
171
+
### General Masking Rules
172
+
173
+
#### View Groups
174
+
175
+
- If a `ViewGroup` is marked as masked, **all its child views will also be masked**, even if some children would normally not be masked. This prioritizes safety and ensures no sensitive information is unintentionally exposed.
176
+
177
+
- If a `ViewGroup` is marked as unmasked, **its child views don't automatically inherit this behavior**. You'll need to explicitly mark each child view as unmasked if you want them to appear unmasked.
178
+
179
+
#### Masking Priority
180
+
181
+
Masking and unmasking rules are applied in the following order:
182
+
183
+
1. Check if a view is marked as `unmasked` via a tag/extension or modifier.
184
+
2. Check if a view is marked as `masked` via a tag/extension or modifier.
185
+
3. Check if a view's class is marked as unmasked via `addUnmaskViewClass`.
186
+
4. Check if a view's class is marked as masked via `addMaskViewClass`.
187
+
19
188
## Viewing Screenshots
20
189
21
190
If one is available, you'll see a thumbnail of the screenshot when you click on a specific issue from the [**Issues**](https://demo.sentry.io/issues/) page.
Copy file name to clipboardExpand all lines: platform-includes/enriching-events/attach-screenshots/android.mdx
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,12 @@
4
4
</application>
5
5
```
6
6
7
+
<Alertlevel="warning">
8
+
9
+
Before enabling screenshots in production, verify your masking configuration to ensure no sensitive data is captured. If you find any masking issues or sensitive data that should be masked but isn't, please [create a GitHub issue](https://github.com/getsentry/sentry-java/issues/new/choose) and avoid deploying to production with screenshots enabled until the issue is resolved.
0 commit comments