Skip to content

Commit 49a1b76

Browse files
msukkariclaude
andcommitted
refactor(web): remove wa_ask_message_sent, set source header on chat transport
Instead of a separate client-side event, the web client now sets the X-Sourcebot-Client-Source header on DefaultChatTransport. This makes ask_message_sent fire with source='sourcebot-web-client' for web UI calls, enabling web-only filtering directly on the server-side event. Updated Ask Usage and Any Feature Usage PostHog actions to filter ask_message_sent by source=sourcebot-web-client. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 818f237 commit 49a1b76

3 files changed

Lines changed: 4 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111
- Added `thinkingLevel` and `thinkingBudget` configuration options for Google Generative AI and Google Vertex providers. [#1110](https://github.com/sourcebot-dev/sourcebot/pull/1110)
1212
- Added unified `tool_used` PostHog event tracking for all tool calls across the ask agent and MCP server. [#1111](https://github.com/sourcebot-dev/sourcebot/pull/1111)
13-
- Added client-side `wa_ask_thread_created` and `wa_ask_message_sent` PostHog events for web-only ask usage tracking. [#1111](https://github.com/sourcebot-dev/sourcebot/pull/1111)
13+
- Web app now sets `X-Sourcebot-Client-Source: sourcebot-web-client` header on chat API requests, enabling web-only ask usage filtering in dashboards. [#1111](https://github.com/sourcebot-dev/sourcebot/pull/1111)
1414

1515
### Changed
1616
- Deprecated `GOOGLE_VERTEX_THINKING_BUDGET_TOKENS` environment variable in favor of per-model `thinkingBudget` config. [#1110](https://github.com/sourcebot-dev/sourcebot/pull/1110)

packages/web/src/features/chat/components/chatThread/chatThread.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ export const ChatThread = ({
102102
messages: initialMessages,
103103
transport: new DefaultChatTransport({
104104
api: '/api/chat',
105+
headers: {
106+
'X-Sourcebot-Client-Source': 'sourcebot-web-client',
107+
},
105108
}),
106109
onData: (dataPart) => {
107110
// Keeps sources added by the assistant in sync.
@@ -126,12 +129,6 @@ export const ChatThread = ({
126129
.map((part) => part.data);
127130
setSources((prev) => [...prev, ...sources]);
128131

129-
captureEvent('wa_ask_message_sent', {
130-
chatId,
131-
messageCount: messages.length + 1,
132-
selectedReposCount: selectedSearchScopes.length,
133-
});
134-
135132
_sendMessage(message, {
136133
body: {
137134
selectedSearchScopes,

packages/web/src/lib/posthogEvents.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,6 @@ export type PosthogEventMap = {
159159
chatId: string,
160160
messageId: string,
161161
},
162-
wa_ask_message_sent: {
163-
chatId: string,
164-
messageCount: number,
165-
selectedReposCount: number,
166-
},
167162
ask_thread_created: {
168163
chatId: string,
169164
isAnonymous: boolean,

0 commit comments

Comments
 (0)