feat: enhance login tracking and logout functionality

- Added session storage flag to track local login success, ensuring OAuth flows do not double track login events.
- Implemented tracking for logout events in both UserDropdown and AppSidebar components, resetting PostHog identity accordingly.
- Minor formatting adjustments in GoogleLoginButton and footer-new components for consistency.
This commit is contained in:
DESKTOP-RTLN3BA\$punk 2026-01-02 01:10:16 -08:00
parent 458c152032
commit d20aef2957
8 changed files with 84 additions and 4 deletions

View file

@ -42,6 +42,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
import { resetUser, trackLogout } from "@/lib/posthog/events";
/**
* Generates a consistent color based on a string (email)
@ -343,6 +344,10 @@ export const AppSidebar = memo(function AppSidebar({
const handleLogout = () => {
try {
// Track logout event and reset PostHog identity
trackLogout();
resetUser();
if (typeof window !== "undefined") {
localStorage.removeItem("surfsense_bearer_token");
router.push("/");