Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Revert custom span #11839

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions app/components/Nav/App/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
import OptionsSheet from '../../UI/SelectOptionSheet/OptionsSheet';
import FoxLoader from '../../../components/UI/FoxLoader';
import { AppStateEventProcessor } from '../../../core/AppStateEventListener';
import { trace, TraceName, TraceOperation } from '../../../util/trace';

const clearStackNavigatorOptions = {
headerShown: false,
Expand Down Expand Up @@ -336,15 +335,7 @@
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 {
Expand Down Expand Up @@ -555,7 +546,7 @@
}
};

const DetectedTokensFlow = () => (

Check warning on line 549 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator
mode={'modal'}
screenOptions={clearStackNavigatorOptions}
Expand All @@ -569,7 +560,7 @@
</Stack.Navigator>
);

const RootModalFlow = () => (

Check warning on line 563 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator mode={'modal'} screenOptions={clearStackNavigatorOptions}>
<Stack.Screen
name={Routes.MODAL.WALLET_ACTIONS}
Expand Down Expand Up @@ -712,7 +703,7 @@
</Stack.Navigator>
);

const ImportPrivateKeyView = () => (

Check warning on line 706 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator
screenOptions={{
headerShown: false,
Expand All @@ -733,7 +724,7 @@
</Stack.Navigator>
);

const ConnectQRHardwareFlow = () => (

Check warning on line 727 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator
screenOptions={{
headerShown: false,
Expand All @@ -743,7 +734,7 @@
</Stack.Navigator>
);

const LedgerConnectFlow = () => (

Check warning on line 737 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator
screenOptions={{
headerShown: false,
Expand All @@ -757,7 +748,7 @@
</Stack.Navigator>
);

const ConnectHardwareWalletFlow = () => (

Check warning on line 751 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator name="ConnectHardwareWallet">
<Stack.Screen
name={Routes.HW.SELECT_DEVICE}
Expand All @@ -767,14 +758,14 @@
</Stack.Navigator>
);

const EditAccountNameFlow = () => (

Check warning on line 761 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator>
<Stack.Screen name="EditAccountName" component={EditAccountName} />
</Stack.Navigator>
);

// eslint-disable-next-line react/prop-types
const AddNetworkFlow = ({ route }) => (

Check warning on line 768 in app/components/Nav/App/index.js

View workflow job for this annotation

GitHub Actions / scripts (lint)

Do not define components during render. React will see a new component type on every render and destroy the entire subtree’s DOM nodes and state (https://reactjs.org/docs/reconciliation.html#elements-of-different-types). Instead, move this component definition out of the parent component “App” and pass data as props
<Stack.Navigator>
<Stack.Screen
name="AddNetwork"
Expand Down
18 changes: 4 additions & 14 deletions app/components/Views/LockScreen/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down Expand Up @@ -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) {
Expand Down
31 changes: 2 additions & 29 deletions app/components/Views/Login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,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;
Expand Down Expand Up @@ -251,10 +245,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);

Expand Down Expand Up @@ -378,15 +368,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();

Expand Down Expand Up @@ -454,15 +436,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);
Expand All @@ -481,7 +455,6 @@ class Login extends PureComponent {
};

triggerLogIn = () => {
endTrace({ name: TraceName.LoginToPasswordEntry });
this.onLogin();
};

Expand Down
38 changes: 14 additions & 24 deletions app/components/Views/Onboarding/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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);
};

Expand Down
1 change: 0 additions & 1 deletion app/components/Views/Wallet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ import {
} from '../../../selectors/notifications';
import { ButtonVariants } from '../../../component-library/components/Buttons/Button';
import { useListNotifications } from '../../../util/notifications/hooks/useNotifications';

const createStyles = ({ colors, typography }: Theme) =>
StyleSheet.create({
base: {
Expand Down
13 changes: 1 addition & 12 deletions app/selectors/nftController.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from 'reselect';
import { Nft, NftState } from '@metamask/assets-controllers';
import { NftState } from '@metamask/assets-controllers';
import { RootState } from '../reducers';

const selectNftControllerState = (state: RootState) =>
Expand All @@ -14,14 +14,3 @@ export const selectAllNfts = createSelector(
selectNftControllerState,
(nftControllerState: NftState) => nftControllerState.allNfts,
);

export const selectAllNftsFlat = createSelector(
selectAllNfts,
(nftsByChainByAccount) => {
const nftsByChainArray = Object.values(nftsByChainByAccount);
return nftsByChainArray.reduce((acc, nftsByChain) => {
const nftsArrays = Object.values(nftsByChain);
return acc.concat(...nftsArrays);
}, [] as Nft[]);
},
);
20 changes: 0 additions & 20 deletions app/selectors/tokensController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,3 @@ export const selectDetectedTokens = createSelector(
selectTokensControllerState,
(tokensControllerState: TokensState) => tokensControllerState?.detectedTokens,
);

const selectAllTokens = createSelector(
selectTokensControllerState,
(tokensControllerState: TokensState) => tokensControllerState?.allTokens,
);

export const selectAllTokensFlat = createSelector(
selectAllTokens,
(tokensByAccountByChain) => {
if (Object.values(tokensByAccountByChain).length === 0) {
return [];
}
const tokensByAccountArray = Object.values(tokensByAccountByChain);

return tokensByAccountArray.reduce((acc, tokensByAccount) => {
const tokensArray = Object.values(tokensByAccount);
return acc.concat(...tokensArray);
}, [] as Token[]);
},
);
60 changes: 4 additions & 56 deletions app/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ 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';
import { AppStateEventProcessor } from '../core/AppStateEventListener';
import { getTraceTags } from '../util/sentry/tags';

// TODO: Improve type safety by using real Action types instead of `any`
// TODO: Replace "any" with type
Expand All @@ -28,7 +24,7 @@ const pReducer = persistReducer<RootState, any>(persistConfig, rootReducer);
// TODO: Replace "any" with type
// eslint-disable-next-line @typescript-eslint/no-explicit-any, import/no-mutable-exports
let store: Store<RootState, any>, persistor;
const createStoreAndPersistor = async (appStartTime: number) => {
const createStoreAndPersistor = async () => {
// Obtain the initial state from ReadOnlyNetworkStore for E2E tests.
const initialState = isE2E
? await ReadOnlyNetworkStore.getState()
Expand All @@ -50,24 +46,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,
Expand All @@ -76,19 +54,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)
Expand All @@ -104,7 +73,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:
Expand All @@ -115,18 +83,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);
Expand All @@ -136,16 +93,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 };
Loading
Loading