Skip to content

Instrument Pendo Track Agent#113

Open
novus-by-pendo[bot] wants to merge 1 commit into
mainfrom
pendo-track-agent-325sj
Open

Instrument Pendo Track Agent#113
novus-by-pendo[bot] wants to merge 1 commit into
mainfrom
pendo-track-agent-325sj

Conversation

@novus-by-pendo

Copy link
Copy Markdown

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

  • Added pendo.trackAgent("prompt", ...) call in handleMessageSubmit to track when users send messages, including whether a command/suggested prompt was used
  • Added pendo.trackAgent("agent_response", ...) call in sendMessageMutation.onSuccess to track when the agent finishes responding
  • Added TypeScript declaration for pendo.trackAgent in global.d.ts
  • Used openChat.id as the conversationId and crypto.randomUUID() for messageId generation

Notes

  • No user_reaction tracking was added because the UI does not have any feedback mechanisms (thumbs up/down, retry, etc.)
  • The agentId ENqdE-F1Bgedm5TdtfzXYCNw2lo is used for all trackAgent calls as specified

Generated by Novus.

@novus-by-pendo novus-by-pendo Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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", {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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", {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants