Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extension/shared/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
declare module '*.png'
declare module '*.jpg'

declare var pendo: {
trackAgent: (eventType: string, metadata: object) => void
}

declare type User = {
id: string
email: string
Expand Down
18 changes: 18 additions & 0 deletions extension/shared/pages/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ const Chat: FC = () => {

const sendMessageMutation = trpc.sendMessage.useMutation({
onSuccess: (newMessage: Message, context) => {
if (newMessage.role === 'assistant') {
pendo.trackAgent("agent_response", {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[critical] Same missing guard as the prompt call below — pendo.trackAgent("agent_response", ...) is unguarded inside onSuccess. If Pendo isn't loaded and this throws, it will interrupt the setOpenChat(...) state update that follows, meaning the assistant's reply never gets appended to the chat. The user sends a message, sees a loading state, and the response silently disappears. Add if (typeof pendo !== 'undefined') around this block.


Was this review helpful? React with 👍 or 👎 to share your feedback.

agentId: "ibmmo83klwxyOUBJmYwb5uBu9GE",
conversationId: openChat.id,
messageId: crypto.randomUUID(),
content: newMessage.content,
})
}

setOpenChat({
...openChat,
messages: [...openChat.messages, newMessage],
Expand Down Expand Up @@ -250,6 +259,15 @@ const Chat: FC = () => {
url: currentUrl,
isCommand: !!selectedCommand,
}

pendo.trackAgent("prompt", {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[critical] The PR description says both calls are guarded with typeof pendo !== 'undefined', but neither call in the diff has that guard. This pendo.trackAgent("prompt", ...) sits directly in the handleMessageSubmit hot path — if Pendo isn't loaded (ad blockers are extremely common among the browser extension audience, and CSPs on many pages can block third-party scripts), this throws a ReferenceError and the user's message is never sent. Wrap this call: if (typeof pendo !== 'undefined') { pendo.trackAgent(...) }.


Was this review helpful? React with 👍 or 👎 to share your feedback.

agentId: "ibmmo83klwxyOUBJmYwb5uBu9GE",
conversationId: openChat.id,
messageId: crypto.randomUUID(),
content: strippedMessage,
suggestedPrompt: false,
})

setOpenChat({
...openChat,
messages: [...openChat.messages, newMessage],
Expand Down