From 90a3907b1c1d752da8cd19d1e7e5d307e10149f5 Mon Sep 17 00:00:00 2001 From: John Oshalusi Date: Tue, 23 Apr 2024 17:24:56 +0100 Subject: [PATCH 1/3] fix: cleanup hd-discovery analytics event for forgot password flow --- .../components/WalletSetupWizard.tsx | 32 ++----------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/apps/browser-extension-wallet/src/views/browser-view/features/wallet-setup/components/WalletSetupWizard.tsx b/apps/browser-extension-wallet/src/views/browser-view/features/wallet-setup/components/WalletSetupWizard.tsx index e514b3a54..1d38ddadc 100644 --- a/apps/browser-extension-wallet/src/views/browser-view/features/wallet-setup/components/WalletSetupWizard.tsx +++ b/apps/browser-extension-wallet/src/views/browser-view/features/wallet-setup/components/WalletSetupWizard.tsx @@ -2,7 +2,7 @@ import React, { Suspense, useCallback, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { wordlists } from 'bip39'; -import { useLocalStorage, useTimeSpentOnPage, useWalletManager } from '@hooks'; +import { useTimeSpentOnPage, useWalletManager } from '@hooks'; import { MnemonicStage, MnemonicVideoPopupContent, @@ -13,20 +13,14 @@ import { import { Wallet } from '@lace/cardano'; import { WalletSetupLayout } from '@src/views/browser-view/components/Layout'; import { WarningModal } from '@src/views/browser-view/components/WarningModal'; -import { - EnhancedAnalyticsOptInStatus, - PostHogAction, - postHogOnboardingActions -} from '@providers/AnalyticsProvider/analyticsTracker'; +import { PostHogAction, postHogOnboardingActions } from '@providers/AnalyticsProvider/analyticsTracker'; import { config } from '@src/config'; import { Fallback } from './Fallback'; import { deleteFromLocalStorage } from '@src/utils/local-storage'; import { useAnalyticsContext } from '@providers'; -import { ENHANCED_ANALYTICS_OPT_IN_STATUS_LS_KEY } from '@providers/AnalyticsProvider/config'; import * as process from 'process'; import { SendOnboardingAnalyticsEvent, SetupType } from '../types'; import { isScriptAddress } from '@cardano-sdk/wallet'; -import { filter, firstValueFrom } from 'rxjs'; import { getWalletFromStorage } from '@src/utils/get-wallet-from-storage'; const WalletSetupModeStep = React.lazy(() => @@ -65,7 +59,6 @@ export const WalletSetupWizard = ({ initialStep = WalletSetupSteps.Register }: WalletSetupWizardProps): React.ReactElement => { const [currentStep, setCurrentStep] = useState(initialStep); - const [walletInstance, setWalletInstance] = useState(); const [mnemonicLength, setMnemonicLength] = useState(DEFAULT_MNEMONIC_LENGTH); const [mnemonic, setMnemonic] = useState([]); const [resetMnemonicStage, setResetMnemonicStage] = useState(''); @@ -75,10 +68,6 @@ export const WalletSetupWizard = ({ const { createWallet } = useWalletManager(); const analytics = useAnalyticsContext(); const { t } = useTranslation(); - const [enhancedAnalyticsStatus] = useLocalStorage( - ENHANCED_ANALYTICS_OPT_IN_STATUS_LS_KEY, - EnhancedAnalyticsOptInStatus.OptedOut - ); const { updateEnteredAtTime } = useTimeSpentOnPage(); @@ -153,19 +142,6 @@ export const WalletSetupWizard = ({ } }; - const goToMyWallet = useCallback( - async (cardanoWallet: Wallet.CardanoWallet = walletInstance) => { - if (enhancedAnalyticsStatus === EnhancedAnalyticsOptInStatus.OptedIn) { - const addresses = await firstValueFrom(cardanoWallet?.wallet?.addresses$.pipe(filter((a) => a.length > 0))); - const hdWalletDiscovered = addresses.some((addr) => !isScriptAddress(addr) && addr.index > 0); - if (hdWalletDiscovered) { - void analytics.sendEventToPostHog(PostHogAction.OnboardingRestoreHdWallet); - } - } - }, - [analytics, enhancedAnalyticsStatus, walletInstance] - ); - const moveForward = useCallback(() => { const nextStep = walletSetupWizard[currentStep].next; setCurrentStep(nextStep); @@ -180,7 +156,6 @@ export const WalletSetupWizard = ({ password, chainId: DEFAULT_CHAIN_ID }); - setWalletInstance(wallet); wallet.wallet.addresses$.subscribe((addresses) => { if (addresses.length === 0) return; @@ -192,7 +167,6 @@ export const WalletSetupWizard = ({ if (setupType === SetupType.FORGOT_PASSWORD) { deleteFromLocalStorage('isForgotPasswordFlow'); - void goToMyWallet(wallet); } else { moveForward(); } @@ -201,7 +175,7 @@ export const WalletSetupWizard = ({ throw new Error(error); } }, - [createWallet, mnemonic, analytics, setupType, goToMyWallet, moveForward] + [createWallet, mnemonic, analytics, setupType, moveForward] ); const handleSubmit = async (result: { password: string; walletName: string }) => { From 7d1f49ca6a5c17cd21ad225ade71aedeefdf219d Mon Sep 17 00:00:00 2001 From: John Oshalusi Date: Mon, 29 Apr 2024 10:52:27 +0100 Subject: [PATCH 2/3] fix: enable unlock wallet button for testing --- .../MainMenu/DropdownMenuOverlay/components/LockWallet.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx b/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx index 9bc84c122..01447e3ba 100644 --- a/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx +++ b/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx @@ -17,7 +17,7 @@ export const LockWallet = (): React.ReactElement => { }; return ( - + {t('browserView.topNavigationBar.links.lockWallet')} ); From d4c95d8b1f7214fe05148d63a77fcb70ca4163e7 Mon Sep 17 00:00:00 2001 From: John Oshalusi Date: Tue, 30 Apr 2024 11:52:54 +0100 Subject: [PATCH 3/3] fix: disable unlock wallet button --- .../MainMenu/DropdownMenuOverlay/components/LockWallet.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx b/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx index 01447e3ba..9bc84c122 100644 --- a/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx +++ b/apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/LockWallet.tsx @@ -17,7 +17,7 @@ export const LockWallet = (): React.ReactElement => { }; return ( - + {t('browserView.topNavigationBar.links.lockWallet')} );