From d9e9b55ae4a2b06bfd37c2338d42ba10b1cf681f Mon Sep 17 00:00:00 2001 From: tommasini <46944231+tommasini@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:14:47 +0100 Subject: [PATCH] cherry-pick bf5bb97 --- app/components/Nav/App/index.js | 11 +---- app/components/Views/LockScreen/index.js | 18 ++------ app/components/Views/Login/index.js | 36 +++------------ app/components/Views/Onboarding/index.js | 38 ++++++--------- app/components/Views/Wallet/index.tsx | 1 - app/store/index.ts | 59 ++---------------------- app/util/trace.ts | 31 +------------ 7 files changed, 31 insertions(+), 163 deletions(-) diff --git a/app/components/Nav/App/index.js b/app/components/Nav/App/index.js index 8f424320041..a587ef6c3ae 100644 --- a/app/components/Nav/App/index.js +++ b/app/components/Nav/App/index.js @@ -131,7 +131,6 @@ import OptionsSheet from '../../UI/SelectOptionSheet/OptionsSheet'; import FoxLoader from '../../../components/UI/FoxLoader'; import { AppStateEventProcessor } from '../../../core/AppStateEventListener'; import MultiRpcModal from '../../../components/Views/MultiRpcModal/MultiRpcModal'; -import { trace, TraceName, TraceOperation } from '../../../util/trace'; const clearStackNavigatorOptions = { headerShown: false, @@ -355,15 +354,7 @@ const App = (props) => { setOnboarded(!!existingUser); try { if (existingUser) { - await trace( - { - name: TraceName.BiometricAuthentication, - op: TraceOperation.BiometricAuthentication, - }, - async () => { - await Authentication.appTriggeredAuth(); - }, - ); + await Authentication.appTriggeredAuth(); // we need to reset the navigator here so that the user cannot go back to the login screen navigator.reset({ routes: [{ name: Routes.ONBOARDING.HOME_NAV }] }); } else { diff --git a/app/components/Views/LockScreen/index.js b/app/components/Views/LockScreen/index.js index 030bc9ace1d..92f04193389 100644 --- a/app/components/Views/LockScreen/index.js +++ b/app/components/Views/LockScreen/index.js @@ -22,7 +22,6 @@ import { import Routes from '../../../constants/navigation/Routes'; import { CommonActions } from '@react-navigation/native'; import trackErrorAsAnalytics from '../../../util/metrics/TrackError/trackErrorAsAnalytics'; -import { trace, TraceName, TraceOperation } from '../../../util/trace'; const LOGO_SIZE = 175; const createStyles = (colors) => @@ -135,19 +134,10 @@ class LockScreen extends PureComponent { // Retrieve the credentials Logger.log('Lockscreen::unlockKeychain - getting credentials'); - await trace( - { - name: TraceName.BiometricAuthentication, - op: TraceOperation.BiometricAuthentication, - }, - async () => { - await Authentication.appTriggeredAuth({ - bioStateMachineId, - disableAutoLogout: true, - }); - }, - ); - + await Authentication.appTriggeredAuth({ + bioStateMachineId, + disableAutoLogout: true, + }); this.setState({ ready: true }); Logger.log('Lockscreen::unlockKeychain - state: ready'); } catch (error) { diff --git a/app/components/Views/Login/index.js b/app/components/Views/Login/index.js index e737df72178..488804f7a36 100644 --- a/app/components/Views/Login/index.js +++ b/app/components/Views/Login/index.js @@ -58,12 +58,6 @@ import { LoginViewSelectors } from '../../../../e2e/selectors/LoginView.selector import { withMetricsAwareness } from '../../../components/hooks/useMetrics'; import trackErrorAsAnalytics from '../../../util/metrics/TrackError/trackErrorAsAnalytics'; import { downloadStateLogs } from '../../../util/logs'; -import { - trace, - endTrace, - TraceName, - TraceOperation, -} from '../../../util/trace'; const deviceHeight = Device.getDeviceHeight(); const breakPoint = deviceHeight < 700; @@ -250,10 +244,6 @@ class Login extends PureComponent { fieldRef = React.createRef(); async componentDidMount() { - trace({ - name: TraceName.LoginToPasswordEntry, - op: TraceOperation.LoginToPasswordEntry, - }); this.props.metrics.trackEvent(MetaMetricsEvents.LOGIN_SCREEN_VIEWED); BackHandler.addEventListener('hardwareBackPress', this.handleBackPress); @@ -377,15 +367,7 @@ class Login extends PureComponent { ); try { - await trace( - { - name: TraceName.AuthenticateUser, - op: TraceOperation.AuthenticateUser, - }, - async () => { - await Authentication.userEntryAuth(password, authType); - }, - ); + await Authentication.userEntryAuth(password, authType); Keyboard.dismiss(); @@ -453,15 +435,7 @@ class Login extends PureComponent { const { current: field } = this.fieldRef; field?.blur(); try { - await trace( - { - name: TraceName.BiometricAuthentication, - op: TraceOperation.BiometricAuthentication, - }, - async () => { - await Authentication.appTriggeredAuth(); - }, - ); + await Authentication.appTriggeredAuth(); const onboardingWizard = await StorageWrapper.getItem(ONBOARDING_WIZARD); if (!onboardingWizard) this.props.setOnboardingWizardStep(1); this.props.navigation.replace(Routes.ONBOARDING.HOME_NAV); @@ -480,7 +454,6 @@ class Login extends PureComponent { }; triggerLogIn = () => { - endTrace({ name: TraceName.LoginToPasswordEntry }); this.onLogin(); }; @@ -563,7 +536,10 @@ class Login extends PureComponent { )} - + {strings('login.title')} diff --git a/app/components/Views/Onboarding/index.js b/app/components/Views/Onboarding/index.js index 52ea24f6192..f15aa33c3c5 100644 --- a/app/components/Views/Onboarding/index.js +++ b/app/components/Views/Onboarding/index.js @@ -49,7 +49,6 @@ import { OnboardingSelectorIDs } from '../../../../e2e/selectors/Onboarding/Onbo import Routes from '../../../constants/navigation/Routes'; import { selectAccounts } from '../../../selectors/accountTrackerController'; import trackOnboarding from '../../../util/metrics/TrackOnboarding/trackOnboarding'; -import { trace, TraceName, TraceOperation } from '../../../util/trace'; const createStyles = (colors) => StyleSheet.create({ @@ -276,33 +275,24 @@ class Onboarding extends PureComponent { }; onPressCreate = () => { - const action = () => { - trace( - { - name: TraceName.CreateNewWalletToChoosePassword, - op: TraceOperation.CreateNewWalletToChoosePassword, - }, - () => { - const { metrics } = this.props; - if (metrics.isEnabled()) { - this.props.navigation.navigate('ChoosePassword', { + const action = async () => { + const { metrics } = this.props; + if (metrics.isEnabled()) { + this.props.navigation.navigate('ChoosePassword', { + [PREVIOUS_SCREEN]: ONBOARDING, + }); + this.track(MetaMetricsEvents.WALLET_SETUP_STARTED); + } else { + this.props.navigation.navigate('OptinMetrics', { + onContinue: () => { + this.props.navigation.replace('ChoosePassword', { [PREVIOUS_SCREEN]: ONBOARDING, }); this.track(MetaMetricsEvents.WALLET_SETUP_STARTED); - } else { - this.props.navigation.navigate('OptinMetrics', { - onContinue: () => { - this.props.navigation.replace('ChoosePassword', { - [PREVIOUS_SCREEN]: ONBOARDING, - }); - this.track(MetaMetricsEvents.WALLET_SETUP_STARTED); - }, - }); - } - }, - ); + }, + }); + } }; - this.handleExistingUser(action); }; diff --git a/app/components/Views/Wallet/index.tsx b/app/components/Views/Wallet/index.tsx index 218840f944c..a5ccb6e25ea 100644 --- a/app/components/Views/Wallet/index.tsx +++ b/app/components/Views/Wallet/index.tsx @@ -105,7 +105,6 @@ import { ButtonVariants } from '../../../component-library/components/Buttons/Bu import { useListNotifications } from '../../../util/notifications/hooks/useNotifications'; import { PortfolioBalance } from '../../UI/Tokens/TokenList/PortfolioBalance'; import { isObject } from 'lodash'; - const createStyles = ({ colors, typography }: Theme) => StyleSheet.create({ base: { diff --git a/app/store/index.ts b/app/store/index.ts index 9cc858e9ac0..b50af799237 100644 --- a/app/store/index.ts +++ b/app/store/index.ts @@ -9,9 +9,6 @@ import { Authentication } from '../core'; import LockManagerService from '../core/LockManagerService'; import ReadOnlyNetworkStore from '../util/test/network-store'; import { isE2E } from '../util/test/utils'; -import { trace, endTrace, TraceName, TraceOperation } from '../util/trace'; -import StorageWrapper from './storage-wrapper'; - import thunk from 'redux-thunk'; import persistConfig from './persistConfig'; @@ -28,7 +25,7 @@ const pReducer = persistReducer(persistConfig, rootReducer); // TODO: Replace "any" with type // eslint-disable-next-line @typescript-eslint/no-explicit-any, import/no-mutable-exports let store: Store, persistor; -const createStoreAndPersistor = async (appStartTime: number) => { +const createStoreAndPersistor = async () => { // Obtain the initial state from ReadOnlyNetworkStore for E2E tests. const initialState = isE2E ? await ReadOnlyNetworkStore.getState() @@ -50,24 +47,6 @@ const createStoreAndPersistor = async (appStartTime: number) => { middlewares.push(createReduxFlipperDebugger()); } - const jsStartTime = performance.now(); - - trace({ - name: TraceName.LoadScripts, - op: TraceOperation.LoadScripts, - startTime: appStartTime, - }); - - endTrace({ - name: TraceName.LoadScripts, - timestamp: appStartTime + jsStartTime, - }); - - trace({ - name: TraceName.CreateStore, - op: TraceOperation.CreateStore, - }); - store = configureStore({ reducer: pReducer, middleware: middlewares, @@ -76,19 +55,10 @@ const createStoreAndPersistor = async (appStartTime: number) => { sagaMiddleware.run(rootSaga); - endTrace({ name: TraceName.CreateStore }); - - trace({ - name: TraceName.StorageRehydration, - op: TraceOperation.StorageRehydration, - }); - /** * Initialize services after persist is completed */ - const onPersistComplete = async () => { - endTrace({ name: TraceName.StorageRehydration }); - + const onPersistComplete = () => { /** * EngineService.initalizeEngine(store) with SES/lockdown: * Requires ethjs nested patches (lib->src) @@ -104,7 +74,6 @@ const createStoreAndPersistor = async (appStartTime: number) => { * - TypeError: undefined is not an object (evaluating 'TokenListController.tokenList') * - V8: SES_UNHANDLED_REJECTION */ - store.dispatch({ type: 'TOGGLE_BASIC_FUNCTIONALITY', basicFunctionalityEnabled: @@ -115,18 +84,7 @@ const createStoreAndPersistor = async (appStartTime: number) => { store.dispatch({ type: 'FETCH_FEATURE_FLAGS', }); - - await trace( - { - name: TraceName.EngineInitialization, - op: TraceOperation.EngineInitialization, - tags: getTraceTags(store.getState?.()), - }, - () => { - EngineService.initalizeEngine(store); - }, - ); - + EngineService.initalizeEngine(store); Authentication.init(store); AppStateEventProcessor.init(store); LockManagerService.init(store); @@ -136,16 +94,7 @@ const createStoreAndPersistor = async (appStartTime: number) => { }; (async () => { - const appStartTime = await StorageWrapper.getItem('appStartTime'); - - await trace( - { - name: TraceName.UIStartup, - op: TraceOperation.UIStartup, - startTime: appStartTime, - }, - async () => await createStoreAndPersistor(appStartTime), - ); + await createStoreAndPersistor(); })(); export { store, persistor }; diff --git a/app/util/trace.ts b/app/util/trace.ts index 05ad23d9dd8..6a29e49087c 100644 --- a/app/util/trace.ts +++ b/app/util/trace.ts @@ -23,29 +23,6 @@ export enum TraceName { NotificationDisplay = 'Notification Display', PPOMValidation = 'PPOM Validation', Signature = 'Signature', - LoadScripts = 'Load Scripts', - SetupStore = 'Setup Store', - LoginToPasswordEntry = 'Login to Password Entry', - AuthenticateUser = 'Authenticate User', - BiometricAuthentication = 'Biometrics Authentication', - EngineInitialization = 'Engine Initialization', - CreateStore = 'Create Store', - CreateNewWalletToChoosePassword = 'Create New Wallet to Choose Password', - StorageRehydration = 'Storage Rehydration', - UIStartup = 'Custom UIStartup', -} - -export enum TraceOperation { - LoadScripts = 'custom.load.scripts', - SetupStore = 'custom.setup.store', - LoginToPasswordEntry = 'custom.login.to.password.entry', - BiometricAuthentication = 'biometrics.authentication', - AuthenticateUser = 'custom.authenticate.user', - EngineInitialization = 'custom.engine.initialization', - CreateStore = 'custom.create.store', - CreateNewWalletToChoosePassword = 'custom.create.new.wallet', - StorageRehydration = 'custom.storage.rehydration', - UIStartup = 'custom.ui.startup', } const ID_DEFAULT = 'default'; @@ -103,10 +80,6 @@ export interface TraceRequest { * Custom tags to associate with the trace. */ tags?: Record; - /** - * Custom operation name to associate with the trace. - */ - op?: string; } /** * A request to end a pending trace. @@ -254,13 +227,13 @@ function startSpan( request: TraceRequest, callback: (spanOptions: StartSpanOptions) => T, ) { - const { data: attributes, name, parentContext, startTime, op } = request; + const { data: attributes, name, parentContext, startTime, tags } = request; const parentSpan = (parentContext ?? null) as Span | null; const spanOptions: StartSpanOptions = { attributes, name, - op: op || OP_DEFAULT, + op: OP_DEFAULT, // This needs to be parentSpan once we have the withIsolatedScope implementation in place in the Sentry SDK for React Native // Reference PR that updates @sentry/react-native: https://github.com/getsentry/sentry-react-native/pull/3895 parentSpanId: parentSpan?.spanId,