ref(logs): Intercept Native SDK logs#1249
Conversation
…gs to JS Migrated from sentry-react-native#5622. Adds an `onNativeLog` option that lets users surface native SDK logs (e.g. HTTP 413 transport errors) in the browser console when `debug: true` is set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fyListeners Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
…/sentry-capacitor into lz/intercept-js-errors
…/sentry-capacitor into lz/intercept-js-errors
…o resolve Swift concurrency warning Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| if (nativeOptions.debug) { | ||
| const logHandler = nativeOptions.onNativeLog ?? defaultNativeLogHandler; | ||
| setupNativeLogListener(logHandler); | ||
| } |
There was a problem hiding this comment.
Re-init leaves log forwarding
Medium Severity
After init runs with debug: true, a later init without close() never tears down native log forwarding. sdkInit only calls setupNativeLogListener when debug is true and never calls stopNativeLogListener when it is false, and setupNativeLogListener ignores further calls while a listener is already registered.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit 99baf27. Configure here.
There was a problem hiding this comment.
q: Is the move of Package.resolved moved to root intentional?
There was a problem hiding this comment.
not really, let me rollback
antonis
left a comment
There was a problem hiding this comment.
Other than the package move LGTM
SDK libraries should not commit Package.resolved — SPM ignores it from dependencies and only the consuming app's lock file is used. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| @@ -1,23 +0,0 @@ | |||
| { | |||
There was a problem hiding this comment.
Tooling opted to not have this file
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 19cae50. Configure here.
| androidLogger.log(level, message, args); | ||
|
|
||
| String formattedMessage = | ||
| (args == null || args.length == 0) ? message : String.format(message, args); |
There was a problem hiding this comment.
Unprotected String.format can throw uncaught exception
Medium Severity
The String.format(message, args) calls in the log methods are not wrapped in try-catch. The underlying AndroidLogger.log() internally catches IllegalFormatException from malformed format strings (this was a known crash, sentry-java#1985), but the subsequent String.format call in CapSentryLogger lacks this same protection. If format specifiers in message don't match args, an IllegalFormatException will propagate uncaught into the SDK internals.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 19cae50. Configure here.


📢 Type of change
📜 Description
Based on getsentry/sentry-react-native#5622
This PR redirects native Sentry logs to be visible along with the JavaScript logs
💡 Motivation and Context
Allow users to see all SDK logs on a unified way.
💚 How did you test it?
Android logs

iOS

📝 Checklist
sendDefaultPIIis enabled🔮 Next steps
Close #1093