feat: added posthog

This commit is contained in:
DESKTOP-RTLN3BA\$punk 2025-12-25 13:53:41 -08:00
parent d9e6947fbd
commit 518958e9a7
15 changed files with 526 additions and 17 deletions

View file

@ -3,12 +3,16 @@ import { IconBrandGoogleFilled } from "@tabler/icons-react";
import { motion } from "motion/react";
import { useTranslations } from "next-intl";
import { Logo } from "@/components/Logo";
import { trackLoginAttempt, trackLoginFailure } from "@/lib/posthog/events";
import { AmbientBackground } from "./AmbientBackground";
export function GoogleLoginButton() {
const t = useTranslations("auth");
const handleGoogleLogin = () => {
// Track Google login attempt
trackLoginAttempt("google");
// Redirect to Google OAuth authorization URL
// credentials: 'include' is required to accept the CSRF cookie from cross-origin response
fetch(`${process.env.NEXT_PUBLIC_FASTAPI_BACKEND_URL}/auth/google/authorize`, {
@ -24,10 +28,12 @@ export function GoogleLoginButton() {
if (data.authorization_url) {
window.location.href = data.authorization_url;
} else {
trackLoginFailure("google", "No authorization URL received");
console.error("No authorization URL received");
}
})
.catch((error) => {
trackLoginFailure("google", error?.message || "Unknown error");
console.error("Error during Google login:", error);
});
};