Provide more debugging information through Sentry

This commit is contained in:
Zhiyuan Zheng 2021-03-21 13:15:43 +01:00
parent 2825e76dad
commit dd345871f8
No known key found for this signature in database
GPG Key ID: 078A93AB607D85E0
1 changed files with 16 additions and 14 deletions

View File

@ -45,7 +45,7 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
dark = 'light-content' dark = 'light-content'
} }
const routeNameRef = useRef<string | undefined>() const routeRef = useRef<{ name?: string; params?: {} }>()
const isConnected = useNetInfo().isConnected const isConnected = useNetInfo().isConnected
useEffect(() => { useEffect(() => {
@ -114,30 +114,32 @@ const Screens: React.FC<Props> = ({ localCorrupt }) => {
}, [instanceActive]) }, [instanceActive])
// Callbacks // Callbacks
const navigationContainerOnReady = useCallback( const navigationContainerOnReady = useCallback(() => {
() => const currentRoute = navigationRef.current?.getCurrentRoute()
(routeNameRef.current = navigationRef.current?.getCurrentRoute()?.name), routeRef.current = {
[] name: currentRoute?.name,
) params: currentRoute?.params
}
}, [])
const navigationContainerOnStateChange = useCallback(() => { const navigationContainerOnStateChange = useCallback(() => {
const previousRouteName = routeNameRef.current const previousRoute = routeRef.current
const currentRouteName = navigationRef.current?.getCurrentRoute()?.name const currentRoute = navigationRef.current?.getCurrentRoute()
const matchTabName = currentRouteName?.match(/(Tab-.*)-Root/) const matchTabName = currentRoute?.name?.match(/(Tab-.*)-Root/)
if (matchTabName) { if (matchTabName) {
//@ts-ignore //@ts-ignore
dispatch(updatePreviousTab(matchTabName[1])) dispatch(updatePreviousTab(matchTabName[1]))
} }
if (previousRouteName !== currentRouteName) { if (previousRoute?.name !== currentRoute?.name) {
Analytics.setCurrentScreen(currentRouteName) Analytics.setCurrentScreen(currentRoute?.name)
Sentry.Native.setContext('page', { Sentry.Native.setContext('page', {
previous: previousRouteName, previous: previousRoute,
current: currentRouteName current: currentRoute
}) })
} }
routeNameRef.current = currentRouteName routeRef.current = currentRoute
}, []) }, [])
return ( return (