@@ -30,7 +30,7 @@ Sentry.init({
30
30
dsn: " ___PUBLIC_DSN___" ,
31
31
32
32
integrations: [
33
- new Sentry.Tracing. ReactNativeTracing ({
33
+ new Sentry.ReactNativeTracing ({
34
34
tracingOrigins: [" localhost" , " my-site-url.com" , / ^ \/ / ],
35
35
// ... other options
36
36
}),
@@ -72,12 +72,12 @@ Note that this routing instrumentation will create a transaction on every route
72
72
import * as Sentry from " @sentry/react-native" ;
73
73
74
74
// Construct a new instrumentation instance. This is needed to communicate between the integration and React
75
- const reactNavigationV5Instrumentation = new Sentry.Tracing. ReactNavigationV5Instrumentation ();
75
+ const reactNavigationV5Instrumentation = new Sentry.ReactNavigationV5Instrumentation ();
76
76
77
77
Sentry .init ({
78
78
...
79
79
integrations: [
80
- new Sentry.Tracing. ReactNativeTracing ({
80
+ new Sentry.ReactNativeTracing ({
81
81
// Pass instrumentation to be used as `routingInstrumentation`
82
82
routingInstrumentation: reactNavigationV5Instrumentation,
83
83
// ...
@@ -110,24 +110,25 @@ You can configure this instrumentation by passing an object as the first argumen
110
110
` shouldSendTransaction ` (route, previousRoute) => boolean
111
111
112
112
``` js
113
-
114
- const reactNavigationV5Instrumentation = new Sentry.Tracing.ReactNavigationV5Instrumentation ({
115
- shouldSendTransaction : (route , previousRoute ) => {
116
- if (route .name === ' Ignore-Route' ) {
117
- return false ;
118
- }
119
-
120
- if (route .params .containsSensitiveInfo ) {
121
- return false ;
122
- }
123
-
124
- if (previousRoute .name === ' ShouldIgnoreAfter' ) {
125
- return false ;
126
- }
127
-
128
- return true ;
113
+ const reactNavigationV5Instrumentation = new Sentry.ReactNavigationV5Instrumentation (
114
+ {
115
+ shouldSendTransaction : (route , previousRoute ) => {
116
+ if (route .name === " Ignore-Route" ) {
117
+ return false ;
118
+ }
119
+
120
+ if (route .params .containsSensitiveInfo ) {
121
+ return false ;
122
+ }
123
+
124
+ if (previousRoute .name === " ShouldIgnoreAfter" ) {
125
+ return false ;
126
+ }
127
+
128
+ return true ;
129
+ },
129
130
}
130
- } );
131
+ );
131
132
132
133
// ...
133
134
```
@@ -138,12 +139,12 @@ Note that this routing instrumentation will create a transaction on every route
138
139
139
140
``` js
140
141
// Construct a new instrumentation instance. This is needed to communicate between the integration and React
141
- const reactNavigationV4Instrumentation = new Sentry.Tracing. ReactNavigationV4Instrumentation ();
142
+ const reactNavigationV4Instrumentation = new Sentry.ReactNavigationV4Instrumentation ();
142
143
143
144
Sentry .init ({
144
145
...
145
146
integrations: [
146
- new Sentry.Tracing. ReactNativeTracing ({
147
+ new Sentry.ReactNativeTracing ({
147
148
// Pass instrumentation to be used as `routingInstrumentation`
148
149
routingInstrumentation: reactNavigationV4Instrumentation,
149
150
...
@@ -174,25 +175,26 @@ You can configure this instrumentation by passing an object as the first argumen
174
175
` shouldSendTransaction ` (route, previousRoute) => boolean
175
176
176
177
``` js
177
-
178
- const reactNavigationV4Instrumentation = new Sentry.Tracing.ReactNavigationV4Instrumentation ({
179
- shouldSendTransaction : (route , previousRoute ) => {
180
- // Note that it is route.routeName here and NOT route.name like in V5, this is directly from React-Navigation
181
- if (route .routeName === ' Ignore-Route' ) {
182
- return false ;
183
- }
184
-
185
- if (route .params .containsSensitiveInfo ) {
186
- return false ;
187
- }
188
-
189
- if (previousRoute .name === ' ShouldIgnoreAfter' ) {
190
- return false ;
191
- }
192
-
193
- return true ;
178
+ const reactNavigationV4Instrumentation = new Sentry.ReactNavigationV4Instrumentation (
179
+ {
180
+ shouldSendTransaction : (route , previousRoute ) => {
181
+ // Note that it is route.routeName here and NOT route.name like in V5, this is directly from React-Navigation
182
+ if (route .routeName === " Ignore-Route" ) {
183
+ return false ;
184
+ }
185
+
186
+ if (route .params .containsSensitiveInfo ) {
187
+ return false ;
188
+ }
189
+
190
+ if (previousRoute .name === " ShouldIgnoreAfter" ) {
191
+ return false ;
192
+ }
193
+
194
+ return true ;
195
+ },
194
196
}
195
- } );
197
+ );
196
198
197
199
// ...
198
200
```
@@ -211,12 +213,12 @@ You need to ensure that this method is called **before** the route change occurs
211
213
212
214
``` js
213
215
// Construct a new instrumentation instance. This is needed to communicate between the integration and React
214
- const routingInstrumentation = new Sentry.Tracing. RoutingInstrumentation ();
216
+ const routingInstrumentation = new Sentry.RoutingInstrumentation ();
215
217
216
218
Sentry .init ({
217
219
...
218
220
integrations: [
219
- new Sentry.Tracing. ReactNativeTracing ({
221
+ new Sentry.ReactNativeTracing ({
220
222
// Pass instrumentation to be used as `routingInstrumentation`
221
223
routingInstrumentation,
222
224
...
@@ -237,27 +239,24 @@ const App = () => {
237
239
};
238
240
```
239
241
240
-
241
242
#### Extending
242
243
243
-
244
244
``` js
245
245
class CustomInstrumentation extends RoutingInstrumentation {
246
-
247
246
constructor (navigator ) {
248
247
super ();
249
-
248
+
250
249
this .navigator .registerRouteChangeListener (this .routeListener .bind (this ));
251
250
}
252
-
251
+
253
252
routeListener (newRoute ) {
254
253
// Again, ensure this is called BEFORE the route changes and BEFORE the route is mounted.
255
254
this .onRouteWillChange ({
256
255
name: newRoute .name ,
257
- op: ' navigation'
256
+ op: " navigation" ,
258
257
});
259
258
}
260
259
}
261
260
```
262
261
263
- More extensive extension examples is by looking at our code for the React Navigation instrumentations.
262
+ More extensive extension examples is by looking at our code for the React Navigation instrumentations.
0 commit comments