Repository navigation
fix(react-native): R8-safe dedup of RN fatal JS errors on Android via ignoredExceptionTypes - #4126
Merged
Merged
Conversation
…pes on Android Replaces the name-based beforeSend dedup of RN's natively rethrown fatal JS errors with posthog-android's Class-based errorTrackingConfig.ignoredExceptionTypes (isInstance + cause-chain), which R8/ProGuard renaming can't defeat. Requires posthog core 6.24.0.
Contributor
Contributor
|
Size Change: 0 B Total Size: 17.3 MB ℹ️ View Unchanged
|
ioannisj
approved these changes
Jul 10, 2026
3 of 5 tasks
turnipdabeets
marked this pull request as ready for review
July 10, 2026 17:14
turnipdabeets
enabled auto-merge (squash)
July 10, 2026 17:14
Contributor
|
Reviews (1): Last reviewed commit: "chore: depend on posthog-android 3.53.6,..." | Re-trigger Greptile |
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes the last gap in PostHog/posthog-android#567: when React Native apps enable native crash autocapture, RN rethrows fatal JS errors natively as
com.facebook.react.common.JavascriptException, duplicating the$exceptionthe JS layer already captured.The Android plugin currently dedups this with a
beforeSendhook that string-matches the serialized class name (type == "JavascriptException",module.startsWith("com.facebook.react")). R8/ProGuard renaming can defeat that match in release builds — the serialized names come from runtime classes, so a minified app sends the duplicate anyway. This is the same reason string matching was rejected in posthog-android's review (PostHog/posthog-android#569 → #608).Changes
JavascriptException::class.javain posthog-android'serrorTrackingConfig.ignoredExceptionTypes(new in core 6.24.0, feat(errortracking): ignoredExceptionTypes config to skip duplicate exception captures posthog-android#608):Class.isInstancematching across the cause chain, unaffected by minification. ThebeforeSendhook and its name-matching helper are removed.beforeSendsemantics and the iOS side (posthog-ios ships anRCTFatalExceptiondefault in core since feat(errortracking): addignoredExceptionTypesconfig to skip RN-duplicate native crashes (closes #653) posthog-ios#666 — iOS needs no change here). A conditional variant (only when JSuncaughtExceptionscapture is enabled) was considered and deliberately not done: it would change existing behavior beyond this mechanism swap. See the design discussion on why the default lives in the RN plugin rather than posthog-android core: feat(errortracking): ignoredExceptionTypes config to skip duplicate exception captures posthog-android#608 (comment)posthog-android3.52.0 → 3.53.5, plus an explicitcom.posthog:posthog:6.24.0(published on Maven Central). The explicit core line is needed because 3.53.5's POM pins core 6.23.3, which predates the API, and no posthog-android release is queued to re-pin it.Release info Sub-libraries affected
Libraries affected
Checklist
ignoredExceptionTypesmatching.pnpm changesetto generate a changeset file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
beforeSendworkaround and swapped its mechanism without changing its semantics.Live test (Android emulator, release build)
Built
examples/example-rn-native-pluginin release mode against this branch, with exception autocapture enabled via remote config, and threw a fatal JS error. Result:The native duplicate is dropped by the new mechanism, the process still terminates (handler chaining preserved), and the PostHog project received zero
$exceptionevents for the test window (verified via the API).