Fix posthog callsites

This commit is contained in:
Will Chen
2025-04-21 14:43:20 -07:00
parent 0e48d02a0b
commit 40132ec5da
4 changed files with 6 additions and 10 deletions

View File

@@ -18,7 +18,6 @@ import {
import { ChatList } from "./ChatList"; import { ChatList } from "./ChatList";
import { AppList } from "./AppList"; import { AppList } from "./AppList";
import { HelpDialog } from "./HelpDialog"; // Import the new dialog import { HelpDialog } from "./HelpDialog"; // Import the new dialog
import { usePostHog } from "posthog-js/react";
// Menu items. // Menu items.
const items = [ const items = [
@@ -146,8 +145,6 @@ function AppIcons({
}: { }: {
onHoverChange: (state: HoverState) => void; onHoverChange: (state: HoverState) => void;
}) { }) {
const { capture } = usePostHog();
const routerState = useRouterState(); const routerState = useRouterState();
const pathname = routerState.location.pathname; const pathname = routerState.location.pathname;

View File

@@ -38,7 +38,7 @@ import { useRunApp } from "@/hooks/useRunApp";
import { AutoApproveSwitch } from "../AutoApproveSwitch"; import { AutoApproveSwitch } from "../AutoApproveSwitch";
import { usePostHog } from "posthog-js/react"; import { usePostHog } from "posthog-js/react";
export function ChatInput({ chatId }: { chatId?: number }) { export function ChatInput({ chatId }: { chatId?: number }) {
const { capture } = usePostHog(); const posthog = usePostHog();
const [inputValue, setInputValue] = useAtom(chatInputValueAtom); const [inputValue, setInputValue] = useAtom(chatInputValueAtom);
const textareaRef = useRef<HTMLTextAreaElement>(null); const textareaRef = useRef<HTMLTextAreaElement>(null);
const { settings, updateSettings, isAnyProviderSetup } = useSettings(); const { settings, updateSettings, isAnyProviderSetup } = useSettings();
@@ -105,7 +105,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
const currentInput = inputValue; const currentInput = inputValue;
setInputValue(""); setInputValue("");
await streamMessage({ prompt: currentInput, chatId }); await streamMessage({ prompt: currentInput, chatId });
capture("chat:submit"); posthog.capture("chat:submit");
}; };
const handleCancel = () => { const handleCancel = () => {
@@ -126,7 +126,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
`Approving proposal for chatId: ${chatId}, messageId: ${messageId}` `Approving proposal for chatId: ${chatId}, messageId: ${messageId}`
); );
setIsApproving(true); setIsApproving(true);
capture("chat:approve"); posthog.capture("chat:approve");
try { try {
const result = await IpcClient.getInstance().approveProposal({ const result = await IpcClient.getInstance().approveProposal({
chatId, chatId,
@@ -160,7 +160,7 @@ export function ChatInput({ chatId }: { chatId?: number }) {
`Rejecting proposal for chatId: ${chatId}, messageId: ${messageId}` `Rejecting proposal for chatId: ${chatId}, messageId: ${messageId}`
); );
setIsRejecting(true); setIsRejecting(true);
capture("chat:reject"); posthog.capture("chat:reject");
try { try {
const result = await IpcClient.getInstance().rejectProposal({ const result = await IpcClient.getInstance().rejectProposal({
chatId, chatId,

View File

@@ -6,7 +6,6 @@ import { useSettings } from "@/hooks/useSettings";
import { homeChatInputValueAtom } from "@/atoms/chatAtoms"; // Use a different atom for home input import { homeChatInputValueAtom } from "@/atoms/chatAtoms"; // Use a different atom for home input
import { useAtom } from "jotai"; import { useAtom } from "jotai";
import { useStreamChat } from "@/hooks/useStreamChat"; import { useStreamChat } from "@/hooks/useStreamChat";
import { usePostHog } from "posthog-js/react";
export function HomeChatInput({ onSubmit }: { onSubmit: () => void }) { export function HomeChatInput({ onSubmit }: { onSubmit: () => void }) {
const [inputValue, setInputValue] = useAtom(homeChatInputValueAtom); const [inputValue, setInputValue] = useAtom(homeChatInputValueAtom);

View File

@@ -24,7 +24,7 @@ export default function HomePage() {
const setIsPreviewOpen = useSetAtom(isPreviewOpenAtom); const setIsPreviewOpen = useSetAtom(isPreviewOpenAtom);
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const { streamMessage } = useStreamChat({ hasChatId: false }); const { streamMessage } = useStreamChat({ hasChatId: false });
const { capture } = usePostHog(); const posthog = usePostHog();
// Get the appId from search params // Get the appId from search params
const appId = search.appId ? Number(search.appId) : null; const appId = search.appId ? Number(search.appId) : null;
@@ -53,7 +53,7 @@ export default function HomePage() {
setSelectedAppId(result.app.id); setSelectedAppId(result.app.id);
setIsPreviewOpen(false); setIsPreviewOpen(false);
await refreshApps(); // Ensure refreshApps is awaited if it's async 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 } }); navigate({ to: "/chat", search: { id: result.chatId } });
} catch (error) { } catch (error) {
console.error("Failed to create chat:", error); console.error("Failed to create chat:", error);