From 3e51b22a49ac06a6e1c5e60610ded1e5b1b91da1 Mon Sep 17 00:00:00 2001 From: Xavier Lien Date: Sat, 9 Nov 2024 19:42:27 -0500 Subject: [PATCH 1/2] Added identify user --- apps/frontend/src/components/Page.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/frontend/src/components/Page.tsx b/apps/frontend/src/components/Page.tsx index 63b52b7..5c683e2 100644 --- a/apps/frontend/src/components/Page.tsx +++ b/apps/frontend/src/components/Page.tsx @@ -9,6 +9,7 @@ import { SideNav } from "./SideNav"; import Link from "./Link"; import { useAuth } from "@clerk/nextjs"; import { userSlice } from "~/app/user"; +import { usePostHog } from "posthog-js/react"; type Props = { sidebar?: React.ReactNode; @@ -23,7 +24,7 @@ export const Page = ({ sidebar, content, activePage }: Props) => { ); const dispatch = useAppDispatch(); - const { isLoaded, userId, sessionId, getToken } = useAuth(); + const { isLoaded, isSignedIn, userId, sessionId, getToken } = useAuth(); useEffect(() => { if (isLoaded && userId && sessionId) { @@ -50,6 +51,16 @@ export const Page = ({ sidebar, content, activePage }: Props) => { } }, [dispatch, loggedIn, modalShown]); + const posthog = usePostHog(); + + useEffect(() => { + if (isSignedIn && userId) { + posthog?.identify(userId); + } else { + posthog?.reset(); + } + }, [posthog, isSignedIn, userId]); + return (
From 0f6e6734df5733fd9586c19f4b757581c22dbeb1 Mon Sep 17 00:00:00 2001 From: Xavier Lien Date: Sat, 9 Nov 2024 19:45:41 -0500 Subject: [PATCH 2/2] Don't mask searches --- apps/frontend/src/app/providers.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/frontend/src/app/providers.tsx b/apps/frontend/src/app/providers.tsx index c0c778a..045911c 100644 --- a/apps/frontend/src/app/providers.tsx +++ b/apps/frontend/src/app/providers.tsx @@ -12,7 +12,13 @@ export function PHProvider({ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY || "", { api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST, person_profiles: 'identified_only', - capture_pageview: false // Disable automatic pageview capture, as we capture manually + capture_pageview: false, // Disable automatic pageview capture, as we capture manually + session_recording: { + maskAllInputs: false, + maskInputOptions: { + password: true, + } + } }) }, []);