Skip to content

Commit 87a42d4

Browse files
authored
Merge branch 'main' into alwx/ci/group-codeql-action-dependabot
2 parents 8e4ae43 + f6d439e commit 87a42d4

4 files changed

Lines changed: 52 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Features
1212

1313
- Add `Sentry.reportFullyDisplayed()` imperative API for signaling Time to Full Display ([#6419](https://github.com/getsentry/sentry-react-native/pull/6419))
14+
- Add `enableHistoricalTombstoneReporting` option to report historical tombstones from Android's `ApplicationExitInfo` ([#6450](https://github.com/getsentry/sentry-react-native/pull/6450))
1415

1516
### Fixes
1617

packages/core/RNSentryAndroidTester/app/src/test/java/io/sentry/react/RNSentryStartTest.kt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,39 @@ class RNSentryStartTest {
314314
assertFalse("Tombstone should be disabled by default", options.isTombstoneEnabled)
315315
}
316316

317+
@Test
318+
fun `when enableHistoricalTombstoneReporting is true, historical tombstone reporting is enabled`() {
319+
val rnOptions = JavaOnlyMap.of("enableHistoricalTombstoneReporting", true)
320+
val options = SentryAndroidOptions()
321+
322+
RNSentryStart.getSentryAndroidOptions(options, rnOptions, logger)
323+
324+
assertTrue("Historical tombstone reporting should be enabled", options.isReportHistoricalTombstones)
325+
}
326+
327+
@Test
328+
fun `when enableHistoricalTombstoneReporting is false, historical tombstone reporting is disabled`() {
329+
val rnOptions = JavaOnlyMap.of("enableHistoricalTombstoneReporting", false)
330+
val options = SentryAndroidOptions()
331+
332+
RNSentryStart.getSentryAndroidOptions(options, rnOptions, logger)
333+
334+
assertFalse("Historical tombstone reporting should be disabled", options.isReportHistoricalTombstones)
335+
}
336+
337+
@Test
338+
fun `when enableHistoricalTombstoneReporting is not set, it remains at default (disabled)`() {
339+
val rnOptions = JavaOnlyMap()
340+
val options = SentryAndroidOptions()
341+
342+
RNSentryStart.getSentryAndroidOptions(options, rnOptions, logger)
343+
344+
assertFalse(
345+
"Historical tombstone reporting should be disabled by default",
346+
options.isReportHistoricalTombstones,
347+
)
348+
}
349+
317350
@Test
318351
fun `network detail replay options are forwarded to the native replay options`() {
319352
val mobileReplayOptions =

packages/core/android/src/main/java/io/sentry/react/RNSentryStart.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ static void getSentryAndroidOptions(
195195
if (rnOptions.hasKey("enableTombstone")) {
196196
options.setTombstoneEnabled(rnOptions.getBoolean("enableTombstone"));
197197
}
198+
if (rnOptions.hasKey("enableHistoricalTombstoneReporting")) {
199+
options.setReportHistoricalTombstones(
200+
rnOptions.getBoolean("enableHistoricalTombstoneReporting"));
201+
}
198202
if (rnOptions.hasKey("enableAnrFingerprinting")) {
199203
options.setEnableAnrFingerprinting(rnOptions.getBoolean("enableAnrFingerprinting"));
200204
}

packages/core/src/js/options.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ export interface BaseReactNativeOptions {
6969
*/
7070
enableTombstone?: boolean;
7171

72+
/**
73+
* When enabled, the SDK reports historical tombstones from Android's
74+
* ApplicationExitInfo system API, as opposed to reporting only the tombstone
75+
* of the latest application run. Historical events are reported without
76+
* current scope data (e.g. breadcrumbs), as it's not possible to know
77+
* the state of the app at the time they happened.
78+
*
79+
* Only has an effect if `enableTombstone` is `true`.
80+
*
81+
* @default false
82+
* @platform android
83+
*/
84+
enableHistoricalTombstoneReporting?: boolean;
85+
7286
/** Enable scope sync from Java to NDK on Android
7387
* Only has an effect if `enableNdk` is `true`.
7488
*

0 commit comments

Comments
 (0)