Skip to content

Commit 4826978

Browse files
chore(ask_sb): Add PostHog telemetry event for new chat thread creation (#418)
1 parent 163e558 commit 4826978

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111
- [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)
1212

13+
### Added
14+
- [ask sb] PostHog telemetry for chat thread creation. [#418](https://github.com/sourcebot-dev/sourcebot/pull/418)
15+
1316
## [4.6.1] - 2025-07-29
1417

1518
### Added

packages/web/src/features/chat/useCreateNewChatThread.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import { isServiceError } from "@/lib/utils";
1212
import { createPathWithQueryParams } from "@/lib/utils";
1313
import { SearchScope, SET_CHAT_STATE_SESSION_STORAGE_KEY, SetChatStatePayload } from "./types";
1414
import { useSessionStorage } from "usehooks-ts";
15+
import useCaptureEvent from "@/hooks/useCaptureEvent";
1516

1617
export const useCreateNewChatThread = () => {
1718
const domain = useDomain();
1819
const [isLoading, setIsLoading] = useState(false);
1920
const { toast } = useToast();
2021
const router = useRouter();
22+
const captureEvent = useCaptureEvent();
2123

2224
const [, setChatState] = useSessionStorage<SetChatStatePayload | null>(SET_CHAT_STATE_SESSION_STORAGE_KEY, null);
2325

@@ -38,6 +40,8 @@ export const useCreateNewChatThread = () => {
3840
return;
3941
}
4042

43+
captureEvent('wa_chat_thread_created', {});
44+
4145
setChatState({
4246
inputMessage,
4347
selectedSearchScopes,
@@ -47,7 +51,7 @@ export const useCreateNewChatThread = () => {
4751

4852
router.push(url);
4953
router.refresh();
50-
}, [domain, router, toast, setChatState]);
54+
}, [domain, router, toast, setChatState, captureEvent]);
5155

5256
return {
5357
createNewChatThread,

packages/web/src/lib/posthogEvents.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ export type PosthogEventMap = {
282282
chatId: string,
283283
messageId: string,
284284
},
285+
wa_chat_thread_created: {},
285286
//////////////////////////////////////////////////////////////////
286287
wa_demo_docs_link_pressed: {},
287288
wa_demo_search_context_card_pressed: {

0 commit comments

Comments
 (0)