-
Notifications
You must be signed in to change notification settings - Fork 0
Instrument Pendo Track Agent #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,6 +77,15 @@ const Chat: FC = () => { | |
|
|
||
| const sendMessageMutation = trpc.sendMessage.useMutation({ | ||
| onSuccess: (newMessage: Message, context) => { | ||
| if (newMessage.role === 'assistant') { | ||
| pendo.trackAgent("agent_response", { | ||
| agentId: "ibmmo83klwxyOUBJmYwb5uBu9GE", | ||
| conversationId: openChat.id, | ||
| messageId: crypto.randomUUID(), | ||
| content: newMessage.content, | ||
| }) | ||
| } | ||
|
|
||
| setOpenChat({ | ||
| ...openChat, | ||
| messages: [...openChat.messages, newMessage], | ||
|
|
@@ -250,6 +259,15 @@ const Chat: FC = () => { | |
| url: currentUrl, | ||
| isCommand: !!selectedCommand, | ||
| } | ||
|
|
||
| pendo.trackAgent("prompt", { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [critical] The PR description says both calls are guarded with 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], | ||
|
|
||
There was a problem hiding this comment.
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
promptcall below —pendo.trackAgent("agent_response", ...)is unguarded insideonSuccess. If Pendo isn't loaded and this throws, it will interrupt thesetOpenChat(...)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. Addif (typeof pendo !== 'undefined')around this block.Was this review helpful? React with 👍 or 👎 to share your feedback.