Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 packages/web/src/common/constants/storage.constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const STORAGE_KEYS = {
REMINDER: "compass.reminder",
HAS_COMPLETED_SIGNUP: "compass.auth.hasCompletedSignup",
};
3 changes: 2 additions & 1 deletion packages/web/src/views/Login/Login.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe("LoginView", () => {

beforeEach(() => {
jest.clearAllMocks();
localStorage.clear();

// Default mock implementations
mockUsePostHog.mockReturnValue({
Expand Down Expand Up @@ -200,7 +201,7 @@ describe("LoginView", () => {
});

// Restore original location
window.location = originalLocation;
(window as any).location = originalLocation;
});
});
});
16 changes: 15 additions & 1 deletion packages/web/src/views/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useAuthCheck } from "@web/auth/useAuthCheck";
import { AuthApi } from "@web/common/apis/auth.api";
import { WaitlistApi } from "@web/common/apis/waitlist.api";
import { ROOT_ROUTES } from "@web/common/constants/routes";
import { STORAGE_KEYS } from "@web/common/constants/storage.constants";
import { AlignItems, FlexDirections } from "@web/components/Flex/styled";
import { LoginAbsoluteOverflowLoader } from "@web/components/LoginAbsoluteOverflowLoader/LoginAbsoluteOverflowLoader";
import { GoogleButton } from "@web/components/oauth/google/GoogleButton";
Expand Down Expand Up @@ -46,7 +47,17 @@ export const LoginView = () => {
const { isAuthenticated: isAlreadyAuthenticated } = useAuthCheck();

useEffect(() => {
if (window.location.hostname === "localhost") {
const hasCompletedSignup = localStorage.getItem(
STORAGE_KEYS.HAS_COMPLETED_SIGNUP,
);
if (hasCompletedSignup === "true") {
setWaitlistStatus({
isOnWaitlist: true,
isInvited: true,
isActive: true,
});
setFlowStep("waitlistStatusKnown");
} else if (window.location.hostname === "localhost") {
setWaitlistStatus({
isOnWaitlist: true,
isInvited: true,
Expand All @@ -64,6 +75,9 @@ export const LoginView = () => {
onSuccess: async (code) => {
const response = await AuthApi.loginOrSignup(code);

// Set flag to track that user has completed signup
localStorage.setItem(STORAGE_KEYS.HAS_COMPLETED_SIGNUP, "true");

// Identify user in PostHog with email as distinct ID
if (response.email && posthog) {
posthog.identify(response.email, { email: response.email });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import { useNavigate } from "react-router-dom";
import { AuthApi } from "@web/common/apis/auth.api";
import { SyncApi } from "@web/common/apis/sync.api";
import { STORAGE_KEYS } from "@web/common/constants/storage.constants";
import { AbsoluteOverflowLoader } from "@web/components/AbsoluteOverflowLoader";
import { GoogleButton } from "@web/components/oauth/google/GoogleButton";
import { useGoogleLogin } from "@web/components/oauth/google/useGoogleLogin";
Expand All @@ -20,6 +21,10 @@ export const MobileSignIn: React.FC<OnboardingStepProps> = ({
const { login, loading } = useGoogleLogin({
onSuccess: async (code) => {
const result = await AuthApi.loginOrSignup(code);

// Set flag to track that user has completed signup
localStorage.setItem(STORAGE_KEYS.HAS_COMPLETED_SIGNUP, "true");

if (result.isNewUser) {
// Start Google Calendar import in the background
// This allows the import to begin while the user continues through onboarding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useNavigate } from "react-router-dom";
import { Key } from "ts-key-enum";
import { AuthApi } from "@web/common/apis/auth.api";
import { SyncApi } from "@web/common/apis/sync.api";
import { STORAGE_KEYS } from "@web/common/constants/storage.constants";
import { AbsoluteOverflowLoader } from "@web/components/AbsoluteOverflowLoader";
import { GoogleButton } from "@web/components/oauth/google/GoogleButton";
import { useGoogleLogin } from "@web/components/oauth/google/useGoogleLogin";
Expand All @@ -21,6 +22,10 @@ export const SignInWithGoogle: React.FC<OnboardingStepProps> = ({
const { login, loading } = useGoogleLogin({
onSuccess: async (code) => {
const result = await AuthApi.loginOrSignup(code);

// Set flag to track that user has completed signup
localStorage.setItem(STORAGE_KEYS.HAS_COMPLETED_SIGNUP, "true");

if (result.isNewUser) {
// Start Google Calendar import in the background
// This allows the import to begin while the user continues through onboarding
Expand Down