From 4dcc561cbf2ca6f74d3017dcc22c9cfc49e9e46e Mon Sep 17 00:00:00 2001 From: Zhiyuan Zheng Date: Wed, 18 May 2022 00:11:31 +0200 Subject: [PATCH] Update error tracing --- src/App.tsx | 17 ++++++++++------- src/components/Timeline/Shared/Actioned.tsx | 2 +- src/screens/Compose.tsx | 7 ++++++- src/screens/Tabs/Shared/Toot.tsx | 7 ++++--- src/startup/sentry.ts | 3 ++- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index c0032d71..bdf6569a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -54,6 +54,7 @@ import { enableFreeze } from 'react-native-screens' import { QueryClientProvider } from 'react-query' import { Provider } from 'react-redux' import { PersistGate } from 'redux-persist/integration/react' +import * as Sentry from 'sentry-expo' Platform.select({ android: LogBox.ignoreLogs(['Setting a timer for a long period of time']) @@ -128,13 +129,15 @@ const App: React.FC = () => { } return ( - - - - - - - + + + + + + + + + ) } else { return null diff --git a/src/components/Timeline/Shared/Actioned.tsx b/src/components/Timeline/Shared/Actioned.tsx index 47b59a9f..9b600d2f 100644 --- a/src/components/Timeline/Shared/Actioned.tsx +++ b/src/components/Timeline/Shared/Actioned.tsx @@ -22,7 +22,7 @@ const TimelineActioned = React.memo( const { colors } = useTheme() const navigation = useNavigation>() - const name = account.display_name || account.username + const name = account?.display_name || account.username const iconColor = colors.primaryDefault const content = (content: string) => ( diff --git a/src/screens/Compose.tsx b/src/screens/Compose.tsx index dbf5ffb8..a848b695 100644 --- a/src/screens/Compose.tsx +++ b/src/screens/Compose.tsx @@ -377,7 +377,12 @@ const ScreenCompose: React.FC> = ({ ] ) } else { - Sentry.Native.captureMessage('Compose posting', error) + Sentry.Native.captureMessage('Compose posting', { + contexts: { + errorObject: error, + errorString: error.toString() + } + }) haptics('Error') composeDispatch({ type: 'posting', payload: false }) Alert.alert(t('heading.right.alert.default.title'), undefined, [ diff --git a/src/screens/Tabs/Shared/Toot.tsx b/src/screens/Tabs/Shared/Toot.tsx index fb1f4d1d..63a6a6ea 100644 --- a/src/screens/Tabs/Shared/Toot.tsx +++ b/src/screens/Tabs/Shared/Toot.tsx @@ -35,7 +35,7 @@ const TabSharedToot: React.FC> = ({ result.data.pages.flatMap(d => [...d.body]) : [] // Auto go back when toot page is empty - if (flattenData.length === 0) { + if (flattenData.length < 1) { navigation.goBack() return } @@ -46,13 +46,14 @@ const TabSharedToot: React.FC> = ({ if (pointer < 1) return try { setTimeout(() => { - console.log('scrolling') flRef.current?.scrollToIndex({ index: pointer, viewOffset: 100 }) }, 500) - } catch {} + } catch (error) { + return + } } } }) diff --git a/src/startup/sentry.ts b/src/startup/sentry.ts index 8e7a3cf0..7d398c66 100644 --- a/src/startup/sentry.ts +++ b/src/startup/sentry.ts @@ -7,7 +7,8 @@ const sentry = () => { Sentry.init({ dsn: 'https://53348b60ff844d52886e90251b3a5f41@o917354.ingest.sentry.io/6410576', enableInExpoDevelopment: false, - debug: !isRelease + debug: !isRelease, + autoSessionTracking: true }) }