Skip to content

Commit 347643d

Browse files
romtsnclaude
andcommitted
feat(replay): Wire capture-surface-views option through ManifestMetadataReader
Allow enabling the experimental SurfaceView capture in Session Replay via the manifest meta-data `io.sentry.session-replay.capture-surface-views`, so users relying on auto-init don't need to switch to manual SentryAndroid.init just to flip the flag. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 29da076 commit 347643d

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Session Replay: experimental support for capturing `SurfaceView` content (e.g. Unity, video players, maps) ([#5333](https://github.com/getsentry/sentry-java/pull/5333))
88
- To enable, set `options.sessionReplay.isCaptureSurfaceViews = true`
9+
- Or via manifest: `<meta-data android:name="io.sentry.session-replay.capture-surface-views" android:value="true" />`
910

1011
## 8.40.0
1112

sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ final class ManifestMetadataReader {
120120

121121
static final String REPLAYS_DEBUG = "io.sentry.session-replay.debug";
122122
static final String REPLAYS_SCREENSHOT_STRATEGY = "io.sentry.session-replay.screenshot-strategy";
123+
static final String REPLAYS_CAPTURE_SURFACE_VIEWS =
124+
"io.sentry.session-replay.capture-surface-views";
123125

124126
static final String REPLAYS_NETWORK_DETAIL_ALLOW_URLS =
125127
"io.sentry.session-replay.network-detail-allow-urls";
@@ -547,6 +549,15 @@ static void applyMetadata(
547549
}
548550
}
549551

552+
options
553+
.getSessionReplay()
554+
.setCaptureSurfaceViews(
555+
readBool(
556+
metadata,
557+
logger,
558+
REPLAYS_CAPTURE_SURFACE_VIEWS,
559+
options.getSessionReplay().isCaptureSurfaceViews()));
560+
550561
// Network Details Configuration
551562
if (options.getSessionReplay().getNetworkDetailAllowUrls().isEmpty()) {
552563
final @Nullable List<String> allowUrls =

sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,31 @@ class ManifestMetadataReaderTest {
20222022
)
20232023
}
20242024

2025+
@Test
2026+
fun `applyMetadata reads capture-surface-views to options`() {
2027+
// Arrange
2028+
val bundle = bundleOf(ManifestMetadataReader.REPLAYS_CAPTURE_SURFACE_VIEWS to true)
2029+
val context = fixture.getContext(metaData = bundle)
2030+
2031+
// Act
2032+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2033+
2034+
// Assert
2035+
assertTrue(fixture.options.sessionReplay.isCaptureSurfaceViews)
2036+
}
2037+
2038+
@Test
2039+
fun `applyMetadata reads capture-surface-views and keeps default if not found`() {
2040+
// Arrange
2041+
val context = fixture.getContext()
2042+
2043+
// Act
2044+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
2045+
2046+
// Assert
2047+
assertFalse(fixture.options.sessionReplay.isCaptureSurfaceViews)
2048+
}
2049+
20252050
@Test
20262051
fun `applyMetadata reads anrProfilingSampleRate to options`() {
20272052
// Arrange

0 commit comments

Comments
 (0)