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