From 40132ec5daea78f631713070ac772a4151cb9207 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Mon, 21 Apr 2025 14:43:20 -0700 Subject: [PATCH] Fix posthog callsites --- src/components/app-sidebar.tsx | 3 --- src/components/chat/ChatInput.tsx | 8 ++++---- src/components/chat/HomeChatInput.tsx | 1 - src/pages/home.tsx | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index fc0f29b..c1574d9 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -18,7 +18,6 @@ import { import { ChatList } from "./ChatList"; import { AppList } from "./AppList"; import { HelpDialog } from "./HelpDialog"; // Import the new dialog -import { usePostHog } from "posthog-js/react"; // Menu items. const items = [ @@ -146,8 +145,6 @@ function AppIcons({ }: { onHoverChange: (state: HoverState) => void; }) { - const { capture } = usePostHog(); - const routerState = useRouterState(); const pathname = routerState.location.pathname; diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx index ac9a300..c1e3112 100644 --- a/src/components/chat/ChatInput.tsx +++ b/src/components/chat/ChatInput.tsx @@ -38,7 +38,7 @@ import { useRunApp } from "@/hooks/useRunApp"; import { AutoApproveSwitch } from "../AutoApproveSwitch"; import { usePostHog } from "posthog-js/react"; export function ChatInput({ chatId }: { chatId?: number }) { - const { capture } = usePostHog(); + const posthog = usePostHog(); const [inputValue, setInputValue] = useAtom(chatInputValueAtom); const textareaRef = useRef(null); const { settings, updateSettings, isAnyProviderSetup } = useSettings(); @@ -105,7 +105,7 @@ export function ChatInput({ chatId }: { chatId?: number }) { const currentInput = inputValue; setInputValue(""); await streamMessage({ prompt: currentInput, chatId }); - capture("chat:submit"); + posthog.capture("chat:submit"); }; const handleCancel = () => { @@ -126,7 +126,7 @@ export function ChatInput({ chatId }: { chatId?: number }) { `Approving proposal for chatId: ${chatId}, messageId: ${messageId}` ); setIsApproving(true); - capture("chat:approve"); + posthog.capture("chat:approve"); try { const result = await IpcClient.getInstance().approveProposal({ chatId, @@ -160,7 +160,7 @@ export function ChatInput({ chatId }: { chatId?: number }) { `Rejecting proposal for chatId: ${chatId}, messageId: ${messageId}` ); setIsRejecting(true); - capture("chat:reject"); + posthog.capture("chat:reject"); try { const result = await IpcClient.getInstance().rejectProposal({ chatId, diff --git a/src/components/chat/HomeChatInput.tsx b/src/components/chat/HomeChatInput.tsx index 3afe740..9bad8f3 100644 --- a/src/components/chat/HomeChatInput.tsx +++ b/src/components/chat/HomeChatInput.tsx @@ -6,7 +6,6 @@ import { useSettings } from "@/hooks/useSettings"; import { homeChatInputValueAtom } from "@/atoms/chatAtoms"; // Use a different atom for home input import { useAtom } from "jotai"; import { useStreamChat } from "@/hooks/useStreamChat"; -import { usePostHog } from "posthog-js/react"; export function HomeChatInput({ onSubmit }: { onSubmit: () => void }) { const [inputValue, setInputValue] = useAtom(homeChatInputValueAtom); diff --git a/src/pages/home.tsx b/src/pages/home.tsx index e43fe2f..e489573 100644 --- a/src/pages/home.tsx +++ b/src/pages/home.tsx @@ -24,7 +24,7 @@ export default function HomePage() { const setIsPreviewOpen = useSetAtom(isPreviewOpenAtom); const [isLoading, setIsLoading] = useState(false); const { streamMessage } = useStreamChat({ hasChatId: false }); - const { capture } = usePostHog(); + const posthog = usePostHog(); // Get the appId from search params const appId = search.appId ? Number(search.appId) : null; @@ -53,7 +53,7 @@ export default function HomePage() { setSelectedAppId(result.app.id); setIsPreviewOpen(false); await refreshApps(); // Ensure refreshApps is awaited if it's async - capture("home:chat-submit"); + posthog.capture("home:chat-submit"); navigate({ to: "/chat", search: { id: result.chatId } }); } catch (error) { console.error("Failed to create chat:", error);