Skip to content

Commit 5aa85d4

Browse files
committed
log assistant errors
1 parent 5f191e7 commit 5aa85d4

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

packages/compass-assistant/src/compass-assistant-provider.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { DocsProviderTransport } from './docs-provider-transport';
88
import { useDrawerActions } from '@mongodb-js/compass-components';
99
import { buildExplainPlanPrompt } from './prompts';
1010
import { usePreference } from 'compass-preferences-model/provider';
11+
import { createLoggerLocator } from '@mongodb-js/compass-logging/provider';
1112

1213
export const ASSISTANT_DRAWER_ID = 'compass-assistant-drawer';
1314

@@ -101,18 +102,19 @@ export const CompassAssistantProvider = registerCompassPlugin(
101102
}
102103
return <AssistantProvider chat={chat}>{children}</AssistantProvider>;
103104
},
104-
activate: (initialProps, { atlasService }) => {
105+
activate: (initialProps, { atlasService, logger }) => {
105106
const chat = new Chat({
106107
transport: new DocsProviderTransport({
107108
baseUrl: atlasService.assistantApiEndpoint(),
108109
}),
109-
/*
110-
onError: () => {
111-
// best we can do is assume it was the last message that caused it
112-
// because there's nothing on the error object this function receives
113-
chat.messages = chat.messages.slice(0, -1);
110+
onError: (err: any) => {
111+
logger.log.error(
112+
logger.mongoLogId(1_001_000_370),
113+
'Assistant',
114+
'Failed to send a message',
115+
{ err }
116+
);
114117
},
115-
*/
116118
});
117119
return {
118120
store: { state: { chat } },
@@ -122,5 +124,6 @@ export const CompassAssistantProvider = registerCompassPlugin(
122124
},
123125
{
124126
atlasService: atlasServiceLocator,
127+
logger: createLoggerLocator('COMPASS-ASSISTANT'),
125128
}
126129
);

0 commit comments

Comments
 (0)