mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
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:
parent
458c152032
commit
d20aef2957
8 changed files with 84 additions and 4 deletions
|
|
@ -3,6 +3,7 @@
|
|||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { useEffect } from "react";
|
||||
import { getAndClearRedirectPath, setBearerToken } from "@/lib/auth-utils";
|
||||
import { trackLoginSuccess } from "@/lib/posthog/events";
|
||||
|
||||
interface TokenHandlerProps {
|
||||
redirectPath?: string; // Default path to redirect after storing token (if no saved path)
|
||||
|
|
@ -36,6 +37,16 @@ const TokenHandler = ({
|
|||
|
||||
if (token) {
|
||||
try {
|
||||
// Track login success for OAuth flows (e.g., Google)
|
||||
// Local login already tracks success before redirecting here
|
||||
const alreadyTracked = sessionStorage.getItem("login_success_tracked");
|
||||
if (!alreadyTracked) {
|
||||
// This is an OAuth flow (Google login) - track success
|
||||
trackLoginSuccess("google");
|
||||
}
|
||||
// Clear the flag for future logins
|
||||
sessionStorage.removeItem("login_success_tracked");
|
||||
|
||||
// Store token in localStorage using both methods for compatibility
|
||||
localStorage.setItem(storageKey, token);
|
||||
setBearerToken(token);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue