@react-native-windows/telemetry 0.75.3 → 0.75.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @format
6
6
  */
7
- import * as appInsights from 'applicationinsights';
7
+ import * as coreOneDS from '@microsoft/1ds-core-js';
8
8
  import { Telemetry, TelemetryOptions } from '../telemetry';
9
9
  export declare class TelemetryTest extends Telemetry {
10
10
  protected static hasTestTelemetryProviders: boolean;
@@ -22,7 +22,5 @@ export declare class TelemetryTest extends Telemetry {
22
22
  /** Retrieves the value of the preserveErrorMessages option. */
23
23
  static getPreserveErrorMessages(): boolean;
24
24
  /** Adds a telemetry processor, usually for verifying the envelope. */
25
- static addTelemetryProcessor(telemetryProcessor: (envelope: appInsights.Contracts.EnvelopeTelemetry, contextObjects?: {
26
- [name: string]: any;
27
- }) => boolean): void;
25
+ static addTelemetryInitializer(telemetryInitializer: (envelope: coreOneDS.ITelemetryItem) => boolean): void;
28
26
  }
@@ -36,6 +36,13 @@ const basePropUtils = __importStar(require("../utils/basePropUtils"));
36
36
  const errorUtils = __importStar(require("../utils/errorUtils"));
37
37
  const projectUtils = __importStar(require("../utils/projectUtils"));
38
38
  const versionUtils = __importStar(require("../utils/versionUtils"));
39
+ class CustomTestError extends Error {
40
+ constructor(message) {
41
+ super(message);
42
+ this.name = 'CustomTestError';
43
+ this.errno = '123';
44
+ }
45
+ }
39
46
  class TelemetryTest extends telemetry_1.Telemetry {
40
47
  /** Run at the beginning of each test. */
41
48
  static async startTest(options) {
@@ -45,21 +52,20 @@ class TelemetryTest extends telemetry_1.Telemetry {
45
52
  telemetry_1.Telemetry.reset();
46
53
  }
47
54
  // Ensure that we don't actually fire events when testing
48
- telemetry_1.Telemetry.isTest = true;
55
+ telemetry_1.Telemetry.isTestEnvironment = true;
49
56
  await telemetry_1.Telemetry.setup(options);
50
57
  }
51
58
  /** Run at the end of each test where telemetry was fired. */
52
59
  static endTest(finalCallback) {
53
60
  var _a;
54
- (_a = telemetry_1.Telemetry.client) === null || _a === void 0 ? void 0 : _a.flush({
55
- callback: _ => {
56
- if (TelemetryTest.hasTestTelemetryProviders) {
57
- expect(TelemetryTest.testTelemetryProvidersRan).toBe(true);
58
- }
59
- if (finalCallback) {
60
- finalCallback();
61
- }
62
- },
61
+ (_a = telemetry_1.Telemetry.appInsightsCore) === null || _a === void 0 ? void 0 : _a.flush(undefined /* isAsync */, () => {
62
+ // Your callback logic here
63
+ if (TelemetryTest.hasTestTelemetryProviders) {
64
+ expect(TelemetryTest.testTelemetryProvidersRan).toBe(true);
65
+ }
66
+ if (finalCallback) {
67
+ finalCallback();
68
+ }
63
69
  });
64
70
  }
65
71
  /** Sets that the telemetry provider has run. */
@@ -68,8 +74,7 @@ class TelemetryTest extends telemetry_1.Telemetry {
68
74
  }
69
75
  /** Retrieves the value of a common property.*/
70
76
  static getCommonProperty(key) {
71
- var _a;
72
- return (_a = TelemetryTest.client) === null || _a === void 0 ? void 0 : _a.commonProperties[key];
77
+ return TelemetryTest.commonProperties[key];
73
78
  }
74
79
  /** Retrieves the version of the specified tool/package. */
75
80
  static getVersion(key) {
@@ -82,9 +87,9 @@ class TelemetryTest extends telemetry_1.Telemetry {
82
87
  return TelemetryTest.options.preserveErrorMessages;
83
88
  }
84
89
  /** Adds a telemetry processor, usually for verifying the envelope. */
85
- static addTelemetryProcessor(telemetryProcessor) {
90
+ static addTelemetryInitializer(telemetryInitializer) {
86
91
  var _a;
87
- (_a = TelemetryTest.client) === null || _a === void 0 ? void 0 : _a.addTelemetryProcessor(telemetryProcessor);
92
+ (_a = TelemetryTest.appInsightsCore) === null || _a === void 0 ? void 0 : _a.addTelemetryInitializer(telemetryInitializer);
88
93
  TelemetryTest.hasTestTelemetryProviders = true;
89
94
  }
90
95
  }
@@ -117,13 +122,12 @@ test('setup() verify static common property values with sync sources', async ()
117
122
  await TelemetryTest.startTest();
118
123
  const props = {
119
124
  deviceArchitecture: () => basePropUtils.deviceArchitecture(),
120
- devicePlatform: () => basePropUtils.devicePlatform(),
125
+ nodePlatform: () => basePropUtils.nodePlatform(),
121
126
  deviceNumCPUs: () => basePropUtils.deviceNumCPUs().toString(),
122
127
  deviceTotalMemory: () => basePropUtils.deviceTotalMemory().toString(),
123
128
  ciCaptured: () => basePropUtils.captureCI().toString(),
124
129
  ciType: () => basePropUtils.ciType(),
125
130
  isMsftInternal: () => basePropUtils.isMsftInternal().toString(),
126
- sampleRate: () => basePropUtils.sampleRate().toString(),
127
131
  isTest: () => 'true',
128
132
  };
129
133
  for (const key in props) {
@@ -285,54 +289,56 @@ async function runTestCommandE2E(commandBody) {
285
289
  }
286
290
  /** Verifies the contents of events fired during the 'test-command'. */
287
291
  function verifyTestCommandTelemetryProcessor(caughtErrors, expectedResultCode, expectedError) {
288
- return (envelope, _) => {
289
- var _a, _b, _c, _d;
292
+ return envelope => {
293
+ var _a, _b;
294
+ TelemetryTest.setTestTelemetryProvidersRan();
290
295
  try {
291
296
  // Processor has run, so the test can (potentially) pass
292
- TelemetryTest.setTestTelemetryProvidersRan();
293
- // Verify roleInstance has been removed
294
- expect(envelope.tags['ai.cloud.roleInstance']).toBeUndefined();
295
- const properties = (_a = envelope.data.baseData) === null || _a === void 0 ? void 0 : _a.properties;
297
+ const properties = envelope.baseData;
296
298
  expect(properties).toBeDefined();
297
299
  // Verify basics
298
- expect(properties.commandName).toBe('test-command');
300
+ const commonProperties = properties.common;
301
+ expect(commonProperties.commandName).toBe('test-command');
299
302
  // Verify versions info
300
- const versions = JSON.parse(properties.versions);
303
+ const versions = properties.versions;
301
304
  expect(versions).toBeDefined();
302
- // Verify project info
303
- const project = JSON.parse(properties.project);
304
- expect(project).toStrictEqual(getTestCommandProjectInfo());
305
305
  expect(Object.keys(versions).length).toBeGreaterThan(0);
306
306
  for (const key of Object.keys(versions)) {
307
307
  expect(versions[key]).toBe(TelemetryTest.getVersion(key));
308
308
  }
309
- if (envelope.data.baseType === 'ExceptionData') {
310
- // Verify event name
311
- expect(properties.eventName).toBe(telemetry_1.CodedErrorEventName);
309
+ // Verify project info
310
+ const project = properties.project;
311
+ expect(project).toStrictEqual(getTestCommandProjectInfo());
312
+ // Verify properties exclusive to error scenarios
313
+ if (envelope.name === telemetry_1.CodedErrorEventName) {
312
314
  // Verify exception info
313
- const exceptions = (_b = envelope.data.baseData) === null || _b === void 0 ? void 0 : _b.exceptions;
314
- expect(exceptions).toBeDefined();
315
- expect(exceptions.length).toBe(1);
316
- expect(exceptions[0].message).toBeDefined();
317
- expect(exceptions[0].message).not.toBe('');
318
- expect(exceptions[0].message).toBe(TelemetryTest.getPreserveErrorMessages()
315
+ const exceptionData = envelope.data.exceptionData;
316
+ expect(exceptionData).toBeDefined();
317
+ expect(exceptionData.message).toBeDefined();
318
+ expect(exceptionData.message).not.toBe('');
319
+ expect(exceptionData.message).toBe(TelemetryTest.getPreserveErrorMessages()
319
320
  ? errorUtils.sanitizeErrorMessage((expectedError === null || expectedError === void 0 ? void 0 : expectedError.message) || 'None')
320
321
  : '[Removed]');
321
322
  // Verify coded error info
322
- const codedError = JSON.parse(properties.codedError);
323
+ const codedError = envelope.data.codedError;
323
324
  expect(codedError).toBeDefined();
324
325
  expect(codedError.type).toBe(expectedError instanceof errorUtils.CodedError
325
326
  ? expectedError.type
326
327
  : 'Unknown');
327
- expect(codedError.data).toStrictEqual((_c = expectedError.data) !== null && _c !== void 0 ? _c : {});
328
+ // If the exception type is not CodedError but any data got copied into envelope.CodedError.data,
329
+ // for instance autolinking error info, build the expected CodedError.data.
330
+ let expectedCodedErrorData = {};
331
+ if (expectedError instanceof CustomTestError) {
332
+ expectedCodedErrorData = { errno: expectedError.errno };
333
+ }
334
+ expect(codedError.data).toStrictEqual((_a = expectedError.data) !== null && _a !== void 0 ? _a : expectedCodedErrorData);
328
335
  }
329
336
  else {
330
- // Verify event name
331
- expect((_d = envelope.data.baseData) === null || _d === void 0 ? void 0 : _d.name).toBe(telemetry_1.CommandEventName);
332
- expect(properties.eventName).toBe(telemetry_1.CommandEventName);
337
+ // If this is not error scenario, it must be a command successful event.
338
+ expect(envelope.name).toBe(telemetry_1.CommandEventName);
333
339
  // Verify command info
334
340
  const expectedInfo = getTestCommandStartInfo();
335
- const command = JSON.parse(properties.command);
341
+ const command = envelope.data.command;
336
342
  expect(command).toBeDefined();
337
343
  expect(command.args).toStrictEqual(expectedInfo.args);
338
344
  expect(command.options).toStrictEqual(expectedInfo.options);
@@ -341,7 +347,7 @@ function verifyTestCommandTelemetryProcessor(caughtErrors, expectedResultCode, e
341
347
  expect(command.resultCode).toBe(expectedResultCode !== null && expectedResultCode !== void 0 ? expectedResultCode : 'Success');
342
348
  // Verify extra props
343
349
  const extraProps = getExtraProps();
344
- expect(JSON.parse(properties.extraProps)).toStrictEqual(extraProps);
350
+ expect((_b = envelope.data) === null || _b === void 0 ? void 0 : _b.additionalData).toStrictEqual(extraProps);
345
351
  }
346
352
  }
347
353
  catch (ex) {
@@ -354,7 +360,7 @@ test('Telemetry run test command end to end, verify event fires', async () => {
354
360
  await TelemetryTest.startTest();
355
361
  // AI eats errors thrown in telemetry processors
356
362
  const caughtErrors = [];
357
- TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors));
363
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors));
358
364
  await runTestCommandE2E(testCommandBody);
359
365
  TelemetryTest.endTest(() => {
360
366
  // Check if any errors were thrown
@@ -370,7 +376,7 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Code
370
376
  const expectedError = new errorUtils.CodedError('MSBuildError', 'test error');
371
377
  // AI eats errors thrown in telemetry processors
372
378
  const caughtErrors = [];
373
- TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
379
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
374
380
  await runTestCommandE2E(() => testCommandBody(expectedError));
375
381
  TelemetryTest.endTest(() => {
376
382
  // Check if any errors were thrown
@@ -382,7 +388,7 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Code
382
388
  const expectedError = new errorUtils.CodedError('MSBuildError', 'error FOO2020: test error');
383
389
  // AI eats errors thrown in telemetry processors
384
390
  const caughtErrors = [];
385
- TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
391
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
386
392
  await runTestCommandE2E(() => testCommandBody(expectedError));
387
393
  TelemetryTest.endTest(() => {
388
394
  // Check if any errors were thrown
@@ -394,7 +400,7 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Code
394
400
  const expectedError = new errorUtils.CodedError('MSBuildError', 'test error', { foo: 42 });
395
401
  // AI eats errors thrown in telemetry processors
396
402
  const caughtErrors = [];
397
- TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
403
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
398
404
  await runTestCommandE2E(() => testCommandBody(expectedError));
399
405
  TelemetryTest.endTest(() => {
400
406
  // Check if any errors were thrown
@@ -406,7 +412,7 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Erro
406
412
  const expectedError = new Error('error FOO2020: test error');
407
413
  // AI eats errors thrown in telemetry processors
408
414
  const caughtErrors = [];
409
- TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError));
415
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError));
410
416
  await runTestCommandE2E(() => testCommandBody(expectedError));
411
417
  TelemetryTest.endTest(() => {
412
418
  // Check if any errors were thrown
@@ -418,7 +424,7 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Erro
418
424
  const expectedError = new Error();
419
425
  // AI eats errors thrown in telemetry processors
420
426
  const caughtErrors = [];
421
- TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError));
427
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError));
422
428
  await runTestCommandE2E(() => testCommandBody(expectedError));
423
429
  TelemetryTest.endTest(() => {
424
430
  // Check if any errors were thrown
@@ -433,29 +439,28 @@ function a(s) {
433
439
  }
434
440
  /** Verifies the contents of an exception's message and stack frames */
435
441
  function getVerifyStackTelemetryProcessor(caughtErrors, expectedError) {
436
- return (envelope, _) => {
442
+ return envelope => {
437
443
  try {
438
444
  // Processor has run, so the test can (potentially) pass
439
445
  TelemetryTest.setTestTelemetryProvidersRan();
440
- if (envelope.data.baseType === 'ExceptionData') {
441
- const data = envelope.data.baseData;
442
- expect(data.exceptions).toBeDefined();
443
- expect(data.exceptions.length).toBe(1);
444
- expect(data.exceptions[0].message).toBeDefined();
445
- expect(data.exceptions[0].message).not.toBe('');
446
- expect(data.exceptions[0].message).toBe(TelemetryTest.getPreserveErrorMessages()
446
+ if (envelope.name === telemetry_1.CodedErrorEventName) {
447
+ const data = envelope.data;
448
+ expect(data.exceptionData).toBeDefined();
449
+ expect(data.exceptionData.message).toBeDefined();
450
+ expect(data.exceptionData.message).not.toBe('');
451
+ expect(data.exceptionData.message).toBe(TelemetryTest.getPreserveErrorMessages()
447
452
  ? errorUtils.sanitizeErrorMessage(expectedError.message || 'None')
448
453
  : '[Removed]');
449
- const stack = data.exceptions[0].parsedStack;
454
+ const stack = data.exceptionData.parsedStack;
450
455
  expect(stack).toBeDefined();
451
456
  expect(stack.length).toBeGreaterThan(2);
452
457
  const filename = path.relative(process.cwd(), __filename);
453
- expect(stack[0].method).toEqual('b');
454
- expect(stack[1].method).toEqual('b');
455
- expect(stack[2].method).toEqual('a');
456
- expect(stack[0].fileName).toEqual(`[project_dir]\\???.ts(${filename.length})`);
457
- expect(stack[1].fileName).toEqual(`[project_dir]\\???.ts(${filename.length})`);
458
- expect(stack[2].fileName).toEqual(`[project_dir]\\???.ts(${filename.length})`);
458
+ expect(stack[0].functionName).toEqual('b');
459
+ expect(stack[1].functionName).toEqual('b');
460
+ expect(stack[2].functionName).toEqual('a');
461
+ expect(stack[0].filePath).toEqual(`[project_dir]\\???.ts(${filename.length})`);
462
+ expect(stack[1].filePath).toEqual(`[project_dir]\\???.ts(${filename.length})`);
463
+ expect(stack[2].filePath).toEqual(`[project_dir]\\???.ts(${filename.length})`);
459
464
  }
460
465
  }
461
466
  catch (ex) {
@@ -469,7 +474,7 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Erro
469
474
  const expectedError = new Error('hello world');
470
475
  // AI eats errors thrown in telemetry processors
471
476
  const caughtErrors = [];
472
- TelemetryTest.addTelemetryProcessor(getVerifyStackTelemetryProcessor(caughtErrors, expectedError));
477
+ TelemetryTest.addTelemetryInitializer(getVerifyStackTelemetryProcessor(caughtErrors, expectedError));
473
478
  await runTestCommandE2E(async () => {
474
479
  await promiseDelay(100);
475
480
  a('world');
@@ -484,7 +489,7 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Erro
484
489
  const expectedError = new Error(`hello ${process.cwd()}`);
485
490
  // AI eats errors thrown in telemetry processors
486
491
  const caughtErrors = [];
487
- TelemetryTest.addTelemetryProcessor(getVerifyStackTelemetryProcessor(caughtErrors, expectedError));
492
+ TelemetryTest.addTelemetryInitializer(getVerifyStackTelemetryProcessor(caughtErrors, expectedError));
488
493
  await runTestCommandE2E(async () => {
489
494
  await promiseDelay(100);
490
495
  a(process.cwd());
@@ -494,4 +499,76 @@ test.each(testTelemetryOptions)('Telemetry run test command end to end with Erro
494
499
  expect(caughtErrors).toHaveLength(0);
495
500
  });
496
501
  });
502
+ test.each(testTelemetryOptions)('A custom Error-based object with MS Build error info is copied into codedError.data appropriately by trackException()', async (options) => {
503
+ await TelemetryTest.startTest(options);
504
+ const expectedError = new CustomTestError('some message');
505
+ // AI eats errors thrown in telemetry processors
506
+ const caughtErrors = [];
507
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError));
508
+ await runTestCommandE2E(() => testCommandBody(expectedError));
509
+ TelemetryTest.endTest(() => {
510
+ // Check if any errors were thrown
511
+ expect(caughtErrors).toHaveLength(0);
512
+ });
513
+ });
514
+ test.each(testTelemetryOptions)('Telemetry run test command end to end with CodedError, verifies PII is scrubbed if present in CodedError.', async (options) => {
515
+ await TelemetryTest.startTest(options);
516
+ const codedErrorInfo = new errorUtils.CodedError('MSBuildError', // type
517
+ 'test error', // message
518
+ {
519
+ fieldWithPath: 'Test Error occurred at C:\\some\\file\\path\\project.build.appxrecipe',
520
+ fieldWithNoPath: 'Test Error data',
521
+ fieldWithNoString: 14,
522
+ arrayField: [
523
+ 'No path',
524
+ 15,
525
+ 'Clean this path: C:\\some\\file\\path2\\project.build.appxrecipe',
526
+ [
527
+ 'No path',
528
+ 150,
529
+ 'Also clean this: C:\\some\\file\\path2\\project.build.appxrecipe',
530
+ ],
531
+ ],
532
+ someObject: {
533
+ fieldWithPath: 'Test Error occurred at C:\\some\\file\\path3\\project.build.appxrecipe',
534
+ fieldWithNoPath: 'Test Error data 2',
535
+ fieldWithNoString: 16,
536
+ nestedObject: {
537
+ fieldWithPath: 'Test Error occurred at C:\\some\\file\\path4\\project.build.appxrecipe',
538
+ fieldWithNoPath: 'Test Error data 3',
539
+ fieldWithNoString: 17, // expectation: no changes to this value.
540
+ },
541
+ },
542
+ });
543
+ const expectedError = new errorUtils.CodedError('MSBuildError', // type
544
+ 'test error', // message
545
+ {
546
+ fieldWithPath: 'Test Error occurred at [path]',
547
+ fieldWithNoPath: 'Test Error data',
548
+ fieldWithNoString: 14,
549
+ arrayField: [
550
+ 'No path',
551
+ 15,
552
+ 'Clean this path: [path]',
553
+ ['No path', 150, 'Also clean this: [path]'],
554
+ ],
555
+ someObject: {
556
+ fieldWithPath: 'Test Error occurred at [path]',
557
+ fieldWithNoPath: 'Test Error data 2',
558
+ fieldWithNoString: 16,
559
+ nestedObject: {
560
+ fieldWithPath: 'Test Error occurred at [path]',
561
+ fieldWithNoPath: 'Test Error data 3',
562
+ fieldWithNoString: 17,
563
+ },
564
+ },
565
+ });
566
+ const caughtErrors = [];
567
+ TelemetryTest.addTelemetryInitializer(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
568
+ await runTestCommandE2E(() => testCommandBody(codedErrorInfo));
569
+ TelemetryTest.endTest(() => {
570
+ // Check if any errors were thrown
571
+ expect(caughtErrors).toHaveLength(0);
572
+ });
573
+ });
497
574
  //# sourceMappingURL=telemetry.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.test.js","sourceRoot":"","sources":["../../src/e2etest/telemetry.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,2CAA6B;AAE7B,4CAOsB;AACtB,sEAAwD;AACxD,gEAAkD;AAClD,oEAAsD;AACtD,oEAAsD;AAEtD,MAAa,aAAc,SAAQ,qBAAS;IAI1C,yCAAyC;IACzC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,OAAmC;QACxD,aAAa,CAAC,yBAAyB,GAAG,KAAK,CAAC;QAChD,aAAa,CAAC,yBAAyB,GAAG,KAAK,CAAC;QAEhD,IAAI,aAAa,CAAC,SAAS,EAAE,EAAE;YAC7B,qBAAS,CAAC,KAAK,EAAE,CAAC;SACnB;QAED,yDAAyD;QACzD,qBAAS,CAAC,MAAM,GAAG,IAAI,CAAC;QAExB,MAAM,qBAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED,6DAA6D;IAC7D,MAAM,CAAC,OAAO,CAAC,aAA0B;;QACvC,MAAA,qBAAS,CAAC,MAAM,0CAAE,KAAK,CAAC;YACtB,QAAQ,EAAE,CAAC,CAAC,EAA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AY,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,CAAC,OAAO,CAAC,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE;QACzB,kCAAkC;QAClC,MAAM,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CACF,CAAC;AAEF,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAC7B,mGAAmG,EACnG,KAAK,EAAC,OAAO,EAAC,EAAE;IACd,MAAM,aAAa,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAEvC,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,SAAS,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAE1D,gDAAgD;IAChD,MAAM,YAAY,GAAY,EAAE,CAAC;IACjC,aAAa,CAAC,qBAAqB,CACjC,gCAAgC,CAAC,YAAY,EAAE,aAAa,CAAC,CAC9D,CAAC;IAEF,MAAM,iBAAiB,CAAC,KAAK,IAAI,EAAE;QACjC,MAAM,YAAY,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE;QACzB,kCAAkC;QAClC,MAAM,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\nimport * as path from 'path';\n\nimport {\n Telemetry,\n TelemetryOptions,\n CommandStartInfo,\n CommandEndInfo,\n CommandEventName,\n CodedErrorEventName,\n} from '../telemetry';\nimport * as basePropUtils from '../utils/basePropUtils';\nimport * as errorUtils from '../utils/errorUtils';\nimport * as projectUtils from '../utils/projectUtils';\nimport * as versionUtils from '../utils/versionUtils';\n\nexport class TelemetryTest extends Telemetry {\n protected static hasTestTelemetryProviders: boolean;\n protected static testTelemetryProvidersRan: boolean;\n\n /** Run at the beginning of each test. */\n static async startTest(options?: Partial<TelemetryOptions>) {\n TelemetryTest.hasTestTelemetryProviders = false;\n TelemetryTest.testTelemetryProvidersRan = false;\n\n if (TelemetryTest.isEnabled()) {\n Telemetry.reset();\n }\n\n // Ensure that we don't actually fire events when testing\n Telemetry.isTest = true;\n\n await Telemetry.setup(options);\n }\n\n /** Run at the end of each test where telemetry was fired. */\n static endTest(finalCallback?: () => void): void {\n Telemetry.client?.flush({\n callback: _ => {\n if (TelemetryTest.hasTestTelemetryProviders) {\n expect(TelemetryTest.testTelemetryProvidersRan).toBe(true);\n }\n if (finalCallback) {\n finalCallback();\n }\n },\n });\n }\n\n /** Sets that the telemetry provider has run. */\n static setTestTelemetryProvidersRan() {\n TelemetryTest.testTelemetryProvidersRan = true;\n }\n\n /** Retrieves the value of a common property.*/\n static getCommonProperty(key: string): string | undefined {\n return TelemetryTest.client?.commonProperties[key];\n }\n\n /** Retrieves the version of the specified tool/package. */\n static getVersion(key: string): string | null {\n return key in TelemetryTest.versionsProp\n ? TelemetryTest.versionsProp[key]\n : null;\n }\n\n /** Retrieves the value of the preserveErrorMessages option. */\n static getPreserveErrorMessages(): boolean {\n return TelemetryTest.options.preserveErrorMessages;\n }\n\n /** Adds a telemetry processor, usually for verifying the envelope. */\n static addTelemetryProcessor(\n telemetryProcessor: (\n envelope: appInsights.Contracts.EnvelopeTelemetry,\n contextObjects?: {\n [name: string]: any;\n },\n ) => boolean,\n ): void {\n TelemetryTest.client?.addTelemetryProcessor(telemetryProcessor);\n TelemetryTest.hasTestTelemetryProviders = true;\n }\n}\n\ntest('setup() verify session id is valid and a common property', async () => {\n await TelemetryTest.startTest();\n\n const sessionId = TelemetryTest.getSessionId();\n expect(sessionId).toBeDefined();\n expect(sessionId!).toHaveLength(32);\n expect(sessionId!).toBe(basePropUtils.getSessionId());\n expect(TelemetryTest.getCommonProperty('sessionId')).toBe(sessionId!);\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify static common property values with async sources', async () => {\n await TelemetryTest.startTest();\n\n const props: Record<string, () => Promise<string | undefined>> = {\n deviceId: basePropUtils.deviceId,\n deviceLocale: basePropUtils.deviceLocale,\n };\n\n for (const key in props) {\n if (!(key in Object.prototype)) {\n const value = TelemetryTest.getCommonProperty(key);\n expect(value).toBeDefined();\n expect(value).toBe(await props[key]());\n }\n }\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify static common property values with sync sources', async () => {\n await TelemetryTest.startTest();\n\n const props: Record<string, () => string | undefined> = {\n deviceArchitecture: () => basePropUtils.deviceArchitecture(),\n devicePlatform: () => basePropUtils.devicePlatform(),\n deviceNumCPUs: () => basePropUtils.deviceNumCPUs().toString(),\n deviceTotalMemory: () => basePropUtils.deviceTotalMemory().toString(),\n ciCaptured: () => basePropUtils.captureCI().toString(),\n ciType: () => basePropUtils.ciType(),\n isMsftInternal: () => basePropUtils.isMsftInternal().toString(),\n sampleRate: () => basePropUtils.sampleRate().toString(),\n isTest: () => 'true',\n };\n\n for (const key in props) {\n if (!(key in Object.prototype)) {\n const value = TelemetryTest.getCommonProperty(key);\n expect(value).toBeDefined();\n expect(value).toBe(props[key]());\n }\n }\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify other common property values are defined', async () => {\n await TelemetryTest.startTest();\n\n const props: string[] = ['deviceDiskFreeSpace'];\n\n for (const key of props) {\n const value = TelemetryTest.getCommonProperty(key);\n expect(value).toBeDefined();\n }\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify tool versions are populated', async () => {\n await TelemetryTest.startTest();\n\n const props: Record<string, () => Promise<string | null>> = {\n node: versionUtils.getNodeVersion,\n npm: versionUtils.getNpmVersion,\n yarn: versionUtils.getYarnVersion,\n VisualStudio: versionUtils.getVisualStudioVersion,\n };\n\n for (const key in props) {\n if (!(key in Object.prototype)) {\n const value = await props[key]();\n expect(value).toBe(TelemetryTest.getVersion(key));\n }\n }\n\n TelemetryTest.endTest();\n});\n\ntest('tryUpdateVersionsProp() returns true for adding a new version', async () => {\n await TelemetryTest.startTest();\n\n const name = 'test';\n const version = '1.0';\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => version),\n ).toBe(true);\n expect(TelemetryTest.getVersion(name)).toBe(version);\n\n TelemetryTest.endTest();\n});\n\ntest('tryUpdateVersionsProp() returns false for adding an existing version with refresh is false', async () => {\n await TelemetryTest.startTest();\n\n const name = 'test';\n const version = '1.0';\n\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => version),\n ).toBe(true);\n\n let getValueCalled = false;\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => {\n getValueCalled = true;\n return version;\n }),\n ).toBe(false);\n\n expect(getValueCalled).toBe(false);\n\n TelemetryTest.endTest();\n});\n\ntest('tryUpdateVersionsProp() returns true for adding an existing version with refresh is true', async () => {\n await TelemetryTest.startTest();\n\n const name = 'test';\n const version = '1.0';\n\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => version),\n ).toBe(true);\n\n let getValueCalled = false;\n expect(\n await TelemetryTest.tryUpdateVersionsProp(\n name,\n async () => {\n getValueCalled = true;\n return version;\n },\n true,\n ),\n ).toBe(true);\n\n expect(getValueCalled).toBe(true);\n\n TelemetryTest.endTest();\n});\n\n/** Returns the CommandStartInfo for our fake 'test-command'. */\nfunction getTestCommandStartInfo(): CommandStartInfo {\n return {\n commandName: 'test-command',\n args: {\n testArg1: 'true',\n testArg2: '10',\n testArg3: 'testValue',\n },\n options: {\n testArg0: 'unsetArg',\n testArg1: true,\n testArg2: 10,\n testArg3: 'testValue',\n },\n defaultOptions: {\n testArg0: 'unsetArg',\n testArg1: false,\n testArg2: 0,\n testArg3: 'defaultValue',\n },\n };\n}\n\n/** Returns the CommandEndInfo for our fake 'test-command'. */\nfunction getTestCommandEndInfo(\n resultCode: errorUtils.CodedErrorType,\n): CommandEndInfo {\n return {\n resultCode,\n };\n}\n\nfunction getTestCommandProjectInfo(): projectUtils.AppProjectInfo {\n return {\n id: projectUtils.getProjectId('test-app-project'),\n platforms: ['windows'],\n rnwLang: 'cpp',\n usesTS: true,\n usesRNConfig: false,\n jsEngine: 'Chakra',\n rnwSource: 'Source',\n dependencies: [\n {\n id: projectUtils.getProjectId('test-module-project'),\n platforms: ['android', 'windows'],\n rnwLang: 'cpp',\n },\n ],\n };\n}\n\nfunction getExtraProps(): Record<string, any> {\n return {\n extraProp1: true,\n extraProp2: 1234,\n extraProp3: 'test',\n extraProp4: ['test'],\n extraProp5: {\n nestedProp1: true,\n nestedProp2: 1234,\n },\n };\n}\n\n/** Asynchronously waits the number in ms. */\nasync function promiseDelay(ms: number) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/** The body of the fake 'test-command' which will throw the provided error. */\nasync function testCommandBody(errorToThrow?: Error): Promise<void> {\n await promiseDelay(100);\n if (errorToThrow) {\n throw errorToThrow;\n }\n}\n\n/** Runs the complete 'test-command' with the right Telemetry setup and cleanup. */\nasync function runTestCommandE2E(commandBody: () => Promise<void>) {\n TelemetryTest.startCommand(getTestCommandStartInfo());\n TelemetryTest.setProjectInfo(getTestCommandProjectInfo());\n let errorCode: errorUtils.CodedErrorType = 'Success';\n let caughtError: Error | undefined;\n try {\n await commandBody();\n } catch (ex) {\n caughtError = ex instanceof Error ? (ex as Error) : new Error(String(ex));\n errorCode =\n caughtError instanceof errorUtils.CodedError\n ? (caughtError as errorUtils.CodedError).type\n : 'Unknown';\n TelemetryTest.trackException(caughtError);\n }\n TelemetryTest.endCommand(getTestCommandEndInfo(errorCode), getExtraProps());\n}\n\n/** Verifies the contents of events fired during the 'test-command'. */\nfunction verifyTestCommandTelemetryProcessor(\n caughtErrors: Error[],\n expectedResultCode?: errorUtils.CodedErrorType,\n expectedError?: Error,\n): (\n envelope: appInsights.Contracts.EnvelopeTelemetry,\n contextObjects?: {\n [name: string]: any;\n },\n) => boolean {\n return (envelope, _) => {\n try {\n // Processor has run, so the test can (potentially) pass\n TelemetryTest.setTestTelemetryProvidersRan();\n\n // Verify roleInstance has been removed\n expect(envelope.tags['ai.cloud.roleInstance']).toBeUndefined();\n\n const properties = envelope.data.baseData?.properties;\n expect(properties).toBeDefined();\n\n // Verify basics\n expect(properties.commandName).toBe('test-command');\n\n // Verify versions info\n const versions = JSON.parse(properties.versions);\n expect(versions).toBeDefined();\n\n // Verify project info\n const project = JSON.parse(properties.project);\n expect(project).toStrictEqual(getTestCommandProjectInfo());\n\n expect(Object.keys(versions).length).toBeGreaterThan(0);\n for (const key of Object.keys(versions)) {\n expect(versions[key]).toBe(TelemetryTest.getVersion(key));\n }\n\n if (envelope.data.baseType === 'ExceptionData') {\n // Verify event name\n expect(properties.eventName).toBe(CodedErrorEventName);\n\n // Verify exception info\n const exceptions = envelope.data.baseData?.exceptions;\n expect(exceptions).toBeDefined();\n expect(exceptions.length).toBe(1);\n expect(exceptions[0].message).toBeDefined();\n expect(exceptions[0].message).not.toBe('');\n\n expect(exceptions[0].message).toBe(\n TelemetryTest.getPreserveErrorMessages()\n ? errorUtils.sanitizeErrorMessage(expectedError?.message || 'None')\n : '[Removed]',\n );\n\n // Verify coded error info\n const codedError = JSON.parse(properties.codedError);\n expect(codedError).toBeDefined();\n\n expect(codedError.type).toBe(\n expectedError instanceof errorUtils.CodedError\n ? expectedError.type\n : 'Unknown',\n );\n\n expect(codedError.data).toStrictEqual(\n (expectedError as errorUtils.CodedError).data ?? {},\n );\n } else {\n // Verify event name\n expect(envelope.data.baseData?.name).toBe(CommandEventName);\n expect(properties.eventName).toBe(CommandEventName);\n\n // Verify command info\n const expectedInfo = getTestCommandStartInfo();\n\n const command = JSON.parse(properties.command);\n expect(command).toBeDefined();\n expect(command.args).toStrictEqual(expectedInfo.args);\n expect(command.options).toStrictEqual(expectedInfo.options);\n expect(command.defaultOptions).toStrictEqual(\n expectedInfo.defaultOptions,\n );\n expect(command.durationInSecs).toBeGreaterThan(0);\n expect(command.resultCode).toBe(expectedResultCode ?? 'Success');\n\n // Verify extra props\n const extraProps = getExtraProps();\n expect(JSON.parse(properties.extraProps)).toStrictEqual(extraProps);\n }\n } catch (ex) {\n caughtErrors.push(\n ex instanceof Error ? (ex as Error) : new Error(String(ex)),\n );\n }\n\n return true;\n };\n}\n\ntest('Telemetry run test command end to end, verify event fires', async () => {\n await TelemetryTest.startTest();\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n verifyTestCommandTelemetryProcessor(caughtErrors),\n );\n\n await runTestCommandE2E(testCommandBody);\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n});\n\nconst testTelemetryOptions = [\n {preserveErrorMessages: false},\n {preserveErrorMessages: true},\n];\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with CodedError, verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new errorUtils.CodedError(\n 'MSBuildError',\n 'test error',\n );\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n expectedError.type,\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with CodedError (with error in message), verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new errorUtils.CodedError(\n 'MSBuildError',\n 'error FOO2020: test error',\n );\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n expectedError.type,\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with CodedError (with data), verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new errorUtils.CodedError(\n 'MSBuildError',\n 'test error',\n {foo: 42},\n );\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n expectedError.type,\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error('error FOO2020: test error');\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n 'Unknown',\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error (no message), verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error();\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n 'Unknown',\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\nfunction b(s: string) {\n throw new Error('hello ' + s);\n}\n\nfunction a(s: string) {\n b(s);\n}\n\n/** Verifies the contents of an exception's message and stack frames */\nfunction getVerifyStackTelemetryProcessor(\n caughtErrors: Error[],\n expectedError: Error,\n): (\n envelope: appInsights.Contracts.EnvelopeTelemetry,\n contextObjects?: {\n [name: string]: any;\n },\n) => boolean {\n return (envelope, _) => {\n try {\n // Processor has run, so the test can (potentially) pass\n TelemetryTest.setTestTelemetryProvidersRan();\n\n if (envelope.data.baseType === 'ExceptionData') {\n const data = (envelope.data as any).baseData;\n expect(data.exceptions).toBeDefined();\n expect(data.exceptions.length).toBe(1);\n expect(data.exceptions[0].message).toBeDefined();\n expect(data.exceptions[0].message).not.toBe('');\n\n expect(data.exceptions[0].message).toBe(\n TelemetryTest.getPreserveErrorMessages()\n ? errorUtils.sanitizeErrorMessage(expectedError.message || 'None')\n : '[Removed]',\n );\n\n const stack = data.exceptions[0].parsedStack;\n expect(stack).toBeDefined();\n expect(stack.length).toBeGreaterThan(2);\n\n const filename = path.relative(process.cwd(), __filename);\n expect(stack[0].method).toEqual('b');\n expect(stack[1].method).toEqual('b');\n expect(stack[2].method).toEqual('a');\n expect(stack[0].fileName).toEqual(\n `[project_dir]\\\\???.ts(${filename.length})`,\n );\n expect(stack[1].fileName).toEqual(\n `[project_dir]\\\\???.ts(${filename.length})`,\n );\n expect(stack[2].fileName).toEqual(\n `[project_dir]\\\\???.ts(${filename.length})`,\n );\n }\n } catch (ex) {\n caughtErrors.push(\n ex instanceof Error ? (ex as Error) : new Error(String(ex)),\n );\n }\n\n return true;\n };\n}\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify sanitized message and stack %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error('hello world');\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n getVerifyStackTelemetryProcessor(caughtErrors, expectedError),\n );\n\n await runTestCommandE2E(async () => {\n await promiseDelay(100);\n a('world');\n });\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify sanitized message with path and stack %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error(`hello ${process.cwd()}`);\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n getVerifyStackTelemetryProcessor(caughtErrors, expectedError),\n );\n\n await runTestCommandE2E(async () => {\n await promiseDelay(100);\n a(process.cwd());\n });\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n"]}
1
+ {"version":3,"file":"telemetry.test.js","sourceRoot":"","sources":["../../src/e2etest/telemetry.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,2CAA6B;AAE7B,4CAOsB;AAEtB,sEAAwD;AACxD,gEAAkD;AAClD,oEAAsD;AACtD,oEAAsD;AAEtD,MAAM,eAAgB,SAAQ,KAAK;IAKjC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED,MAAa,aAAc,SAAQ,qBAAS;IAI1C,yCAAyC;IACzC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,OAAmC;QACxD,aAAa,CAAC,yBAAyB,GAAG,KAAK,CAAC;QAChD,aAAa,CAAC,yBAAyB,GAAG,KAAK,CAAC;QAEhD,IAAI,aAAa,CAAC,SAAS,EAAE,EAAE;YAC7B,qBAAS,CAAC,KAAK,EAAE,CAAC;SACnB;QAED,yDAAyD;QACzD,qBAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC;QAEnC,MAAM,qBAAS,CAAC,KAAK,CAAC,OAAO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C,CAAC;IAE/D,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE;QACzB,kCAAkC;QAClC,MAAM,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CACF,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as coreOneDS from '@microsoft/1ds-core-js';\nimport * as path from 'path';\n\nimport {\n Telemetry,\n TelemetryOptions,\n CommandStartInfo,\n CommandEndInfo,\n CommandEventName,\n CodedErrorEventName,\n} from '../telemetry';\n\nimport * as basePropUtils from '../utils/basePropUtils';\nimport * as errorUtils from '../utils/errorUtils';\nimport * as projectUtils from '../utils/projectUtils';\nimport * as versionUtils from '../utils/versionUtils';\n\nclass CustomTestError extends Error {\n // Declare a mock errno field, so it is picked up by trackException() (see syscallExceptionFieldsToCopy)\n // to copy it into codedError.data.\n errno: string;\n\n constructor(message: string) {\n super(message);\n this.name = 'CustomTestError';\n this.errno = '123';\n }\n}\n\nexport class TelemetryTest extends Telemetry {\n protected static hasTestTelemetryProviders: boolean;\n protected static testTelemetryProvidersRan: boolean;\n\n /** Run at the beginning of each test. */\n static async startTest(options?: Partial<TelemetryOptions>) {\n TelemetryTest.hasTestTelemetryProviders = false;\n TelemetryTest.testTelemetryProvidersRan = false;\n\n if (TelemetryTest.isEnabled()) {\n Telemetry.reset();\n }\n\n // Ensure that we don't actually fire events when testing\n Telemetry.isTestEnvironment = true;\n\n await Telemetry.setup(options);\n }\n\n /** Run at the end of each test where telemetry was fired. */\n static endTest(finalCallback?: () => void): void {\n Telemetry.appInsightsCore?.flush(undefined /* isAsync */, () => {\n // Your callback logic here\n if (TelemetryTest.hasTestTelemetryProviders) {\n expect(TelemetryTest.testTelemetryProvidersRan).toBe(true);\n }\n if (finalCallback) {\n finalCallback();\n }\n });\n }\n\n /** Sets that the telemetry provider has run. */\n static setTestTelemetryProvidersRan() {\n TelemetryTest.testTelemetryProvidersRan = true;\n }\n\n /** Retrieves the value of a common property.*/\n static getCommonProperty(key: string): string | undefined {\n return TelemetryTest.commonProperties[key];\n }\n\n /** Retrieves the version of the specified tool/package. */\n static getVersion(key: string): string | null {\n return key in TelemetryTest.versionsProp\n ? TelemetryTest.versionsProp[key]\n : null;\n }\n\n /** Retrieves the value of the preserveErrorMessages option. */\n static getPreserveErrorMessages(): boolean {\n return TelemetryTest.options.preserveErrorMessages;\n }\n\n /** Adds a telemetry processor, usually for verifying the envelope. */\n static addTelemetryInitializer(\n telemetryInitializer: (envelope: coreOneDS.ITelemetryItem) => boolean,\n ): void {\n TelemetryTest.appInsightsCore?.addTelemetryInitializer(\n telemetryInitializer,\n );\n TelemetryTest.hasTestTelemetryProviders = true;\n }\n}\n\ntest('setup() verify session id is valid and a common property', async () => {\n await TelemetryTest.startTest();\n\n const sessionId = TelemetryTest.getSessionId();\n expect(sessionId).toBeDefined();\n expect(sessionId!).toHaveLength(32);\n expect(sessionId!).toBe(basePropUtils.getSessionId());\n expect(TelemetryTest.getCommonProperty('sessionId')).toBe(sessionId!);\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify static common property values with async sources', async () => {\n await TelemetryTest.startTest();\n\n const props: Record<string, () => Promise<string | undefined>> = {\n deviceId: basePropUtils.deviceId,\n deviceLocale: basePropUtils.deviceLocale,\n };\n\n for (const key in props) {\n if (!(key in Object.prototype)) {\n const value = TelemetryTest.getCommonProperty(key);\n expect(value).toBeDefined();\n expect(value).toBe(await props[key]());\n }\n }\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify static common property values with sync sources', async () => {\n await TelemetryTest.startTest();\n\n const props: Record<string, () => string | undefined> = {\n deviceArchitecture: () => basePropUtils.deviceArchitecture(),\n nodePlatform: () => basePropUtils.nodePlatform(),\n deviceNumCPUs: () => basePropUtils.deviceNumCPUs().toString(),\n deviceTotalMemory: () => basePropUtils.deviceTotalMemory().toString(),\n ciCaptured: () => basePropUtils.captureCI().toString(),\n ciType: () => basePropUtils.ciType(),\n isMsftInternal: () => basePropUtils.isMsftInternal().toString(),\n isTest: () => 'true',\n };\n\n for (const key in props) {\n if (!(key in Object.prototype)) {\n const value = TelemetryTest.getCommonProperty(key);\n expect(value).toBeDefined();\n expect(value).toBe(props[key]());\n }\n }\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify other common property values are defined', async () => {\n await TelemetryTest.startTest();\n\n const props: string[] = ['deviceDiskFreeSpace'];\n\n for (const key of props) {\n const value = TelemetryTest.getCommonProperty(key);\n expect(value).toBeDefined();\n }\n\n TelemetryTest.endTest();\n});\n\ntest('setup() verify tool versions are populated', async () => {\n await TelemetryTest.startTest();\n\n const props: Record<string, () => Promise<string | null>> = {\n node: versionUtils.getNodeVersion,\n npm: versionUtils.getNpmVersion,\n yarn: versionUtils.getYarnVersion,\n VisualStudio: versionUtils.getVisualStudioVersion,\n };\n\n for (const key in props) {\n if (!(key in Object.prototype)) {\n const value = await props[key]();\n expect(value).toBe(TelemetryTest.getVersion(key));\n }\n }\n\n TelemetryTest.endTest();\n});\n\ntest('tryUpdateVersionsProp() returns true for adding a new version', async () => {\n await TelemetryTest.startTest();\n\n const name = 'test';\n const version = '1.0';\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => version),\n ).toBe(true);\n expect(TelemetryTest.getVersion(name)).toBe(version);\n\n TelemetryTest.endTest();\n});\n\ntest('tryUpdateVersionsProp() returns false for adding an existing version with refresh is false', async () => {\n await TelemetryTest.startTest();\n\n const name = 'test';\n const version = '1.0';\n\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => version),\n ).toBe(true);\n\n let getValueCalled = false;\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => {\n getValueCalled = true;\n return version;\n }),\n ).toBe(false);\n\n expect(getValueCalled).toBe(false);\n\n TelemetryTest.endTest();\n});\n\ntest('tryUpdateVersionsProp() returns true for adding an existing version with refresh is true', async () => {\n await TelemetryTest.startTest();\n\n const name = 'test';\n const version = '1.0';\n\n expect(\n await TelemetryTest.tryUpdateVersionsProp(name, async () => version),\n ).toBe(true);\n\n let getValueCalled = false;\n expect(\n await TelemetryTest.tryUpdateVersionsProp(\n name,\n async () => {\n getValueCalled = true;\n return version;\n },\n true,\n ),\n ).toBe(true);\n\n expect(getValueCalled).toBe(true);\n\n TelemetryTest.endTest();\n});\n\n/** Returns the CommandStartInfo for our fake 'test-command'. */\nfunction getTestCommandStartInfo(): CommandStartInfo {\n return {\n commandName: 'test-command',\n args: {\n testArg1: 'true',\n testArg2: '10',\n testArg3: 'testValue',\n },\n options: {\n testArg0: 'unsetArg',\n testArg1: true,\n testArg2: 10,\n testArg3: 'testValue',\n },\n defaultOptions: {\n testArg0: 'unsetArg',\n testArg1: false,\n testArg2: 0,\n testArg3: 'defaultValue',\n },\n };\n}\n\n/** Returns the CommandEndInfo for our fake 'test-command'. */\nfunction getTestCommandEndInfo(\n resultCode: errorUtils.CodedErrorType,\n): CommandEndInfo {\n return {\n resultCode,\n };\n}\n\nfunction getTestCommandProjectInfo(): projectUtils.AppProjectInfo {\n return {\n id: projectUtils.getProjectId('test-app-project'),\n platforms: ['windows'],\n rnwLang: 'cpp',\n usesTS: true,\n usesRNConfig: false,\n jsEngine: 'Chakra',\n rnwSource: 'Source',\n dependencies: [\n {\n id: projectUtils.getProjectId('test-module-project'),\n platforms: ['android', 'windows'],\n rnwLang: 'cpp',\n },\n ],\n };\n}\n\nfunction getExtraProps(): Record<string, any> {\n return {\n extraProp1: true,\n extraProp2: 1234,\n extraProp3: 'test',\n extraProp4: ['test'],\n extraProp5: {\n nestedProp1: true,\n nestedProp2: 1234,\n },\n };\n}\n\n/** Asynchronously waits the number in ms. */\nasync function promiseDelay(ms: number) {\n return new Promise(resolve => setTimeout(resolve, ms));\n}\n\n/** The body of the fake 'test-command' which will throw the provided error. */\nasync function testCommandBody(errorToThrow?: Error): Promise<void> {\n await promiseDelay(100);\n if (errorToThrow) {\n throw errorToThrow;\n }\n}\n\n/** Runs the complete 'test-command' with the right Telemetry setup and cleanup. */\nasync function runTestCommandE2E(commandBody: () => Promise<void>) {\n TelemetryTest.startCommand(getTestCommandStartInfo());\n TelemetryTest.setProjectInfo(getTestCommandProjectInfo());\n let errorCode: errorUtils.CodedErrorType = 'Success';\n let caughtError: Error | undefined;\n try {\n await commandBody();\n } catch (ex) {\n caughtError = ex instanceof Error ? (ex as Error) : new Error(String(ex));\n errorCode =\n caughtError instanceof errorUtils.CodedError\n ? (caughtError as errorUtils.CodedError).type\n : 'Unknown';\n TelemetryTest.trackException(caughtError);\n }\n TelemetryTest.endCommand(getTestCommandEndInfo(errorCode), getExtraProps());\n}\n\n/** Verifies the contents of events fired during the 'test-command'. */\nfunction verifyTestCommandTelemetryProcessor(\n caughtErrors: Error[],\n expectedResultCode?: errorUtils.CodedErrorType,\n expectedError?: Error,\n): (envelope: coreOneDS.ITelemetryItem) => boolean {\n return envelope => {\n TelemetryTest.setTestTelemetryProvidersRan();\n\n try {\n // Processor has run, so the test can (potentially) pass\n const properties = envelope.baseData;\n expect(properties).toBeDefined();\n\n // Verify basics\n const commonProperties = properties!.common;\n expect(commonProperties.commandName).toBe('test-command');\n\n // Verify versions info\n const versions = properties!.versions;\n expect(versions).toBeDefined();\n\n expect(Object.keys(versions).length).toBeGreaterThan(0);\n for (const key of Object.keys(versions)) {\n expect(versions[key]).toBe(TelemetryTest.getVersion(key));\n }\n\n // Verify project info\n const project = properties!.project;\n expect(project).toStrictEqual(getTestCommandProjectInfo());\n\n // Verify properties exclusive to error scenarios\n if (envelope.name === CodedErrorEventName) {\n // Verify exception info\n const exceptionData = envelope.data!.exceptionData;\n expect(exceptionData).toBeDefined();\n expect(exceptionData.message).toBeDefined();\n expect(exceptionData.message).not.toBe('');\n\n expect(exceptionData.message).toBe(\n TelemetryTest.getPreserveErrorMessages()\n ? errorUtils.sanitizeErrorMessage(expectedError?.message || 'None')\n : '[Removed]',\n );\n\n // Verify coded error info\n const codedError = envelope.data!.codedError;\n expect(codedError).toBeDefined();\n\n expect(codedError.type).toBe(\n expectedError instanceof errorUtils.CodedError\n ? expectedError.type\n : 'Unknown',\n );\n\n // If the exception type is not CodedError but any data got copied into envelope.CodedError.data,\n // for instance autolinking error info, build the expected CodedError.data.\n let expectedCodedErrorData = {};\n if (expectedError instanceof CustomTestError) {\n expectedCodedErrorData = {errno: expectedError.errno};\n }\n\n expect(codedError.data).toStrictEqual(\n (expectedError as errorUtils.CodedError).data ??\n expectedCodedErrorData,\n );\n } else {\n // If this is not error scenario, it must be a command successful event.\n expect(envelope.name).toBe(CommandEventName);\n\n // Verify command info\n const expectedInfo = getTestCommandStartInfo();\n\n const command = envelope.data!.command;\n expect(command).toBeDefined();\n expect(command.args).toStrictEqual(expectedInfo.args);\n expect(command.options).toStrictEqual(expectedInfo.options);\n expect(command.defaultOptions).toStrictEqual(\n expectedInfo.defaultOptions,\n );\n expect(command.durationInSecs).toBeGreaterThan(0);\n expect(command.resultCode).toBe(expectedResultCode ?? 'Success');\n\n // Verify extra props\n const extraProps = getExtraProps();\n expect(envelope.data?.additionalData).toStrictEqual(extraProps);\n }\n } catch (ex) {\n caughtErrors.push(\n ex instanceof Error ? (ex as Error) : new Error(String(ex)),\n );\n }\n\n return true;\n };\n}\n\ntest('Telemetry run test command end to end, verify event fires', async () => {\n await TelemetryTest.startTest();\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(caughtErrors),\n );\n\n await runTestCommandE2E(testCommandBody);\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n});\n\nconst testTelemetryOptions = [\n {preserveErrorMessages: false},\n {preserveErrorMessages: true},\n];\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with CodedError, verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new errorUtils.CodedError(\n 'MSBuildError',\n 'test error',\n );\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n expectedError.type,\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with CodedError (with error in message), verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new errorUtils.CodedError(\n 'MSBuildError',\n 'error FOO2020: test error',\n );\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n expectedError.type,\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with CodedError (with data), verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new errorUtils.CodedError(\n 'MSBuildError',\n 'test error',\n {foo: 42},\n );\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n expectedError.type,\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error('error FOO2020: test error');\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n 'Unknown',\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error (no message), verify events fire %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error();\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n 'Unknown',\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\nfunction b(s: string) {\n throw new Error('hello ' + s);\n}\n\nfunction a(s: string) {\n b(s);\n}\n\n/** Verifies the contents of an exception's message and stack frames */\nfunction getVerifyStackTelemetryProcessor(\n caughtErrors: Error[],\n expectedError: Error,\n): (envelope: coreOneDS.ITelemetryItem) => boolean {\n return envelope => {\n try {\n // Processor has run, so the test can (potentially) pass\n TelemetryTest.setTestTelemetryProvidersRan();\n\n if (envelope.name === CodedErrorEventName) {\n const data = envelope.data as any;\n expect(data.exceptionData).toBeDefined();\n expect(data.exceptionData.message).toBeDefined();\n expect(data.exceptionData.message).not.toBe('');\n\n expect(data.exceptionData.message).toBe(\n TelemetryTest.getPreserveErrorMessages()\n ? errorUtils.sanitizeErrorMessage(expectedError.message || 'None')\n : '[Removed]',\n );\n\n const stack = data.exceptionData.parsedStack;\n expect(stack).toBeDefined();\n expect(stack.length).toBeGreaterThan(2);\n\n const filename = path.relative(process.cwd(), __filename);\n expect(stack[0].functionName).toEqual('b');\n expect(stack[1].functionName).toEqual('b');\n expect(stack[2].functionName).toEqual('a');\n expect(stack[0].filePath).toEqual(\n `[project_dir]\\\\???.ts(${filename.length})`,\n );\n expect(stack[1].filePath).toEqual(\n `[project_dir]\\\\???.ts(${filename.length})`,\n );\n expect(stack[2].filePath).toEqual(\n `[project_dir]\\\\???.ts(${filename.length})`,\n );\n }\n } catch (ex) {\n caughtErrors.push(\n ex instanceof Error ? (ex as Error) : new Error(String(ex)),\n );\n }\n\n return true;\n };\n}\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify sanitized message and stack %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error('hello world');\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n getVerifyStackTelemetryProcessor(caughtErrors, expectedError),\n );\n\n await runTestCommandE2E(async () => {\n await promiseDelay(100);\n a('world');\n });\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify sanitized message with path and stack %s',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new Error(`hello ${process.cwd()}`);\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n getVerifyStackTelemetryProcessor(caughtErrors, expectedError),\n );\n\n await runTestCommandE2E(async () => {\n await promiseDelay(100);\n a(process.cwd());\n });\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'A custom Error-based object with MS Build error info is copied into codedError.data appropriately by trackException()',\n async options => {\n await TelemetryTest.startTest(options);\n\n const expectedError = new CustomTestError('some message');\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n 'Unknown',\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with CodedError, verifies PII is scrubbed if present in CodedError.',\n async options => {\n await TelemetryTest.startTest(options);\n\n const codedErrorInfo = new errorUtils.CodedError(\n 'MSBuildError', // type\n 'test error', // message\n {\n fieldWithPath:\n 'Test Error occurred at C:\\\\some\\\\file\\\\path\\\\project.build.appxrecipe', // expectation: replace the whole C:\\\\... thing with \"[path]\".\n fieldWithNoPath: 'Test Error data', // expectation: no changes to this string.\n fieldWithNoString: 14, // expectation: no changes to this value.\n arrayField: [\n 'No path',\n 15,\n 'Clean this path: C:\\\\some\\\\file\\\\path2\\\\project.build.appxrecipe',\n [\n 'No path',\n 150,\n 'Also clean this: C:\\\\some\\\\file\\\\path2\\\\project.build.appxrecipe',\n ],\n ],\n someObject: {\n fieldWithPath:\n 'Test Error occurred at C:\\\\some\\\\file\\\\path3\\\\project.build.appxrecipe', // expectation: replace the whole C:\\\\... thing with \"[path]\".\n fieldWithNoPath: 'Test Error data 2', // expectation: no changes to this string.\n fieldWithNoString: 16, // expectation: no changes to this value.\n nestedObject: {\n fieldWithPath:\n 'Test Error occurred at C:\\\\some\\\\file\\\\path4\\\\project.build.appxrecipe', // expectation: replace the whole C:\\\\... thing with \"[path]\".\n fieldWithNoPath: 'Test Error data 3', // expectation: no changes to this string.\n fieldWithNoString: 17, // expectation: no changes to this value.\n },\n },\n }, // data\n );\n\n const expectedError = new errorUtils.CodedError(\n 'MSBuildError', // type\n 'test error', // message\n {\n fieldWithPath: 'Test Error occurred at [path]',\n fieldWithNoPath: 'Test Error data',\n fieldWithNoString: 14,\n arrayField: [\n 'No path',\n 15,\n 'Clean this path: [path]',\n ['No path', 150, 'Also clean this: [path]'],\n ],\n someObject: {\n fieldWithPath: 'Test Error occurred at [path]',\n fieldWithNoPath: 'Test Error data 2',\n fieldWithNoString: 16,\n nestedObject: {\n fieldWithPath: 'Test Error occurred at [path]',\n fieldWithNoPath: 'Test Error data 3',\n fieldWithNoString: 17,\n },\n },\n }, // data\n );\n\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryInitializer(\n verifyTestCommandTelemetryProcessor(\n caughtErrors,\n expectedError.type,\n expectedError,\n ),\n );\n\n await runTestCommandE2E(() => testCommandBody(codedErrorInfo));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n });\n },\n);\n"]}