mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Include slashCommand type in chat telemetry (#186565)
This commit is contained in:
parent
4000c1da1f
commit
68dc2206ef
|
@ -401,7 +401,8 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||
}
|
||||
this._chatAccessibilityService.acceptRequest();
|
||||
const input = query ?? editorValue;
|
||||
const result = await this.chatService.sendRequest(this.viewModel.sessionId, input);
|
||||
const usedSlashCommand = this.lookupSlashCommand(typeof input === 'string' ? input : input.message);
|
||||
const result = await this.chatService.sendRequest(this.viewModel.sessionId, input, usedSlashCommand);
|
||||
|
||||
if (result) {
|
||||
this.inputPart.acceptInput(query);
|
||||
|
@ -416,6 +417,10 @@ export class ChatWidget extends Disposable implements IChatWidget {
|
|||
}
|
||||
}
|
||||
|
||||
private lookupSlashCommand(input: string): ISlashCommand | undefined {
|
||||
return this.lastSlashCommands?.find(sc => input.startsWith(`/${sc.command}`));
|
||||
}
|
||||
|
||||
getCodeBlockInfosForResponse(response: IChatResponseViewModel): IChatCodeBlockInfo[] {
|
||||
return this.renderer.getCodeBlockInfosForResponse(response);
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ export interface IChatService {
|
|||
/**
|
||||
* Returns whether the request was accepted.
|
||||
*/
|
||||
sendRequest(sessionId: string, message: string | IChatReplyFollowup): Promise<{ responseCompletePromise: Promise<void> } | undefined>;
|
||||
sendRequest(sessionId: string, message: string | IChatReplyFollowup, usedSlashCommand?: ISlashCommand): Promise<{ responseCompletePromise: Promise<void> } | undefined>;
|
||||
removeRequest(sessionid: string, requestId: string): Promise<void>;
|
||||
cancelCurrentRequestForSession(sessionId: string): void;
|
||||
getSlashCommands(sessionId: string, token: CancellationToken): Promise<ISlashCommand[] | undefined>;
|
||||
|
|
|
@ -41,6 +41,7 @@ type ChatProviderInvokedEvent = {
|
|||
totalTime: number;
|
||||
result: 'success' | 'error' | 'errorWithOutput' | 'cancelled' | 'filtered';
|
||||
requestType: 'string' | 'followup' | 'slashCommand';
|
||||
slashCommand: string | undefined;
|
||||
};
|
||||
|
||||
type ChatProviderInvokedClassification = {
|
||||
|
@ -49,6 +50,7 @@ type ChatProviderInvokedClassification = {
|
|||
totalTime: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth'; isMeasurement: true; comment: 'The total time it took to run the provider\'s `provideResponseWithProgress`.' };
|
||||
result: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Whether invoking the ChatProvider resulted in an error.' };
|
||||
requestType: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The type of request that the user made.' };
|
||||
slashCommand?: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'The type of slashCommand used.' };
|
||||
owner: 'roblourens';
|
||||
comment: 'Provides insight into the performance of Chat providers.';
|
||||
};
|
||||
|
@ -357,7 +359,7 @@ export class ChatService extends Disposable implements IChatService {
|
|||
return this._startSession(data.providerId, data, CancellationToken.None);
|
||||
}
|
||||
|
||||
async sendRequest(sessionId: string, request: string | IChatReplyFollowup): Promise<{ responseCompletePromise: Promise<void> } | undefined> {
|
||||
async sendRequest(sessionId: string, request: string | IChatReplyFollowup, usedSlashCommand?: ISlashCommand): Promise<{ responseCompletePromise: Promise<void> } | undefined> {
|
||||
const messageText = typeof request === 'string' ? request : request.message;
|
||||
this.trace('sendRequest', `sessionId: ${sessionId}, message: ${messageText.substring(0, 20)}${messageText.length > 20 ? '[...]' : ''}}`);
|
||||
if (!messageText.trim()) {
|
||||
|
@ -382,10 +384,10 @@ export class ChatService extends Disposable implements IChatService {
|
|||
}
|
||||
|
||||
// This method is only returning whether the request was accepted - don't block on the actual request
|
||||
return { responseCompletePromise: this._sendRequestAsync(model, provider, request) };
|
||||
return { responseCompletePromise: this._sendRequestAsync(model, provider, request, usedSlashCommand) };
|
||||
}
|
||||
|
||||
private async _sendRequestAsync(model: ChatModel, provider: IChatProvider, message: string | IChatReplyFollowup): Promise<void> {
|
||||
private async _sendRequestAsync(model: ChatModel, provider: IChatProvider, message: string | IChatReplyFollowup, usedSlashCommand?: ISlashCommand): Promise<void> {
|
||||
const request = model.addRequest(message);
|
||||
|
||||
const resolvedCommand = typeof message === 'string' && message.startsWith('/') ? await this.handleSlashCommand(model.sessionId, message) : message;
|
||||
|
@ -420,7 +422,8 @@ export class ChatService extends Disposable implements IChatService {
|
|||
// Normally timings happen inside the EH around the actual provider. For cancellation we can measure how long the user waited before cancelling
|
||||
totalTime: stopWatch.elapsed(),
|
||||
result: 'cancelled',
|
||||
requestType
|
||||
requestType,
|
||||
slashCommand: usedSlashCommand?.command
|
||||
});
|
||||
|
||||
model.cancelRequest(request);
|
||||
|
@ -443,7 +446,8 @@ export class ChatService extends Disposable implements IChatService {
|
|||
timeToFirstProgress: rawResponse.timings?.firstProgress ?? 0,
|
||||
totalTime: rawResponse.timings?.totalElapsed ?? 0,
|
||||
result,
|
||||
requestType
|
||||
requestType,
|
||||
slashCommand: usedSlashCommand?.command
|
||||
});
|
||||
model.completeResponse(request, rawResponse);
|
||||
this.trace('sendRequest', `Provider returned response for session ${model.sessionId}`);
|
||||
|
|
Loading…
Reference in a new issue