Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix: posthog reset (#11481)

Nimarae6acee9c934
diff --git a/web/src/components/layouts/app-layout/index.tsx b/web/src/components/layouts/app-layout/index.tsx
index 068888de53..a8ae73e5a3 100644
--- a/web/src/components/layouts/app-layout/index.tsx
+++ b/web/src/components/layouts/app-layout/index.tsx
@@ -12,6 +12,8 @@
import { type PropsWithChildren, useEffect } from "react";
import { useRouter } from "next/router";
import { signOut } from "next-auth/react";
+import posthog from "posthog-js";
+import { env } from "@/src/env.mjs";
import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
import { ErrorPageWithSentry } from "@/src/components/error-page";
@@ -127,6 +129,9 @@ export function AppLayout(props: PropsWithChildren) {
const handleSignOut = async () => {
sessionStorage.clear();
+ if (env.NEXT_PUBLIC_POSTHOG_KEY && env.NEXT_PUBLIC_POSTHOG_HOST) {
+ posthog.reset();
+ }
await signOut({ callbackUrl: `/auth/sign-in` });
};
diff --git a/web/src/pages/_app.tsx b/web/src/pages/_app.tsx
index 1752783003..0ca876a0cb 100644
--- a/web/src/pages/_app.tsx
+++ b/web/src/pages/_app.tsx
@@ -204,10 +204,6 @@ function UserTracking() {
});
} else if (session.status === "unauthenticated") {
lastIdentifiedUser.current = null;
- // PostHog
- if (env.NEXT_PUBLIC_POSTHOG_KEY && env.NEXT_PUBLIC_POSTHOG_HOST) {
- posthog.reset();
- }
// Sentry
setUser(null);
}