@@ -51,6 +51,7 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
51
51
}
52
52
53
53
private async getContext ( token : vscode . CancellationToken ) : Promise < string > {
54
+ const telemetryProperties : Record < string , string > = { } ;
54
55
try {
55
56
const currentDoc = vscode . window . activeTextEditor ?. document ;
56
57
if ( ! currentDoc || ( ! util . isCpp ( currentDoc ) && ! util . isHeaderFile ( currentDoc . uri ) ) ) {
@@ -62,16 +63,6 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
62
63
return 'No configuration information is available for the active document.' ;
63
64
}
64
65
65
- telemetry . logLanguageModelToolEvent (
66
- 'cpp' ,
67
- {
68
- "language" : chatContext . language ,
69
- "compiler" : chatContext . compiler ,
70
- "standardVersion" : chatContext . standardVersion ,
71
- "targetPlatform" : chatContext . targetPlatform ,
72
- "targetArchitecture" : chatContext . targetArchitecture
73
- } ) ;
74
-
75
66
for ( const key in knownValues ) {
76
67
const knownKey = key as keyof ChatContextResult ;
77
68
if ( knownValues [ knownKey ] && chatContext [ knownKey ] ) {
@@ -83,25 +74,33 @@ export class CppConfigurationLanguageModelTool implements vscode.LanguageModelTo
83
74
let contextString = "" ;
84
75
if ( chatContext . language ) {
85
76
contextString += `The user is working on a ${ chatContext . language } project. ` ;
77
+ telemetryProperties [ "language" ] = chatContext . language ;
86
78
}
87
79
if ( chatContext . standardVersion ) {
88
80
contextString += `The project uses language version ${ chatContext . standardVersion } . ` ;
81
+ telemetryProperties [ "standardVersion" ] = chatContext . standardVersion ;
89
82
}
90
83
if ( chatContext . compiler ) {
91
84
contextString += `The project compiles using the ${ chatContext . compiler } compiler. ` ;
85
+ telemetryProperties [ "compiler" ] = chatContext . compiler ;
92
86
}
93
87
if ( chatContext . targetPlatform ) {
94
88
contextString += `The project targets the ${ chatContext . targetPlatform } platform. ` ;
89
+ telemetryProperties [ "targetPlatform" ] = chatContext . targetPlatform ;
95
90
}
96
91
if ( chatContext . targetArchitecture ) {
97
92
contextString += `The project targets the ${ chatContext . targetArchitecture } architecture. ` ;
93
+ telemetryProperties [ "targetArchitecture" ] = chatContext . targetArchitecture ;
98
94
}
99
95
100
96
return contextString ;
101
97
}
102
98
catch {
103
99
await this . reportError ( ) ;
100
+ telemetryProperties [ "error" ] = "true" ;
104
101
return "" ;
102
+ } finally {
103
+ telemetry . logLanguageModelToolEvent ( 'cpp' , telemetryProperties ) ;
105
104
}
106
105
}
107
106
0 commit comments