Skip to content

Commit abe92dd

Browse files
committed
feat(web): add HAS_COMPLETED_SIGNUP key to localStorage and update LoginView for signup tracking
1 parent 44a40de commit abe92dd

File tree

5 files changed

+28
-2
lines changed

5 files changed

+28
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const STORAGE_KEYS = {
22
REMINDER: "compass.reminder",
3+
HAS_COMPLETED_SIGNUP: "compass.auth.hasCompletedSignup",
34
};

packages/web/src/views/Login/Login.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ describe("LoginView", () => {
5050

5151
beforeEach(() => {
5252
jest.clearAllMocks();
53+
localStorage.clear();
5354

5455
// Default mock implementations
5556
mockUsePostHog.mockReturnValue({
@@ -200,7 +201,7 @@ describe("LoginView", () => {
200201
});
201202

202203
// Restore original location
203-
window.location = originalLocation;
204+
(window as any).location = originalLocation;
204205
});
205206
});
206207
});

packages/web/src/views/Login/Login.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useAuthCheck } from "@web/auth/useAuthCheck";
55
import { AuthApi } from "@web/common/apis/auth.api";
66
import { WaitlistApi } from "@web/common/apis/waitlist.api";
77
import { ROOT_ROUTES } from "@web/common/constants/routes";
8+
import { STORAGE_KEYS } from "@web/common/constants/storage.constants";
89
import { AlignItems, FlexDirections } from "@web/components/Flex/styled";
910
import { LoginAbsoluteOverflowLoader } from "@web/components/LoginAbsoluteOverflowLoader/LoginAbsoluteOverflowLoader";
1011
import { GoogleButton } from "@web/components/oauth/google/GoogleButton";
@@ -46,7 +47,17 @@ export const LoginView = () => {
4647
const { isAuthenticated: isAlreadyAuthenticated } = useAuthCheck();
4748

4849
useEffect(() => {
49-
if (window.location.hostname === "localhost") {
50+
const hasCompletedSignup = localStorage.getItem(
51+
STORAGE_KEYS.HAS_COMPLETED_SIGNUP,
52+
);
53+
if (hasCompletedSignup === "true") {
54+
setWaitlistStatus({
55+
isOnWaitlist: true,
56+
isInvited: true,
57+
isActive: true,
58+
});
59+
setFlowStep("waitlistStatusKnown");
60+
} else if (window.location.hostname === "localhost") {
5061
setWaitlistStatus({
5162
isOnWaitlist: true,
5263
isInvited: true,
@@ -64,6 +75,9 @@ export const LoginView = () => {
6475
onSuccess: async (code) => {
6576
const response = await AuthApi.loginOrSignup(code);
6677

78+
// Set flag to track that user has completed signup
79+
localStorage.setItem(STORAGE_KEYS.HAS_COMPLETED_SIGNUP, "true");
80+
6781
// Identify user in PostHog with email as distinct ID
6882
if (response.email && posthog) {
6983
posthog.identify(response.email, { email: response.email });

packages/web/src/views/Onboarding/steps/mobile/MobileSignIn.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { useNavigate } from "react-router-dom";
33
import { AuthApi } from "@web/common/apis/auth.api";
44
import { SyncApi } from "@web/common/apis/sync.api";
5+
import { STORAGE_KEYS } from "@web/common/constants/storage.constants";
56
import { AbsoluteOverflowLoader } from "@web/components/AbsoluteOverflowLoader";
67
import { GoogleButton } from "@web/components/oauth/google/GoogleButton";
78
import { useGoogleLogin } from "@web/components/oauth/google/useGoogleLogin";
@@ -20,6 +21,10 @@ export const MobileSignIn: React.FC<OnboardingStepProps> = ({
2021
const { login, loading } = useGoogleLogin({
2122
onSuccess: async (code) => {
2223
const result = await AuthApi.loginOrSignup(code);
24+
25+
// Set flag to track that user has completed signup
26+
localStorage.setItem(STORAGE_KEYS.HAS_COMPLETED_SIGNUP, "true");
27+
2328
if (result.isNewUser) {
2429
// Start Google Calendar import in the background
2530
// This allows the import to begin while the user continues through onboarding

packages/web/src/views/Onboarding/steps/oauth/SignInWithGoogle.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom";
33
import { Key } from "ts-key-enum";
44
import { AuthApi } from "@web/common/apis/auth.api";
55
import { SyncApi } from "@web/common/apis/sync.api";
6+
import { STORAGE_KEYS } from "@web/common/constants/storage.constants";
67
import { AbsoluteOverflowLoader } from "@web/components/AbsoluteOverflowLoader";
78
import { GoogleButton } from "@web/components/oauth/google/GoogleButton";
89
import { useGoogleLogin } from "@web/components/oauth/google/useGoogleLogin";
@@ -21,6 +22,10 @@ export const SignInWithGoogle: React.FC<OnboardingStepProps> = ({
2122
const { login, loading } = useGoogleLogin({
2223
onSuccess: async (code) => {
2324
const result = await AuthApi.loginOrSignup(code);
25+
26+
// Set flag to track that user has completed signup
27+
localStorage.setItem(STORAGE_KEYS.HAS_COMPLETED_SIGNUP, "true");
28+
2429
if (result.isNewUser) {
2530
// Start Google Calendar import in the background
2631
// This allows the import to begin while the user continues through onboarding

0 commit comments

Comments
 (0)