Skip to content

Commit f5e1451

Browse files
Merge branch 'main' into bkellam/bump_ai_to_v5
2 parents 7b09a9a + e47fdb5 commit f5e1451

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

CHANGELOG.md

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

16+
### Added
17+
- [ask sb] PostHog telemetry for chat thread creation. [#418](https://github.com/sourcebot-dev/sourcebot/pull/418)
18+
1619
## [4.6.1] - 2025-07-29
1720

1821
### Added

packages/backend/src/repoManager.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,16 +552,15 @@ export class RepoManager implements IRepoManager {
552552
return;
553553
}
554554

555+
const files = readdirSync(this.ctx.indexPath);
555556
const reposToReindex: number[] = [];
556-
557557
for (const repo of indexedRepos) {
558558
const shardPrefix = getShardPrefix(repo.orgId, repo.id);
559559

560560
// TODO: this doesn't take into account if a repo has multiple shards and only some of them are missing. To support that, this logic
561561
// would need to know how many total shards are expected for this repo
562562
let hasShards = false;
563563
try {
564-
const files = readdirSync(this.ctx.indexPath);
565564
hasShards = files.some(file => file.startsWith(shardPrefix));
566565
} catch (error) {
567566
logger.error(`Failed to read index directory ${this.ctx.indexPath}: ${error}`);

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)