feat: added posthog

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-12-25 13:25:13 -08:00
parent 80e4f1b798
commit c96be7d9e1
18 changed files with 506 additions and 19 deletions

View file

@ -2,6 +2,7 @@
import { useRouter, useSearchParams } from "next/navigation";
import { useEffect } from "react";
import { trackUserLoggedIn } from "@/lib/analytics";
import { getAndClearRedirectPath, setBearerToken } from "@/lib/auth-utils";
interface TokenHandlerProps {
@ -40,6 +41,10 @@ const TokenHandler = ({
localStorage.setItem(storageKey, token);
setBearerToken(token);
// Track successful login (works for both email and Google OAuth)
const authType = process.env.NEXT_PUBLIC_FASTAPI_BACKEND_AUTH_TYPE || "GOOGLE";
trackUserLoggedIn({ method: authType === "GOOGLE" ? "google" : "email" });
// Check if there's a saved redirect path from before the auth flow
const savedRedirectPath = getAndClearRedirectPath();