Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 0 additions & 113 deletions docs/platforms/android/configuration/manual-init.mdx

This file was deleted.

159 changes: 159 additions & 0 deletions docs/platforms/android/enriching-events/screenshots/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,165 @@ Because screenshots may contain <PlatformLink to="/data-management/sensitive-dat

<PlatformContent includePath="enriching-events/attach-screenshots" />

## Screenshot Masking

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.

<Alert>

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:

```groovy {filename:app/build.gradle}
dependencies {
implementation 'io.sentry:sentry-android-replay:{{@inject packages.version('sentry.java.android', '8.34.0') }}'
}
```

```kotlin {filename:app/build.gradle.kts}
dependencies {
implementation("io.sentry:sentry-android-replay:{{@inject packages.version('sentry.java.android', '8.34.0') }}")
}
```

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.

</Alert>

### Default Masking Behavior

Unlike Session Replay, screenshot masking is **disabled by default**. You can enable masking for all text and image content:

```java
import io.sentry.android.core.SentryAndroid;

SentryAndroid.init(this, options -> {
options.getScreenshot().setMaskAllText(true);
options.getScreenshot().setMaskAllImages(true);
});
```

```kotlin
import io.sentry.android.core.SentryAndroid

SentryAndroid.init(this) { options ->
options.screenshot.setMaskAllText(true)
options.screenshot.setMaskAllImages(true)
}
```

```xml {filename:AndroidManifest.xml}
<application>
<meta-data android:name="io.sentry.screenshot.mask-all-text" android:value="true" />
<meta-data android:name="io.sentry.screenshot.mask-all-images" android:value="true" />
</application>
```

<Alert>

When `setMaskAllImages(true)` is set, the SDK will also mask `WebView`, `VideoView`, CameraX `PreviewView`, ExoPlayer, and Media3 player views in addition to `ImageView`.

</Alert>

### Mask by View Class

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.

```java
import io.sentry.android.core.SentryAndroid;

SentryAndroid.init(this, options -> {
options.getScreenshot().addMaskViewClass("com.example.MyCustomView");
options.getScreenshot().addUnmaskViewClass("com.example.PublicLabel");
});
```

```kotlin
import io.sentry.android.core.SentryAndroid

SentryAndroid.init(this) { options ->
options.screenshot.addMaskViewClass("com.example.MyCustomView")
options.screenshot.addUnmaskViewClass("com.example.PublicLabel")
}
```

<Alert>

If you use R8/ProGuard, make sure to keep the class names you reference in masking rules. Obfuscated class names will not match at runtime.

</Alert>

### Mask by View Instance

You can mask or unmask specific view instances using extension functions from the `sentry-android-replay` module:

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

myTextView.sentryReplayMask()
myImageView.sentryReplayUnmask()
```

In Kotlin and Java, you can also use view tags with the `sentry_privacy` resource ID:

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

view.setTag(R.id.sentry_privacy, "mask")
view.setTag(R.id.sentry_privacy, "unmask")
```

```java
import io.sentry.android.replay.R;

view.setTag(R.id.sentry_privacy, "mask");
view.setTag(R.id.sentry_privacy, "unmask");
```

You can also set masking via XML layout tags:

```xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sensitive data">
<tag android:id="@id/sentry_privacy" android:value="mask" />
</TextView>
```

Alternatively, you can use the `android:tag` attribute with the `sentry-mask` or `sentry-unmask` string values:

```xml
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="sentry-mask"
android:text="Sensitive data" />
```

### Jetpack Compose

For Jetpack Compose, use the `sentryReplayMask()` and `sentryReplayUnmask()` modifiers:

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

@Composable
fun MyScreen() {
Column {
Text(
text = "Sensitive info",
modifier = Modifier.sentryReplayMask()
)
Text(
text = "Public info",
modifier = Modifier.sentryReplayUnmask()
)
}
}
```

## Viewing Screenshots

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.
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/android/integrations/apollo3/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Alternatively, you can customize the event and scrub the data yourself.

### Customize or Drop the Error Event

To customize or drop the error event, you'll need to do a [manual initialization](/platforms/android/configuration/manual-init/#manual-initialization) of the Sentry Android SDK. The captured error event can then be customized or dropped with a `BeforeSendCallback`:
To customize or drop the error event, you'll need to do a [manual initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions) of the Sentry Android SDK. The captured error event can then be customized or dropped with a `BeforeSendCallback`:

```kotlin
import io.sentry.android.core.SentryAndroid
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/android/integrations/fragment/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ However, you can still override the default behaviour by adding your own instanc

### Install

To add the Fragment integration, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the Android SDK, then add the `sentry-android-fragment` dependency. Using Gradle:
To add the Fragment integration, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the Android SDK, then add the `sentry-android-fragment` dependency. Using Gradle:

```groovy
implementation 'io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '5.1.0') }}'
Expand Down
4 changes: 2 additions & 2 deletions docs/platforms/android/integrations/jetpack-compose/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ This feature is disabled by default, but you can enable it the following ways.

#### Using `SentryOptions`

If you initialize the SDK [manually as mentioned here](/platforms/android/configuration/manual-init/#manual-initialization), you can enable user interactions like this:
If you initialize the SDK [manually as mentioned here](/platforms/android/manual-setup/#configuration-via-sentryoptions), you can enable user interactions like this:

```kotlin {filename:MyApplication.kt}
SentryAndroid.init(this) { options ->
Expand Down Expand Up @@ -330,7 +330,7 @@ fun Second() {

## Customize the Recorded Breadcrumb/Transaction

By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the SDK and add the following snippet:
By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the SDK and add the following snippet:

```kotlin
import io.sentry.EventProcessor
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/android/integrations/ktor-client/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Those events are searchable and you can set alerts on them if you use the `http.

### Customize or Drop the Error Event

To customize or drop the error event, you need to do a [manual initialization](/platforms/android/configuration/manual-init/#manual-initialization) of the Sentry Android SDK.
To customize or drop the error event, you need to do a [manual initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions) of the Sentry Android SDK.

The captured error event can be customized or dropped with a `BeforeSendCallback`:

Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/android/integrations/navigation/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class HomeFragment : Fragment() {

## Customize the Recorded Breadcrumb/Transaction

By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the SDK and add the following snippet:
By default, the Navigation integration captures route arguments as additional data on breadcrumbs and transactions. In case the arguments contain any PII data, you can strip it out by way of `BeforeBreadcrumbCallback` and `EventProcessor` respectively. To do that, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the SDK and add the following snippet:

```kotlin
import io.sentry.EventProcessor
Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/android/integrations/okhttp/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ Those events are searchable and you can set alerts on them if you use the `http.

### Customize or Drop the Error Event

To customize or drop the error event, you need to do a [manual initialization](/platforms/android/configuration/manual-init/#manual-initialization) of the Sentry Android SDK.
To customize or drop the error event, you need to do a [manual initialization](/platforms/android/manual-setup/#configuration-via-sentryoptions) of the Sentry Android SDK.

The captured error event can be customized or dropped with a `BeforeSendCallback`:

Expand Down
2 changes: 1 addition & 1 deletion docs/platforms/android/integrations/timber/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ configurations.configureEach {

### Install

To add the Timber integration, [manually initialize](/platforms/android/configuration/manual-init/#manual-initialization) the Android SDK, then add the `sentry-android-timber` dependency. Using Gradle:
To add the Timber integration, [manually initialize](/platforms/android/manual-setup/#configuration-via-sentryoptions) the Android SDK, then add the `sentry-android-timber` dependency. Using Gradle:

```groovy
implementation 'io.sentry:sentry-android:{{@inject packages.version('sentry.java.android', '4.2.0') }}'
Expand Down
Loading