@@ -8,9 +8,10 @@ import {createStackNavigator} from '@react-navigation/stack';
8
8
9
9
// Import the Sentry React Native SDK
10
10
import * as Sentry from '@sentry/react-native' ;
11
+ import { TransactionContext } from '@sentry/types' ;
11
12
12
13
import HomeScreen from './screens/HomeScreen' ;
13
- import ListApp from './screens/ListApp'
14
+ import ListApp from './screens/ListApp' ;
14
15
import TrackerScreen from './screens/TrackerScreen' ;
15
16
import ManualTrackerScreen from './screens/ManualTrackerScreen' ;
16
17
import PerformanceTimingScreen from './screens/PerformanceTimingScreen' ;
@@ -24,45 +25,45 @@ import Toast from 'react-native-toast-message';
24
25
import { store } from './reduxApp' ;
25
26
import { DSN } from './config' ;
26
27
import { SE } from '@env' ; // SE is undefined if no .env file is set
27
- console . log ( "> SE" , SE )
28
+ import { RootStackParamList } from './navigation' ;
29
+ console . log ( '> SE' , SE ) ;
28
30
29
- const reactNavigationV5Instrumentation = new Sentry . ReactNavigationV5Instrumentation (
30
- {
31
+ const reactNavigationV5Instrumentation =
32
+ new Sentry . ReactNavigationV5Instrumentation ( {
31
33
// How long it will wait for the route change to complete. Default is 1000ms
32
34
routeChangeTimeoutMs : 500 ,
33
- } ,
34
- ) ;
35
+ } ) ;
35
36
36
37
// Get app version from package.json, for fingerprinting
37
38
const packageJson = require ( '../package.json' ) ;
38
39
39
40
Sentry . init ( {
40
41
dsn : DSN ,
41
42
debug : true ,
42
- environment : " dev" ,
43
+ environment : ' dev' ,
43
44
beforeSend : ( event ) => {
44
- if ( SE === " tda" ) {
45
+ if ( SE === ' tda' ) {
45
46
// Make issues unique to the release (app version) for Release Health
46
- event . fingerprint = [ '{{ default }}' , SE , packageJson . version ] ;
47
+ event . fingerprint = [ '{{ default }}' , SE , packageJson . version ] ;
47
48
} else if ( SE ) {
48
49
// Make issue for the SE
49
- event . fingerprint = [ '{{ default }}' , SE ] ;
50
+ event . fingerprint = [ '{{ default }}' , SE ] ;
50
51
}
51
52
return event ;
52
53
} ,
53
54
integrations : [
54
55
new Sentry . ReactNativeTracing ( {
55
56
routingInstrumentation : reactNavigationV5Instrumentation ,
56
57
tracingOrigins : [ 'localhost' , / ^ \/ / , / ^ h t t p s : \/ \/ / ] ,
57
- idleTimeout : 15000 // set to prevent spans in the home screen from cancelling prematurely
58
+ idleTimeout : 15000 , // set to prevent spans in the home screen from cancelling prematurely
58
59
59
60
// How to ignore transactions for the "Manual Tracker" screen
60
- // beforeNavigate: (context: Sentry.ReactNavigationTransactionContext ) => {
61
- // if (context.data.route.name === 'ManualTracker') {
62
- // context.sampled = false;
63
- // }
64
- // return context;
65
- // },
61
+ beforeNavigate : ( context : TransactionContext ) => {
62
+ if ( context . data ? .route . name === 'ManualTracker' ) {
63
+ context . sampled = false ;
64
+ }
65
+ return context ;
66
+ } ,
66
67
} ) ,
67
68
] ,
68
69
tracesSampleRate : 1.0 ,
@@ -74,21 +75,32 @@ Sentry.init({
74
75
75
76
Sentry . setTag ( 'se' , SE ) ;
76
77
77
- const Stack = createStackNavigator ( ) ;
78
+ const Stack = createStackNavigator < RootStackParamList > ( ) ;
78
79
79
80
const App = ( ) => {
80
81
const navigation = React . useRef < NavigationContainerRef < [ ] > | null > ( null ) ;
81
82
82
- Sentry . configureScope ( scope => {
83
- const customerType = [ "medium-plan" , "large-plan" , "small-plan" , "enterprise" ] [ Math . floor ( Math . random ( ) * 4 ) ]
84
- scope . setTag ( "customerType" , customerType )
85
- let email = Math . random ( ) . toString ( 36 ) . substring ( 2 , 6 ) + "@yahoo.com" ;
86
- scope . setUser ( { email : email } )
87
- } )
83
+ Sentry . configureScope ( ( scope ) => {
84
+ const customerType = [
85
+ 'medium-plan' ,
86
+ 'large-plan' ,
87
+ 'small-plan' ,
88
+ 'enterprise' ,
89
+ ] [ Math . floor ( Math . random ( ) * 4 ) ] ;
90
+ scope . setTag ( 'customerType' , customerType ) ;
91
+ let email = Math . random ( ) . toString ( 36 ) . substring ( 2 , 6 ) + '@yahoo.com' ;
92
+ scope . setUser ( { email : email } ) ;
93
+ } ) ;
88
94
89
95
return (
90
96
< Provider store = { store } >
91
- < NavigationContainer >
97
+ < NavigationContainer
98
+ ref = { navigation }
99
+ onReady = { ( ) => {
100
+ reactNavigationV5Instrumentation . registerNavigationContainer (
101
+ navigation ,
102
+ ) ;
103
+ } } >
92
104
< Stack . Navigator >
93
105
< Stack . Screen name = "Home" component = { HomeScreen } />
94
106
< Stack . Screen name = "Tracker" component = { TrackerScreen } />
@@ -104,7 +116,7 @@ const App = () => {
104
116
< Stack . Screen name = "ListApp" component = { ListApp } />
105
117
< Stack . Screen name = "Checkout" component = { CheckoutScreen } />
106
118
</ Stack . Navigator >
107
- < Toast />
119
+ < Toast />
108
120
</ NavigationContainer >
109
121
</ Provider >
110
122
) ;
0 commit comments