Skip to content

Commit e8f9d29

Browse files
add wa_chat_tool_used event
1 parent 1561c72 commit e8f9d29

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getFileSource } from '@/features/git';
22
import { isServiceError } from "@/lib/utils";
3+
import { captureEvent } from "@/lib/posthog";
34
import { ProviderOptions } from "@ai-sdk/provider-utils";
45
import { createLogger, env } from "@sourcebot/shared";
56
import { env as clientEnv } from "@sourcebot/shared/client";
@@ -82,6 +83,11 @@ export const createAgentStream = async ({
8283
toolChoice: "auto",
8384
onStepFinish: ({ toolResults }) => {
8485
toolResults.forEach(({ toolName, output, dynamic }) => {
86+
captureEvent('wa_chat_tool_used', {
87+
toolName,
88+
success: !isServiceError(output),
89+
});
90+
8591
if (dynamic || isServiceError(output)) {
8692
return;
8793
}

packages/web/src/lib/posthogEvents.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ export type PosthogEventMap = {
154154
wa_chat_message_sent: {
155155
messageCount: number,
156156
},
157+
wa_chat_tool_used: {
158+
toolName: string,
159+
success: boolean,
160+
},
157161
//////////////////////////////////////////////////////////////////
158162
wa_demo_docs_link_pressed: {},
159163
wa_demo_search_example_card_pressed: {

0 commit comments

Comments
 (0)