@@ -179,13 +179,17 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
179
179
expectedCompiler,
180
180
context,
181
181
compilerArguments : compilerArguments ,
182
- expectedCompilerArguments
182
+ expectedCompilerArguments,
183
+ telemetryProperties,
184
+ telemetryMetrics
183
185
} : {
184
186
compiler : string ;
185
187
expectedCompiler : string ;
186
188
context : { flags : Record < string , unknown > } ;
187
189
compilerArguments : string [ ] ;
188
190
expectedCompilerArguments : Record < string , string > ;
191
+ telemetryProperties : Record < string , string > ;
192
+ telemetryMetrics : Record < string , number > ;
189
193
} ) => {
190
194
arrangeProjectContextFromCppTools ( {
191
195
projectContextFromCppTools : {
@@ -200,7 +204,7 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
200
204
}
201
205
} ) ;
202
206
203
- const result = await getProjectContext ( mockTextDocumentStub . uri , context ) ;
207
+ const result = await getProjectContext ( mockTextDocumentStub . uri , context , telemetryProperties , telemetryMetrics ) ;
204
208
205
209
ok ( result , 'result should not be undefined' ) ;
206
210
ok ( result . language === 'C++' ) ;
@@ -217,7 +221,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
217
221
expectedCompiler : 'MSVC' ,
218
222
context : { flags : { copilotcppMsvcCompilerArgumentFilter : '{"foo-?": ""}' } } ,
219
223
compilerArguments : [ 'foo' , 'bar' , 'abc' , 'foo-' ] ,
220
- expectedCompilerArguments : { 'foo-?' : 'foo-' }
224
+ expectedCompilerArguments : { 'foo-?' : 'foo-' } ,
225
+ telemetryProperties : { } ,
226
+ telemetryMetrics : { }
221
227
} ) ;
222
228
} ) ;
223
229
@@ -227,7 +233,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
227
233
expectedCompiler : 'Clang' ,
228
234
context : { flags : { copilotcppClangCompilerArgumentFilter : '{"foo": "", "bar": ""}' } } ,
229
235
compilerArguments : [ 'foo' , 'bar' , 'abc' ] ,
230
- expectedCompilerArguments : { 'foo' : 'foo' , 'bar' : 'bar' }
236
+ expectedCompilerArguments : { 'foo' : 'foo' , 'bar' : 'bar' } ,
237
+ telemetryProperties : { } ,
238
+ telemetryMetrics : { }
231
239
} ) ;
232
240
} ) ;
233
241
@@ -237,7 +245,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
237
245
expectedCompiler : 'Clang' ,
238
246
context : { flags : { copilotcppClangCompilerArgumentFilter : '{"-std\\\\sc\\\\+\\\\+\\\\d+": ""}' } } ,
239
247
compilerArguments : [ '-std' , 'c++17' , '-std' , 'foo' , '-std' , 'c++11' , '-std' , 'bar' ] ,
240
- expectedCompilerArguments : { '-std\\sc\\+\\+\\d+' : '-std c++11' }
248
+ expectedCompilerArguments : { '-std\\sc\\+\\+\\d+' : '-std c++11' } ,
249
+ telemetryProperties : { } ,
250
+ telemetryMetrics : { }
241
251
} ) ;
242
252
} ) ;
243
253
@@ -247,7 +257,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
247
257
expectedCompiler : 'GCC' ,
248
258
context : { flags : { copilotcppGccCompilerArgumentFilter : '{"foo": "", "bar": ""}' } } ,
249
259
compilerArguments : [ 'foo' , 'bar' , 'abc' , 'bar' , 'foo' , 'bar' ] ,
250
- expectedCompilerArguments : { 'foo' : 'foo' , 'bar' : 'bar' }
260
+ expectedCompilerArguments : { 'foo' : 'foo' , 'bar' : 'bar' } ,
261
+ telemetryProperties : { } ,
262
+ telemetryMetrics : { }
251
263
} ) ;
252
264
} ) ;
253
265
@@ -257,7 +269,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
257
269
expectedCompiler : 'MSVC' ,
258
270
context : { flags : { copilotcppMsvcCompilerArgumentFilter : '{"foo": "", "bar": ""}' } } ,
259
271
compilerArguments : [ ] ,
260
- expectedCompilerArguments : { }
272
+ expectedCompilerArguments : { } ,
273
+ telemetryProperties : { } ,
274
+ telemetryMetrics : { }
261
275
} ) ;
262
276
} ) ;
263
277
@@ -267,7 +281,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
267
281
expectedCompiler : 'GCC' ,
268
282
context : { flags : { } } ,
269
283
compilerArguments : [ 'foo' , 'bar' ] ,
270
- expectedCompilerArguments : { }
284
+ expectedCompilerArguments : { } ,
285
+ telemetryProperties : { } ,
286
+ telemetryMetrics : { }
271
287
} ) ;
272
288
} ) ;
273
289
@@ -277,7 +293,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
277
293
expectedCompiler : 'MSVC' ,
278
294
context : { flags : { copilotcppMsvcCompilerArgumentFilter : '{"": ""}' } } ,
279
295
compilerArguments : [ 'foo' , 'bar' ] ,
280
- expectedCompilerArguments : { }
296
+ expectedCompilerArguments : { } ,
297
+ telemetryProperties : { } ,
298
+ telemetryMetrics : { }
281
299
} ) ;
282
300
} ) ;
283
301
@@ -291,7 +309,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
291
309
}
292
310
} ,
293
311
compilerArguments : [ 'foo' , 'bar' ] ,
294
- expectedCompilerArguments : { }
312
+ expectedCompilerArguments : { } ,
313
+ telemetryProperties : { } ,
314
+ telemetryMetrics : { }
295
315
} ) ;
296
316
} ) ;
297
317
@@ -305,7 +325,9 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
305
325
}
306
326
} ,
307
327
compilerArguments : [ 'foo' , 'bar' ] ,
308
- expectedCompilerArguments : { }
328
+ expectedCompilerArguments : { } ,
329
+ telemetryProperties : { } ,
330
+ telemetryMetrics : { }
309
331
} ) ;
310
332
} ) ;
311
333
@@ -321,33 +343,60 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
321
343
}
322
344
} ,
323
345
compilerArguments : [ 'foo' , 'bar' ] ,
324
- expectedCompilerArguments : { }
346
+ expectedCompilerArguments : { } ,
347
+ telemetryProperties : { } ,
348
+ telemetryMetrics : { }
325
349
} ) ;
326
350
} ) ;
327
351
328
352
it ( 'should send telemetry.' , async ( ) => {
353
+ const telemetryProperties : Record < string , string > = { } ;
354
+ const telemetryMetrics : Record < string , number > = { } ;
329
355
const input = {
330
356
compiler : 'msvc' ,
331
357
expectedCompiler : 'MSVC' ,
332
358
context : { flags : { copilotcppMsvcCompilerArgumentFilter : '{"foo-?": "", "": "", "bar": "", "xyz": ""}' } } ,
333
359
compilerArguments : [ 'foo' , 'bar' , 'foo-' , 'abc' ] ,
334
- expectedCompilerArguments : { 'foo-?' : 'foo-' , 'bar' : 'bar' }
360
+ expectedCompilerArguments : { 'foo-?' : 'foo-' , 'bar' : 'bar' } ,
361
+ telemetryProperties,
362
+ telemetryMetrics
335
363
} ;
336
364
await testGetProjectContext ( input ) ;
337
365
338
- ok ( telemetryStub . calledOnce , 'Telemetry should be called once' ) ;
339
- ok ( telemetryStub . calledWithMatch ( 'ProjectContext' , sinon . match ( {
340
- "language" : 'C++' ,
341
- "compiler" : input . expectedCompiler ,
342
- "standardVersion" : 'C++20' ,
343
- "targetPlatform" : 'Windows' ,
344
- "targetArchitecture" : 'x64' ,
345
- "filteredCompilerArguments" : "foo,foo-,bar" ,
346
- "filters" : "foo-?,bar,xyz"
347
- } ) , sinon . match ( {
348
- "compilerArgumentCount" : input . compilerArguments . length ,
349
- 'duration' : sinon . match . number
350
- } ) ) ) ;
366
+ ok ( telemetryProperties [ 'language' ] === 'C++' ) ;
367
+ ok ( telemetryProperties [ 'compiler' ] === input . expectedCompiler ) ;
368
+ ok ( telemetryProperties [ 'standardVersion' ] === 'C++20' ) ;
369
+ ok ( telemetryProperties [ 'targetPlatform' ] === 'Windows' ) ;
370
+ ok ( telemetryProperties [ 'targetArchitecture' ] === 'x64' ) ;
371
+ ok ( telemetryProperties [ 'filteredCompilerArguments' ] === 'foo,foo-,bar' ) ;
372
+ ok ( telemetryProperties [ 'filters' ] === 'foo-?,bar,xyz' ) ;
373
+ ok ( telemetryMetrics [ 'compilerArgumentCount' ] === input . compilerArguments . length ) ;
374
+ ok ( telemetryMetrics [ 'projectContextDuration' ] !== undefined ) ;
375
+ } ) ;
376
+
377
+ it ( 'should send filter telemetry if available.' , async ( ) => {
378
+ const telemetryProperties : Record < string , string > = { } ;
379
+ const telemetryMetrics : Record < string , number > = { } ;
380
+ const input = {
381
+ compiler : 'msvc' ,
382
+ expectedCompiler : 'MSVC' ,
383
+ context : { flags : { copilotcppMsvcCompilerArgumentFilter : '{"foo-?": "", "": "", "bar": "", "xyz": ""}' } } ,
384
+ compilerArguments : [ 'abc' ] ,
385
+ expectedCompilerArguments : { } ,
386
+ telemetryProperties,
387
+ telemetryMetrics
388
+ } ;
389
+ await testGetProjectContext ( input ) ;
390
+
391
+ ok ( telemetryProperties [ 'language' ] === 'C++' ) ;
392
+ ok ( telemetryProperties [ 'compiler' ] === input . expectedCompiler ) ;
393
+ ok ( telemetryProperties [ 'standardVersion' ] === 'C++20' ) ;
394
+ ok ( telemetryProperties [ 'targetPlatform' ] === 'Windows' ) ;
395
+ ok ( telemetryProperties [ 'targetArchitecture' ] === 'x64' ) ;
396
+ ok ( telemetryProperties [ 'filteredCompilerArguments' ] === undefined ) ;
397
+ ok ( telemetryProperties [ 'filters' ] === 'foo-?,bar,xyz' ) ;
398
+ ok ( telemetryMetrics [ 'compilerArgumentCount' ] === input . compilerArguments . length ) ;
399
+ ok ( telemetryMetrics [ 'projectContextDuration' ] !== undefined ) ;
351
400
} ) ;
352
401
353
402
it ( 'should not send telemetry for unknown values' , async ( ) => {
@@ -363,21 +412,21 @@ describe('CppConfigurationLanguageModelTool Tests', () => {
363
412
}
364
413
}
365
414
} ) ;
415
+ const telemetryProperties : Record < string , string > = { } ;
416
+ const telemetryMetrics : Record < string , number > = { } ;
366
417
367
- const result = await getProjectContext ( mockTextDocumentStub . uri , { flags : { } } ) ;
418
+ const result = await getProjectContext ( mockTextDocumentStub . uri , {
419
+ flags : { copilotcppMsvcCompilerArgumentFilter : '{"foo-?": "", "": "", "bar": "", "xyz": ""}' }
420
+ } , telemetryProperties , telemetryMetrics ) ;
368
421
369
- ok ( telemetryStub . calledOnce , 'Telemetry should be called once' ) ;
370
- ok ( telemetryStub . calledWithMatch ( 'ProjectContext' , sinon . match ( {
371
- "targetArchitecture" : 'bar'
372
- } ) , sinon . match ( {
373
- "compilerArgumentCount" : 0
374
- } ) ) ) ;
375
- ok ( telemetryStub . calledWithMatch ( 'ProjectContext' , sinon . match ( property =>
376
- property [ 'language' ] === undefined &&
377
- property [ 'compiler' ] === undefined &&
378
- property [ 'standardVersion' ] === undefined &&
379
- property [ 'originalStandardVersion' ] === 'gnu++17' &&
380
- property [ 'targetPlatform' ] === undefined ) ) ) ;
422
+ ok ( telemetryProperties [ "targetArchitecture" ] === 'bar' ) ;
423
+ ok ( telemetryProperties [ "filters" ] === undefined ) ;
424
+ ok ( telemetryProperties [ "language" ] === undefined ) ;
425
+ ok ( telemetryProperties [ "compiler" ] === undefined ) ;
426
+ ok ( telemetryProperties [ "standardVersion" ] === undefined ) ;
427
+ ok ( telemetryProperties [ "originalStandardVersion" ] === 'gnu++17' ) ;
428
+ ok ( telemetryProperties [ "targetPlatform" ] === undefined ) ;
429
+ ok ( telemetryMetrics [ "compilerArgumentCount" ] === 0 ) ;
381
430
ok ( result , 'result should not be undefined' ) ;
382
431
ok ( result . language === '' ) ;
383
432
ok ( result . compiler === '' ) ;
0 commit comments