Skip to content

Add pendo availability guards to trackAgent calls#118

Open
novus-by-pendo[bot] wants to merge 1 commit into
novus/instrument-pendo-track-agentfrom
novus/fix-pendo-track-agent-guards
Open

Add pendo availability guards to trackAgent calls#118
novus-by-pendo[bot] wants to merge 1 commit into
novus/instrument-pendo-track-agentfrom
novus/fix-pendo-track-agent-guards

Conversation

@novus-by-pendo

@novus-by-pendo novus-by-pendo Bot commented Jun 4, 2026

Copy link
Copy Markdown

Summary

  • Wraps the pendo.trackAgent("agent_response", ...) call with typeof pendo !== 'undefined' by folding the check into the existing if (newMessage.role === 'assistant') condition
  • Wraps the pendo.trackAgent("prompt", ...) call in handleMessageSubmit with a typeof pendo !== 'undefined' guard block

Problem

PR #115 added both pendo.trackAgent() calls without the safety guards that were described in its PR body. Without these guards, a ReferenceError is thrown at runtime whenever the Pendo script fails to load (e.g. in development environments or when blocked by an ad-blocker), crashing the chat submit handler.

Files changed

  • extension/shared/pages/chat.tsx — Added typeof pendo !== 'undefined' guards around both pendo.trackAgent() calls

Both pendo.trackAgent() calls in handleMessageSubmit and sendMessageMutation.onSuccess
are now guarded with typeof pendo !== 'undefined' to prevent runtime errors when the
Pendo script is not loaded.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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