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

Disable request diagnostics modal on install #5306

Merged
merged 1 commit into from
Apr 25, 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
7 changes: 2 additions & 5 deletions src/app/common/hooks/analytics/use-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { analytics, initAnalytics } from '@shared/utils/analytics';
import { flow, origin } from '@app/common/initial-search-params';
import { useWalletType } from '@app/common/use-wallet-type';
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks';
import { useHasUserExplicitlyDeclinedAnalytics } from '@app/store/settings/settings.selectors';

const IGNORED_PATH_REGEXPS = [/^\/$/];

Expand All @@ -27,12 +26,10 @@ function isHiroApiUrl(url: string) {
}

export function useInitalizeAnalytics() {
const hasUserDeclinedAnalytics = useHasUserExplicitlyDeclinedAnalytics();

useEffect(() => {
if (hasUserDeclinedAnalytics || !SEGMENT_WRITE_KEY || IS_TEST_ENV) return;
if (!SEGMENT_WRITE_KEY || IS_TEST_ENV) return;
initAnalytics();
}, [hasUserDeclinedAnalytics]);
}, []);
}

export function useAnalytics() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/container/utils/route-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function isHomePage(pathname: RouteUrls) {
}

export function isLandingPage(pathname: RouteUrls) {
return pathname === RouteUrls.RequestDiagnostics || pathname.match(RouteUrls.Onboarding); // need to match get-started/ledger
return pathname.match(RouteUrls.Onboarding); // need to match get-started/ledger
}

function isOnboardingPage(pathname: RouteUrls) {
Expand Down

This file was deleted.

45 changes: 0 additions & 45 deletions src/app/pages/onboarding/allow-diagnostics/allow-diagnostics.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/app/pages/onboarding/welcome/welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import { useOnboardingState } from '@app/common/hooks/auth/use-onboarding-state'
import { useKeyActions } from '@app/common/hooks/use-key-actions';
import { doesBrowserSupportWebUsbApi, isPopupMode, whenPageMode } from '@app/common/utils';
import { openIndexPageInNewTab } from '@app/common/utils/open-in-new-tab';
import { useHasUserRespondedToAnalyticsConsent } from '@app/store/settings/settings.selectors';
import { WelcomeLayout } from '@app/ui/pages/welcome.layout';

export function WelcomePage() {
const hasResponded = useHasUserRespondedToAnalyticsConsent();
const navigate = useNavigate();
const { decodedAuthRequest } = useOnboardingState();
const analytics = useAnalytics();
Expand All @@ -39,7 +37,6 @@ export function WelcomePage() {
}, [keyActions, analytics, decodedAuthRequest, navigate]);

useEffect(() => {
if (!hasResponded) navigate(RouteUrls.RequestDiagnostics);
return () => setIsGeneratingWallet(false);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand Down
2 changes: 0 additions & 2 deletions src/app/routes/app-routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import { ChooseAccount } from '@app/pages/choose-account/choose-account';
import { ChooseCryptoAssetToFund } from '@app/pages/fund/choose-asset-to-fund/choose-asset-to-fund';
import { FundPage } from '@app/pages/fund/fund';
import { Home } from '@app/pages/home/home';
import { AllowDiagnosticsModal } from '@app/pages/onboarding/allow-diagnostics/allow-diagnostics';
import { BackUpSecretKeyPage } from '@app/pages/onboarding/back-up-secret-key/back-up-secret-key';
import { SignIn } from '@app/pages/onboarding/sign-in/sign-in';
import { WelcomePage } from '@app/pages/onboarding/welcome/welcome';
Expand Down Expand Up @@ -129,7 +128,6 @@ function useAppRoutes() {
</OnboardingGate>
}
>
<Route path={RouteUrls.RequestDiagnostics} element={<AllowDiagnosticsModal />} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to remove the import of AllowDiagnosticsModal and also delete that file @app/pages/onboarding/allow-diagnostics/allow-diagnostics'

<Route path={RouteUrls.ConnectLedgerStart} element={<ConnectLedgerStart />} />
<Route path={RouteUrls.LedgerUnsupportedBrowser} element={<UnsupportedBrowserLayout />} />

Expand Down
18 changes: 0 additions & 18 deletions src/app/store/settings/settings.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,6 @@ export function useUserSelectedTheme() {
return useSelector(selectUserSelectedTheme);
}

const selectHasUserExplicitlyDeclinedAnalytics = createSelector(
selectSettings,
state => state.hasAllowedAnalytics === false
);

export function useHasUserExplicitlyDeclinedAnalytics() {
return useSelector(selectHasUserExplicitlyDeclinedAnalytics);
}

const selectHasUserRespondedToAnalyticsConsent = createSelector(
selectSettings,
state => state.hasAllowedAnalytics !== null
);

export function useHasUserRespondedToAnalyticsConsent() {
return useSelector(selectHasUserRespondedToAnalyticsConsent);
}

const selectDismissedMessageIds = createSelector(
selectSettings,
state => state.dismissedMessages ?? []
Expand Down
6 changes: 0 additions & 6 deletions src/app/store/settings/settings.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ import { PayloadAction, createSlice } from '@reduxjs/toolkit';

import { UserSelectedTheme } from '@app/common/theme-provider';

type HasAcceptedAnalytics = null | boolean;
interface InitialState {
userSelectedTheme: UserSelectedTheme;
hasAllowedAnalytics: HasAcceptedAnalytics;
dismissedMessages: string[];
}

const initialState: InitialState = {
userSelectedTheme: 'system',
hasAllowedAnalytics: null,
dismissedMessages: [],
};

Expand All @@ -22,9 +19,6 @@ export const settingsSlice = createSlice({
setUserSelectedTheme(state, action: PayloadAction<UserSelectedTheme>) {
state.userSelectedTheme = action.payload;
},
setHasAllowedAnalytics(state, action: PayloadAction<boolean>) {
state.hasAllowedAnalytics = action.payload;
},
messageDismissed(state, action: PayloadAction<string>) {
if (!Array.isArray(state.dismissedMessages)) state.dismissedMessages = [];
state.dismissedMessages = [...state.dismissedMessages, action.payload];
Expand Down
6 changes: 5 additions & 1 deletion src/app/ui/components/containers/dialog/dialog.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export function Dialog() {
return (
<>
<Button onClick={() => setIsShowing(!isShowing)}>Open</Button>
<Component isShowing={isShowing} onClose={() => setIsShowing(false)}>
<Component
header={<h1>Some Header</h1>}
isShowing={isShowing}
onClose={() => setIsShowing(false)}
>
<h1>Some Dialog</h1>
</Component>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/components/containers/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface DialogProps {
interface RadixDialogProps extends DialogProps {
children: ReactNode;
footer?: ReactNode;
header?: ReactElement<any, string | JSXElementConstructor<any>>;
header: ReactElement<any, string | JSXElementConstructor<any>>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a change in this PR but, why not ReactNode here 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it separately👍 . Not sure why I didn't do that in the first place

onGoBack?(): void;
wrapChildren?: boolean;
}
Expand Down
3 changes: 1 addition & 2 deletions src/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// https://developer.chrome.com/docs/extensions/mv3/architecture-overview/#background_script
import { logger } from '@shared/logger';
import { CONTENT_SCRIPT_PORT, type LegacyMessageFromContentScript } from '@shared/message-types';
import { RouteUrls } from '@shared/route-urls';
import { WalletRequests } from '@shared/rpc/rpc-methods';
import { warnUsersAboutDevToolsDangers } from '@shared/utils/dev-tools-warning-log';

Expand All @@ -21,7 +20,7 @@ warnUsersAboutDevToolsDangers();
chrome.runtime.onInstalled.addListener(async details => {
if (details.reason === 'install' && process.env.WALLET_ENVIRONMENT !== 'testing') {
await chrome.tabs.create({
url: chrome.runtime.getURL(`index.html#${RouteUrls.RequestDiagnostics}`),
url: chrome.runtime.getURL(`index.html`),
});
}
});
Expand Down
1 change: 0 additions & 1 deletion src/shared/route-urls.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum RouteUrls {
// Onboarding routes
RequestDiagnostics = '/get-started/request-diagnostics',
Onboarding = '/get-started',
BackUpSecretKey = '/back-up-secret-key',
SetPassword = '/set-password',
Expand Down
9 changes: 0 additions & 9 deletions src/shared/utils/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@ import { base58 } from '@scure/base';
import { AnalyticsBrowser } from '@segment/analytics-next';
import * as Sentry from '@sentry/react';
import { token } from 'leather-styles/tokens';
import { getStoredState } from 'redux-persist';

import {
IS_TEST_ENV,
SEGMENT_WRITE_KEY,
SENTRY_DSN,
WALLET_ENVIRONMENT,
} from '@shared/environment';
import { persistConfig } from '@shared/storage/redux-pesist';

import type { RootState } from '@app/store';

export const analytics = new AnalyticsBrowser();

Expand Down Expand Up @@ -110,11 +106,6 @@ export function initSentry() {
environment: WALLET_ENVIRONMENT,
autoSessionTracking: false,
async beforeSend(event) {
const state = (await getStoredState(persistConfig)) as RootState;
const hasAllowedAnalytics = state.settings.hasAllowedAnalytics;

if (!hasAllowedAnalytics) return null;

delete event.user?.ip_address;
delete event.extra?.ip_address;

Expand Down
10 changes: 1 addition & 9 deletions tests/page-object-models/onboarding.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const testSoftwareAccountDefaultWalletState = {
},
settings: {
userSelectedTheme: 'system',
hasAllowedAnalytics: false,
dismissedMessages: [],
},
_persist: { version: 2, rehydrated: true },
Expand Down Expand Up @@ -225,18 +224,13 @@ export function makeLedgerTestAccountWalletState(keysToInclude: SupportedBlockch
'Explore apps': 0,
},
},
settings: { dismissedMessages: [], hasAllowedAnalytics: false, userSelectedTheme: 'system' },
settings: { dismissedMessages: [], userSelectedTheme: 'system' },
};
}

export class OnboardingPage {
constructor(readonly page: Page) {}

async denyAnalytics() {
await this.page.getByTestId(OnboardingSelectors.DenyAnalyticsBtn).click();
await this.page.waitForURL('**' + RouteUrls.Onboarding);
}

async setPassword() {
await this.page.waitForURL('**' + RouteUrls.SetPassword);
await this.page.getByTestId(OnboardingSelectors.NewPasswordInput).fill(TEST_PASSWORD);
Expand All @@ -245,14 +239,12 @@ export class OnboardingPage {
}

async signUpNewUser() {
await this.denyAnalytics();
await this.page.getByTestId(OnboardingSelectors.SignUpBtn).click();
await this.page.waitForURL('**' + RouteUrls.BackUpSecretKey);
await this.page.getByTestId(OnboardingSelectors.BackUpSecretKeyBtn).click();
await this.setPassword();
}
async initiateSignIn() {
await this.denyAnalytics();
await this.page.getByTestId(OnboardingSelectors.SignInLink).click();
}

Expand Down
2 changes: 0 additions & 2 deletions tests/selectors/onboarding.selectors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
export enum OnboardingSelectors {
AllowAnalyticsBtn = 'allow-analytics-btn',
BackUpSecretKeyBtn = 'back-up-secret-key-btn',
DenyAnalyticsBtn = 'deny-analytics-btn',
LogoRouteToHome = 'logo-route-to-home',
NewPasswordInput = 'set-or-enter-password-input',
NoAssetsFundAccountLink = 'no-assets-fund-account-link',
Expand Down
2 changes: 1 addition & 1 deletion tests/specs/settings/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { test } from '../../fixtures/fixtures';

test.describe('Settings menu', () => {
test.beforeEach(async ({ extensionId, globalPage, onboardingPage }) => {

Check failure on line 8 in tests/specs/settings/settings.spec.ts

View workflow job for this annotation

GitHub Actions / Shard 8 of 8

[chromium] › specs/settings/settings.spec.ts:32:3 › Settings menu › that menu item can lock and unlock the extension

1) [chromium] › specs/settings/settings.spec.ts:32:3 › Settings menu › that menu item can lock and unlock the extension Test timeout of 30000ms exceeded while running "beforeEach" hook. 6 | 7 | test.describe('Settings menu', () => { > 8 | test.beforeEach(async ({ extensionId, globalPage, onboardingPage }) => { | ^ 9 | await globalPage.setupAndUseApiCalls(extensionId); 10 | await onboardingPage.signInWithTestAccount(extensionId); 11 | }); at /home/runner/work/extension/extension/tests/specs/settings/settings.spec.ts:8:8
await globalPage.setupAndUseApiCalls(extensionId);
await onboardingPage.signInWithTestAccount(extensionId);
});
Expand All @@ -25,7 +25,7 @@

test('that menu item can perform sign out', async ({ homePage, onboardingPage }) => {
await homePage.signOut();
const button = onboardingPage.page.getByTestId(OnboardingSelectors.DenyAnalyticsBtn);
const button = onboardingPage.page.getByTestId(OnboardingSelectors.SignUpBtn);
test.expect(button).toBeTruthy();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/specs/store-migrations/store-migrations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test.describe('Store migrations', () => {

test.describe('Migration 0 --> 2', () => {
const previousSerializedState =
'{"analytics":"{\\"hasStxDeposits\\":{\\"1\\":true,\\"2147483648\\":true}}","chains":"{\\"stx\\":{\\"default\\":{\\"highestAccountIndex\\":16,\\"currentAccountIndex\\":0}}}","keys":"{\\"ids\\":[\\"default\\"],\\"entities\\":{\\"default\\":{\\"type\\":\\"software\\",\\"id\\":\\"default\\",\\"salt\\":\\"c4cccf33166051f7704cd877a2f03f93\\",\\"encryptedSecretKey\\":\\"b7f516798e7160eca15c50b62e588698937f8ecf3930efc42baa690ddc0c7a51b74e3e4b129859274ed272652bc47651c6b6effbddf4d72a3eb9d2ea657b64a833c9bdccb562e45d94f0cc1366154072f12d35290566a99a6f952cd234ca9259\\"}}}","networks":"{\\"ids\\":[],\\"entities\\":{},\\"currentNetworkId\\":\\"mainnet\\"}","onboarding":"{\\"hideSteps\\":true,\\"stepsStatus\\":{\\"Back up secret key\\":1,\\"Add some funds\\":0,\\"Explore apps\\":0,\\"Buy an NFT\\":0}}","settings":"{\\"userSelectedTheme\\":\\"system\\",\\"hasAllowedAnalytics\\":false,\\"dismissedMessages\\":[]}","_persist":"{\\"version\\":1,\\"rehydrated\\":true}"}';
'{"analytics":"{\\"hasStxDeposits\\":{\\"1\\":true,\\"2147483648\\":true}}","chains":"{\\"stx\\":{\\"default\\":{\\"highestAccountIndex\\":16,\\"currentAccountIndex\\":0}}}","keys":"{\\"ids\\":[\\"default\\"],\\"entities\\":{\\"default\\":{\\"type\\":\\"software\\",\\"id\\":\\"default\\",\\"salt\\":\\"c4cccf33166051f7704cd877a2f03f93\\",\\"encryptedSecretKey\\":\\"b7f516798e7160eca15c50b62e588698937f8ecf3930efc42baa690ddc0c7a51b74e3e4b129859274ed272652bc47651c6b6effbddf4d72a3eb9d2ea657b64a833c9bdccb562e45d94f0cc1366154072f12d35290566a99a6f952cd234ca9259\\"}}}","networks":"{\\"ids\\":[],\\"entities\\":{},\\"currentNetworkId\\":\\"mainnet\\"}","onboarding":"{\\"hideSteps\\":true,\\"stepsStatus\\":{\\"Back up secret key\\":1,\\"Add some funds\\":0,\\"Explore apps\\":0,\\"Buy an NFT\\":0}}","settings":"{\\"userSelectedTheme\\":\\"system\\",\\"dismissedMessages\\":[]}","_persist":"{\\"version\\":1,\\"rehydrated\\":true}"}';

test('that the app detects old store format', async ({ extensionId, globalPage }) => {
const { page } = globalPage;
Expand Down
Loading