From e3a231bba5817ac23fbfbb468e1ddab32746f528 Mon Sep 17 00:00:00 2001 From: MarconLP <13001502+MarconLP@users.noreply.github.com> Date: Sat, 12 Aug 2023 10:39:14 +0200 Subject: [PATCH] do not reset posthog users everytime someone is unauthenticated --- src/components/ProfileMenu.tsx | 7 ++++++- src/pages/_app.tsx | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/ProfileMenu.tsx b/src/components/ProfileMenu.tsx index 8a38a0d..7aee3d5 100644 --- a/src/components/ProfileMenu.tsx +++ b/src/components/ProfileMenu.tsx @@ -26,6 +26,11 @@ export default function ProfileMenu() { }); }; + const handleSignOut = () => { + if (posthog?.__loaded) posthog?.reset(); + void signOut(); + }; + return ( @@ -67,7 +72,7 @@ export default function ProfileMenu() { {({ active }) => (
void signOut()} + onClick={handleSignOut} className={`mx-2 flex h-8 w-40 cursor-pointer flex-row content-center rounded-md p-2 ${ active ? "bg-gray-100" : "" }`} diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 4ca0309..b003768 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -59,8 +59,6 @@ const PostHogIdentificationWrapper = ({ email, stripeSubscriptionStatus, }); - } else if (status === "unauthenticated") { - posthog?.reset(); } }, [posthog, session, status]);