Pārlūkot izejas kodu

global handler + source map

Viktoriia 3 nedēļas atpakaļ
vecāks
revīzija
06f99927c6

+ 7 - 0
App.tsx

@@ -19,6 +19,7 @@ import { API_HOST, API_URL, APP_VERSION } from 'src/constants';
 import axios from 'axios';
 import { API } from 'src/types';
 import { storage, StoreType } from 'src/storage';
+import { setupGlobalErrorHandler } from 'src/utils/globalErrorHandler';
 
 const IOS_STORE_URL = 'https://apps.apple.com/app/id6502843543';
 const ANDROID_STORE_URL =
@@ -34,6 +35,8 @@ Sentry.init({
   dsn: 'https://c9b37005f4be22a17a582603ebc17598@o4507781200543744.ingest.de.sentry.io/4507781253824592',
   integrations: [Sentry.reactNativeTracingIntegration({ routingInstrumentation })],
   debug: false,
+  enableNative: true,
+  enableNativeCrashHandling: true,
   ignoreErrors: ['Network Error', 'ECONNABORTED', 'timeout of 10000ms exceeded'],
   beforeSend(event, hint) {
     if (userId) {
@@ -88,6 +91,10 @@ const InnerApp = () => {
   const navigation = React.useRef(null);
   const [isUpdateAvailable, setIsUpdateAvailable] = useState(false);
 
+  useEffect(() => {
+    setupGlobalErrorHandler(navigation);
+  }, []);
+
   useEffect(() => {
     setupInterceptors(errorContext);
   }, [errorContext]);

+ 1 - 0
app.config.ts

@@ -166,6 +166,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
       '@sentry/react-native/expo',
       {
         organization: env.SENTRY_ORG,
+        note: 'Use SENTRY_AUTH_TOKEN env to authenticate with Sentry.',
         project: env.SENTRY_PROJECT,
         url: 'https://sentry.io/'
       }

+ 10 - 5
eas.json

@@ -9,7 +9,8 @@
         "buildType": "apk"
       },
       "env": {
-        "ENV": "development"
+        "ENV": "development",
+        "SENTRY_AUTH_TOKEN": "$SENTRY_AUTH_TOKEN"
       }
     },
     "preview2": {
@@ -28,13 +29,15 @@
       "distribution": "internal",
       "channel": "development",
       "env": {
-        "ENV": "development"
+        "ENV": "development",
+        "SENTRY_AUTH_TOKEN": "$SENTRY_AUTH_TOKEN"
       }
     },
     "testflight": {
       "channel": "development",
       "env": {
-        "ENV": "production"
+        "ENV": "production",
+        "SENTRY_AUTH_TOKEN": "$SENTRY_AUTH_TOKEN"
       }
     },
     "production": {
@@ -43,7 +46,8 @@
         "buildType": "app-bundle"
       },
       "env": {
-        "ENV": "production"
+        "ENV": "production",
+        "SENTRY_AUTH_TOKEN": "$SENTRY_AUTH_TOKEN"
       }
     },
     "production-apk": {
@@ -52,7 +56,8 @@
         "buildType": "apk"
       },
       "env": {
-        "ENV": "production"
+        "ENV": "production",
+        "SENTRY_AUTH_TOKEN": "$SENTRY_AUTH_TOKEN"
       }
     }
   },

+ 2 - 2
src/screens/InAppScreens/MessagesScreen/Components/EmojiSelectorModal.tsx

@@ -1,5 +1,5 @@
 import React from 'react';
-import { StyleSheet, View } from 'react-native';
+import { Platform, StyleSheet, View } from 'react-native';
 import EmojiSelector from 'react-native-emoji-selector';
 import ActionSheet from 'react-native-actions-sheet';
 
@@ -18,7 +18,7 @@ const EmojiSelectorModal: React.FC<EmojiSelectorModalProps> = ({
   <ActionSheet
     id="emoji-selector"
     closeOnPressBack={true}
-    gestureEnabled={true}
+    gestureEnabled={Platform.OS === 'ios'}
     containerStyle={{
       borderTopLeftRadius: 15,
       borderTopRightRadius: 15,

+ 23 - 0
src/utils/globalErrorHandler.ts

@@ -0,0 +1,23 @@
+import * as Sentry from '@sentry/react-native';
+import type { NavigationContainerRef } from '@react-navigation/native';
+import { NAVIGATION_PAGES } from 'src/types';
+
+export const setupGlobalErrorHandler = (
+  navigationRef: React.RefObject<NavigationContainerRef<any>>
+) => {
+  ErrorUtils.setGlobalHandler(async (error: any, isFatal?: boolean) => {
+    Sentry.captureException(error);
+    await Sentry.flush();
+
+    if (isFatal && navigationRef.current?.reset) {
+      navigationRef.current.reset({
+        index: 0,
+        routes: [{ name: NAVIGATION_PAGES.IN_APP_MAP_TAB }]
+      });
+    }
+  });
+
+  process.on?.('unhandledRejection', (reason: any) => {
+    Sentry.captureException(reason);
+  });
+};