From 49691ca8095d8c4cc47016631b9e1e31c0899e88 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Wed, 5 Jun 2024 01:12:45 +0530 Subject: [PATCH 01/25] Associate crashes with user info --- src/Expensify.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Expensify.tsx b/src/Expensify.tsx index ddc4b5f88a69..3e07c47463a0 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -37,6 +37,7 @@ import PopoverReportActionContextMenu from './pages/home/report/ContextMenu/Popo import * as ReportActionContextMenu from './pages/home/report/ContextMenu/ReportActionContextMenu'; import type {Route} from './ROUTES'; import type {ScreenShareRequest, Session} from './types/onyx'; +import crashlytics from "@react-native-firebase/crashlytics"; Onyx.registerLogger(({level, message}) => { if (level === 'alert') { @@ -216,6 +217,13 @@ function Expensify({ Audio.setAudioModeAsync({playsInSilentModeIOS: true}); }, []); + useEffect(() => { + if (!isAuthenticated) { + return + } + crashlytics().setUserId(Number(session?.accountID).toString()) + }, [isAuthenticated, session?.accountID]) + // Display a blank page until the onyx migration completes if (!isOnyxMigrated) { return null; From e7c695047e1114c5d61f6df7cb99c6d4894c5d36 Mon Sep 17 00:00:00 2001 From: ShridharGoel <35566748+ShridharGoel@users.noreply.github.com> Date: Sat, 8 Jun 2024 00:44:39 +0530 Subject: [PATCH 02/25] Update --- src/Expensify.tsx | 7 ++---- src/components/TestToolMenu.tsx | 22 +++++++++++++++++-- src/libs/setCrashlyticsUserId/index.native.ts | 11 ++++++++++ src/libs/setCrashlyticsUserId/index.ts | 4 ++++ src/libs/setCrashlyticsUserId/types.ts | 6 +++++ src/libs/testCrash/index.native.ts | 6 +++++ src/libs/testCrash/index.ts | 2 ++ 7 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 src/libs/setCrashlyticsUserId/index.native.ts create mode 100644 src/libs/setCrashlyticsUserId/index.ts create mode 100644 src/libs/setCrashlyticsUserId/types.ts create mode 100644 src/libs/testCrash/index.native.ts create mode 100644 src/libs/testCrash/index.ts diff --git a/src/Expensify.tsx b/src/Expensify.tsx index 3e07c47463a0..060ea4492b17 100644 --- a/src/Expensify.tsx +++ b/src/Expensify.tsx @@ -37,7 +37,7 @@ import PopoverReportActionContextMenu from './pages/home/report/ContextMenu/Popo import * as ReportActionContextMenu from './pages/home/report/ContextMenu/ReportActionContextMenu'; import type {Route} from './ROUTES'; import type {ScreenShareRequest, Session} from './types/onyx'; -import crashlytics from "@react-native-firebase/crashlytics"; +import setCrashlyticsUserId from "@libs/setCrashlyticsUserId"; Onyx.registerLogger(({level, message}) => { if (level === 'alert') { @@ -218,10 +218,7 @@ function Expensify({ }, []); useEffect(() => { - if (!isAuthenticated) { - return - } - crashlytics().setUserId(Number(session?.accountID).toString()) + setCrashlyticsUserId({isAuthenticated, accountID: session?.accountID}) }, [isAuthenticated, session?.accountID]) // Display a blank page until the onyx migration completes diff --git a/src/components/TestToolMenu.tsx b/src/components/TestToolMenu.tsx index e4d33957f7f1..bd2855523712 100644 --- a/src/components/TestToolMenu.tsx +++ b/src/components/TestToolMenu.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useState} from 'react'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; import useLocalize from '@hooks/useLocalize'; @@ -19,6 +19,7 @@ import {withNetwork} from './OnyxProvider'; import Switch from './Switch'; import TestToolRow from './TestToolRow'; import Text from './Text'; +import testCrash from "@libs/testCrash"; type TestToolMenuOnyxProps = { /** User object in Onyx */ @@ -29,12 +30,19 @@ type TestToolMenuProps = TestToolMenuOnyxProps & { /** Network object in Onyx */ network: OnyxEntry; }; -const USER_DEFAULT: UserOnyx = {shouldUseStagingServer: undefined, isSubscribedToNewsletter: false, validated: false, isFromPublicDomain: false, isUsingExpensifyCard: false}; +const USER_DEFAULT: UserOnyx = { + shouldUseStagingServer: undefined, + isSubscribedToNewsletter: false, + validated: false, + isFromPublicDomain: false, + isUsingExpensifyCard: false +}; function TestToolMenu({user = USER_DEFAULT, network}: TestToolMenuProps) { const shouldUseStagingServer = user?.shouldUseStagingServer ?? ApiUtils.isUsingStagingApi(); const styles = useThemeStyles(); const {translate} = useLocalize(); + const {showDummyUndefinedView, setShowDummyUndefinedView} = useState(false) return ( <> @@ -103,6 +111,16 @@ function TestToolMenu({user = USER_DEFAULT, network}: TestToolMenuProps) { }} /> + + +