---
title: "Privacy"
description: "Learn how to mask parts of your app's data in Session Replay."
url: https://docs.sentry.io/platforms/android/session-replay/privacy/
---

# Privacy | Sentry for Android

The masking options below only apply when using the default `PixelCopy` strategy. If you set the strategy to [Canvas](https://docs.sentry.io/platforms/android/session-replay.md#screenshot-strategy), those options will be ignored and all sensitive content (texts, inputs, images) will be **always** masked.

Before enabling Session Replay in production, verify your masking configuration to ensure no sensitive data is captured. Our default settings aggressively mask potentially sensitive data, but if you modify these settings or update UI frameworks or system SDKs, you must thoroughly test your application. 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 Session Replay enabled until the issue is resolved.

By default, our Session Replay SDK masks all text content, images, webviews, and user input. This helps ensure that no sensitive data is exposed. You can also manually choose which parts of your app's data you want to mask by using the different options listed below.

To disable the default masking behavior (not to be used on applications with sensitive data):

```kotlin
options.sessionReplay.maskAllText = false
options.sessionReplay.maskAllImages = false
```

| Session Replay Unmasked | Session Replay Masked |
| ----------------------- | --------------------- |
|                         |                       |

*Make sure your Sentry Android SDK version is at least 7.20.0.*

## [Mask by View Class](https://docs.sentry.io/platforms/android/session-replay/privacy.md#mask-by-view-class)

You can choose which type of view you want to mask or unmask by using the `addMaskViewClass` or `addUnmaskViewClass` options.

Let's say you have:

* A custom view that you want to mask
* A `TextView` subclass (which normally would be masked) that you don't want to mask

You can set the options like this:

```kotlin
options.sessionReplay.addMaskViewClass("com.example.MyCustomView")
options.sessionReplay.addUnmaskViewClass("com.example.MyCustomTextView")
```

If you're using a code obfuscation tool (R8/ProGuard), adjust your proguard rules accordingly so your custom view class names don't get minified.

### [Class Hierarchy](https://docs.sentry.io/platforms/android/session-replay/privacy.md#class-hierarchy)

The masking behavior applies to classes and their subclasses. This means if you add a view via `addMaskViewClass` (for example, `TextView`, which is the default behavior), its respective subclasses (`RadioButton`, `CheckBox`, `EditText`, and so on) will also be masked. For example, you can do the following:

```kotlin
options.sessionReplay.addMaskViewClass("android.widget.TextView") // mask TextView and all its subclasses
options.sessionReplay.addUnmaskViewClass("android.widget.RadioButton") // but unmask RadioButton and all its subclasses
```

## [Mask by View Instance](https://docs.sentry.io/platforms/android/session-replay/privacy.md#mask-by-view-instance)

You can also choose to mask or unmask a specific view instance by using tags like this:

```xml
<View
  android:id="@+id/my_view"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:tag="sentry-mask|sentry-unmask"
/>
```

If your view already has a tag assigned, you can set the masking tag by a sentry-specific id:

```xml
<View
  android:id="@+id/my_view"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
>

  <tag android:id="@id/sentry_privacy" android:value="mask|unmask" />
</View>
```

We also provide convenient extension functions for Kotlin:

```kotlin
view.sentryReplayMask()
// or
view.sentryReplayUnmask()
```

## [Jetpack Compose](https://docs.sentry.io/platforms/android/session-replay/privacy.md#jetpack-compose)

We only support masking specific composables in Jetpack Compose. Since composables are functions, not classes, masking by view class isn't possible.

In the example below, we want the "Hello" message to be captured in the replay, but not the custom composable. (By default, all text composables are masked.)

```kotlin
import io.sentry.android.replay.sentryReplayMask
import io.sentry.android.replay.sentryReplayUnmask

Column(
  verticalArrangement = Arrangement.Center,
  horizontalAlignment = Alignment.CenterHorizontally,
  modifier = Modifier.fillMaxSize()
) {
  MyCustomComposable(
    modifier = Modifier.fillMaxWidth().sentryReplayMask()
    ...
  )
  Text("Hello", modifier = Modifier.sentryReplayUnmask())
}
```

Currently, we don't support masking anything within embedded Android views (`AndroidView`), but you can still mask the entire view as follows:

```kotlin
import io.sentry.android.replay.sentryReplayMask

AndroidView(
  modifier = Modifier.sentryReplayMask(),
  factory = { context -> ... }
)
```

## [General Masking Rules](https://docs.sentry.io/platforms/android/session-replay/privacy.md#general-masking-rules)

### [View Groups](https://docs.sentry.io/platforms/android/session-replay/privacy.md#view-groups)

* If a `ViewGroup` is marked as masked, **all its child views will also be masked**, even if some views would normally not be masked. This prioritizes safety and ensures no sensitive information is unintentionally exposed.

* 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 in the replay.

### [Masking Priority](https://docs.sentry.io/platforms/android/session-replay/privacy.md#masking-priority)

Masking and unmasking rules are applied in the following order:

1. Check if a view is marked as `unmasked` via a tag/extension or function/modifier.
2. Check if a view is marked as `masked` via a tag/extension or function/modifier.
3. Check if a view's class is marked as unmasked via `addUnmaskViewClass`.
4. Check if a view's class is marked as masked via `addMaskViewClass`.
