diff --git a/CHANGELOG.md b/CHANGELOG.md index 846904b1..d1e74436 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - [ask sb] Fixed "413 content too large" error when starting a new chat with many repos selected. [#416](https://github.com/sourcebot-dev/sourcebot/pull/416) +### Added +- [ask sb] PostHog telemetry for chat thread creation. [#418](https://github.com/sourcebot-dev/sourcebot/pull/418) + ## [4.6.1] - 2025-07-29 ### Added diff --git a/packages/web/src/features/chat/useCreateNewChatThread.ts b/packages/web/src/features/chat/useCreateNewChatThread.ts index 22489fbb..25c67b22 100644 --- a/packages/web/src/features/chat/useCreateNewChatThread.ts +++ b/packages/web/src/features/chat/useCreateNewChatThread.ts @@ -12,12 +12,14 @@ import { isServiceError } from "@/lib/utils"; import { createPathWithQueryParams } from "@/lib/utils"; import { SearchScope, SET_CHAT_STATE_SESSION_STORAGE_KEY, SetChatStatePayload } from "./types"; import { useSessionStorage } from "usehooks-ts"; +import useCaptureEvent from "@/hooks/useCaptureEvent"; export const useCreateNewChatThread = () => { const domain = useDomain(); const [isLoading, setIsLoading] = useState(false); const { toast } = useToast(); const router = useRouter(); + const captureEvent = useCaptureEvent(); const [, setChatState] = useSessionStorage(SET_CHAT_STATE_SESSION_STORAGE_KEY, null); @@ -38,6 +40,8 @@ export const useCreateNewChatThread = () => { return; } + captureEvent('wa_chat_thread_created', {}); + setChatState({ inputMessage, selectedSearchScopes, @@ -47,7 +51,7 @@ export const useCreateNewChatThread = () => { router.push(url); router.refresh(); - }, [domain, router, toast, setChatState]); + }, [domain, router, toast, setChatState, captureEvent]); return { createNewChatThread, diff --git a/packages/web/src/lib/posthogEvents.ts b/packages/web/src/lib/posthogEvents.ts index b20e06db..d9a9ed4b 100644 --- a/packages/web/src/lib/posthogEvents.ts +++ b/packages/web/src/lib/posthogEvents.ts @@ -282,6 +282,7 @@ export type PosthogEventMap = { chatId: string, messageId: string, }, + wa_chat_thread_created: {}, ////////////////////////////////////////////////////////////////// wa_demo_docs_link_pressed: {}, wa_demo_search_context_card_pressed: {