Skip to content

Commit 9991c8a

Browse files
committed
Add Pendo trackAgent instrumentation for AI chat interactions
Track user prompts and agent responses via pendo.trackAgent() to enable analytics on conversational AI usage within the BrowseGPT extension. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5d8b942 commit 9991c8a

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

extension/shared/global.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
declare module '*.png'
22
declare module '*.jpg'
33

4+
declare var pendo: { trackAgent: (eventType: string, metadata: object) => void }
5+
46
declare type User = {
57
id: string
68
email: string

extension/shared/pages/chat.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ const Chat: FC = () => {
7777

7878
const sendMessageMutation = trpc.sendMessage.useMutation({
7979
onSuccess: (newMessage: Message, context) => {
80+
if (typeof pendo !== 'undefined') {
81+
pendo.trackAgent("agent_response", {
82+
agentId: "xVQwu1YJtAIP58_Z4pR49NyDu8w",
83+
conversationId: openChat.id,
84+
messageId: crypto.randomUUID(),
85+
content: newMessage.content,
86+
modelUsed: "gpt-4o-mini",
87+
})
88+
}
8089
setOpenChat({
8190
...openChat,
8291
messages: [...openChat.messages, newMessage],
@@ -264,6 +273,16 @@ const Chat: FC = () => {
264273
},
265274
])
266275
}
276+
const promptMessageId = crypto.randomUUID()
277+
if (typeof pendo !== 'undefined') {
278+
pendo.trackAgent("prompt", {
279+
agentId: "xVQwu1YJtAIP58_Z4pR49NyDu8w",
280+
conversationId: openChat.id,
281+
messageId: promptMessageId,
282+
content: strippedMessage,
283+
suggestedPrompt: !!selectedCommand,
284+
})
285+
}
267286
sendMessageMutation.mutate({
268287
chatId: openChat.id,
269288
message: newMessage,

0 commit comments

Comments
 (0)