Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion packages/web/src/features/chat/useCreateNewChatThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SetChatStatePayload | null>(SET_CHAT_STATE_SESSION_STORAGE_KEY, null);

Expand All @@ -38,6 +40,8 @@ export const useCreateNewChatThread = () => {
return;
}

captureEvent('wa_chat_thread_created', {});

setChatState({
inputMessage,
selectedSearchScopes,
Expand All @@ -47,7 +51,7 @@ export const useCreateNewChatThread = () => {

router.push(url);
router.refresh();
}, [domain, router, toast, setChatState]);
}, [domain, router, toast, setChatState, captureEvent]);

return {
createNewChatThread,
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/lib/posthogEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down