Instrument Pendo Track Agent#113
Conversation
There was a problem hiding this comment.
Novus UX Review
Two critical issues: the pendo.trackAgent() calls lack a null guard on the pendo global. In a browser extension context where ad blockers are common, Pendo is frequently blocked — causing pendo to be undefined at runtime. The prompt-tracking call is placed before sendMessageMutation.mutate(), so an uncaught TypeError will prevent messages from being sent; the agent-response tracking call is placed before setOpenChat(), so successful AI responses will never be rendered. Both calls need a typeof pendo !== 'undefined' guard or try-catch to keep instrumentation from breaking the core chat flow.
| ]) | ||
| } | ||
| const promptMessageId = crypto.randomUUID() | ||
| pendo.trackAgent("prompt", { |
There was a problem hiding this comment.
[critical] pendo is not guaranteed to be defined at runtime — this is a browser extension where ad blockers (uBlock Origin, Privacy Badger, etc.) routinely block analytics scripts. If Pendo fails to load, pendo is undefined and pendo.trackAgent(...) throws a TypeError. Because this call is placed before sendMessageMutation.mutate(), that exception will prevent the user's message from ever being sent. Their message silently disappears. Wrap both tracking calls in if (typeof pendo !== 'undefined') { ... } or a try-catch to keep the analytics from taking down the core chat flow.
Was this review helpful? React with 👍 or 👎 to share your feedback.
|
|
||
| const sendMessageMutation = trpc.sendMessage.useMutation({ | ||
| onSuccess: (newMessage: Message, context) => { | ||
| pendo.trackAgent("agent_response", { |
There was a problem hiding this comment.
[critical] Same pendo null-safety issue on the response side: if Pendo is blocked and this throws in onSuccess, the setOpenChat(...) call below never executes — meaning the AI response is received from the server but never rendered in the UI. The user sees the typing indicator disappear and nothing appear. This silently swallows a successful response.
Was this review helpful? React with 👍 or 👎 to share your feedback.
Summary
Add Pendo trackAgent() instrumentation to the BrowseGPT chat page to track user prompts and agent responses. This enables analytics on conversational AI agent interactions within the browser extension.
Changes
pendo.trackAgent("prompt", ...)call inhandleMessageSubmitto track when users send messages, including whether a command/suggested prompt was usedpendo.trackAgent("agent_response", ...)call insendMessageMutation.onSuccessto track when the agent finishes respondingpendo.trackAgentinglobal.d.tsopenChat.idas the conversationId andcrypto.randomUUID()for messageId generationNotes
ENqdE-F1Bgedm5TdtfzXYCNw2lois used for all trackAgent calls as specifiedGenerated by Novus.