Skip to content

Commit d1cf195

Browse files
antonisclaudelucas-zimermancoolguyzone
authored
feat(react-native): Document Android NDK app hang tracking options (#18901)
## DESCRIBE YOUR PR Documents two new Android-only React Native SDK options that surface `sentry-native`'s heartbeat-based app-hang detection: - `enableNdkAppHangTracking` (boolean, default `false`) - `ndkAppHangTimeoutIntervalMillis` (number, default `5000`) Changes: - `configuration/options.mdx` — added `<SdkOption>` entries for both options, next to the other Android options. - `configuration/app-hangs.mdx` — added an "App Hang Tracking on Android" section with init examples, and clarified that the existing `enableAppHangTracking` / `appHangTimeoutInterval` options are iOS-only. Accompanies the SDK change in getsentry/sentry-react-native#6548. ## IS YOUR CHANGE URGENT? - [x] None: Not urgent, can wait up to 1 week+ ## PRE-MERGE CHECKLIST - [ ] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ⚠️ Should be merged after getsentry/sentry-react-native#6548 is released ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com> Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com> Co-authored-by: Alex Krawiec <alexanderkrawiec@gmail.com>
1 parent 4ad8ba7 commit d1cf195

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

docs/platforms/react-native/common/configuration/app-hangs.mdx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_order: 11
44
description: "Learn about how to add app hang detection reporting."
55
---
66

7-
This integration tracks app hangs. This feature is available on iOS, tvOS, and macOS.
7+
This integration tracks app hangs. It's available on iOS, tvOS, macOS, and on Android through NDK-based detection (see [App Hang Tracking on Android](#app-hang-tracking-on-android)).
88

99
Trying to use an unresponsive app is extremely frustrating for users. There are many reasons why an app may become unresponsive, such as long-running code, infinite loop bugs, and so on. With app hang tracking you can detect and fix them.
1010

@@ -30,6 +30,31 @@ Sentry.init({
3030
});
3131
```
3232

33+
### App Hang Tracking on Android
34+
35+
The `enableAppHangTracking` and `appHangTimeoutInterval` options above apply to iOS, tvOS, and macOS. On Android, you can enable `sentry-native`'s heartbeat-based app hang detection with the `enableNdkAppHangTracking` option. This is independent of the JVM-based ANR detection and requires NDK to be enabled. It's disabled by default:
36+
37+
```javascript
38+
import * as Sentry from "@sentry/react-native";
39+
40+
Sentry.init({
41+
dsn: "DSN",
42+
enableNdkAppHangTracking: true,
43+
});
44+
```
45+
46+
The default timeout is 5000 milliseconds. This represents the minimum amount of time the app can be unresponsive before it's classified as hanging. You can change the timeout by setting the `ndkAppHangTimeoutIntervalMillis` option:
47+
48+
```javascript
49+
import * as Sentry from "@sentry/react-native";
50+
51+
Sentry.init({
52+
dsn: "DSN",
53+
enableNdkAppHangTracking: true,
54+
ndkAppHangTimeoutIntervalMillis: 3000,
55+
});
56+
```
57+
3358
### Pause and Resume App Hang Tracking (iOS only)
3459

3560
Starting with version 8.13.0, you can pause and resume app hang tracking at runtime. This is useful when showing system dialogs (for example, permission prompts) that block the main thread but aren't real app hangs.

docs/platforms/react-native/common/configuration/options.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,18 @@ When enabled, ANR events whose stacktraces contain only system frames (for examp
418418

419419
</SdkOption>
420420

421+
<SdkOption name="enableNdkAppHangTracking" type="boolean" defaultValue="false">
422+
423+
Set this boolean to `true` to enable `sentry-native`'s heartbeat-based app hang detection on Android. This is independent of the JVM-based ANR detection and requires NDK to be enabled. Use `ndkAppHangTimeoutIntervalMillis` to configure the threshold.
424+
425+
</SdkOption>
426+
427+
<SdkOption name="ndkAppHangTimeoutIntervalMillis" type="number" defaultValue="5000">
428+
429+
The minimum amount of time (in milliseconds) an app must be unresponsive before it's classified as an app hang when using NDK app hang detection on Android. This only has an effect if `enableNdkAppHangTracking` is `true`.
430+
431+
</SdkOption>
432+
421433
<SdkOption name="enableAutoPerformanceTracing" type="boolean" defaultValue="true">
422434

423435
Set this boolean to `false` to disable auto [performance monitoring](/product/dashboards/sentry-dashboards/) tracking.

0 commit comments

Comments
 (0)