Skip to content

Commit 066c6ca

Browse files
authored
feat: added report historic tombstones option to the manifest reader (#5683)
1 parent 44d18f5 commit 066c6ca

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

CHANGELOG.md

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

77
- Add `trace_metric_byte` data category and record byte-level client reports when trace metrics are discarded ([#5626](https://github.com/getsentry/sentry-java/pull/5626))
8+
- Support the `io.sentry.tombstone.report-historical` manifest option to enable historical tombstone reporting via `AndroidManifest.xml` `<meta-data>` ([#5683](https://github.com/getsentry/sentry-java/pull/5683))
89

910
### Fixes
1011

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ final class ManifestMetadataReader {
3737

3838
static final String TOMBSTONE_ENABLE = "io.sentry.tombstone.enable";
3939
static final String TOMBSTONE_ATTACH_RAW = "io.sentry.tombstone.attach-raw";
40+
static final String TOMBSTONE_REPORT_HISTORICAL = "io.sentry.tombstone.report-historical";
4041

4142
static final String AUTO_INIT = "io.sentry.auto-init";
4243
static final String NDK_ENABLE = "io.sentry.ndk.enable";
@@ -232,6 +233,12 @@ static void applyMetadata(
232233
readBool(metadata, logger, TOMBSTONE_ENABLE, options.isTombstoneEnabled()));
233234
options.setAttachRawTombstone(
234235
readBool(metadata, logger, TOMBSTONE_ATTACH_RAW, options.isAttachRawTombstone()));
236+
options.setReportHistoricalTombstones(
237+
readBool(
238+
metadata,
239+
logger,
240+
TOMBSTONE_REPORT_HISTORICAL,
241+
options.isReportHistoricalTombstones()));
235242

236243
// use enableAutoSessionTracking as fallback
237244
options.setEnableAutoSessionTracking(

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,56 @@ class ManifestMetadataReaderTest {
313313
assertEquals(false, fixture.options.isAttachRawTombstone)
314314
}
315315

316+
@Test
317+
fun `applyMetadata reads tombstone enable to options`() {
318+
// Arrange
319+
val bundle = bundleOf(ManifestMetadataReader.TOMBSTONE_ENABLE to true)
320+
val context = fixture.getContext(metaData = bundle)
321+
322+
// Act
323+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
324+
325+
// Assert
326+
assertEquals(true, fixture.options.isTombstoneEnabled)
327+
}
328+
329+
@Test
330+
fun `applyMetadata reads tombstone enable to options and keeps default`() {
331+
// Arrange
332+
val context = fixture.getContext()
333+
334+
// Act
335+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
336+
337+
// Assert
338+
assertEquals(false, fixture.options.isTombstoneEnabled)
339+
}
340+
341+
@Test
342+
fun `applyMetadata reads tombstone report historical to options`() {
343+
// Arrange
344+
val bundle = bundleOf(ManifestMetadataReader.TOMBSTONE_REPORT_HISTORICAL to true)
345+
val context = fixture.getContext(metaData = bundle)
346+
347+
// Act
348+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
349+
350+
// Assert
351+
assertEquals(true, fixture.options.isReportHistoricalTombstones)
352+
}
353+
354+
@Test
355+
fun `applyMetadata reads tombstone report historical to options and keeps default`() {
356+
// Arrange
357+
val context = fixture.getContext()
358+
359+
// Act
360+
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)
361+
362+
// Assert
363+
assertEquals(false, fixture.options.isReportHistoricalTombstones)
364+
}
365+
316366
@Test
317367
fun `applyMetadata reads anr report historical to options`() {
318368
// Arrange

0 commit comments

Comments
 (0)