From 67d84afa0957ade5e41843936a6ea1f10b7a6af0 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 21 Oct 2025 09:20:30 +0200 Subject: [PATCH 1/7] feat(android): Add screenshot strategy to session replay docs --- .../android/session-replay/index.mdx | 34 +++++++++++++++++++ .../android/session-replay/privacy/index.mdx | 6 ++++ 2 files changed, 40 insertions(+) diff --git a/docs/platforms/android/session-replay/index.mdx b/docs/platforms/android/session-replay/index.mdx index 153d5704836b1..edce618ff7d10 100644 --- a/docs/platforms/android/session-replay/index.mdx +++ b/docs/platforms/android/session-replay/index.mdx @@ -57,12 +57,20 @@ SentryAndroid.init(context) { options -> options.sessionReplay.onErrorSampleRate = 1.0 options.sessionReplay.sessionSampleRate = 0.1 + + // if your application is strictly PII sensitive we recommend using the Canvas screenshot strategy + // Note: this strategy does **not** support any masking options, it always masks text and images + // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS } ``` ```XML {filename:AndroidManifest.xml} + + + + ``` ## Verify @@ -117,6 +125,32 @@ options.sessionReplay.maskAllImages = false ``` +### Screenshot Strategy + +The SDK offers two strategies for recording replays: `PixelCopy` and `Canvas`. + +`PixelCopy` uses Android's [PixelCopy](https://developer.android.com/reference/android/view/PixelCopy) API to capture screenshots of the current screen and takes a snapshot of the view hierarchy within the same frame. The view hierarchy is then used to find the position of controls such as text boxes, images, labels, and buttons and mask them with a block that's drawn over these controls. This strategy has slightly lower performance overhead but may result in masking misalignments due to the asynchronous nature of the PixelCopy API. We recommend using this strategy for apps that do not have strict PII requirements or do not require masking functionality. + +`Canvas` uses Android's custom [Canvas](https://developer.android.com/reference/android/graphics/Canvas) API to redraw the screen contents onto a bitmap, masking all `drawText` and `drawBitmap` operations in the process to produce a masked screenshot. This strategy has a slightly higher performance overhead but provides more reliable masking. We recommend using this strategy for apps with strict PII requirements. + + + +The `Canvas` screenshot strategy currently does **not** support any masking options. When the screenshot strategy is set to `Canvas`, it will **always** mask all texts, input fields and images, disregarding any masking options set. If you need more flexibility with masking, switch back to `PixelCopy`. + + + +You can change the strategy as follows: + +```kotlin +import io.sentry.ScreenshotStrategyType + +options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS // or ScreenshotStrategyType.PIXEL_COPY (default) +``` + +```XML {filename:AndroidManifest.xml} + +``` + ## Error Linking Errors that happen while a replay is running will be linked to the replay, making it possible to jump between related issues and replays. However, it's **possible** that in some cases the error count reported on the **Replays Details** page won't match the actual errors that have been captured. That's because errors can be lost, and while this is uncommon, there are a few reasons why it could happen: diff --git a/docs/platforms/android/session-replay/privacy/index.mdx b/docs/platforms/android/session-replay/privacy/index.mdx index c301f3a0cabf2..627b909763e33 100644 --- a/docs/platforms/android/session-replay/privacy/index.mdx +++ b/docs/platforms/android/session-replay/privacy/index.mdx @@ -7,6 +7,12 @@ description: "Learn how to mask parts of your app's data in Session Replay." +The masking options below only apply when using the default `PixelCopy` strategy. If you set the strategy to [Canvas](/platforms/android/session-replay/#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. From 8066f9e7b480496aeb52d1d9cb2728f1cef5cce0 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 21 Oct 2025 09:30:39 +0200 Subject: [PATCH 2/7] wording --- docs/platforms/android/session-replay/index.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/platforms/android/session-replay/index.mdx b/docs/platforms/android/session-replay/index.mdx index edce618ff7d10..5c3a1374ef559 100644 --- a/docs/platforms/android/session-replay/index.mdx +++ b/docs/platforms/android/session-replay/index.mdx @@ -58,7 +58,7 @@ SentryAndroid.init(context) { options -> options.sessionReplay.onErrorSampleRate = 1.0 options.sessionReplay.sessionSampleRate = 0.1 - // if your application is strictly PII sensitive we recommend using the Canvas screenshot strategy + // if your application has strict PII requirements we recommend using the Canvas screenshot strategy // Note: this strategy does **not** support any masking options, it always masks text and images // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS } @@ -68,7 +68,7 @@ SentryAndroid.init(context) { options -> - + ``` From 3aaba1dbdec45df0ea5a2aae62430a668bd2fe22 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 28 Oct 2025 17:55:01 +0100 Subject: [PATCH 3/7] Update docs/platforms/android/session-replay/index.mdx --- docs/platforms/android/session-replay/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/android/session-replay/index.mdx b/docs/platforms/android/session-replay/index.mdx index 5c3a1374ef559..509b7b1481c00 100644 --- a/docs/platforms/android/session-replay/index.mdx +++ b/docs/platforms/android/session-replay/index.mdx @@ -69,7 +69,7 @@ SentryAndroid.init(context) { options -> - + ``` From 11acb8f7febabff78916eb31948a701314ea49d3 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 28 Oct 2025 17:55:10 +0100 Subject: [PATCH 4/7] Update docs/platforms/android/session-replay/index.mdx --- docs/platforms/android/session-replay/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/android/session-replay/index.mdx b/docs/platforms/android/session-replay/index.mdx index 509b7b1481c00..f2719efc8d789 100644 --- a/docs/platforms/android/session-replay/index.mdx +++ b/docs/platforms/android/session-replay/index.mdx @@ -59,7 +59,7 @@ SentryAndroid.init(context) { options -> options.sessionReplay.sessionSampleRate = 0.1 // if your application has strict PII requirements we recommend using the Canvas screenshot strategy - // Note: this strategy does **not** support any masking options, it always masks text and images + // Note: this strategy is experimental and does **not** support any masking options, it always masks text and images // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS } ``` From 1f51aa5dfe6ad63a750b8f357229684d5c203692 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Tue, 28 Oct 2025 17:55:22 +0100 Subject: [PATCH 5/7] Update docs/platforms/android/session-replay/index.mdx --- docs/platforms/android/session-replay/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/android/session-replay/index.mdx b/docs/platforms/android/session-replay/index.mdx index f2719efc8d789..16bfa72aa79fd 100644 --- a/docs/platforms/android/session-replay/index.mdx +++ b/docs/platforms/android/session-replay/index.mdx @@ -135,7 +135,7 @@ The SDK offers two strategies for recording replays: `PixelCopy` and `Canvas`. -The `Canvas` screenshot strategy currently does **not** support any masking options. When the screenshot strategy is set to `Canvas`, it will **always** mask all texts, input fields and images, disregarding any masking options set. If you need more flexibility with masking, switch back to `PixelCopy`. +The `Canvas` screenshot strategy is currently experimental and does **not** support any masking options. When the screenshot strategy is set to `Canvas`, it will **always** mask all texts, input fields and images, disregarding any masking options set. If you need more flexibility with masking, switch back to `PixelCopy`. From 37d52a813899a354a9eed6be8b23e517369974bc Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Wed, 29 Oct 2025 08:32:40 +0100 Subject: [PATCH 6/7] Update docs/platforms/android/session-replay/index.mdx --- docs/platforms/android/session-replay/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/platforms/android/session-replay/index.mdx b/docs/platforms/android/session-replay/index.mdx index 16bfa72aa79fd..a9d8f21a345f2 100644 --- a/docs/platforms/android/session-replay/index.mdx +++ b/docs/platforms/android/session-replay/index.mdx @@ -70,6 +70,7 @@ SentryAndroid.init(context) { options -> + ``` From 70cfa089e8238d7af9b408cbcbcb809735187334 Mon Sep 17 00:00:00 2001 From: Roman Zavarnitsyn Date: Wed, 29 Oct 2025 08:40:51 +0100 Subject: [PATCH 7/7] Update docs/platforms/android/session-replay/index.mdx --- docs/platforms/android/session-replay/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/platforms/android/session-replay/index.mdx b/docs/platforms/android/session-replay/index.mdx index a9d8f21a345f2..bc15b8cdae896 100644 --- a/docs/platforms/android/session-replay/index.mdx +++ b/docs/platforms/android/session-replay/index.mdx @@ -60,6 +60,7 @@ SentryAndroid.init(context) { options -> // if your application has strict PII requirements we recommend using the Canvas screenshot strategy // Note: this strategy is experimental and does **not** support any masking options, it always masks text and images + // Available in the Android SDK version 8.24.0 or above // options.sessionReplay.screenshotStrategy = ScreenshotStrategyType.CANVAS } ```