Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR] Add redactClasses option #3546

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Features

- Add `redactClasses` to Session Replay options ([#3546](https://github.com/getsentry/sentry-java/pull/3546))

krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved
## 7.11.0-alpha.2

- Session Replay for Android ([#3339](https://github.com/getsentry/sentry-java/pull/3339))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: I think for completeness we should also have this check for TextViewHierarchyNode and ImageViewHierarchyNode, but you can skip this if you don't have time right now

Copy link
Member Author

@krystofwoldrich krystofwoldrich Jul 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes, that make sense. But that code is only used when redactAllText and redactAllmages is used, so checking the redactedClasses won't change anything.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but I meant we should change that, i.e. if you disable redactAllText but add TextView to redactClasses it should still redact textviews. But as I said you don't have to do it now, so it's fine to ignore this comment

isImportantForContentCapture = false, /* will be set by children */
isVisible = isVisible,
visibleRect = visibleRect
Expand Down
2 changes: 2 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,7 @@ public final class io/sentry/SentryReplayOptions {
public fun getQuality ()Lio/sentry/SentryReplayOptions$SentryReplayQuality;
public fun getRedactAllImages ()Z
public fun getRedactAllText ()Z
public fun getRedactClasses ()Ljava/util/Set;
public fun getSessionDuration ()J
public fun getSessionSampleRate ()Ljava/lang/Double;
public fun getSessionSegmentDuration ()J
Expand All @@ -2710,6 +2711,7 @@ public final class io/sentry/SentryReplayOptions {
public fun setQuality (Lio/sentry/SentryReplayOptions$SentryReplayQuality;)V
public fun setRedactAllImages (Z)V
public fun setRedactAllText (Z)V
public fun setRedactClasses (Ljava/util/Set;)V
public fun setSessionSampleRate (Ljava/lang/Double;)V
}

Expand Down
18 changes: 18 additions & 0 deletions sentry/src/main/java/io/sentry/SentryReplayOptions.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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.
*
* <p>Default is empty.
*/
private Set<String> redactClasses = new HashSet<>();
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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.
Expand Down Expand Up @@ -147,6 +157,14 @@ public void setRedactAllImages(final boolean redactAllImages) {
this.redactAllImages = redactAllImages;
}

public Set<String> getRedactClasses() {
return this.redactClasses;
}

public void setRedactClasses(final Set<String> redactClasses) {
krystofwoldrich marked this conversation as resolved.
Show resolved Hide resolved
this.redactClasses = redactClasses;
}

@ApiStatus.Internal
public @NotNull SentryReplayQuality getQuality() {
return quality;
Expand Down
Loading