Skip to content

feat(core): Extend TurboModule instrumentation to legacy NativeModules#6504

Draft
alwx wants to merge 1 commit into
alwx/feature/6165from
alwx/features/6166
Draft

feat(core): Extend TurboModule instrumentation to legacy NativeModules#6504
alwx wants to merge 1 commit into
alwx/feature/6165from
alwx/features/6166

Conversation

@alwx

@alwx alwx commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • New feature

📜 Description

Extends the TurboModule aggregate + span attribution + slow-call breadcrumb surface (from #6377 and #6478) to Old Architecture apps by wrapping NativeModules.* at setup. Consumer side stays identical — only the arch field distinguishes new-arch ('new') vs bridge ('legacy') sources.

Approach

This ships the JS Proxy path. The native BridgeNativeModulePerfLogger path (option 1) is symmetric but requires new C++/JNI code and a version gate — left for a follow-up. The JS approach works on every RN version we support and has the same shape as the existing TurboModule wrap; hot-path cost is bounded (one property access + function call per bridge invocation).

💡 Motivation and Context

TurboModulePerfLogger only fires for TurboModules, so apps on the Old Architecture were dark to the entire aggregator / span-attribution / breadcrumb surface. This PR closes that gap so the long tail of un-migrated apps gets the same signals.

Closes #6166.

💚 How did you test it?

There are a few tests added!

📝 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.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

@github-actions

Copy link
Copy Markdown
Contributor

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).


  • feat(core): Extend TurboModule instrumentation to legacy NativeModules by alwx in #6504
  • feat(core): Attach TurboModule breakdown to active spans on spanEnd by alwx in #6478
  • fix(android): make Sentry Gradle tasks Configuration Cache compatible by fabiendem in #6469
  • docs: Update 8.19.0 changelog by antonis in #6498
  • chore(deps): bump fast-uri from 3.1.2 to 3.1.4 by dependabot in #6496
  • chore(deps): pin glob 10.x to ^10.5.0 (dev-only advisory) by antonis in #6489
  • chore(deps): bump brace-expansion resolutions to ^2.1.2 (dev-only advisory) by antonis in #6488
  • chore(deps): add cross-spawn ^7.0.6 resolution (dev-only advisory) by antonis in #6487
  • chore(deps): bump js-yaml resolution to ^4.3.0 (dev-only advisory) by antonis in #6486
  • chore(deps): update CLI to v3.6.1 by github-actions in #6493
  • chore(deps): update JavaScript SDK to v10.67.0 by github-actions in #6494
  • chore(deps): update JavaScript SDK to v10.66.0 by github-actions in #6471
  • chore(deps): update Maestro to v2.7.0 by github-actions in #6481
  • chore(ios): Bump iOS binary size limit to 1650 KiB by antonis in #6485
  • chore(deps): bump tar from 7.5.16 to 7.5.20 by dependabot in #6483
  • chore(deps): bump shell-quote from 1.8.4 to 1.10.0 by dependabot in #6484
  • chore(deps): bump the codeql-action group with 3 updates by dependabot in #6475
  • chore(deps): bump brace-expansion from 1.1.13 to 1.1.16 by dependabot in #6482
  • chore(deps): bump axios from 1.16.0 to 1.18.1 by dependabot in #6479
  • chore(deps): bump actions/setup-java from 5.5.0 to 5.6.0 by dependabot in #6476

🤖 This preview updates automatically when you update the PR.

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor
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.
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

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

- Extend TurboModule instrumentation to legacy NativeModules ([#6504](https://github.com/getsentry/sentry-react-native/pull/6504))

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 e8e56a6

Wraps `NativeModules.*` on the Old Architecture so bridge calls flow
through the same aggregator, span-attribution, and slow-call breadcrumb
surface as TurboModules on the New Architecture.

- Adds `arch: 'new' | 'legacy'` to TurboModuleRecord / TurboModuleAggregate
  / TurboModuleCallStart, threaded through `wrapTurboModule`, and folded
  into the aggregate key so new-arch and legacy calls stay separate on
  flush.
- New `wrapAllNativeModules` enumerates `NativeModules` on the Old Arch
  and wraps each registered module (skipping RNSentry, which the
  integration wraps explicitly with a curated recursion-safe skip list).
- `turboModuleContextIntegration` auto-invokes it on the Old Arch. Opt
  out with `enableLegacyNativeModules: false`, or scope with
  `legacyModulesSkip` / `legacyModulesSkipMethods`.
- Aggregate flush emits `turbo_modules.<name>.<method>.<kind>.arch`;
  attributed spans get a top-level `turbo_module.arch` derived from
  `isTurboModuleEnabled()` at integration construction (an app doesn't
  switch archs at runtime).

Closes #6166.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@alwx
alwx force-pushed the alwx/features/6166 branch from 6c180fc to e8e56a6 Compare July 23, 2026 08:54
@alwx

alwx commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e8e56a6. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant