-
-
Notifications
You must be signed in to change notification settings - Fork 357
feat: v8: Capture app start errors before JS #5582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v8
Are you sure you want to change the base?
Conversation
…ructures (#4445) * Extract Android SDK Init * Update tests * Adds changelog * Fix lint issues * Rename RNSentryStart instance for clarity * Converts RNSentryStart to utility class * Update CHANGELOG.md --------- Co-authored-by: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com>
* Convert json object to writable map * Make class/methods package-private(default)
- Resolved merge conflicts across iOS, Android, and JavaScript/TypeScript code - Updated iOS implementation to use RNSentryStart API - Fixed Android compilation errors for Sentry Android SDK v7 compatibility - Removed deprecated API calls (setEnableTracing, getPackages, getIntegrations) - Updated Gradle build scripts and resolved conflict markers - All builds verified: iOS, Android, and Expo sample apps compile successfully
… plugin (#4633) * useNativeInit Android implementation * Adds changelog * useNativeInit iOS implementation * Fix indentation * Extend test cases with realistic data * Adds code sample in the changelog * Fix CHANGELOG.md Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com> * Warn if RESentySDK.init/start wasn't injected * Make useNativeInit opt-in * Make Android failure warning more clear Co-authored-by: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> * Make Android no update warning more clear Co-authored-by: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> * Use path.basename to get last path component * Update tests to account for the new warnings * Explicitly check for kotlin * Add filename in the warning message * Import only if init injection succeeds * Explicitly check for Objective-C * Add filename in the warning * Make iOS file not found warning more clear * Import only if init injection succeeds * Reset test mock config in a function * Lint issue * Add missing quote Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com> * Remove unneeded async Co-authored-by: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> * Set useNativeInit = false by default * dynamically fill white spaces * Add unsupported language in warning message * Add objcpp in detected languages Co-authored-by: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> * Update tests for objcpp * ref(expo-plugin): Split utils to logger, version and utils (#4906) Co-authored-by: Antonis Lilis <antonis.lilis@gmail.com> * Update changelog * fix(ios): Add Swift module support for RNSentrySDK native init Fixes Swift compilation errors when using the useNativeInit Expo plugin feature. Changes: - Updated RNSentry.h to use angle bracket import for RNSentrySDK, properly exposing it through the module system - Added DEFINES_MODULE to RNSentry.podspec to enable Swift module generation - Fixed Expo plugin to insert import after first import statement (supports modern Expo AppDelegate structure without UIKit import) This enables Swift code to successfully import RNSentry and call RNSentrySDK.start() when using native initialization. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Fix test * Update changelog * Fix native tests * Fix lint issue * Fix native tests * Revert unneeded changes * Fix sample app build --------- Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com> Co-authored-by: Krystof Woldrich <31292499+krystofwoldrich@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
…o antonis/capture-app-start-errors-v8 # Conflicts: # packages/core/RNSentry.podspec # packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryDependencyContainerTests.h # packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryFramesTrackerListenerTests.h # packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
|
Android (new) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| fa0d109+dirty | 413.71 ms | 434.22 ms | 20.51 ms |
| bc8a1ed+dirty | 396.10 ms | 426.80 ms | 30.69 ms |
| b4fa5b4+dirty | 382.09 ms | 398.28 ms | 16.19 ms |
| 206e87e+dirty | 416.94 ms | 440.98 ms | 24.04 ms |
| d6aa223+dirty | 436.98 ms | 466.42 ms | 29.44 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| fa0d109+dirty | 43.94 MiB | 49.22 MiB | 5.29 MiB |
| bc8a1ed+dirty | 43.94 MiB | 48.91 MiB | 4.97 MiB |
| b4fa5b4+dirty | 43.94 MiB | 48.91 MiB | 4.97 MiB |
| 206e87e+dirty | 43.94 MiB | 49.22 MiB | 5.29 MiB |
| d6aa223+dirty | 43.94 MiB | 49.38 MiB | 5.44 MiB |
Previous results on branch: antonis/capture-app-start-errors-v8
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 88812b1+dirty | 425.90 ms | 435.25 ms | 9.35 ms |
| 82de722+dirty | 398.52 ms | 422.70 ms | 24.18 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 88812b1+dirty | 43.94 MiB | 49.22 MiB | 5.29 MiB |
| 82de722+dirty | 43.94 MiB | 49.22 MiB | 5.29 MiB |
Android (legacy) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| fa0d109+dirty | 429.60 ms | 452.50 ms | 22.90 ms |
| bc8a1ed+dirty | 442.18 ms | 476.27 ms | 34.08 ms |
| b4fa5b4+dirty | 449.55 ms | 481.50 ms | 31.95 ms |
| 206e87e+dirty | 464.80 ms | 504.68 ms | 39.88 ms |
| d6aa223+dirty | 543.40 ms | 564.24 ms | 20.84 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| fa0d109+dirty | 43.75 MiB | 48.40 MiB | 4.64 MiB |
| bc8a1ed+dirty | 43.75 MiB | 48.08 MiB | 4.33 MiB |
| b4fa5b4+dirty | 43.75 MiB | 48.08 MiB | 4.33 MiB |
| 206e87e+dirty | 43.75 MiB | 48.40 MiB | 4.64 MiB |
| d6aa223+dirty | 43.75 MiB | 48.55 MiB | 4.80 MiB |
Previous results on branch: antonis/capture-app-start-errors-v8
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 88812b1+dirty | 428.04 ms | 462.22 ms | 34.18 ms |
| 82de722+dirty | 425.13 ms | 457.02 ms | 31.89 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 88812b1+dirty | 43.75 MiB | 48.40 MiB | 4.64 MiB |
| 82de722+dirty | 43.75 MiB | 48.40 MiB | 4.64 MiB |
iOS (new) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d6aa223+dirty | 1216.76 ms | 1213.40 ms | -3.37 ms |
| b4fa5b4+dirty | 1213.59 ms | 1211.26 ms | -2.33 ms |
| bc8a1ed+dirty | 1198.66 ms | 1200.60 ms | 1.94 ms |
| 206e87e+dirty | 1197.12 ms | 1204.25 ms | 7.13 ms |
| fa0d109+dirty | 1206.81 ms | 1205.38 ms | -1.43 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d6aa223+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
| b4fa5b4+dirty | 3.44 MiB | 4.66 MiB | 1.22 MiB |
| bc8a1ed+dirty | 3.44 MiB | 4.66 MiB | 1.22 MiB |
| 206e87e+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
| fa0d109+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
Previous results on branch: antonis/capture-app-start-errors-v8
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 82de722+dirty | 1210.87 ms | 1217.00 ms | 6.13 ms |
| 88812b1+dirty | 1210.98 ms | 1215.22 ms | 4.24 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 82de722+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
| 88812b1+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
iOS (legacy) Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d6aa223+dirty | 1192.33 ms | 1208.17 ms | 15.84 ms |
| b4fa5b4+dirty | 1203.83 ms | 1207.13 ms | 3.30 ms |
| bc8a1ed+dirty | 1194.70 ms | 1201.18 ms | 6.48 ms |
| 206e87e+dirty | 1184.11 ms | 1183.19 ms | -0.92 ms |
| fa0d109+dirty | 1216.02 ms | 1220.67 ms | 4.65 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| d6aa223+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
| b4fa5b4+dirty | 3.44 MiB | 4.66 MiB | 1.22 MiB |
| bc8a1ed+dirty | 3.44 MiB | 4.66 MiB | 1.22 MiB |
| 206e87e+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
| fa0d109+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
Previous results on branch: antonis/capture-app-start-errors-v8
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 82de722+dirty | 1213.09 ms | 1208.90 ms | -4.19 ms |
| 88812b1+dirty | 1216.63 ms | 1215.55 ms | -1.08 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 82de722+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
| 88812b1+dirty | 3.38 MiB | 4.67 MiB | 1.29 MiB |
|
@sentry review |
|
No noticeable impact on iOS, the app size increase by adding sentry on java is interesting though, but no extra impact from this PR. |
That's a good catch @lucas-zimerman 🤔 I wonder if this has to do with the Gradle Plugin bump #5578 on the v8 base branch #5501 |
| [ | ||
| "@sentry/react-native/expo", | ||
| { | ||
| "useNativeInit": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Do all sentry options work here? we should document this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only added option in the plugin. I've started a documentation PR in getsentry/sentry-docs#16170
Looking at it again I think the |
lucas-zimerman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a complete PR review and also loads of tokens, I can really say, LGTM!
# Conflicts: # CHANGELOG.md
|
@sentry review |
📢 Type of change
📜 Description
Follow up to #4472 (v6) > #5470 (v7) targeting v8 #5501
Capture App Start errors and crashes by initializing Sentry from
sentry.options.json(#4472)Create
sentry.options.jsonin the React Native project root and set options the same as you currently have inSentry.initin JS.{ "dsn": "https://key@example.io/value", }Initialize Sentry on the native layers by newly provided native methods.
Add RNSentrySDK APIs support to @sentry/react-native/expo plugin (#4633)
useNativeInitoption to automatically initialize Sentry natively before JavaScript loads, enabling capture of app start errors{ "expo": { "plugins": [ [ "@sentry/react-native/expo", { "useNativeInit": true } ] ] } }Changes
optionsFileinto the JS bundle during Metro bundle process (#4476)startWithConfigureOptionsfor Apple platforms (#4444)initwith optionalOptionsConfiguration<SentryAndroidOptions>for Android (#4451)sentry.options.jsonfor Apple platforms (#4447)sentry.options.jsonfor Android (#4451)Sentry.initoptions in JS (#4510)Internal
Note
The feature the feature should be 100% backwards compatible and opt-in. Users who don't create sentry.options.json or call RNSentrySDK.start()/init() will experience zero changes to their existing Sentry implementation. The traditional JS-only initialization path remains fully functional and is the default behavior.
📝 Documentation PR: getsentry/sentry-docs#16170
💡 Motivation and Context
Fixes #3608
Previously, React Native apps couldn't capture errors that occurred during app startup before JavaScript initialized, because Sentry was only initialized from JavaScript code (Sentry.init()). This meant crashes during:
were never captured.
💚 How did you test it?
CI, Manually
📝 Checklist
sendDefaultPIIis enabled🔮 Next steps
#skip-changelog