Skip to content

Commit

Permalink
[SR] Mask web and video views (#3775)
Browse files Browse the repository at this point in the history
  • Loading branch information
romtsn authored Oct 8, 2024
1 parent 724865d commit b7489d7
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- If you're using code obfuscation, adjust your proguard-rules accordingly, so your custom view class name is not minified
- Session Replay: Support Jetpack Compose masking ([#3739](https://github.com/getsentry/sentry-java/pull/3739))
- To selectively mask/unmask @Composables, use `Modifier.sentryReplayMask()` and `Modifier.sentryReplayUnmask()` modifiers
- Session Replay: Mask `WebView`, `VideoView` and `androidx.media3.ui.PlayerView` by default ([#3775](https://github.com/getsentry/sentry-java/pull/3775))

### Fixes

Expand Down
3 changes: 3 additions & 0 deletions sentry-android-replay/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
# Rules to detect a compose view to parse its hierarchy
-dontwarn androidx.compose.ui.platform.AndroidComposeView
-keepnames class androidx.compose.ui.platform.AndroidComposeView
# Rules to detect a media player view to later mask it
-dontwarn androidx.media3.ui.PlayerView
-keepnames class androidx.media3.ui.PlayerView
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ internal class SimpleVideoEncoder(
)
format.setInteger(MediaFormat.KEY_BIT_RATE, bitRate)
format.setFloat(MediaFormat.KEY_FRAME_RATE, muxerConfig.frameRate.toFloat())
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, -1) // use -1 to force always non-key frames, meaning only partial updates to save the video size
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 6) // use 6 to force non-key frames, meaning only partial updates to save the video size. Every 6th second is a key frame, which is useful for buffer mode

format
}
Expand Down
5 changes: 5 additions & 0 deletions sentry/api/sentry.api
Original file line number Diff line number Diff line change
Expand Up @@ -2709,8 +2709,13 @@ public final class io/sentry/SentryReplayEvent$ReplayType$Deserializer : io/sent
}

public final class io/sentry/SentryReplayOptions {
public static final field ANDROIDX_MEDIA_VIEW_CLASS_NAME Ljava/lang/String;
public static final field EXOPLAYER_CLASS_NAME Ljava/lang/String;
public static final field EXOPLAYER_STYLED_CLASS_NAME Ljava/lang/String;
public static final field IMAGE_VIEW_CLASS_NAME Ljava/lang/String;
public static final field TEXT_VIEW_CLASS_NAME Ljava/lang/String;
public static final field VIDEO_VIEW_CLASS_NAME Ljava/lang/String;
public static final field WEB_VIEW_CLASS_NAME Ljava/lang/String;
public fun <init> ()V
public fun <init> (Ljava/lang/Double;Ljava/lang/Double;)V
public fun addMaskViewClass (Ljava/lang/String;)V
Expand Down
11 changes: 11 additions & 0 deletions sentry/src/main/java/io/sentry/SentryReplayOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ public final class SentryReplayOptions {

public static final String TEXT_VIEW_CLASS_NAME = "android.widget.TextView";
public static final String IMAGE_VIEW_CLASS_NAME = "android.widget.ImageView";
public static final String WEB_VIEW_CLASS_NAME = "android.webkit.WebView";
public static final String VIDEO_VIEW_CLASS_NAME = "android.widget.VideoView";
public static final String ANDROIDX_MEDIA_VIEW_CLASS_NAME = "androidx.media3.ui.PlayerView";
public static final String EXOPLAYER_CLASS_NAME = "com.google.android.exoplayer2.ui.PlayerView";
public static final String EXOPLAYER_STYLED_CLASS_NAME =
"com.google.android.exoplayer2.ui.StyledPlayerView";

public enum SentryReplayQuality {
/** Video Scale: 80% Bit Rate: 50.000 */
Expand Down Expand Up @@ -99,6 +105,11 @@ public enum SentryReplayQuality {
public SentryReplayOptions() {
setMaskAllText(true);
setMaskAllImages(true);
maskViewClasses.add(WEB_VIEW_CLASS_NAME);
maskViewClasses.add(VIDEO_VIEW_CLASS_NAME);
maskViewClasses.add(ANDROIDX_MEDIA_VIEW_CLASS_NAME);
maskViewClasses.add(EXOPLAYER_CLASS_NAME);
maskViewClasses.add(EXOPLAYER_STYLED_CLASS_NAME);
}

public SentryReplayOptions(
Expand Down

0 comments on commit b7489d7

Please sign in to comment.