Skip to content

Conversation

@alwx
Copy link
Contributor

@alwx alwx commented Feb 5, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Was born as an attempt to fix #5566 and turned out to be a good idea in general.
It also fixes #5242

This PR makes it possible to intercept native logs (currently only works with iOS and only with a patch, see notes below) and forward them to JS console:

Sentry.init({
  onNativeLog: ({ level, component, message }) => {
    // Use logWithoutTracing to avoid feedback loops with Sentry's console integration
    logWithoutTracing(`[Sentry Native] [${level.toUpperCase()}] [${component}] ${message}`);
  },
  debug: true,
}

(that only works when debug is set to true)

This PR makes it so that instead of handling HTTP code 413 somehow separately we can allow users to just get native logs in their JS console and see code 413 or any other error codes themselves. Filtering per level or component is also possible.

Notes

⚠️ Currently is works on Android without any further changes but on iOS it only works with a minor change to SentrySDKLog.swift. The change is done in this PR: getsentry/sentry-cocoa#7444

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • [iOS + Android] Add the ability to intercept errors from native side and forward them to JS console by alwx in #5622
  • chore(deps): update Bundler Plugins to v4.9.1 by github-actions in #5649
  • CI: update workflows with newer version of Xcode (+ iOS SDK) by alwx in #5635
  • chore(deps): update Android SDK to v8.32.0 by github-actions in #5633
  • chore(deps): bump getsentry/craft from 2.20.1 to 2.21.2 by dependabot in #5630
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.20.1 to 2.21.2 by dependabot in #5632
  • chore(deps): bump github/codeql-action from 4.32.0 to 4.32.2 by dependabot in #5631
  • feat(feedback): Add autoCorrect and spellCheck config to FeedbackWidget by sbs44 in #5627
  • fix(feedback): Deep merge custom styles with defaults in FeedbackWidget by sbs44 in #5625

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 5, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
🚫 Please consider adding a changelog entry for the next release.
Warnings
⚠️

🤖 Replay Stubs Check

No changes detected in replay-stubs.jar

All file contents are identical (verified by SHA-256 hash comparison).

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- An (ongoing) experiment with adding native logs listener ([#5622](https://github.com/getsentry/sentry-react-native/pull/5622))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against 365ab16

@alwx alwx force-pushed the alwx/experiment/native-logs branch from 2108fe1 to f369c1d Compare February 9, 2026 12:40
@alwx alwx changed the title WIP: An (ongoing) experiment with adding native logs listener Native logs listener Feb 10, 2026
@alwx alwx changed the title Native logs listener Native logs listener to intercept errors from native side and forward them to JS console Feb 10, 2026
@alwx alwx changed the title Native logs listener to intercept errors from native side and forward them to JS console Intercept errors from native side and forward them to JS console Feb 10, 2026
@alwx alwx changed the title Intercept errors from native side and forward them to JS console Add the ability to intercept errors from native side and forward them to JS console Feb 10, 2026
@alwx alwx self-assigned this Feb 10, 2026
@alwx alwx marked this pull request as ready for review February 10, 2026 10:51
@alwx alwx added the ready-to-merge Triggers the full CI test suite label Feb 10, 2026
@alwx alwx changed the title Add the ability to intercept errors from native side and forward them to JS console [iOS only] Add the ability to intercept errors from native side and forward them to JS console Feb 10, 2026
Copy link
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far it's looking good! I left a few suggestions that would be nice to be addressed before merging.

@alwx alwx changed the title [iOS only] Add the ability to intercept errors from native side and forward them to JS console [iOS + Android] Add the ability to intercept errors from native side and forward them to JS console Feb 12, 2026
@alwx
Copy link
Contributor Author

alwx commented Feb 12, 2026

I've updated this PR to support Android as well (that was easy on Android because all the required methods are already there) 🎉

@alwx alwx requested a review from lucas-zimerman February 12, 2026 10:32
@alwx alwx force-pushed the alwx/experiment/native-logs branch from 524e190 to 313b4e6 Compare February 12, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SDK Handling HTTP 413 [React Native] Show Native Logs

2 participants