Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
190 commits
Select commit Hold shift + click to select a range
6613043
feat: clean up oauth service
ieow Jun 26, 2025
d1465f8
fix: remove build flag
ieow Jun 26, 2025
e08a4ca
fix: remove unused added assets
ieow Jun 26, 2025
9554498
fix: oauth config
ieow Jun 27, 2025
6a7aca4
chore: address comment
ieow Jun 27, 2025
78bc655
fix : check for getBundleId
ieow Jun 27, 2025
ee72c36
fix: default ios google client bundleid
ieow Jun 27, 2025
20b3a03
fix: remove oauth env from js.env.example
ieow Jun 27, 2025
a4950c6
feat: implement onboarding sheet and account status screens
ieow Jun 27, 2025
f929f36
fix: add OTHER_METHODS_BUTTON selector to LoginView
ieow Jun 27, 2025
0eecdd9
feat: remove seedless onboarding Build Flag from Login, Onboarding, a…
ieow Jun 27, 2025
375660c
fix: update snapshot
ieow Jun 27, 2025
ebbeaab
test: enhance Login component tests with authentication scenarios
huggingbot Jun 27, 2025
d365d5d
fix: Failing tests in Onboarding view after merge
huggingbot Jun 28, 2025
a4649ef
test: enhance App component tests with onboarding navigation scenarios
huggingbot Jun 28, 2025
db0af35
test: add tests for SOLANA_DISCOVERY_PENDING handling in wallet creat…
huggingbot Jun 29, 2025
368ff2c
test: add rehydrateSeedPhrase tests for seed phrase handling in Authe…
huggingbot Jun 29, 2025
6cea7a3
fix: seedless onboarding runtime env
ieow Jun 30, 2025
d08fbac
feat: multi-srp
ieow Jun 30, 2025
4b17a02
test: enhance Onboarding tests with OAuth login scenarios and seedles…
huggingbot Jun 30, 2025
e4109ff
feat: init with default state when env is not enabled
ieow Jun 30, 2025
e9f01e2
feat: buildtype mapping
ieow Jun 30, 2025
938221f
feat: browser bff apple flow
ieow Jun 30, 2025
be70766
fix: address comment
ieow Jul 1, 2025
9de4ee4
Merge branch 'feat/new-srp-oauth-service' into feat/seedless-oauth-flow
ieow Jul 1, 2025
1ca4d2c
fix: update config
ieow Jul 1, 2025
e13a58c
fix: address comment, update config
ieow Jul 1, 2025
719fb5f
fix: remove console.log
ieow Jul 1, 2025
be62797
fix: extension parity
ieow Jul 1, 2025
b5ca197
chore: move client id out of config
ieow Jul 1, 2025
e293c2c
fix: update acm with main commit
ieow Jul 1, 2025
8f8acb1
fix: update acm with main commit
ieow Jul 1, 2025
0a15e01
fix: mock base handler
ieow Jul 1, 2025
66575f9
fix: tests
ieow Jul 1, 2025
252f54c
Merge branch 'feat/new-srp-oauth-service' into feat/seedless-oauth-flow
ieow Jul 1, 2025
d2757b1
fix: push coverage
ieow Jul 1, 2025
86ff499
fix: add test for getAuthToken
ieow Jul 1, 2025
37bc2fe
Merge branch 'feat/new-srp-oauth-service' into feat/seedless-oauth-flow
ieow Jul 1, 2025
ee181ef
fix: revert controller default state
ieow Jul 1, 2025
9a62ef1
Merge branch 'feat/new-srp-oauth-service' into feat/oauth-clientId
ieow Jul 1, 2025
7210473
feat: add
ieow Jul 1, 2025
752057d
fix: address comment
ieow Jul 1, 2025
73c0269
fix: test
ieow Jul 1, 2025
d2ef5cf
fix: mock react-native-quick-crypto
ieow Jul 1, 2025
20c041c
fix: lint
ieow Jul 1, 2025
f3ee809
chroe: remaping buildtype env
ieow Jul 1, 2025
2b07291
Merge branch 'feat/new-srp-oauth-service' into feat/oauth-clientId
ieow Jul 1, 2025
5f0d3e6
Feat/oauth-clientId (#16823)
ieow Jul 1, 2025
72d4270
Merge branch 'main' into feat/new-srp-oauth-service
ieow Jul 1, 2025
3ed6713
fix: bff start with authserver url
ieow Jul 1, 2025
d883ecd
fix: use base64 url for pcke
ieow Jul 1, 2025
376dfd9
Merge branch 'feat/new-srp-oauth-service' into feat/seedless-oauth-flow
ieow Jul 2, 2025
3b31a10
fix: update with mm authserver flow
ieow Jul 2, 2025
d8a95e4
chore: update example with mm dev client id
ieow Jul 2, 2025
770b11d
fix: update with mm authserver flow
ieow Jul 2, 2025
0d5faf3
chore: update example with mm dev client id
ieow Jul 2, 2025
8e2d09b
fix code class
chaitanyapotti Jul 2, 2025
d8c160c
Merge branch 'feat/new-srp-oauth-service' into feat/seedless-oauth-flow
ieow Jul 2, 2025
c1f3457
fix: bff and typing
ieow Jul 2, 2025
1347354
fix: bff and typing
ieow Jul 2, 2025
5c904cd
fix: remapping prod variable for seedless onboarding
ieow Jul 2, 2025
b0c3a51
fix: remapping prod variable for seedless onboarding
ieow Jul 2, 2025
e08f820
fix: tests
ieow Jul 2, 2025
1c4e6ff
fix: tests
ieow Jul 2, 2025
21d9ae3
fix: lint
ieow Jul 2, 2025
56369f5
fix: update with qa env checking for buildtype
ieow Jul 2, 2025
fe7300b
fix: js.env.example
ieow Jul 2, 2025
dd55df2
fix: lint
ieow Jul 2, 2025
2697abf
Merge branch 'feat/new-srp-oauth-service' into feat/seedless-oauth-flow
ieow Jul 2, 2025
f10f091
chore: remove ignored lefthook.yml
ieow Jul 2, 2025
12d1fa8
fix: update snapshot
ieow Jul 2, 2025
aadd3e4
Merge branch 'main' into feat/new-srp-oauth-service
chaitanyapotti Jul 2, 2025
1e53a6e
Merge branch 'main' into feat/new-srp-oauth-service
hieu-w Jul 2, 2025
7b7db7b
test: fix flaky scroll to element util
hieu-w Jul 2, 2025
d6a525c
Merge branch 'main' into feat/new-srp-oauth-service
hieu-w Jul 2, 2025
f005fda
test: revert ImportWalletView page object to latest
hieu-w Jul 2, 2025
7a33662
Merge branch 'main' into feat/new-srp-oauth-service
chaitanyapotti Jul 3, 2025
65737d9
Revert "test: fix flaky scroll to element util"
hieu-w Jul 3, 2025
113232c
Merge branch 'feat/new-srp-oauth-service' into feat/seedless-oauth-flow
ieow Jul 3, 2025
df66a5b
fix: update snapshot
ieow Jul 3, 2025
08d11c6
fix: checkbox
ieow Jul 3, 2025
9d4c33a
fix: update snapshot
ieow Jul 3, 2025
22b4273
fix: use uint8ArrayToMnemonic
ieow Jul 3, 2025
0968a9e
fix: parity with delete(reset) wallet
ieow Jul 3, 2025
5644646
Merge branch 'main' into feat/seedless-oauth-flow
ieow Jul 3, 2025
6e94375
Merge branch 'feat/seedless-oauth-flow' into feat/seedless-multi-srp-…
ieow Jul 3, 2025
6bd2912
fix: test case update
smgv Jul 3, 2025
0a3d073
fix: test case update
smgv Jul 3, 2025
df9ecf1
fix: test case update
smgv Jul 3, 2025
e821bff
fix: snapshot update
smgv Jul 3, 2025
a1d0cff
fix: snapshot update
smgv Jul 3, 2025
2c76a95
fix: snapshot update
smgv Jul 3, 2025
583d3f7
fix: test case update
smgv Jul 3, 2025
a5223ec
fix: Organize commits
huggingbot Jul 4, 2025
79af538
fix: update snapshot for StyledButton background color
huggingbot Jul 4, 2025
3bc6ea5
fix: update test for rehydration with multiple seed phrases
huggingbot Jul 4, 2025
bd82a0a
fix: update StyledButton snapshot to reflect new background color
huggingbot Jul 4, 2025
2bbd0ac
fix: update OrderProcessing snapshot to remove obsolete button elements
huggingbot Jul 4, 2025
d1c0701
fix: update AccountStatus snapshot to reflect font family changes
huggingbot Jul 4, 2025
a2a6b55
fix: update OAuthService tests to reflect changes in token structure
huggingbot Jul 4, 2025
a3eda12
fix: remove unused imports in multiSrp test file
huggingbot Jul 4, 2025
cd7fee2
fix: sonarqube quality issue
huggingbot Jul 4, 2025
2bc579c
test: add tracing functionality tests for ChoosePassword component
huggingbot Jul 4, 2025
c2f18b6
test: enhance ImportFromSecretRecoveryPhrase component tests with new…
huggingbot Jul 4, 2025
657d490
fix: remove unused lightTheme import in WhatsNewModal tests
huggingbot Jul 7, 2025
df6e50d
test: enhance Login component tests with error handling scenarios and…
huggingbot Jul 8, 2025
3073ced
test: refactor Swaps component tests
huggingbot Jul 8, 2025
9b81e6a
fix: Password UI fix for social Login
smgv Jul 8, 2025
bbd3bb2
Merge branch 'feat/seedless-multi-srp-sync' into chore/sentry-onboarding
hieu-w Jul 9, 2025
d216be2
fix: Wallet Recovery
smgv Jul 9, 2025
dcae927
fix: conflct merge
smgv Jul 9, 2025
6c1584a
fix: UI changes update
smgv Jul 9, 2025
5232728
fix: test case update
smgv Jul 9, 2025
5c997d1
fix: email masking
smgv Jul 9, 2025
aad937a
fix: test case update
smgv Jul 9, 2025
adf5ed4
fix: account status style fix
smgv Jul 9, 2025
057706d
fix: sanpshot update
smgv Jul 9, 2025
aecdcf5
Merge branch 'main' into feat/seedless-multi-srp-sync
smgv Jul 9, 2025
6a98139
fix: test case update
smgv Jul 9, 2025
63fc622
fix: test case update
smgv Jul 9, 2025
bc2d94c
fix: test case update
smgv Jul 9, 2025
35376f9
fix: test case update
smgv Jul 9, 2025
5fbe4cb
fix: sanpshot update
smgv Jul 9, 2025
c3629e7
fix: test case update
smgv Jul 9, 2025
667281f
fix: snapshot update
smgv Jul 9, 2025
4ba771a
Merge branch 'main' into feat/seedless-multi-srp-sync
smgv Jul 9, 2025
9e8fadc
fix: cursor bot
smgv Jul 9, 2025
ac1d20a
Merge branch 'main' into feat/seedless-multi-srp-sync
smgv Jul 9, 2025
ed7c920
fix: snapshot update
smgv Jul 9, 2025
c613c64
Merge branch 'main' into feat/seedless-multi-srp-sync
smgv Jul 9, 2025
6a04ffb
fix: accountstatus snapshot update
smgv Jul 9, 2025
0a86b3f
Merge branch 'main' into feat/seedless-multi-srp-sync
smgv Jul 9, 2025
c0b3b79
fix: masked email
smgv Jul 9, 2025
ecdadd3
fix: removed unused code
smgv Jul 9, 2025
b33e52d
Merge branch 'feat/seedless-multi-srp-sync' into chore/sentry-onboarding
huggingbot Jul 10, 2025
dfbc7bb
fix: Syntax error
huggingbot Jul 10, 2025
ca1b7c6
fix: Remove conflicting spy
huggingbot Jul 10, 2025
da46a3c
fix: replace mock mnemonics with string literals in authentication tests
huggingbot Jul 10, 2025
43b0032
Merge branch 'main' into chore/sentry-onboarding
hieu-w Jul 11, 2025
fa5bb83
fix: fix unit test
hieu-w Jul 11, 2025
87310b5
fix: fix unit test
hieu-w Jul 14, 2025
219e503
Merge branch 'main' into chore/sentry-onboarding
hieu-w Jul 14, 2025
53717ab
feat: implement buffered traces management
huggingbot Jul 14, 2025
0f8a897
fix: Incorrect buffer trace call used
huggingbot Jul 14, 2025
fb22b56
refactor: Update BufferedTrace type in actions and initialize buffere…
huggingbot Jul 15, 2025
7d67c8f
refactor: Clean up code formatting
huggingbot Jul 15, 2025
471d39d
fix: Safeguard against undefined buffered traces state
huggingbot Jul 15, 2025
f910d8a
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 15, 2025
e19dd82
test: Fix tests with new trace logic
huggingbot Jul 15, 2025
42f33c6
test: Add unit test for handling multiple traces with the same name b…
huggingbot Jul 15, 2025
ef3ab9f
fix: Cursor bug bot report
huggingbot Jul 15, 2025
3539769
refactor: Fix import structure for BufferedTrace in actions
huggingbot Jul 15, 2025
27f0638
fix: Regression
huggingbot Jul 15, 2025
29eaad0
refactor: Enhance Redux store access safety in trace functions
huggingbot Jul 15, 2025
e76f38c
test: Mock ReduxService in trace tests
huggingbot Jul 15, 2025
0738f59
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 15, 2025
0a69ebb
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 15, 2025
fbe7bde
fix: Prettier
huggingbot Jul 15, 2025
d8fb2c3
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 15, 2025
c0eabec
test: Update Authentication and EngineService tests to reflect additi…
huggingbot Jul 15, 2025
00b298b
refactor: Remove unnecessary ESLint disable comment in WalletRecovery…
huggingbot Jul 16, 2025
7319ecd
refactor: Remove logging of SeedlessOnboardingController state in Aut…
huggingbot Jul 16, 2025
5b95ab5
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 16, 2025
c0a48ed
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 16, 2025
4a8b4ce
feat: implement selectorSafe for Redux tracing to prevent infinite loops
huggingbot Jul 16, 2025
d372e8e
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 16, 2025
13e0bce
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 16, 2025
c0fb242
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 16, 2025
fbf6014
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 16, 2025
75e8012
Merge branch 'main' into chore/sentry-onboarding
hieu-w Jul 16, 2025
6b1b1ec
Merge branch 'main' into chore/sentry-onboarding
hieu-w Jul 16, 2025
9b5e21f
Merge branch 'main' into chore/sentry-onboarding
hieu-w Jul 16, 2025
6d5d1b8
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 17, 2025
b38dc53
Merge branch 'main' into chore/sentry-onboarding
chaitanyapotti Jul 17, 2025
7bf8ba1
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 17, 2025
bfb94b4
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 17, 2025
f2799a7
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 17, 2025
b73f20c
fix: Unit tests
huggingbot Jul 17, 2025
52db692
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 17, 2025
e4e4c61
fix: Format
huggingbot Jul 18, 2025
62468fd
Merge branch 'chore/sentry-onboarding' of https://github.com/MetaMask…
huggingbot Jul 18, 2025
e1ea5cd
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 18, 2025
08dd0cc
fix: switch use trace buffer in local instead redux
hieu-w Jul 18, 2025
83f188c
fix: lint
hieu-w Jul 18, 2025
80460c4
fix: unit test
hieu-w Jul 18, 2025
bb0c7db
fix: unit test
hieu-w Jul 18, 2025
53fa634
fix: lint
hieu-w Jul 18, 2025
642eed7
fix: lint
hieu-w Jul 18, 2025
c6fcfec
Merge branch 'main' into chore/sentry-onboarding
hieu-w Jul 18, 2025
4139148
Merge branch 'main' into chore/sentry-onboarding
huggingbot Jul 20, 2025
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
101 changes: 96 additions & 5 deletions app/actions/multiSrp/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './';
import { wordlist } from '@metamask/scure-bip39/dist/wordlists/english';
import { createMockInternalAccount } from '../../util/test/accountsControllerTestUtils';
import { TraceName, TraceOperation } from '../../util/trace';
import ReduxService from '../../core/redux/ReduxService';
import { RootState } from '../../reducers';

Expand All @@ -28,6 +29,12 @@ const mockControllerMessenger = jest.fn();
const mockAddDiscoveredAccounts = jest.fn();
const mockGetAccountByAddress = jest.fn().mockReturnValue(mockExpectedAccount);

// Mock for seedless onboarding
const mockSelectSeedlessOnboardingLoginFlow = jest.fn();
const mockAddNewSeedPhraseBackup = jest.fn();
const mockTrace = jest.fn();
const mockEndTrace = jest.fn();

const hdKeyring = {
getAccounts: () => {
mockGetAccounts();
Expand All @@ -43,6 +50,17 @@ const mockSnapClient = {
addDiscoveredAccounts: mockAddDiscoveredAccounts,
};

jest.mock('../../selectors/seedlessOnboardingController', () => ({
selectSeedlessOnboardingLoginFlow: (state: unknown) =>
mockSelectSeedlessOnboardingLoginFlow(state),
}));

jest.mock('../../util/trace', () => ({
...jest.requireActual('../../util/trace'),
trace: (options: unknown) => mockTrace(options),
endTrace: (options: unknown) => mockEndTrace(options),
}));

const createMockState = (hasVault: boolean) => ({
engine: {
backgroundState: {
Expand Down Expand Up @@ -81,7 +99,8 @@ jest.mock('../../core/Engine', () => ({
getAccountByAddress: () => mockGetAccountByAddress(),
},
SeedlessOnboardingController: {
addNewSeedPhraseBackup: jest.fn().mockResolvedValue(undefined),
addNewSeedPhraseBackup: (seed: Uint8Array, keyringId: string) =>
mockAddNewSeedPhraseBackup(seed, keyringId),
},
},
setSelectedAddress: (address: string) => mockSetSelectedAddress(address),
Expand All @@ -103,7 +122,11 @@ describe('MultiSRP Actions', () => {
describe('importNewSecretRecoveryPhrase', () => {
it('imports new SRP', async () => {
mockGetKeyringsByType.mockResolvedValue([]);
mockAddNewKeyring.mockResolvedValue({ getAccounts: () => [testAddress] });
mockAddNewKeyring.mockResolvedValue({
getAccounts: () => [testAddress],
id: 'keyring-id-123',
});
mockSelectSeedlessOnboardingLoginFlow.mockReturnValue(false);

await importNewSecretRecoveryPhrase(testMnemonic);

Expand Down Expand Up @@ -131,7 +154,74 @@ describe('MultiSRP Actions', () => {
expect(mockAddNewKeyring).not.toHaveBeenCalled();
});

describe('seedless onboarding login flow', () => {
beforeEach(() => {
mockGetKeyringsByType.mockResolvedValue([]);
mockAddNewKeyring.mockResolvedValue({
getAccounts: () => [testAddress],
id: 'keyring-id-123',
});
mockSelectSeedlessOnboardingLoginFlow.mockReturnValue(true);
});

it('successfully adds seed phrase backup when seedless onboarding is enabled', async () => {
mockAddNewSeedPhraseBackup.mockResolvedValue(undefined);

const result = await importNewSecretRecoveryPhrase(testMnemonic);

expect(mockSelectSeedlessOnboardingLoginFlow).toHaveBeenCalled();
expect(mockTrace).toHaveBeenCalledWith({
name: TraceName.OnboardingAddSrp,
op: TraceOperation.OnboardingSecurityOp,
});
expect(mockAddNewSeedPhraseBackup).toHaveBeenCalledWith(
expect.any(Uint8Array),
'keyring-id-123',
);
expect(mockEndTrace).toHaveBeenCalledWith({
name: TraceName.OnboardingAddSrp,
data: { success: true },
});
expect(mockSetSelectedAddress).toHaveBeenCalledWith(testAddress);
expect(result.address).toBe(testAddress);
expect(mockAddDiscoveredAccounts).toHaveBeenCalled();
});

it('handles error when seed phrase backup fails and traces error', async () => {
mockAddNewSeedPhraseBackup.mockRejectedValue(
new Error('Backup failed'),
);

await expect(
async () => await importNewSecretRecoveryPhrase(testMnemonic),
).rejects.toThrow('Backup failed');

expect(mockSelectSeedlessOnboardingLoginFlow).toHaveBeenCalled();
expect(mockTrace).toHaveBeenCalledWith({
name: TraceName.OnboardingAddSrp,
op: TraceOperation.OnboardingSecurityOp,
});
expect(mockAddNewSeedPhraseBackup).toHaveBeenCalledWith(
expect.any(Uint8Array),
'keyring-id-123',
);
expect(mockTrace).toHaveBeenCalledWith({
name: TraceName.OnboardingAddSrpError,
op: TraceOperation.OnboardingError,
tags: { errorMessage: 'Backup failed' },
});
expect(mockEndTrace).toHaveBeenCalledWith({
name: TraceName.OnboardingAddSrpError,
});
expect(mockEndTrace).toHaveBeenCalledWith({
name: TraceName.OnboardingAddSrp,
data: { success: false },
});
});
});

it('calls addNewSeedPhraseBackup when seedless onboarding login flow is active', async () => {
mockAddNewSeedPhraseBackup.mockResolvedValue(undefined);
mockGetKeyringsByType.mockResolvedValue([]);
mockAddNewKeyring.mockResolvedValue({
id: 'test-keyring-id',
Expand All @@ -144,9 +234,10 @@ describe('MultiSRP Actions', () => {

await importNewSecretRecoveryPhrase(testMnemonic);

expect(
Engine.context.SeedlessOnboardingController.addNewSeedPhraseBackup,
).toHaveBeenCalledWith(expect.any(Uint8Array), 'test-keyring-id');
expect(mockAddNewSeedPhraseBackup).toHaveBeenCalledWith(
expect.any(Uint8Array),
'test-keyring-id',
);
});
});

Expand Down
32 changes: 28 additions & 4 deletions app/actions/multiSrp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
} from '../../core/redux/slices/performance';
import { PerformanceEventNames } from '../../core/redux/slices/performance/constants';
import { store } from '../../store';
import { endTrace, trace, TraceName, TraceOperation } from '../../util/trace';
import { getTraceTags } from '../../util/sentry/tags';

import ReduxService from '../../core/redux';
import { TraceName, TraceOperation, trace, endTrace } from '../../util/trace';
import { selectSeedlessOnboardingLoginFlow } from '../../selectors/seedlessOnboardingController';

export async function importNewSecretRecoveryPhrase(mnemonic: string) {
Expand Down Expand Up @@ -72,24 +72,48 @@ export async function importNewSecretRecoveryPhrase(mnemonic: string) {

const { SeedlessOnboardingController } = Engine.context;

let discoveredAccountsCount = 0;

// TODO: to use loginCompleted
if (selectSeedlessOnboardingLoginFlow(ReduxService.store.getState())) {
// on Error, wallet should notify user that the newly added seed phrase is not synced properly
// user can try manual sync again (phase 2)
const seed = new Uint8Array(inputCodePoints.buffer);
let addSeedPhraseSuccess = false;
try {
trace({
name: TraceName.OnboardingAddSrp,
op: TraceOperation.OnboardingSecurityOp,
});
await SeedlessOnboardingController.addNewSeedPhraseBackup(
seed,
newKeyring.id,
);
addSeedPhraseSuccess = true;
} catch (error) {
const errorMessage =
error instanceof Error ? error.message : 'Unknown error';
// Log the error but don't let it crash the import process
console.error('Failed to backup seed phrase:', error);
console.error('Failed to backup seed phrase:', errorMessage);

trace({
name: TraceName.OnboardingAddSrpError,
op: TraceOperation.OnboardingError,
tags: { errorMessage },
});
endTrace({
name: TraceName.OnboardingAddSrpError,
});

throw error;
} finally {
endTrace({
name: TraceName.OnboardingAddSrp,
data: { success: addSeedPhraseSuccess },
});
}
}

let discoveredAccountsCount = 0;

///: BEGIN:ONLY_INCLUDE_IF(solana)
const multichainClient = MultichainWalletSnapFactory.createClient(
WalletClientType.Solana,
Expand Down
13 changes: 13 additions & 0 deletions app/components/UI/OptinMetrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ import Icon, {
IconColor,
} from '../../../component-library/components/Icons/Icon';
import { getConfiguredCaipChainIds } from '../../../util/metrics/MultichainAPI/networkMetricUtils';
import {
updateCachedConsent,
flushBufferedTraces,
discardBufferedTraces,
} from '../../../util/trace';
import { setupSentry } from '../../../util/sentry/utils';

const createStyles = ({ colors }) =>
StyleSheet.create({
Expand Down Expand Up @@ -330,6 +336,9 @@ class OptinMetrics extends PureComponent {
// and disable analytics
clearOnboardingEvents();
await metrics.enable(false);
await setupSentry(); // Re-setup Sentry with enabled: false
discardBufferedTraces();
updateCachedConsent(false);
}, 200);
this.continue();
};
Expand All @@ -346,6 +355,10 @@ class OptinMetrics extends PureComponent {
} = this.props;

await metrics.enable();
await setupSentry(); // Re-setup Sentry with enabled: true
await flushBufferedTraces();
updateCachedConsent(true);

// Handle null case for marketing consent
if (
isDataCollectionForMarketingEnabled === null &&
Expand Down
6 changes: 5 additions & 1 deletion app/components/Views/AccountBackupStep1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import Icon, {
import { CommonActions, useNavigation } from '@react-navigation/native';
import { useMetrics } from '../../hooks/useMetrics';
import { ONBOARDING_SUCCESS_FLOW } from '../../../constants/onboarding';
import { TraceName, endTrace } from '../../../util/trace';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down Expand Up @@ -114,6 +115,7 @@ const AccountBackupStep1 = (props) => {
const [hasFunds, setHasFunds] = useState(false);
const { colors } = useTheme();
const styles = createStyles(colors);
const { isEnabled: isMetricsEnabled } = useMetrics();

const track = (event, properties) => {
const eventBuilder = MetricsEventBuilder.createEventBuilder(event);
Expand Down Expand Up @@ -175,7 +177,6 @@ const AccountBackupStep1 = (props) => {
track(MetaMetricsEvents.WALLET_SECURITY_STARTED);
};

const { isEnabled: isMetricsEnabled } = useMetrics();
const skip = async () => {
track(MetaMetricsEvents.WALLET_SECURITY_SKIP_CONFIRMED);
// Get onboarding wizard state
Expand All @@ -197,6 +198,9 @@ const AccountBackupStep1 = (props) => {
},
],
});
endTrace({ name: TraceName.OnboardingNewSrpCreateWallet });
endTrace({ name: TraceName.OnboardingJourneyOverall });

if (isMetricsEnabled()) {
navigation.dispatch(resetAction);
} else {
Expand Down
46 changes: 44 additions & 2 deletions app/components/Views/AccountStatus/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import {
View,
Image,
Expand Down Expand Up @@ -29,6 +29,14 @@ import { MetaMetricsEvents } from '../../../core/Analytics/MetaMetrics.events';
import { PREVIOUS_SCREEN } from '../../../constants/navigation';
import { MetricsEventBuilder } from '../../../core/Analytics/MetricsEventBuilder';
import trackOnboarding from '../../../util/metrics/TrackOnboarding/trackOnboarding';
import {
endTrace,
trace,
TraceName,
TraceOperation,
} from '../../../util/trace';
import { getTraceTags } from '../../../util/sentry/tags';
import { store } from '../../../store';
import {
IMetaMetricsEvent,
ITrackingEvent,
Expand All @@ -37,7 +45,6 @@ import {
OnboardingActionTypes,
saveOnboardingEvent as saveEvent,
} from '../../../actions/onboarding';

import AccountStatusImg from '../../../images/account_status.png';

interface AccountStatusProps {
Expand All @@ -48,6 +55,7 @@ interface AccountStatusProps {
interface AccountRouteParams {
accountName?: string;
oauthLoginSuccess?: boolean;
onboardingTraceCtx?: string;
}

const AccountStatus = ({
Expand All @@ -60,6 +68,8 @@ const AccountStatus = ({
const accountName = (route.params as AccountRouteParams)?.accountName;
const oauthLoginSuccess = (route.params as AccountRouteParams)
?.oauthLoginSuccess;
const onboardingTraceCtx = (route.params as AccountRouteParams)
?.onboardingTraceCtx;

// check for small screen size
const isSmallScreen = Dimensions.get('window').width < 375;
Expand All @@ -71,15 +81,47 @@ const AccountStatus = ({
);
};

useEffect(() => {
const traceName =
type === 'found'
? TraceName.OnboardingNewSocialAccountExists
: TraceName.OnboardingExistingSocialAccountNotFound;

trace({
name: traceName,
op: TraceOperation.OnboardingUserJourney,
tags: getTraceTags(store.getState()),
parentContext: onboardingTraceCtx,
});
return () => {
endTrace({ name: traceName });
};
}, [onboardingTraceCtx, type]);

const navigateNextScreen = (
targetRoute: string,
previousScreen: string,
metricEvent: string,
) => {
const nextScenarioTraceName =
type === 'found'
? TraceName.OnboardingExistingSocialLogin
: TraceName.OnboardingNewSocialCreateWallet;
trace({
name: nextScenarioTraceName,
op: TraceOperation.OnboardingUserJourney,
tags: {
...getTraceTags(store.getState()),
source: 'account_status_redirect',
},
parentContext: onboardingTraceCtx,
});

navigation.dispatch(
StackActions.replace(targetRoute, {
[PREVIOUS_SCREEN]: previousScreen,
oauthLoginSuccess,
onboardingTraceCtx,
}),
);
track(
Expand Down
Loading
Loading