Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
📈 Only identify logged in users and reset on sign out
Luke Vella30424ac2795c
diff --git a/apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsx b/apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsxindex 6f722850c..876153853 100644--- a/apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsx+++ b/apps/web/src/app/[locale]/(space)/(dashboard)/components/nav-user.tsx@@ -1,5 +1,6 @@"use client";+import { usePostHog } from "@rallly/posthog/client";import { Button } from "@rallly/ui/button";import {DropdownMenu,@@ -33,6 +34,7 @@ export function NavUser({email: string;}) {const [isPending, setIsPending] = React.useState(false);+ const posthog = usePostHog();return (<>{isPending && <RouterLoadingIndicator />}@@ -80,6 +82,7 @@ export function NavUser({onClick={async () => {setIsPending(true);await signOut();+ posthog?.reset();}}><Icon>diff --git a/apps/web/src/app/[locale]/accept-invite/[inviteId]/components/sign-out-button.tsx b/apps/web/src/app/[locale]/accept-invite/[inviteId]/components/sign-out-button.tsxindex caceb9271..6c182edc2 100644--- a/apps/web/src/app/[locale]/accept-invite/[inviteId]/components/sign-out-button.tsx+++ b/apps/web/src/app/[locale]/accept-invite/[inviteId]/components/sign-out-button.tsx@@ -1,5 +1,6 @@"use client";+import { usePostHog } from "@rallly/posthog/client";import { Button } from "@rallly/ui/button";import React from "react";import { Trans } from "@/components/trans";@@ -7,6 +8,7 @@ import { signOut } from "@/lib/auth-client";export function SignOutButton() {const [isPending, setIsPending] = React.useState(false);+ const posthog = usePostHog();return (<Buttonvariant="link"@@ -14,6 +16,7 @@ export function SignOutButton() {onClick={async () => {setIsPending(true);await signOut();+ posthog?.reset();}}><Transdiff --git a/apps/web/src/app/[locale]/layout.tsx b/apps/web/src/app/[locale]/layout.tsxindex 668836d79..ec9993b63 100644--- a/apps/web/src/app/[locale]/layout.tsx+++ b/apps/web/src/app/[locale]/layout.tsx@@ -79,7 +79,9 @@ export default async function Root({<TRPCProvider><LazyMotion features={domAnimation}><PostHogProvider>- <PostHogIdentify distinctId={user?.id} />+ <PostHogIdentify+ distinctId={user && !user.isGuest ? user.id : undefined}+ /><PostHogPageView /><TooltipProvider><UserProvider user={user ?? undefined}>diff --git a/apps/web/src/components/user-dropdown.tsx b/apps/web/src/components/user-dropdown.tsxindex 00359b324..cb35a4b4d 100644--- a/apps/web/src/components/user-dropdown.tsx+++ b/apps/web/src/components/user-dropdown.tsx@@ -1,4 +1,5 @@"use client";+import { usePostHog } from "@rallly/posthog/client";import { cn } from "@rallly/ui";import { Button } from "@rallly/ui/button";import {@@ -30,6 +31,7 @@ import { useAuthenticatedUser } from "./user-provider";export const UserDropdown = ({ className }: { className?: string }) => {const { user } = useAuthenticatedUser();+ const posthog = usePostHog();if (!user) return null;return (<DropdownMenu modal={false}>@@ -123,6 +125,7 @@ export const UserDropdown = ({ className }: { className?: string }) => {<DropdownMenuItemonClick={async () => {await signOut();+ posthog?.reset();}}className="flex items-center gap-x-2">diff --git a/apps/web/src/trpc/client/provider.tsx b/apps/web/src/trpc/client/provider.tsxindex 6e72a5106..885ed9723 100644--- a/apps/web/src/trpc/client/provider.tsx+++ b/apps/web/src/trpc/client/provider.tsx@@ -50,7 +50,9 @@ export function TRPCProvider(props: { children: React.ReactNode }) {);break;case "FORBIDDEN":- signOut();+ signOut().then(() => {+ posthog?.reset();+ });break;default:console.error(error);diff --git a/packages/posthog/src/client.tsx b/packages/posthog/src/client.tsxindex ca11abac5..9215b0892 100644--- a/packages/posthog/src/client.tsx+++ b/packages/posthog/src/client.tsx@@ -29,8 +29,6 @@ export function PostHogIdentify({ distinctId }: { distinctId?: string }) {React.useEffect(() => {if (distinctId) {posthog?.identify(distinctId);- } else {- posthog?.reset();}}, [distinctId]);return null;