Skip to content

Commit 7886639

Browse files
romtsnclaude
andauthored
Add enableTombstone option for native crash reporting on Android 12+ (#5680)
* feat(android): Add enableTombstone option for native crash reporting Adds the `enableTombstone` SDK option to enable tombstone-based native crash reporting on Android 12+. When enabled, the SDK uses Android's ApplicationExitInfo (REASON_CRASH_NATIVE) to capture native crashes with more detailed information including thread details. Slack thread: https://sentry.slack.com/archives/CP4UUUF1S/p1771403837316269?thread_ts=1769055443.846779&cid=CP4UUUF1S https://claude.ai/code/session_01Ti4KAqCW79Ecw6tpcxDzq1 * Apply suggestion from @romtsn --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 77271cd commit 7886639

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010

1111
### Features
1212

13+
- Add `enableTombstone` option for improved native crash reporting on Android 12+ ([#5680](https://github.com/getsentry/sentry-react-native/pull/5680))
14+
- When enabled, uses Android's `ApplicationExitInfo.REASON_CRASH_NATIVE` to capture native crashes with more detailed thread information
15+
```js
16+
import * as Sentry from '@sentry/react-native';
17+
18+
Sentry.init({
19+
dsn: 'YOUR_DSN',
20+
enableTombstone: true,
21+
});
22+
```
1323
- Expose iOS options to ignore views from subtree traversal in version 8 ([#5663](https://github.com/getsentry/sentry-react-native/pull/5663))
1424
- Use `includedViewClasses` to only traverse specific view classes, or `excludedViewClasses` to skip problematic view classes during session replay and screenshot capture
1525
```js

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,4 +282,34 @@ class RNSentryStartTest {
282282
val integrations = options.getIntegrations()
283283
assertNotNull("Integrations list should not be null", integrations)
284284
}
285+
286+
@Test
287+
fun `when enableTombstone is true, tombstone reporting is enabled`() {
288+
val rnOptions = JavaOnlyMap.of("enableTombstone", true)
289+
val options = SentryAndroidOptions()
290+
291+
RNSentryStart.getSentryAndroidOptions(options, rnOptions, logger)
292+
293+
assertTrue("Tombstone should be enabled", options.isTombstoneEnabled)
294+
}
295+
296+
@Test
297+
fun `when enableTombstone is false, tombstone reporting is disabled`() {
298+
val rnOptions = JavaOnlyMap.of("enableTombstone", false)
299+
val options = SentryAndroidOptions()
300+
301+
RNSentryStart.getSentryAndroidOptions(options, rnOptions, logger)
302+
303+
assertFalse("Tombstone should be disabled", options.isTombstoneEnabled)
304+
}
305+
306+
@Test
307+
fun `when enableTombstone is not set, tombstone reporting remains at default (disabled)`() {
308+
val rnOptions = JavaOnlyMap()
309+
val options = SentryAndroidOptions()
310+
311+
RNSentryStart.getSentryAndroidOptions(options, rnOptions, logger)
312+
313+
assertFalse("Tombstone should be disabled by default", options.isTombstoneEnabled)
314+
}
285315
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ static void getSentryAndroidOptions(
145145
if (rnOptions.hasKey("enableNdk")) {
146146
options.setEnableNdk(rnOptions.getBoolean("enableNdk"));
147147
}
148+
if (rnOptions.hasKey("enableTombstone")) {
149+
options.setTombstoneEnabled(rnOptions.getBoolean("enableTombstone"));
150+
}
148151
if (rnOptions.hasKey("spotlight")) {
149152
if (rnOptions.getType("spotlight") == ReadableType.Boolean) {
150153
options.setEnableSpotlight(rnOptions.getBoolean("spotlight"));

packages/core/src/js/options.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ export interface BaseReactNativeOptions {
5656
*/
5757
enableNdk?: boolean;
5858

59+
/**
60+
* When enabled, the SDK captures native crashes using Android's ApplicationExitInfo
61+
* (REASON_CRASH_NATIVE) available on Android 12+. This provides more detailed crash
62+
* information including thread details.
63+
*
64+
* @default false
65+
* @platform android
66+
*/
67+
enableTombstone?: boolean;
68+
5969
/** Enable scope sync from Java to NDK on Android
6070
* Only has an effect if `enableNdk` is `true`.
6171
*

0 commit comments

Comments
 (0)