Skip to content

Commit 8ffb39d

Browse files
committed
chore: use chat response as default source
1 parent dc1b4bd commit 8ffb39d

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

packages/compass-assistant/src/components/assistant-chat.spec.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,34 @@ describe('AssistantChat', function () {
519519
});
520520
});
521521

522+
it('tracks it as "chat response" when source is not present', async function () {
523+
const { result } = renderWithChat([
524+
{
525+
...mockMessages[1],
526+
metadata: {
527+
...mockMessages[1].metadata,
528+
source: undefined,
529+
},
530+
},
531+
]);
532+
const { track } = result;
533+
534+
const thumbsDownButton = within(
535+
screen.getByTestId('assistant-message-assistant')
536+
).getByLabelText('Dislike this message');
537+
538+
userEvent.click(thumbsDownButton);
539+
540+
await waitFor(() => {
541+
expect(track).to.have.been.calledWith('Assistant Feedback Submitted', {
542+
feedback: 'negative',
543+
text: undefined,
544+
request_id: null,
545+
source: 'chat response',
546+
});
547+
});
548+
});
549+
522550
it('does not show feedback buttons when there are no assistant messages', function () {
523551
const userOnlyMessages: AssistantMessage[] = [
524552
{
@@ -807,6 +835,29 @@ describe('AssistantChat', function () {
807835
);
808836
});
809837
});
838+
839+
it('tracks it as "chat response" when source is not present', async function () {
840+
const { result } = renderWithChat([
841+
{
842+
...mockConfirmationMessage,
843+
metadata: {
844+
...mockConfirmationMessage.metadata,
845+
source: undefined,
846+
},
847+
},
848+
]);
849+
const { track } = result;
850+
851+
const confirmButton = screen.getByText('Confirm');
852+
userEvent.click(confirmButton);
853+
854+
await waitFor(() => {
855+
expect(track).to.have.been.calledWith(
856+
'Assistant Confirmation Submitted',
857+
{ status: 'confirmed', source: 'chat response' }
858+
);
859+
});
860+
});
810861
});
811862

812863
describe('related sources', function () {

packages/compass-assistant/src/components/assistant-chat.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export const AssistantChat: React.FunctionComponent<AssistantChatProps> = ({
222222
feedback,
223223
text: textFeedback,
224224
request_id: null,
225-
source: message.metadata?.source,
225+
source: message.metadata?.source ?? 'chat response',
226226
});
227227
},
228228
[track]
@@ -268,7 +268,7 @@ export const AssistantChat: React.FunctionComponent<AssistantChatProps> = ({
268268
});
269269
track('Assistant Confirmation Submitted', {
270270
status: newState,
271-
source: confirmedMessage.metadata?.source,
271+
source: confirmedMessage.metadata?.source ?? 'chat response',
272272
});
273273
if (newState === 'confirmed') {
274274
// Force the new message request to be sent

packages/compass-telemetry/src/telemetry-events.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,7 +1494,7 @@ type AssistantFeedbackSubmittedEvent = CommonEvent<{
14941494
feedback: 'positive' | 'negative';
14951495
text: string | undefined;
14961496
request_id: string | null;
1497-
source: AssistantEntryPointUsedEvent['payload']['source'] | undefined;
1497+
source: AssistantEntryPointUsedEvent['payload']['source'] | 'chat response';
14981498
};
14991499
}>;
15001500

@@ -1507,7 +1507,7 @@ type AssistantConfirmationSubmittedEvent = CommonEvent<{
15071507
name: 'Assistant Confirmation Submitted';
15081508
payload: {
15091509
status: 'confirmed' | 'rejected';
1510-
source: AssistantEntryPointUsedEvent['payload']['source'] | undefined;
1510+
source: AssistantEntryPointUsedEvent['payload']['source'] | 'chat response';
15111511
};
15121512
}>;
15131513

0 commit comments

Comments
 (0)