Skip to content

Commit 1561c72

Browse files
Add wa_chat_message_sent event to ask
1 parent 2654454 commit 1561c72

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { RepositoryQuery, SearchContextQuery } from '@/lib/types';
2525
import { generateAndUpdateChatNameFromMessage } from '../../actions';
2626
import { isServiceError } from '@/lib/utils';
2727
import { NotConfiguredErrorBanner } from '../notConfiguredErrorBanner';
28+
import useCaptureEvent from '@/hooks/useCaptureEvent';
2829

2930
type ChatHistoryState = {
3031
scrollOffset?: number;
@@ -61,6 +62,7 @@ export const ChatThread = ({
6162
const { toast } = useToast();
6263
const router = useRouter();
6364
const [isContextSelectorOpen, setIsContextSelectorOpen] = useState(false);
65+
const captureEvent = useCaptureEvent();
6466

6567
// Initial state is from attachments that exist in in the chat history.
6668
const [sources, setSources] = useState<Source[]>(
@@ -118,6 +120,10 @@ export const ChatThread = ({
118120
} satisfies AdditionalChatRequestParams,
119121
});
120122

123+
captureEvent('wa_chat_message_sent', {
124+
messageCount: messages.length + 1,
125+
});
126+
121127
if (
122128
messages.length === 0 &&
123129
message.parts.length > 0 &&
@@ -148,6 +154,7 @@ export const ChatThread = ({
148154
toast,
149155
chatId,
150156
router,
157+
captureEvent,
151158
]);
152159

153160

packages/web/src/lib/posthogEvents.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ export type PosthogEventMap = {
151151
messageId: string,
152152
},
153153
wa_chat_thread_created: {},
154+
wa_chat_message_sent: {
155+
messageCount: number,
156+
},
154157
//////////////////////////////////////////////////////////////////
155158
wa_demo_docs_link_pressed: {},
156159
wa_demo_search_example_card_pressed: {

0 commit comments

Comments
 (0)