parent
7ffbee18b5
commit
fa821943da
|
@ -1,10 +1,3 @@
|
||||||
jest.mock('sentry-expo', () => ({
|
jest.mock('sentry-expo', () => ({
|
||||||
init: () => jest.fn(),
|
init: () => jest.fn(),
|
||||||
Native: {
|
|
||||||
ReactNativeTracing: jest.fn().mockImplementation(() => ({
|
|
||||||
start: jest.fn(),
|
|
||||||
stop: jest.fn(),
|
|
||||||
})),
|
|
||||||
ReactNavigationInstrumentation: jest.fn(),
|
|
||||||
},
|
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -10,7 +10,6 @@ import {QueryClientProvider} from '@tanstack/react-query'
|
||||||
|
|
||||||
import 'view/icons'
|
import 'view/icons'
|
||||||
|
|
||||||
import {withSentry} from 'lib/sentry'
|
|
||||||
import {ThemeProvider} from 'lib/ThemeContext'
|
import {ThemeProvider} from 'lib/ThemeContext'
|
||||||
import {s} from 'lib/styles'
|
import {s} from 'lib/styles'
|
||||||
import {RootStoreModel, setupState, RootStoreProvider} from './state'
|
import {RootStoreModel, setupState, RootStoreProvider} from './state'
|
||||||
|
@ -62,4 +61,4 @@ const App = observer(function AppImpl() {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
export default withSentry(App)
|
export default App
|
||||||
|
|
|
@ -34,7 +34,6 @@ import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle'
|
||||||
import {router} from './routes'
|
import {router} from './routes'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {useStores} from './state'
|
import {useStores} from './state'
|
||||||
import {getRoutingInstrumentation} from 'lib/sentry'
|
|
||||||
import {bskyTitle} from 'lib/strings/headings'
|
import {bskyTitle} from 'lib/strings/headings'
|
||||||
import {JSX} from 'react/jsx-runtime'
|
import {JSX} from 'react/jsx-runtime'
|
||||||
import {timeout} from 'lib/async/timeout'
|
import {timeout} from 'lib/async/timeout'
|
||||||
|
@ -478,12 +477,6 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
||||||
)
|
)
|
||||||
console.log(`Time to first paint: ${initMs} ms`)
|
console.log(`Time to first paint: ${initMs} ms`)
|
||||||
logModuleInitTrace()
|
logModuleInitTrace()
|
||||||
|
|
||||||
// Register the navigation container with the Sentry instrumentation (only works on native)
|
|
||||||
if (isNative) {
|
|
||||||
const routingInstrumentation = getRoutingInstrumentation()
|
|
||||||
routingInstrumentation.registerNavigationContainer(navigationRef)
|
|
||||||
}
|
|
||||||
}}>
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
|
|
|
@ -1,52 +1,8 @@
|
||||||
import {isNative, isWeb} from 'platform/detection'
|
import {init} from 'sentry-expo'
|
||||||
import {FC} from 'react'
|
|
||||||
import * as Sentry from 'sentry-expo'
|
|
||||||
|
|
||||||
// Sentry Initialization
|
init({
|
||||||
|
|
||||||
export const getRoutingInstrumentation = () => {
|
|
||||||
return new Sentry.Native.ReactNavigationInstrumentation() // initialize this in `onReady` prop of NavigationContainer
|
|
||||||
}
|
|
||||||
|
|
||||||
Sentry.init({
|
|
||||||
dsn: 'https://05bc3789bf994b81bd7ce20c86ccd3ae@o4505071687041024.ingest.sentry.io/4505071690514432',
|
dsn: 'https://05bc3789bf994b81bd7ce20c86ccd3ae@o4505071687041024.ingest.sentry.io/4505071690514432',
|
||||||
enableInExpoDevelopment: false, // if true, Sentry will try to send events/errors in development mode.
|
enableInExpoDevelopment: false, // if true, Sentry will try to send events/errors in development mode.
|
||||||
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
|
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
|
||||||
environment: __DEV__ ? 'development' : 'production', // Set the environment
|
environment: __DEV__ ? 'development' : 'production', // Set the environment
|
||||||
// @ts-ignore exists but not in types, see https://docs.sentry.io/platforms/react-native/configuration/options/#enableAutoPerformanceTracking
|
|
||||||
enableAutoPerformanceTracking: true, // Enable auto performance tracking
|
|
||||||
tracesSampleRate: 0.5, // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. // TODO: this might be too much in production
|
|
||||||
_experiments: {
|
|
||||||
// The sampling rate for profiling is relative to TracesSampleRate.
|
|
||||||
// In this case, we'll capture profiles for 50% of transactions.
|
|
||||||
profilesSampleRate: 0.5,
|
|
||||||
},
|
|
||||||
integrations: isNative
|
|
||||||
? [
|
|
||||||
new Sentry.Native.ReactNativeTracing({
|
|
||||||
shouldCreateSpanForRequest: url => {
|
|
||||||
// Do not create spans for outgoing requests to a `/logs` endpoint as it is too noisy due to expo
|
|
||||||
return !url.match(/\/logs$/)
|
|
||||||
},
|
|
||||||
routingInstrumentation: getRoutingInstrumentation(),
|
|
||||||
}),
|
|
||||||
]
|
|
||||||
: [], // no integrations for web, yet
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// if web, use Browser client, otherwise use Native client
|
|
||||||
export function getSentryClient() {
|
|
||||||
if (isWeb) {
|
|
||||||
return Sentry.Browser
|
|
||||||
}
|
|
||||||
return Sentry.Native
|
|
||||||
}
|
|
||||||
|
|
||||||
// wrap root App component with Sentry for automatic touch event tracking and performance monitoring
|
|
||||||
export function withSentry(Component: FC) {
|
|
||||||
if (isWeb) {
|
|
||||||
return Component // .wrap is not required or available for web
|
|
||||||
}
|
|
||||||
const sentryClient = getSentryClient()
|
|
||||||
return sentryClient.wrap(Component)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue