diff --git a/android/app/src/main/java/com/avapp/DeviceUtilsModule.java b/android/app/src/main/java/com/avapp/DeviceUtilsModule.java index 4a129db4..73d0b580 100644 --- a/android/app/src/main/java/com/avapp/DeviceUtilsModule.java +++ b/android/app/src/main/java/com/avapp/DeviceUtilsModule.java @@ -161,6 +161,16 @@ public class DeviceUtilsModule extends ReactContextBaseJavaModule { } } + @ReactMethod + public void handleCrash(String message, String screenName) { // + if (isAlfredEnabledFromFirebase) { + HashMap properties = new HashMap<>(); + properties.put("message", message); + properties.put("screenName", screenName); + AlfredManager.INSTANCE.handleCrashEvent(properties); + } + } + @ReactMethod public void setCodePushVersion(String codePushVersion) { if (isAlfredEnabledFromFirebase && codePushVersion != null) { diff --git a/src/common/ErrorBoundary.tsx b/src/common/ErrorBoundary.tsx index c21d3eaa..bf87cf95 100644 --- a/src/common/ErrorBoundary.tsx +++ b/src/common/ErrorBoundary.tsx @@ -9,8 +9,9 @@ import VersionNumber from 'react-native-version-number'; import Text from '../../RN-UI-LIB/src/components/Text'; import { getAppVersion } from '../components/utlis/commonFunctions'; import { COLORS } from '../../RN-UI-LIB/src/styles/colors'; -import { alfredHandleSWWEvent } from '../components/utlis/DeviceUtils'; +import { handleCrash } from '../components/utlis/DeviceUtils'; import crashlytics from '@react-native-firebase/crashlytics'; +import { getCurrentScreen } from '@components/utlis/navigationUtlis'; interface IErrorBoundary { children?: ReactNode; @@ -37,7 +38,7 @@ class ErrorBoundary extends Component { }); logError(error); crashlytics().recordError(error); - alfredHandleSWWEvent(new Error("Error in Alfred recording")); + handleCrash({ message: error.message, screenName: getCurrentScreen()?.name }); } render() { diff --git a/src/components/utlis/DeviceUtils.ts b/src/components/utlis/DeviceUtils.ts index df16842c..8ea9f465 100644 --- a/src/components/utlis/DeviceUtils.ts +++ b/src/components/utlis/DeviceUtils.ts @@ -1,6 +1,11 @@ import { buildFlavour } from '@reducers/metadataSlice'; import { NativeModules } from 'react-native'; +interface CrashError { + message: string; + screenName: string; +} + const { DeviceUtilsModule } = NativeModules; // this is the same name we returned in getName function. // returns true if enabled, and false if disabled. @@ -15,7 +20,10 @@ export const alfredHandleSWWEvent = (error: Error) => { DeviceUtilsModule.handleSWWEvent(message, stack, name); }; -export const handleCrash = () => DeviceUtilsModule.handleCrash(); +export const handleCrash = (error: CrashError) => { + const { message = '', screenName = '' } = error; + DeviceUtilsModule.handleCrash(message, screenName); +}; export const handleANR = () => DeviceUtilsModule.handleANR();