Skip to content

Commit

Permalink
fix(rn): Add mission labelName option to touchevents (#8540)
Browse files Browse the repository at this point in the history
Co-authored-by: Shana Matthews <[email protected]>
  • Loading branch information
krystofwoldrich and shanamatthews authored Nov 22, 2023
1 parent 54fe3a8 commit 3eeab91
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/platforms/react-native/touchevents/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Each touch event is automatically logged as a breadcrumb and displays on the das

## Tracking Specific Components

You can let Sentry know which components to track specifically by passing the `sentry-label` prop to them. If Sentry detects a component with a `sentry-label` within a touch's component tree, it will be logged on the dashboard as having occurred in that component. If we cannot find a component with the label, we will fall back to the `accessibilityLabel` prop.
You can let Sentry know which components to track specifically by passing the `sentry-label` prop to them. If Sentry detects a component with a `sentry-label` within a touch's component tree, it will be logged on the dashboard as having occurred in that component. If Sentry cannot find a component with the label, Sentry will fall back to the `labelName` prop if specified, or else use `displayName`.

```javascript
const YourCoolComponent = (props) => {
Expand All @@ -77,13 +77,23 @@ You can pass specific options to configure the boundary either as props to the `
```javascript{tabTitle:Default}
<Sentry.TouchEventBoundary
ignoreNames={["BadComponent", /^Connect\(/, /^LibraryComponent$/]}
labelName="testLabel"
>
<RestOfTheApp />
</Sentry.TouchEventBoundary>
```

```javascript{tabTitle:HOC}
Sentry.withTouchEventBoundary(App, { maxComponentTreeSize: 15 });
Sentry.withTouchEventBoundary(App, { maxComponentTreeSize: 15, labelName: "testLabel" });
```

```javascript{tabTitle:Sentry.wrap()}
Sentry.wrap(App, {
touchEventBoundaryProps: {
ignoreNames: ["BadComponent", /^Connect\(/, /^LibraryComponent$/]
labelName: 'accessibilityLabel',
},
}
```

`breadcrumbCategory`
Expand All @@ -102,6 +112,10 @@ Sentry.withTouchEventBoundary(App, { maxComponentTreeSize: 15 });

: _Array<string | RegExp>, Accepts strings and regular expressions_. Component names to ignore when logging the touch event. This prevents unhelpful logs such as "Touch event within element: View" where you still can't tell which `View` it occurred in.

`labelName`

: _String_. The name of the prop to look for when determining the label of a component. If the prop is not found, Sentry will fall back to the `displayName` of the component.

## Minified Names in Production

When bundling for production, React Native will minify class and function names to reduce the bundle size. This means that **you won't get the full original component names in your touch event breadcrumbs** and instead you will see minified names. Check out our [troubleshooting guide for minified production bundles](/platforms/react-native/troubleshooting/#minified-names-in-production) documentation to solve this.

1 comment on commit 3eeab91

@vercel
Copy link

@vercel vercel bot commented on 3eeab91 Nov 22, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs.sentry.dev
docs.sentry.io
sentry-docs-git-master.sentry.dev

Please sign in to comment.