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

Feat/add having issues btn to migration #968

Merged
merged 2 commits into from
Jan 3, 2025
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
1 change: 1 addition & 0 deletions src/features/analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export enum Events {
NamiMigrationDismissedNotStarted = 'nami tool | nami | migration dismissed | not started | click',
NamiMigrationDismissedInProgress = 'nami tool | nami | migration dismissed | in progress | click',
NamiMigrationOpenLaceOrOpenChromeStore = 'nami tool | nami | open lace or open chrome store link | click',
NamiMigrationHavingIssuesClick = 'nami tool | nami | having migration issues | click',
}

export type Property =
Expand Down
4 changes: 3 additions & 1 deletion src/pages/Content/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ const injectScript = () => {
};

async function shouldInject() {
const { laceMigration } = (await storage.local.get(MIGRATION_KEY)) || {
const { laceMigration } = (await storage.local.get([MIGRATION_KEY])) || {
laceMigration: undefined,
};

// Prevent injection into window.cardano namespace if migration has been completed
// or if the user has dismissed because they are having issues migrating (setting migration state back to 'none')
if (laceMigration === MigrationState.Completed) return false;
const documentElement = document.documentElement.nodeName;
const docElemCheck = documentElement
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import React, { useEffect } from 'react';
import { MigrationState } from '../../../../api/migration-tool/migrator/migration-state.data';
import {
MigrationState,
MIGRATION_KEY,
} from '../../../../api/migration-tool/migrator/migration-state.data';
import { Carousel } from '../carousel/carousel.component';
import { Slide1 } from '../carousel/slides/Slide1.component';
import { Slide2 } from '../carousel/slides/Slide2.component';
import { Slide3 } from '../carousel/slides/Slide3.component';
import { AlmostThere } from '../almost-there/almost-there.component';
import { AllDone } from '../all-done/all-done.component';
import { NoWallet } from '../no-wallet/no-wallet.component';
import { useColorModeValue, Flex } from '@chakra-ui/react';
import { useColorModeValue, Flex, Link } from '@chakra-ui/react';
import { useFeatureFlagsContext } from '../../../../features/feature-flags/provider';
import { Events } from '../../../../features/analytics/events';
import { useCaptureEvent } from '../../../../features/analytics/hooks';
import { AnalyticsConsentModal } from '../../../../features/analytics/ui/AnalyticsConsentModal';
import { useAnalyticsContext } from '../../../../features/analytics/provider';
import { storage } from 'webextension-polyfill';

export const MigrationView = ({
migrationState,
Expand Down Expand Up @@ -42,36 +46,44 @@ export const MigrationView = ({
const dismissibleSeconds =
featureFlags?.['is-migration-active']?.dismissInterval;

const hasShowIssuesButton =
featureFlags?.['show-having-issues-button'] || false;

const handleHavingIssuesClick = () => {
storage.local.set({
[MIGRATION_KEY]: MigrationState.None,
});
captureEvent(Events.NamiMigrationHavingIssuesClick);
};

if (!hasWallet) {
captureEvent(Events.MigrationViewNoWalletViewed);
return (
<><Flex
h="100%"
backgroundColor={panelBg}
>
<Flex
pt="40px"
pb="30px"
px="40px"
borderTopRadius='20px'
backgroundColor={bgColor}
mt='17px'
flexDirection='column'
h='calc(100% - 17px)'
w="100%"
>
<NoWallet
isLaceInstalled={isLaceInstalled}
onAction={onNoWalletActionClick}
isDismissable={isDismissable}
dismissibleSeconds={dismissibleSeconds}
/>
<>
<Flex h="100%" backgroundColor={panelBg}>
<Flex
pt="40px"
pb="30px"
px="40px"
borderTopRadius="20px"
backgroundColor={bgColor}
mt="17px"
flexDirection="column"
h="calc(100% - 17px)"
w="100%"
>
<NoWallet
isLaceInstalled={isLaceInstalled}
onAction={onNoWalletActionClick}
isDismissable={isDismissable}
dismissibleSeconds={dismissibleSeconds}
/>
</Flex>
</Flex>
</Flex>
<AnalyticsConsentModal
askForConsent={analytics.consent === undefined}
setConsent={setAnalyticsConsent}
/>
<AnalyticsConsentModal
askForConsent={analytics.consent === undefined}
setConsent={setAnalyticsConsent}
/>
</>
);
}
Expand All @@ -81,19 +93,16 @@ export const MigrationView = ({
case MigrationState.None:
captureEvent(Events.MigrationNoStartedViewed);
return (
<Flex
h="100%"
backgroundColor={panelBg}
>
<Flex h="100%" backgroundColor={panelBg}>
<Flex
flexDirection={'column'}
pt="40px"
pb="30px"
px="0px"
borderTopRadius='20px'
borderTopRadius="20px"
backgroundColor={bgColor}
mt='17px'
h='calc(100% - 17px)'
mt="17px"
h="calc(100% - 17px)"
w="100%"
>
<Carousel onSlideSwitched={onSlideSwitched}>
Expand Down Expand Up @@ -124,19 +133,16 @@ export const MigrationView = ({
if (!isLaceInstalled) {
onWaitingForLaceScreenViewed?.();
return (
<Flex
h="100%"
backgroundColor={panelBg}
>
<Flex h="100%" backgroundColor={panelBg}>
<Flex
pt="40px"
pb="30px"
px="40px"
borderTopRadius='20px'
borderTopRadius="20px"
backgroundColor={bgColor}
mt='17px'
flexDirection='column'
h='calc(100% - 17px)'
mt="17px"
flexDirection="column"
h="calc(100% - 17px)"
w="100%"
>
<AlmostThere
Expand All @@ -151,19 +157,16 @@ export const MigrationView = ({
} else {
onOpenLaceScreenViewed?.();
return (
<Flex
h="100%"
backgroundColor={panelBg}
>
<Flex h="100%" backgroundColor={panelBg}>
<Flex
pt="40px"
pb="30px"
px="40px"
borderTopRadius='20px'
borderTopRadius="20px"
backgroundColor={bgColor}
mt='17px'
flexDirection='column'
h='calc(100% - 17px)'
mt="17px"
flexDirection="column"
h="calc(100% - 17px)"
w="100%"
>
<AlmostThere
Expand All @@ -180,19 +183,16 @@ export const MigrationView = ({
case MigrationState.Completed:
onAllDoneScreenViewed?.();
return (
<Flex
h="100%"
backgroundColor={panelBg}
>
<Flex h="100%" backgroundColor={panelBg}>
<Flex
pt="40px"
pb="30px"
px="40px"
borderTopRadius='20px'
borderTopRadius="20px"
backgroundColor={bgColor}
mt='17px'
flexDirection='column'
h='calc(100% - 17px)'
mt="17px"
flexDirection="column"
h="calc(100% - 17px)"
w="100%"
>
<AllDone
Expand All @@ -201,6 +201,15 @@ export const MigrationView = ({
isLaceInstalled ? onOpenLaceClicked : onDownloadLaceClicked
}
/>
{hasShowIssuesButton && (
<Link
textAlign="center"
marginTop={4}
onClick={handleHavingIssuesClick}
>
Having issues? Click here to continue using Nami
</Link>
)}
</Flex>
</Flex>
);
Expand Down
18 changes: 9 additions & 9 deletions src/ui/lace-migration/components/migration.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,30 @@ export const AppWithMigration = () => {
slideIndex: nextSlideIndex,
});
}}
onUpgradeWalletClicked={async() => {
onUpgradeWalletClicked={async () => {
enableMigration();
await captureEvent(Events.MigrationUpgradeYourWalletClicked);
}}
onWaitingForLaceScreenViewed={async() => {
await captureEvent(Events.MigrationDownloadLaceScreenViewed);
onWaitingForLaceScreenViewed={async () => {
await captureEvent(Events.MigrationDownloadLaceScreenViewed);
}}
onOpenLaceScreenViewed={async() => {
onOpenLaceScreenViewed={async () => {
await captureEvent(Events.MigrationOpenLaceScreenViewed);
}}
onDownloadLaceClicked={async() => {
onDownloadLaceClicked={async () => {
await captureEvent(Events.MigrationDownloadLaceClicked);
window.open(
`https://chromewebstore.google.com/detail/lace/${secrets.LACE_EXTENSION_ID}`
);
}}
onOpenLaceClicked={async() => {
await captureEvent(Events.MigrationOpenLaceClicked);
onOpenLaceClicked={async () => {
await captureEvent(Events.MigrationOpenLaceClicked);
openLace();
}}
onAllDoneScreenViewed={async() => {
onAllDoneScreenViewed={async () => {
await captureEvent(Events.MigrationAllDoneScreenViewed);
}}
onNoWalletActionClick={async() => {
onNoWalletActionClick={async () => {
if (state.isLaceInstalled) {
await captureEvent(Events.MigrationOpenLaceClicked);
openLace();
Expand Down
Loading