sentry-react-native icon indicating copy to clipboard operation
sentry-react-native copied to clipboard

Link Components Stack to Source Code (touch breadcrumbs, jsx errors)

Open krystofwoldrich opened this issue 2 years ago • 1 comments

Description

Currently, we send components stack as reported by React:

    in div (created by HomeScreen)
    in ErrorBoundary (created by HomeScreen)
    in RCTScrollContentView (created by ScrollView)
    in RCTScrollView (created by ScrollView)
    in ScrollView (created by ScrollView)
    in ScrollView (created by HomeScreen)
    in HomeScreen (created by SceneView)
    in StaticContainer

We could explore @babel/plugin-transform-react-jsx-source to include components source code in the components stack.

How does the plugin work: https://babeljs.io/docs/babel-plugin-transform-react-jsx-source

Example with the sources: Screenshot 2023-09-18 at 19 14 58

krystofwoldrich avatar Sep 18 '23 14:09 krystofwoldrich

Sentry Component Annotate Plugin

https://www.npmjs.com/package/@sentry/babel-plugin-component-annotate

Adds the source file name, we could utilize this in RN as well.

<div
  data-sentry-component="MyAwesomeComponent"
  data-sentry-source-file="myAwesomeComponent.jsx"
>
  This is a really cool and awesome component!
</div>

https://docs.sentry.io/platforms/javascript/guides/react/features/component-names/#how-it-works

krystofwoldrich avatar Jun 13 '24 08:06 krystofwoldrich