diff --git a/Extension/src/LanguageServer/lmTool.ts b/Extension/src/LanguageServer/lmTool.ts index 6a39e4e91d..c3fad8b6eb 100644 --- a/Extension/src/LanguageServer/lmTool.ts +++ b/Extension/src/LanguageServer/lmTool.ts @@ -51,6 +51,7 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo } private async getContext(token: vscode.CancellationToken): Promise { + const telemetryProperties: Record = {}; try { const currentDoc = vscode.window.activeTextEditor?.document; if (!currentDoc || (!util.isCpp(currentDoc) && !util.isHeaderFile(currentDoc.uri))) { @@ -62,16 +63,6 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo return 'No configuration information is available for the active document.'; } - telemetry.logLanguageModelToolEvent( - 'cpp', - { - "language": chatContext.language, - "compiler": chatContext.compiler, - "standardVersion": chatContext.standardVersion, - "targetPlatform": chatContext.targetPlatform, - "targetArchitecture": chatContext.targetArchitecture - }); - for (const key in knownValues) { const knownKey = key as keyof ChatContextResult; if (knownValues[knownKey] && chatContext[knownKey]) { @@ -83,25 +74,33 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo let contextString = ""; if (chatContext.language) { contextString += `The user is working on a ${chatContext.language} project. `; + telemetryProperties["language"] = chatContext.language; } if (chatContext.standardVersion) { contextString += `The project uses language version ${chatContext.standardVersion}. `; + telemetryProperties["standardVersion"] = chatContext.standardVersion; } if (chatContext.compiler) { contextString += `The project compiles using the ${chatContext.compiler} compiler. `; + telemetryProperties["compiler"] = chatContext.compiler; } if (chatContext.targetPlatform) { contextString += `The project targets the ${chatContext.targetPlatform} platform. `; + telemetryProperties["targetPlatform"] = chatContext.targetPlatform; } if (chatContext.targetArchitecture) { contextString += `The project targets the ${chatContext.targetArchitecture} architecture. `; + telemetryProperties["targetArchitecture"] = chatContext.targetArchitecture; } return contextString; } catch { await this.reportError(); + telemetryProperties["error"] = "true"; return ""; + } finally { + telemetry.logLanguageModelToolEvent('cpp', telemetryProperties); } }