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
2 changes: 2 additions & 0 deletions extension/shared/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
declare module '*.png'
declare module '*.jpg'

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

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

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.

agentId: "ENqdE-F1Bgedm5TdtfzXYCNw2lo",
conversationId: openChat.id,
messageId: crypto.randomUUID(),
content: newMessage.content,
})
setOpenChat({
...openChat,
messages: [...openChat.messages, newMessage],
Expand Down Expand Up @@ -264,6 +270,14 @@ const Chat: FC = () => {
},
])
}
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.

agentId: "ENqdE-F1Bgedm5TdtfzXYCNw2lo",
conversationId: openChat.id,
messageId: promptMessageId,
content: strippedMessage,
suggestedPrompt: !!selectedCommand,
})
sendMessageMutation.mutate({
chatId: openChat.id,
message: newMessage,
Expand Down