Skip to content

Comments

feat: Handle wrapped onPress event in DdEventsInterceptor for react-native-ui-lib compatibility#1157

Open
jhssilva wants to merge 1 commit intoDataDog:developfrom
jhssilva:hugo.silva/events-interceptor-action
Open

feat: Handle wrapped onPress event in DdEventsInterceptor for react-native-ui-lib compatibility#1157
jhssilva wants to merge 1 commit intoDataDog:developfrom
jhssilva:hugo.silva/events-interceptor-action

Conversation

@jhssilva
Copy link
Contributor

@jhssilva jhssilva commented Feb 23, 2026

What does this PR do?

  • Adds fallback event resolution in DdEventsInterceptor.interceptOnPress to handle third-party libraries that wrap the native GestureResponderEvent inside a props object (e.g. react-native-ui-lib passes {...componentProps, event: GestureResponderEvent} instead of the raw event)
  • When args[0]._targetInst is not found (standard RN path), the interceptor now checks args[0].event._targetInst before dropping the action
  • Adds 4 new test cases covering the wrapped event pattern, including positive tracking and correct drop behavior for invalid/missing nested events

Motivation

  • react-native-ui-lib's TouchableOpacity wraps the native GestureResponderEvent inside a props object before passing it to onPress, causing the args[0]._targetInst check to fail and RUM actions to be silently dropped
Source args[0] Has _targetInst? Link
Native RN TouchableOpacity GestureResponderEvent Yes Pressability.js#L547
react-native-ui-lib (main) {...props, event: GestureResponderEvent} No — nested under .event touchableOpacity/index.tsx#L175
react-native-ui-lib (Incubator) props (no event at all) No incubator/TouchableOpacity.tsx#L94

Note: The Incubator variant remains unsupported — it uses react-native-gesture-handler's TapGestureHandler which never produces a GestureResponderEvent, so there is no native event to extract.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

Some third-party libraries (e.g. react-native-ui-lib) change the onPress
callback signature by wrapping the native GestureResponderEvent inside a
props object: onPress({...componentProps, event: GestureResponderEvent}).

The SDK checks args[0]._targetInst to identify the tapped element, which
only exists on the native event — not on the wrapper object — causing
actions to be silently dropped.

This adds a fallback in DdEventsInterceptor.interceptOnPress that checks
args[0].event._targetInst when args[0]._targetInst is not present,
allowing the SDK to extract the native event from the wrapper.
@jhssilva jhssilva marked this pull request as ready for review February 23, 2026 11:26
@jhssilva jhssilva requested a review from a team as a code owner February 23, 2026 11:26
Copy link
Contributor

@cdn34dd cdn34dd left a comment

Choose a reason for hiding this comment

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

Looks good, also open one for feature/v2.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants