Skip to content

feat(RN): Touch event boundary now take a sentry-label prop #4766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions src/platforms/react-native/touchevents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,39 @@ 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 setting the `displayName` property for them. If Sentry detects a component with a `displayName` within a touch's component tree, it will be logged on the dashboard as having occurred in that component.
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.

```javascript
class YourCoolComponent extends React.Component {
static displayName = "CoolComponent";
render() {
return <View>{/* ... */}</View>;
}
}
const YourCoolComponent = props => {
return (
<View sentry-label="CardContainer">
<Text sentry-label="CoolText">
You are cool
</Text>
</View>
);
};
```

or
<Note>

```javascript
const YourCoolComponent = props => {
return <View>{/* ... */}</View>;
};
You don't have to worry about Typescript errors when passing the `sentry-label` prop. [Typescript will not throw an error on props with the '-' character](https://www.typescriptlang.org/docs/handbook/jsx.html#attribute-type-checking).

YourCoolComponent.displayName = "CoolComponent";
```
</Note>

## Options

You can pass specific options to configure the boundary either as props to the `Sentry.TouchEventBoundary` component or as the second argument to the `Sentry.withTouchEventBoundary` higher-order component (HOC).

```javascript
```javascript{tabTitle:Default}
<Sentry.TouchEventBoundary
ignoreNames={["BadComponent", /^Connect\(/, /^LibraryComponent$/]}
>
<RestOfTheApp />
</Sentry.TouchEventBoundary>
```

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

Expand All @@ -103,7 +102,7 @@ Sentry.withTouchEventBoundary(App, { maxComponentTreeSize: 15 });

`ignoreNames`

: _Array<string | RegExp>, Accepts strings and regular expressions_. (New in version 1.7.0) 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.
: _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.

## Minified Names in Production

Expand Down