Skip to content

Commit 81d5650

Browse files
authored
feat(RN): Touch event boundary now take a sentry-label prop (#4766)
1 parent ce079ff commit 81d5650

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/platforms/react-native/touchevents.mdx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,39 @@ Each touch event is automatically logged as a breadcrumb and displays on the das
5252

5353
## Tracking Specific Components
5454

55-
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.
55+
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.
5656

5757
```javascript
58-
class YourCoolComponent extends React.Component {
59-
static displayName = "CoolComponent";
60-
render() {
61-
return <View>{/* ... */}</View>;
62-
}
63-
}
58+
const YourCoolComponent = props => {
59+
return (
60+
<View sentry-label="CardContainer">
61+
<Text sentry-label="CoolText">
62+
You are cool
63+
</Text>
64+
</View>
65+
);
66+
};
6467
```
6568

66-
or
69+
<Note>
6770

68-
```javascript
69-
const YourCoolComponent = props => {
70-
return <View>{/* ... */}</View>;
71-
};
71+
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).
7272

73-
YourCoolComponent.displayName = "CoolComponent";
74-
```
73+
</Note>
7574

7675
## Options
7776

7877
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).
7978

80-
```javascript
79+
```javascript{tabTitle:Default}
8180
<Sentry.TouchEventBoundary
8281
ignoreNames={["BadComponent", /^Connect\(/, /^LibraryComponent$/]}
8382
>
8483
<RestOfTheApp />
8584
</Sentry.TouchEventBoundary>
8685
```
8786

88-
```javascript
87+
```javascript{tabTitle:HOC}
8988
Sentry.withTouchEventBoundary(App, { maxComponentTreeSize: 15 });
9089
```
9190

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

104103
`ignoreNames`
105104

106-
: _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.
105+
: _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.
107106

108107
## Minified Names in Production
109108

0 commit comments

Comments
 (0)