···1011import 'view/icons'
1213-import {withSentry} from 'lib/sentry'
14import {ThemeProvider} from 'lib/ThemeContext'
15import {s} from 'lib/styles'
16import {RootStoreModel, setupState, RootStoreProvider} from './state'
···62 )
63})
6465-export default withSentry(App)
···1011import 'view/icons'
12013import {ThemeProvider} from 'lib/ThemeContext'
14import {s} from 'lib/styles'
15import {RootStoreModel, setupState, RootStoreProvider} from './state'
···61 )
62})
6364+export default App
-7
src/Navigation.tsx
···34import {router} from './routes'
35import {usePalette} from 'lib/hooks/usePalette'
36import {useStores} from './state'
37-import {getRoutingInstrumentation} from 'lib/sentry'
38import {bskyTitle} from 'lib/strings/headings'
39import {JSX} from 'react/jsx-runtime'
40import {timeout} from 'lib/async/timeout'
···478 )
479 console.log(`Time to first paint: ${initMs} ms`)
480 logModuleInitTrace()
481-482- // Register the navigation container with the Sentry instrumentation (only works on native)
483- if (isNative) {
484- const routingInstrumentation = getRoutingInstrumentation()
485- routingInstrumentation.registerNavigationContainer(navigationRef)
486- }
487 }}>
488 {children}
489 </NavigationContainer>
···34import {router} from './routes'
35import {usePalette} from 'lib/hooks/usePalette'
36import {useStores} from './state'
037import {bskyTitle} from 'lib/strings/headings'
38import {JSX} from 'react/jsx-runtime'
39import {timeout} from 'lib/async/timeout'
···477 )
478 console.log(`Time to first paint: ${initMs} ms`)
479 logModuleInitTrace()
000000480 }}>
481 {children}
482 </NavigationContainer>
+2-46
src/lib/sentry.ts
···1-import {isNative, isWeb} from 'platform/detection'
2-import {FC} from 'react'
3-import * as Sentry from 'sentry-expo'
4-5-// Sentry Initialization
6-7-export const getRoutingInstrumentation = () => {
8- return new Sentry.Native.ReactNavigationInstrumentation() // initialize this in `onReady` prop of NavigationContainer
9-}
1011-Sentry.init({
12 dsn: 'https://05bc3789bf994b81bd7ce20c86ccd3ae@o4505071687041024.ingest.sentry.io/4505071690514432',
13 enableInExpoDevelopment: false, // if true, Sentry will try to send events/errors in development mode.
14 debug: false, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
15 environment: __DEV__ ? 'development' : 'production', // Set the environment
16- // @ts-ignore exists but not in types, see https://docs.sentry.io/platforms/react-native/configuration/options/#enableAutoPerformanceTracking
17- enableAutoPerformanceTracking: true, // Enable auto performance tracking
18- tracesSampleRate: 0.5, // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // TODO: this might be too much in production
19- _experiments: {
20- // The sampling rate for profiling is relative to TracesSampleRate.
21- // In this case, we'll capture profiles for 50% of transactions.
22- profilesSampleRate: 0.5,
23- },
24- integrations: isNative
25- ? [
26- new Sentry.Native.ReactNativeTracing({
27- shouldCreateSpanForRequest: url => {
28- // Do not create spans for outgoing requests to a `/logs` endpoint as it is too noisy due to expo
29- return !url.match(/\/logs$/)
30- },
31- routingInstrumentation: getRoutingInstrumentation(),
32- }),
33- ]
34- : [], // no integrations for web, yet
35})
36-37-// if web, use Browser client, otherwise use Native client
38-export function getSentryClient() {
39- if (isWeb) {
40- return Sentry.Browser
41- }
42- return Sentry.Native
43-}
44-45-// wrap root App component with Sentry for automatic touch event tracking and performance monitoring
46-export function withSentry(Component: FC) {
47- if (isWeb) {
48- return Component // .wrap is not required or available for web
49- }
50- const sentryClient = getSentryClient()
51- return sentryClient.wrap(Component)
52-}
···1+import {init} from 'sentry-expo'
0000000023+init({
4 dsn: 'https://05bc3789bf994b81bd7ce20c86ccd3ae@o4505071687041024.ingest.sentry.io/4505071690514432',
5 enableInExpoDevelopment: false, // if true, Sentry will try to send events/errors in development mode.
6 debug: false, // If `true`, Sentry will try to print out useful debugging information if something goes wrong with sending the event. Set it to `false` in production
7 environment: __DEV__ ? 'development' : 'production', // Set the environment
00000000000000000008})
00000000000000000