mirror of
https://github.com/tooot-app/app
synced 2024-12-28 18:30:20 +01:00
Use new Sentry tracing
This commit is contained in:
parent
64b367a247
commit
1e0e8842db
@ -9,7 +9,6 @@ import ScreenAnnouncements from '@screens/Announcements'
|
|||||||
import ScreenCompose from '@screens/Compose'
|
import ScreenCompose from '@screens/Compose'
|
||||||
import ScreenImagesViewer from '@screens/ImagesViewer'
|
import ScreenImagesViewer from '@screens/ImagesViewer'
|
||||||
import ScreenTabs from '@screens/Tabs'
|
import ScreenTabs from '@screens/Tabs'
|
||||||
import * as Sentry from '@sentry/react-native'
|
|
||||||
import initQuery from '@utils/initQuery'
|
import initQuery from '@utils/initQuery'
|
||||||
import { RootStackParamList } from '@utils/navigation/navigators'
|
import { RootStackParamList } from '@utils/navigation/navigators'
|
||||||
import pushUseConnect from '@utils/push/useConnect'
|
import pushUseConnect from '@utils/push/useConnect'
|
||||||
@ -25,11 +24,12 @@ import { useTheme } from '@utils/styles/ThemeManager'
|
|||||||
import { themes } from '@utils/styles/themes'
|
import { themes } from '@utils/styles/themes'
|
||||||
import * as Linking from 'expo-linking'
|
import * as Linking from 'expo-linking'
|
||||||
import { addScreenshotListener } from 'expo-screen-capture'
|
import { addScreenshotListener } from 'expo-screen-capture'
|
||||||
import React, { useCallback, useEffect, useRef, useState } from 'react'
|
import React, { useCallback, useEffect, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Alert, Platform, StatusBar } from 'react-native'
|
import { Alert, Platform, StatusBar } from 'react-native'
|
||||||
import ShareMenu from 'react-native-share-menu'
|
import ShareMenu from 'react-native-share-menu'
|
||||||
import { useSelector } from 'react-redux'
|
import { useSelector } from 'react-redux'
|
||||||
|
import { routingInstrumentation } from './startup/sentry'
|
||||||
import { useAppDispatch } from './store'
|
import { useAppDispatch } from './store'
|
||||||
|
|
||||||
const Stack = createNativeStackNavigator<RootStackParamList>()
|
const Stack = createNativeStackNavigator<RootStackParamList>()
|
||||||
@ -49,8 +49,6 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
|
|||||||
const instanceActive = useSelector(getInstanceActive)
|
const instanceActive = useSelector(getInstanceActive)
|
||||||
const { colors, theme } = useTheme()
|
const { colors, theme } = useTheme()
|
||||||
|
|
||||||
const routeRef = useRef<{ name?: string; params?: {} }>()
|
|
||||||
|
|
||||||
// Push hooks
|
// Push hooks
|
||||||
const instances = useSelector(getInstances, (prev, next) => prev.length === next.length)
|
const instances = useSelector(getInstances, (prev, next) => prev.length === next.length)
|
||||||
pushUseConnect()
|
pushUseConnect()
|
||||||
@ -97,15 +95,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
|
|||||||
}, [instanceActive])
|
}, [instanceActive])
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
const navigationContainerOnReady = useCallback(() => {
|
|
||||||
const currentRoute = navigationRef.getCurrentRoute()
|
|
||||||
routeRef.current = {
|
|
||||||
name: currentRoute?.name,
|
|
||||||
params: currentRoute?.params ? JSON.stringify(currentRoute.params) : undefined
|
|
||||||
}
|
|
||||||
}, [])
|
|
||||||
const navigationContainerOnStateChange = useCallback(() => {
|
const navigationContainerOnStateChange = useCallback(() => {
|
||||||
const previousRoute = routeRef.current
|
|
||||||
const currentRoute = navigationRef.getCurrentRoute()
|
const currentRoute = navigationRef.getCurrentRoute()
|
||||||
|
|
||||||
const matchTabName = currentRoute?.name?.match(/(Tab-.*)-Root/)
|
const matchTabName = currentRoute?.name?.match(/(Tab-.*)-Root/)
|
||||||
@ -113,15 +103,6 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
|
|||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
dispatch(updatePreviousTab(matchTabName[1]))
|
dispatch(updatePreviousTab(matchTabName[1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousRoute?.name !== currentRoute?.name) {
|
|
||||||
Sentry.setContext('page', {
|
|
||||||
previous: previousRoute,
|
|
||||||
current: currentRoute
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
routeRef.current = currentRoute
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Deep linking for compose
|
// Deep linking for compose
|
||||||
@ -279,7 +260,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
|
|||||||
<NavigationContainer
|
<NavigationContainer
|
||||||
ref={navigationRef}
|
ref={navigationRef}
|
||||||
theme={themes[theme]}
|
theme={themes[theme]}
|
||||||
onReady={navigationContainerOnReady}
|
onReady={() => routingInstrumentation.registerNavigationContainer(navigationRef)}
|
||||||
onStateChange={navigationContainerOnStateChange}
|
onStateChange={navigationContainerOnStateChange}
|
||||||
>
|
>
|
||||||
<Stack.Navigator initialRouteName='Screen-Tabs'>
|
<Stack.Navigator initialRouteName='Screen-Tabs'>
|
||||||
|
@ -2,15 +2,19 @@ import * as Sentry from '@sentry/react-native'
|
|||||||
import { isDevelopment } from '@utils/checkEnvironment'
|
import { isDevelopment } from '@utils/checkEnvironment'
|
||||||
import log from './log'
|
import log from './log'
|
||||||
|
|
||||||
|
export const routingInstrumentation = new Sentry.ReactNavigationInstrumentation()
|
||||||
|
|
||||||
const sentry = () => {
|
const sentry = () => {
|
||||||
log('log', 'Sentry', 'initializing')
|
log('log', 'Sentry', 'initializing')
|
||||||
|
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
enabled: !isDevelopment,
|
enabled: !isDevelopment,
|
||||||
dsn: 'https://53348b60ff844d52886e90251b3a5f41@o917354.ingest.sentry.io/6410576',
|
dsn: 'https://53348b60ff844d52886e90251b3a5f41@o917354.ingest.sentry.io/6410576',
|
||||||
tracesSampleRate: 0.35,
|
tracesSampleRate: 0.35,
|
||||||
integrations: [
|
integrations: [
|
||||||
new Sentry.ReactNativeTracing({
|
new Sentry.ReactNativeTracing({
|
||||||
tracingOrigins: ['api.tooot.app']
|
routingInstrumentation,
|
||||||
|
tracingOrigins: ['tooot.app']
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
autoSessionTracking: true
|
autoSessionTracking: true
|
||||||
|
Loading…
Reference in New Issue
Block a user