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
🚫 Please consider adding a changelog entry for the next release.

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

- [iOS + Android] Add the ability to intercept errors from native side and forward them to JS console ([#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 313b4e6

@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
@github-actions
Copy link
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 471.51 ms 527.06 ms 55.55 ms
Size 43.75 MiB 48.41 MiB 4.66 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
9a81842+dirty 412.23 ms 416.56 ms 4.33 ms
6c36ba5+dirty 385.48 ms 442.36 ms 56.88 ms
bc9680d 375.15 ms 401.12 ms 25.97 ms
eec00c2+dirty 447.08 ms 469.04 ms 21.96 ms
ebf60f9+dirty 378.38 ms 405.48 ms 27.10 ms
bfe454a+dirty 573.44 ms 579.46 ms 6.02 ms
20daa0a 359.51 ms 374.90 ms 15.39 ms
1bea095+dirty 401.42 ms 426.93 ms 25.52 ms
88890fe+dirty 350.94 ms 365.74 ms 14.80 ms
682f0f5+dirty 422.31 ms 431.87 ms 9.57 ms

App size

Revision Plain With Sentry Diff
9a81842+dirty 43.75 MiB 48.08 MiB 4.33 MiB
6c36ba5+dirty 43.75 MiB 48.41 MiB 4.66 MiB
bc9680d 17.75 MiB 20.15 MiB 2.41 MiB
eec00c2+dirty 43.75 MiB 48.05 MiB 4.29 MiB
ebf60f9+dirty 43.75 MiB 48.07 MiB 4.32 MiB
bfe454a+dirty 17.75 MiB 19.69 MiB 1.94 MiB
20daa0a 17.75 MiB 20.15 MiB 2.41 MiB
1bea095+dirty 17.75 MiB 19.70 MiB 1.95 MiB
88890fe+dirty 17.75 MiB 19.71 MiB 1.96 MiB
682f0f5+dirty 43.75 MiB 48.08 MiB 4.33 MiB

@github-actions
Copy link
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 377.38 ms 435.79 ms 58.41 ms
Size 43.94 MiB 49.27 MiB 5.33 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
9a81842+dirty 508.08 ms 566.65 ms 58.56 ms
af9331b+dirty 374.42 ms 425.68 ms 51.26 ms
6c36ba5+dirty 367.14 ms 426.80 ms 59.66 ms
eec00c2+dirty 367.00 ms 392.12 ms 25.12 ms
ec14be7+dirty 401.58 ms 475.26 ms 73.68 ms
170d5ea+dirty 348.79 ms 406.94 ms 58.15 ms
ebf60f9+dirty 398.18 ms 426.27 ms 28.08 ms
bc9680d+dirty 346.77 ms 463.48 ms 116.71 ms
90afdd3+dirty 367.79 ms 404.84 ms 37.05 ms
8db9631+dirty 351.44 ms 396.28 ms 44.84 ms

App size

Revision Plain With Sentry Diff
9a81842+dirty 43.94 MiB 48.91 MiB 4.97 MiB
af9331b+dirty 7.15 MiB 8.41 MiB 1.26 MiB
6c36ba5+dirty 43.94 MiB 49.27 MiB 5.33 MiB
eec00c2+dirty 43.94 MiB 48.87 MiB 4.93 MiB
ec14be7+dirty 7.15 MiB 8.42 MiB 1.26 MiB
170d5ea+dirty 7.15 MiB 8.42 MiB 1.27 MiB
ebf60f9+dirty 43.94 MiB 48.90 MiB 4.96 MiB
bc9680d+dirty 7.15 MiB 8.42 MiB 1.27 MiB
90afdd3+dirty 7.15 MiB 8.43 MiB 1.28 MiB
8db9631+dirty 7.15 MiB 8.43 MiB 1.28 MiB

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Let's skip the changes on this file since it's mainly formatting

Copy link
Contributor

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Awesome idea and execution @alwx 🎸

⚠️ 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

Since this requires a Cocoa change we may target v8 (or wait to be merged) since the v9 bumped required changes in the ObjC gluecode and there might be conflicts with the changes here.

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

3 participants