@@ -135,33 +135,30 @@ The starter kit did not come with Sentry pre-configured, but it's very easy to s
135135 Create a new file ` src/lib/sentry.ts ` and add the following code:
136136
137137 ``` tsx title='src/lib/sentry.ts'
138+ import { Env } from ' @env' ;
139+ import * as Sentry from ' @sentry/react-native' ;
138140 import { useNavigationContainerRef } from ' expo-router' ;
139141 import { useEffect } from ' react' ;
140- import * as Sentry from ' @sentry/react-native' ;
141- import { Env } from ' @env' ;
142142
143- const routingInstrumentation = new Sentry .ReactNavigationInstrumentation ();
143+ const navigationIntegration = Sentry .reactNavigationIntegration ({
144+ enableTimeToInitialDisplay: true ,
145+ });
144146
145147 export const initSentry = () => {
146- Sentry .init ({
147- dsn: Env .SENTRY_DSN ,
148- // debug: Env.APP_ENV === 'development',
149- integrations: [
150- new Sentry .ReactNativeTracing ({
151- routingInstrumentation ,
152- enableNativeFramesTracking: true ,
153- // ...
154- }),
155- ],
156- });
148+ if (! __DEV__ ) {
149+ Sentry .init ({
150+ dsn: Env .SENTRY_DSN ,
151+ integrations: [navigationIntegration ],
152+ });
153+ }
157154 };
158155
159156 export const useSentryNavigationConfig = () => {
160157 const navigationRef = useNavigationContainerRef ();
161158
162159 useEffect (() => {
163- if (navigationRef ) {
164- routingInstrumentation .registerNavigationContainer (navigationRef );
160+ if (navigationRef && ! __DEV__ ) {
161+ navigationIntegration .registerNavigationContainer (navigationRef );
165162 }
166163 }, [navigationRef ]);
167164 };
0 commit comments