Repository navigation
Conversation
…n options getJSXElementActionPaths collected handler attributes with path.traverse, which also visits nested elements, so a tracked component inside another tracked component was wrapped with the outer element's ddValues (useContent/getContent) and then skipped on its own visit. Only accept handler attributes that belong to the element being processed. Fixes DataDog#1469
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused fix correctly addresses the traversal bug and includes coverage for both reported scenarios.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes nested tracked components inheriting their parent’s RUM options and content.
Changes:
- Restricts handler collection to the current JSX element.
- Adds regression tests for nested tracked components with and without parent handlers.
| File | Description |
|---|---|
packages/react-native-babel-plugin/src/actions/rum/index.ts |
Limits actionable handlers to direct attributes. |
packages/react-native-babel-plugin/test/plugin.test.ts |
Tests correct nested-component wrapping. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #1469.
In
getJSXElementActionPaths, handler attributes are collected withpath.traverse({ JSXAttribute }), which also visits nested elements. When a tracked component contains another tracked component, the inner component's handler was collected during the outer element's pass and wrapped with the outer element'sddValues(options.useContent,getContent); the inner element's ownJSXElementvisit then skipped it as__wrappedForRum.This PR only accepts handler attributes whose parent is the element being processed (
subpath.parentPath?.node === path.node.openingElement). Nested tracked elements are then wrapped on their own visit with their own options and content. Descendant collection ofdd-action-name/accessibilityLabelliterals (compound components) is unchanged.Two tests cover a tracked container with and without its own handler enclosing a tracked button; the existing suite (210 tests) passes.
Motivation
We track layout containers (Tamagui
XStack/YStack) withuseContent: falsefor their ownonPress, and every tracked button nested in one lost its content getter and reported as the bare component name. With auseContent: trueouter component the inner button instead reports the outer component's content.Additional Notes
The fix is a single condition; before/after output is in the issue.