Problem
When the React Native SDK enables native crash autocapture (@posthog/react-native-plugin, errorTracking.autocapture.nativeCrashes, see PostHog/posthog-js#3677), a fatal JS error can be captured twice:
- The JS layer captures it via
uncaughtExceptions autocapture (with the JS stack trace), and
- React Native rethrows fatal JS errors on the native side through
RCTFatal(...), which raises an uncaught NSException named RCTFatalException. posthog-ios' crash reporter then captures that as a separate native crash (with a native stack trace).
The result is two $exception events for one logical error.
Suggested fix
posthog-ios should expose a way to ignore native exceptions that originate from React Native's fatal-JS path, and/or skip reporting uncaught NSExceptions whose name is RCTFatalException, so the JS-captured event is the single source of truth.
For reference, sentry-react-native does the equivalent on the native side:
// React native internally throws a JavascriptException. we want to ignore it on the native side to avoid sending it twice.
(addIgnoredExceptionForType(...) — they ignore the RN-internal exception type so it isn't sent twice.)
Notes
Problem
When the React Native SDK enables native crash autocapture (
@posthog/react-native-plugin,errorTracking.autocapture.nativeCrashes, see PostHog/posthog-js#3677), a fatal JS error can be captured twice:uncaughtExceptionsautocapture (with the JS stack trace), andRCTFatal(...), which raises an uncaughtNSExceptionnamedRCTFatalException. posthog-ios' crash reporter then captures that as a separate native crash (with a native stack trace).The result is two
$exceptionevents for one logical error.Suggested fix
posthog-ios should expose a way to ignore native exceptions that originate from React Native's fatal-JS path, and/or skip reporting uncaught
NSExceptions whose name isRCTFatalException, so the JS-captured event is the single source of truth.For reference, sentry-react-native does the equivalent on the native side:
(
addIgnoredExceptionForType(...)— they ignore the RN-internal exception type so it isn't sent twice.)Notes