diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c8ee83a3df..905ff117435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Features + +- Add `redactClasses` to Session Replay options ([#3546](https://github.com/getsentry/sentry-java/pull/3546)) + ## 7.11.0-alpha.2 - Session Replay for Android ([#3339](https://github.com/getsentry/sentry-java/pull/3339)) diff --git a/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ViewHierarchyNode.kt b/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ViewHierarchyNode.kt index 60014e8f64a..888d489a1f4 100644 --- a/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ViewHierarchyNode.kt +++ b/sentry-android-replay/src/main/java/io/sentry/android/replay/viewhierarchy/ViewHierarchyNode.kt @@ -282,7 +282,7 @@ sealed class ViewHierarchyNode( (parent?.elevation ?: 0f) + view.elevation, distance = distance, parent = parent, - shouldRedact = false, + shouldRedact = options.experimental.sessionReplay.redactClasses.contains(view.javaClass.canonicalName), isImportantForContentCapture = false, /* will be set by children */ isVisible = isVisible, visibleRect = visibleRect diff --git a/sentry/src/main/java/io/sentry/SentryReplayOptions.java b/sentry/src/main/java/io/sentry/SentryReplayOptions.java index 54cabeaef6b..da686b18c78 100644 --- a/sentry/src/main/java/io/sentry/SentryReplayOptions.java +++ b/sentry/src/main/java/io/sentry/SentryReplayOptions.java @@ -1,6 +1,8 @@ package io.sentry; import io.sentry.util.SampleRateUtils; +import java.util.HashSet; +import java.util.Set; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -64,6 +66,14 @@ public enum SentryReplayQuality { */ private boolean redactAllImages = true; + /** + * Redact all views with the specified class names. The class name is the fully qualified class + * name of the view, e.g. android.widget.TextView. + * + *

Default is empty. + */ + private Set redactClasses = new HashSet<>(); + /** * Defines the quality of the session replay. The higher the quality, the more accurate the replay * will be, but also more data to transfer and more CPU load, defaults to MEDIUM. @@ -147,6 +157,14 @@ public void setRedactAllImages(final boolean redactAllImages) { this.redactAllImages = redactAllImages; } + public Set getRedactClasses() { + return this.redactClasses; + } + + public void setRedactClasses(final Set redactClasses) { + this.redactClasses = redactClasses; + } + @ApiStatus.Internal public @NotNull SentryReplayQuality getQuality() { return quality;