Skip to content

Commit

Permalink
Merge 868910d into 615bb0e
Browse files Browse the repository at this point in the history
  • Loading branch information
krystofwoldrich authored Jul 4, 2024
2 parents 615bb0e + 868910d commit 5c7e6f0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ sealed class ViewHierarchyNode(
}
}

private fun shouldRedact(view: View, options: SentryOptions): Boolean {
return options.experimental.sessionReplay.redactClasses.contains(view.javaClass.canonicalName)
}

fun fromView(view: View, parent: ViewHierarchyNode?, distance: Int, options: SentryOptions): ViewHierarchyNode {
val (isVisible, visibleRect) = view.isVisibleToUser()
when {
Expand Down Expand Up @@ -282,7 +286,7 @@ sealed class ViewHierarchyNode(
(parent?.elevation ?: 0f) + view.elevation,
distance = distance,
parent = parent,
shouldRedact = false,
shouldRedact = isVisible && shouldRedact(view, options),
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 @@ -2699,12 +2699,14 @@ public final class io/sentry/SentryReplayEvent$ReplayType$Deserializer : io/sent
public final class io/sentry/SentryReplayOptions {
public fun <init> ()V
public fun <init> (Ljava/lang/Double;Ljava/lang/Double;)V
public fun addClassToRedact (Ljava/lang/String;)V
public fun getErrorReplayDuration ()J
public fun getErrorSampleRate ()Ljava/lang/Double;
public fun getFrameRate ()I
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 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.Set;
import java.util.concurrent.CopyOnWriteArraySet;
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 CopyOnWriteArraySet<>();

/**
* 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 addClassToRedact(final String className) {
this.redactClasses.add(className);
}

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

0 comments on commit 5c7e6f0

Please sign in to comment.