Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
wip
  • Loading branch information
romtsn committed Sep 9, 2024
commit 6e23fe5b4847560751f883e9a8e52eb482b6b7ff
49 changes: 49 additions & 0 deletions sentry/src/main/java/io/sentry/ReplayApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.sentry;

import io.sentry.protocol.SentryId;
import javax.swing.text.View;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

@ApiStatus.Experimental
public class ReplayApi {

private final @NotNull ReplayController replayController;

public ReplayApi(final @NotNull ReplayController replayController) {
this.replayController = replayController;
}

public void start() {
replayController.start();
}

public void stop() {
replayController.stop();
}

public void pause() {
replayController.pause();
}

public void resume() {
replayController.resume();
}

public boolean isRecording() {
return replayController.isRecording();
}

@NotNull
public SentryId getReplayId() {
return replayController.getReplayId();
}

public void redactView(final @NotNull View view) {
replayController.redactView(view);
}

public void ignoreView(final @NotNull View view) {
replayController.ignoreView(view);
}
}
7 changes: 7 additions & 0 deletions sentry/src/main/java/io/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,13 @@ public static MetricsApi metrics() {
return getCurrentHub().metrics();
}

/** the replay API */
@NotNull
@ApiStatus.Experimental
public static ReplayController replay() {
return getCurrentHub().getOptions().getReplayController();
}

/**
* Configuration options callback
*
Expand Down
30 changes: 28 additions & 2 deletions sentry/src/main/java/io/sentry/SentryReplayOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,28 @@ public enum SentryReplayQuality {

/**
* 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.
* name of the view, e.g. android.widget.TextView. The subclasses of the specified classes will be
* redacted as well.
*
* <p>If you're using an obfuscation tool, make sure
* to add the respective proguard rules to keep the class names.
*
* <p>Default is empty.
*/
private Set<String> redactClasses = new CopyOnWriteArraySet<>();
Copy link
Member Author

Choose a reason for hiding this comment

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

@brustolin @bruno-garcia I guess we should align on naming here. Do you prefer this or redactViewTypes? I'm fine with either

Choose a reason for hiding this comment

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

I think we should align but just Classes is too generic, what about "redactViewClasses"?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, sounds good. I can also change it to redactViewTypes so you don't have to :)


/**
* Ignore all views with the specified class names from redaction. The class name is the fully
* qualified class name of the view, e.g. android.widget.TextView. The subclasses of the specified
* classes will be ignored as well.
*
* <p>If you're using an obfuscation tool, make sure
* to add the respective proguard rules to keep the class names.
*
* <p>Default is empty.
*/
private Set<String> ignoreClasses = 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 @@ -157,14 +173,24 @@ public void setRedactAllImages(final boolean redactAllImages) {
this.redactAllImages = redactAllImages;
}

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

public void addClassToRedact(final String className) {
public void addRedactClass(final @NotNull String className) {
this.redactClasses.add(className);
}

@NotNull
public Set<String> getIgnoreClasses() {
return this.ignoreClasses;
}

public void addIgnoreClass(final @NotNull String className) {
this.ignoreClasses.add(className);
}

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