Skip to content
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
2 changes: 1 addition & 1 deletion apps/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@divvi/cookies": "^6.2.3",
"@divvi/mobile": "*",
"@divvi/react-native-fs": "^2.20.1",
"@divvi/react-native-keychain": "^10.0.0",
"@divvi/react-native-keychain": "^10.0.0-divvi.1",
"@interaxyz/react-native-webview": "^13.13.4",
"@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-clipboard/clipboard": "^1.16.3",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"resolutions": {
"@divvi/cookies": "^6.2.3",
"@divvi/react-native-fs": "^2.20.1",
"@divvi/react-native-keychain": "^10.0.0",
"@divvi/react-native-keychain": "^10.0.0-divvi.1",
"@interaxyz/react-native-webview": "^13.13.4",
"@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-clipboard/clipboard": "^1.16.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/@divvi/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"peerDependencies": {
"@divvi/cookies": "^6.2.3",
"@divvi/react-native-fs": "^2.20.1",
"@divvi/react-native-keychain": "^10.0.0",
"@divvi/react-native-keychain": "^10.0.0-divvi.1",
"@interaxyz/react-native-webview": "^13.13.4",
"@react-native-async-storage/async-storage": "^2.2.0",
"@react-native-clipboard/clipboard": "^1.16.3",
Expand Down
30 changes: 0 additions & 30 deletions packages/@divvi/mobile/src/account/saga.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import * as matchers from 'redux-saga-test-plan/matchers'
import { throwError } from 'redux-saga-test-plan/providers'
import { call, select } from 'redux-saga/effects'
import {
clearStoredItemsSaga,
generateSignedMessage,
handleUpdateAccountRegistration,
initializeAccountSaga,
Expand All @@ -18,7 +17,6 @@ import { Actions as AccountActions, phoneNumberVerificationCompleted } from 'src
import { currentLanguageSelector } from 'src/i18n/selectors'
import { userLocationDataSelector } from 'src/networkInfo/selectors'
import { retrieveSignedMessage, storeSignedMessage } from 'src/pincode/authentication'
import { clearStoredItems } from 'src/storage/keychain'
import Logger from 'src/utils/Logger'
import { ViemKeychainAccount } from 'src/viem/keychainAccountToAccount'
import { getKeychainAccounts } from 'src/web3/contracts'
Expand Down Expand Up @@ -209,31 +207,3 @@ describe('initializeAccount', () => {
expect(mockFetch).toHaveBeenCalledTimes(1)
})
})

describe('clearStoredItemsSaga', () => {
it('should call clearStoredItems and track analytics event', async () => {
const mockStaleItems = ['item1', 'item2']
await expectSaga(clearStoredItemsSaga)
.provide([[call(clearStoredItems), mockStaleItems]])
.call(clearStoredItems)
.call([AppAnalytics, 'track'], OnboardingEvents.stale_keychain_items_cleared, {
staleItems: mockStaleItems,
staleItemsCount: mockStaleItems.length,
})
.run()
})

it('should log error if clearStoredItems fails', async () => {
const error = new Error('Failed to clear items')
await expectSaga(clearStoredItemsSaga)
.provide([[call(clearStoredItems), throwError(error)]])
.call(clearStoredItems)
.run()

expect(loggerErrorSpy).toHaveBeenCalledWith(
'account/saga@clearKeychainItems',
'Failed to clear keychain items',
error
)
})
})
23 changes: 0 additions & 23 deletions packages/@divvi/mobile/src/account/saga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
} from 'src/pincode/authentication'
import { persistor } from 'src/redux/store'
import { patchUpdateStatsigUser } from 'src/statsig'
import { clearStoredItems } from 'src/storage/keychain'
import { restartApp } from 'src/utils/AppRestart'
import Logger from 'src/utils/Logger'
import { ensureError } from 'src/utils/ensureError'
Expand Down Expand Up @@ -95,20 +94,6 @@ export function* initializeAccountSaga() {
}
}

export function* clearStoredItemsSaga() {
Logger.debug(TAG + '@clearKeychainItems', 'Clearing keychain items')
try {
const staleItems = yield* call(clearStoredItems)
yield* call([AppAnalytics, 'track'], OnboardingEvents.stale_keychain_items_cleared, {
staleItems,
staleItemsCount: staleItems.length,
})
} catch (err) {
const error = ensureError(err)
Logger.error(TAG + '@clearKeychainItems', 'Failed to clear keychain items', error)
}
}

function* handlePreviouslyVerifiedPhoneNumber() {
const address = yield* select(walletAddressSelector)

Expand Down Expand Up @@ -256,17 +241,9 @@ export function* watchSignedMessage() {
yield* call(handleUpdateAccountRegistration)
}

function* watchOnboardingStart() {
yield* takeLeading(
[Actions.CHOOSE_CREATE_ACCOUNT, Actions.CHOOSE_RESTORE_ACCOUNT],
safely(clearStoredItemsSaga)
)
}

export function* accountSaga() {
yield* spawn(watchUpdateStatsigAndNavigate)
yield* spawn(watchClearStoredAccount)
yield* spawn(watchInitializeAccount)
yield* spawn(watchSignedMessage)
yield* spawn(watchOnboardingStart)
}
2 changes: 0 additions & 2 deletions packages/@divvi/mobile/src/analytics/Events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,6 @@ export enum OnboardingEvents {

link_phone_number = 'link_phone_number',
link_phone_number_later = 'link_phone_number_later',

stale_keychain_items_cleared = 'stale_keychain_items_cleared',
}

// Events emitted in the CPV flow
Expand Down
4 changes: 0 additions & 4 deletions packages/@divvi/mobile/src/analytics/Properties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,6 @@ interface OnboardingEventsProperties {
[OnboardingEvents.protect_wallet_complete]: undefined
[OnboardingEvents.link_phone_number]: undefined
[OnboardingEvents.link_phone_number_later]: undefined
[OnboardingEvents.stale_keychain_items_cleared]: {
staleItems: string[]
staleItemsCount: number
}
}

interface PhoneVerificationEventsProperties {
Expand Down
2 changes: 1 addition & 1 deletion packages/@divvi/mobile/src/analytics/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ export const eventDocs: Record<AnalyticsEventType, string> = {
[OnboardingEvents.protect_wallet_complete]: ``,
[OnboardingEvents.link_phone_number]: `User chooses to link phone number for CPV after recovery flow`,
[OnboardingEvents.link_phone_number_later]: `User chooses not to link phone number for CPV after recovery flow`,
[OnboardingEvents.stale_keychain_items_cleared]: `Stale keychain items where found during onboarding and cleared`,

// Events emitted in the CPV flow
[PhoneVerificationEvents.phone_verification_skip_confirm]: `when skip is confirmed from the dialog in the phone number input screen`,
Expand Down Expand Up @@ -669,4 +668,5 @@ export const eventDocs: Record<AnalyticsEventType, string> = {
// [JumpstartEvents.jumpstart_add_assets_show_actions]: 'When user taps the CTA to show ways to add assets',
// [JumpstartEvents.jumpstart_add_assets_action_press]: 'When user selects an add assets action from the available options',
// [JumpstartEvents.jumpstart_intro_seen]: `when jumpstart intro is seen by the user`,
// [OnboardingEvents.stale_keychain_items_cleared]: `Stale keychain items where found during onboarding and cleared`,
}
14 changes: 0 additions & 14 deletions packages/@divvi/mobile/src/storage/keychain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,3 @@ export async function listStoredItems() {
throw error
}
}

export async function clearStoredItems(): Promise<string[]> {
const items = await listStoredItems()
const promises = items.map((item) => removeStoredItem(item))
const results = await Promise.allSettled(promises)

results.forEach((result, index) => {
if (result.status === 'rejected') {
Logger.error(TAG, `Failed to remove stored item: ${items[index]}`, result.reason)
}
})

return items
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1110,10 +1110,10 @@
base-64 "^0.1.0"
utf8 "^3.0.0"

"@divvi/react-native-keychain@^10.0.0":
version "10.0.0"
resolved "https://registry.yarnpkg.com/@divvi/react-native-keychain/-/react-native-keychain-10.0.0.tgz#607e6a6170b1a73740c18d8dc66b45293f28dcd0"
integrity sha512-S6+NgTO8d9P6jEPo2T2V9N1iX98XOBG9+gznOuexuvIcGZ4j1CsaM1s8Gede0CqTTHnBgkox12Z2d0/JCm7EoA==
"@divvi/react-native-keychain@^10.0.0-divvi.1":
version "10.0.0-divvi.1"
resolved "https://registry.yarnpkg.com/@divvi/react-native-keychain/-/react-native-keychain-10.0.0-divvi.1.tgz#33c0464880d248af0bc69f44b0f2e6f95b032ff3"
integrity sha512-3UuNLwnsNuDUm5N5318a/B1MBpyCdoJl9ZR7ehqEQukGRMvGvd3jAjisWSF1H6pnc96ly5fC/H0Z7gbjIdudlg==

"@divvi/referral-sdk@^2.2.0":
version "2.2.0"
Expand Down
Loading