diff --git a/apps/web/src/app/components/logout-button.tsx b/apps/web/src/app/components/logout-button.tsx index 5b3613c6dc3..c78496dfc26 100644 --- a/apps/web/src/app/components/logout-button.tsx +++ b/apps/web/src/app/components/logout-button.tsx @@ -1,14 +1,29 @@ +"use client"; import { Button, ButtonProps } from "@rallly/ui/button"; +import { signOut } from "next-auth/react"; + +import { usePostHog } from "@/utils/posthog"; export function LogoutButton({ children, + onClick, ...rest }: React.PropsWithChildren) { + const posthog = usePostHog(); return ( -
- -
+ ); } diff --git a/apps/web/src/contexts/posthog.tsx b/apps/web/src/contexts/posthog.tsx index 0a6d7bfa55c..16b82248871 100644 --- a/apps/web/src/contexts/posthog.tsx +++ b/apps/web/src/contexts/posthog.tsx @@ -5,6 +5,7 @@ import { PostHogProvider as Provider, usePostHog } from "posthog-js/react"; import React from "react"; import { useMount } from "react-use"; +import { useTranslation } from "@/app/i18n/client"; import { useUser } from "@/components/user-provider"; import { env } from "@/env"; @@ -48,14 +49,18 @@ function usePostHogPageView() { export function PostHogProvider(props: PostHogProviderProps) { const { user } = useUser(); + const { i18n } = useTranslation(); + usePostHogPageView(); useMount(() => { if (user.email) { - posthog.identify(user.id); - posthog.people.set({ - $email: user.email, - $name: user.name, + posthog.identify(user.id, { + email: user.email, + name: user.name, + tier: user.tier, + timeZone: user.timeZone, + locale: i18n.language, }); } }); diff --git a/apps/web/src/utils/auth.ts b/apps/web/src/utils/auth.ts index b1065aea6ac..fc94b382e98 100644 --- a/apps/web/src/utils/auth.ts +++ b/apps/web/src/utils/auth.ts @@ -174,7 +174,6 @@ const getAuthOptions = (...args: GetServerSessionParams) => providers: providers, pages: { signIn: "/login", - signOut: "/logout", error: "/auth/error", }, events: { @@ -193,12 +192,6 @@ const getAuthOptions = (...args: GetServerSessionParams) => }, }); }, - signOut({ session }) { - posthog?.capture({ - distinctId: session.user.id, - event: "logout", - }); - }, }, callbacks: { async signIn({ user, email, profile }) {