Skip to content

Conversation

gagik
Copy link
Contributor

@gagik gagik commented Aug 27, 2025

Adds telemetry events and feedback buttons to the assistant
Screenshot 2025-08-27 at 9 00 29 PM

* @category Gen AI
*/
type AssistantPromptSubmittedEvent = CommonEvent<{
name: 'Assistant Prompt Submitted';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I originally wanted to combine these with "AI Prompt... equivalent but I think they diverge enough to be separate. Open to ideas though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also open to ideas on what other props to include

}
const { rating } = state;
const textFeedback = 'feedback' in state ? state.feedback : undefined;
const feedback: 'positive' | 'negative' =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

keeping it this way to align with our NLQ AI Prompt feedback wording

chat,
onError: (error) => {
track('Assistant Response Failed', () => ({
error_name: error.name,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think error name should be safe from any sensitive info right?

Copy link
Contributor

@lerouxb lerouxb Aug 29, 2025

Choose a reason for hiding this comment

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

In my experience I don't think there are error names. The errors I saw from inside ai sdk were from new Error('something'). But I suppose some third party dep might be doing more?

Otherwise this is just:

> (new Error('')).name
'Error'

which is probably fine, but not super helpful either.

(This is probably more a limitation of vercel's ai libraries that anything.)

@gagik gagik marked this pull request as ready for review August 28, 2025 08:13
@Copilot Copilot AI review requested due to automatic review settings August 28, 2025 08:13
@gagik gagik requested a review from a team as a code owner August 28, 2025 08:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds telemetry tracking and feedback buttons to the MongoDB Compass assistant feature. The changes enable tracking of user interactions with the assistant and collecting user feedback on responses.

  • Adds four new telemetry events for tracking assistant usage, prompts, feedback, and errors
  • Implements feedback buttons on assistant messages to collect user ratings and text feedback
  • Tracks entry point usage when assistant is opened from explain plan or connection error flows

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/compass-telemetry/src/telemetry-events.ts Defines new telemetry event types for assistant interactions
packages/compass-assistant/src/compass-assistant-provider.tsx Adds telemetry tracking for assistant entry points
packages/compass-assistant/src/assistant-chat.tsx Implements feedback buttons and tracks user prompts and errors
packages/compass-assistant/src/assistant-chat.spec.tsx Adds comprehensive tests for feedback functionality
packages/compass-assistant/package.json Adds compass-telemetry dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gagik gagik force-pushed the gagik/feedback-buttons branch from 73669f9 to f5a9683 Compare August 29, 2025 09:39

track('Assistant Feedback Submitted', {
feedback,
text: textFeedback,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe if this is a dev build we can just safely include the prompt and the message?

Copy link
Contributor

Choose a reason for hiding this comment

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

We can probably also do that in some follow-up. Let's get this merged.

import type { AssistantMessage } from './compass-assistant-provider';

describe('AssistantChat', function () {
let originalScrollTo: typeof Element.prototype.scrollTo;
Copy link
Contributor

Choose a reason for hiding this comment

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

driveby?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah this was meant to be removed earlier just ended up staying

@gagik gagik merged commit 4eec636 into main Aug 29, 2025
50 of 59 checks passed
@gagik gagik deleted the gagik/feedback-buttons branch August 29, 2025 12:10
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.

2 participants