@react-native-windows/telemetry 0.67.1 → 0.68.0

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.
Files changed (49) hide show
  1. package/lib-commonjs/index.d.ts +5 -2
  2. package/lib-commonjs/index.js +14 -6
  3. package/lib-commonjs/index.js.map +1 -1
  4. package/lib-commonjs/telemetry.d.ts +75 -20
  5. package/lib-commonjs/telemetry.js +284 -168
  6. package/lib-commonjs/telemetry.js.map +1 -1
  7. package/lib-commonjs/test/{sanitize.test.d.ts → basePropUtils.test.d.ts} +0 -0
  8. package/lib-commonjs/test/basePropUtils.test.js +116 -0
  9. package/lib-commonjs/test/basePropUtils.test.js.map +1 -0
  10. package/lib-commonjs/test/errorUtils.test.d.ts +7 -0
  11. package/lib-commonjs/test/errorUtils.test.js +159 -0
  12. package/lib-commonjs/test/errorUtils.test.js.map +1 -0
  13. package/lib-commonjs/test/projectUtils.test.d.ts +7 -0
  14. package/lib-commonjs/test/projectUtils.test.js +84 -0
  15. package/lib-commonjs/test/projectUtils.test.js.map +1 -0
  16. package/lib-commonjs/test/sanitizeUtils.test.d.ts +7 -0
  17. package/lib-commonjs/test/sanitizeUtils.test.js +94 -0
  18. package/lib-commonjs/test/sanitizeUtils.test.js.map +1 -0
  19. package/lib-commonjs/test/telemetry.test.d.ts +26 -0
  20. package/lib-commonjs/test/telemetry.test.js +469 -0
  21. package/lib-commonjs/test/telemetry.test.js.map +1 -0
  22. package/lib-commonjs/test/versionUtils.test.d.ts +7 -0
  23. package/lib-commonjs/test/versionUtils.test.js +111 -0
  24. package/lib-commonjs/test/versionUtils.test.js.map +1 -0
  25. package/lib-commonjs/utils/basePropUtils.d.ts +66 -0
  26. package/lib-commonjs/utils/basePropUtils.js +131 -0
  27. package/lib-commonjs/utils/basePropUtils.js.map +1 -0
  28. package/lib-commonjs/{CodedError.d.ts → utils/errorUtils.d.ts} +27 -8
  29. package/lib-commonjs/utils/errorUtils.js +164 -0
  30. package/lib-commonjs/utils/errorUtils.js.map +1 -0
  31. package/lib-commonjs/utils/optionUtils.d.ts +45 -0
  32. package/lib-commonjs/utils/optionUtils.js +96 -0
  33. package/lib-commonjs/utils/optionUtils.js.map +1 -0
  34. package/lib-commonjs/utils/projectUtils.d.ts +50 -0
  35. package/lib-commonjs/utils/projectUtils.js +187 -0
  36. package/lib-commonjs/utils/projectUtils.js.map +1 -0
  37. package/lib-commonjs/utils/sanitizeUtils.d.ts +12 -0
  38. package/lib-commonjs/utils/sanitizeUtils.js +82 -0
  39. package/lib-commonjs/utils/sanitizeUtils.js.map +1 -0
  40. package/lib-commonjs/utils/versionUtils.d.ts +38 -0
  41. package/lib-commonjs/utils/versionUtils.js +156 -0
  42. package/lib-commonjs/utils/versionUtils.js.map +1 -0
  43. package/package.json +20 -9
  44. package/CHANGELOG.json +0 -618
  45. package/CHANGELOG.md +0 -260
  46. package/lib-commonjs/CodedError.js +0 -77
  47. package/lib-commonjs/CodedError.js.map +0 -1
  48. package/lib-commonjs/test/sanitize.test.js +0 -259
  49. package/lib-commonjs/test/sanitize.test.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sanitizeUtils.test.js","sourceRoot":"","sources":["../../src/test/sanitizeUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AAExB,sEAAwD;AAExD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAEjC,IAAI,CAAC,oDAAoD,EAAE,GAAG,EAAE;IAC9D,MAAM,YAAY,GAAG,UAAU,CAAC;IAChC,MAAM,cAAc,GAAG,aAAa,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC;IACrE,MAAM,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,C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Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport path from 'path';\n\nimport * as sanitizeUtils from '../utils/sanitizeUtils';\n\nconst projectDir = process.cwd();\n\ntest('getAnonymizedPath() with project dir is anonymized', () => {\n const originalPath = projectDir;\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[project_dir]')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/index.js is anonymized', () => {\n const originalPath = path.join(projectDir, 'index.js');\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[project_dir]\\\\???.js')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/windows/test.sln is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'windows/test.sln'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[windows]\\\\???.sln')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/node_modules for untracked package is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/untracked/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[node_modules]\\\\???.js')).toBe(true);\n});\n\ntest('getAnonymizedPath() with project/node_modules for react-secret-pii package is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/react-secret-pii/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[node_modules]\\\\???.js')).toBe(true);\n});\n\ntest('getAnonymizedPath() with path under react-native-windows is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/react-native-windows/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe('[node_modules]\\\\react-native-windows\\\\index.js');\n});\n\ntest('getAnonymizedPath() with path under @react-native-windows/cli is anonymized', () => {\n const originalPath = path.normalize(\n path.join(projectDir, 'node_modules/@react-native-windows/cli/index.js'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe(\n '[node_modules]\\\\@react-native-windows\\\\cli\\\\index.js',\n );\n});\n\ntest('getAnonymizedPath() with path under %%LocalAppData%% is anonymized', () => {\n const originalPath = path.normalize(\n path.join(process.env.LocalAppData!, 'test.sln'),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath.startsWith('[LocalAppData]\\\\???')).toBe(true);\n});\n\ntest('getAnonymizedPath() with a tracked npm package under %%LocalAppData%% is anonymized', () => {\n const originalPath = path.normalize(\n path.join(\n process.env.LocalAppData!,\n 'node_modules/@react-native-windows/cli/index.js',\n ),\n );\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe(\n '[node_modules]\\\\@react-native-windows\\\\cli\\\\index.js',\n );\n});\n\ntest('getAnonymizedPath() with arbitrary path not under project dir is anonymized', () => {\n const originalPath = 'test.sln';\n const anonymizedPath = sanitizeUtils.getAnonymizedPath(originalPath);\n expect(anonymizedPath).not.toBe(originalPath);\n expect(anonymizedPath).toBe('[path]');\n});\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ import * as appInsights from 'applicationinsights';
8
+ import { Telemetry } from '../telemetry';
9
+ export declare class TelemetryTest extends Telemetry {
10
+ protected static hasTestTelemetryProviders: boolean;
11
+ protected static testTelemetryProvidersRan: boolean;
12
+ /** Run at the beginning of each test. */
13
+ static startTest(): Promise<void>;
14
+ /** Run at the end of each test where telemetry was fired. */
15
+ static endTest(finalCallback: () => void): void;
16
+ /** Sets that the telemetry provider has run. */
17
+ static setTestTelemetryProvidersRan(): void;
18
+ /** Retrieves the value of a common property.*/
19
+ static getCommonProperty(key: string): string | undefined;
20
+ /** Retrieves the version of the specified tool/package. */
21
+ static getVersion(key: string): string | null;
22
+ /** Adds a telemetry processor, usually for verifying the envelope. */
23
+ static addTelemetryProcessor(telemetryProcessor: (envelope: appInsights.Contracts.EnvelopeTelemetry, contextObjects?: {
24
+ [name: string]: any;
25
+ }) => boolean): void;
26
+ }
@@ -0,0 +1,469 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * @format
7
+ */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
11
+ }) : (function(o, m, k, k2) {
12
+ if (k2 === undefined) k2 = k;
13
+ o[k2] = m[k];
14
+ }));
15
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
16
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
17
+ }) : function(o, v) {
18
+ o["default"] = v;
19
+ });
20
+ var __importStar = (this && this.__importStar) || function (mod) {
21
+ if (mod && mod.__esModule) return mod;
22
+ var result = {};
23
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
+ __setModuleDefault(result, mod);
25
+ return result;
26
+ };
27
+ var __importDefault = (this && this.__importDefault) || function (mod) {
28
+ return (mod && mod.__esModule) ? mod : { "default": mod };
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.TelemetryTest = void 0;
32
+ const CorrelationIdManager_1 = __importDefault(require("applicationinsights/out/Library/CorrelationIdManager"));
33
+ const path = __importStar(require("path"));
34
+ const telemetry_1 = require("../telemetry");
35
+ const basePropUtils = __importStar(require("../utils/basePropUtils"));
36
+ const errorUtils = __importStar(require("../utils/errorUtils"));
37
+ const projectUtils = __importStar(require("../utils/projectUtils"));
38
+ const versionUtils = __importStar(require("../utils/versionUtils"));
39
+ class TelemetryTest extends telemetry_1.Telemetry {
40
+ /** Run at the beginning of each test. */
41
+ static async startTest() {
42
+ TelemetryTest.hasTestTelemetryProviders = false;
43
+ TelemetryTest.testTelemetryProvidersRan = false;
44
+ jest.setTimeout(10000); // These E2E tests can run longer than the default 5000ms
45
+ if (TelemetryTest.isEnabled()) {
46
+ telemetry_1.Telemetry.reset();
47
+ }
48
+ // Ensure that we don't actually fire events when testing
49
+ telemetry_1.Telemetry.isTest = true;
50
+ await telemetry_1.Telemetry.setup({ preserveErrorMessages: true });
51
+ // Workaround for https://github.com/microsoft/ApplicationInsights-node.js/issues/833
52
+ telemetry_1.Telemetry.client.config.correlationIdRetryIntervalMs = 500;
53
+ CorrelationIdManager_1.default.cancelCorrelationIdQuery(telemetry_1.Telemetry.client.config, () => { });
54
+ }
55
+ /** Run at the end of each test where telemetry was fired. */
56
+ static endTest(finalCallback) {
57
+ var _a;
58
+ (_a = telemetry_1.Telemetry.client) === null || _a === void 0 ? void 0 : _a.flush({
59
+ callback: (_) => {
60
+ if (TelemetryTest.hasTestTelemetryProviders) {
61
+ expect(TelemetryTest.testTelemetryProvidersRan).toBe(true);
62
+ }
63
+ finalCallback();
64
+ },
65
+ });
66
+ }
67
+ /** Sets that the telemetry provider has run. */
68
+ static setTestTelemetryProvidersRan() {
69
+ TelemetryTest.testTelemetryProvidersRan = true;
70
+ }
71
+ /** Retrieves the value of a common property.*/
72
+ static getCommonProperty(key) {
73
+ var _a;
74
+ return (_a = TelemetryTest.client) === null || _a === void 0 ? void 0 : _a.commonProperties[key];
75
+ }
76
+ /** Retrieves the version of the specified tool/package. */
77
+ static getVersion(key) {
78
+ return key in TelemetryTest.versionsProp
79
+ ? TelemetryTest.versionsProp[key]
80
+ : null;
81
+ }
82
+ /** Adds a telemetry processor, usually for verifying the envelope. */
83
+ static addTelemetryProcessor(telemetryProcessor) {
84
+ var _a;
85
+ (_a = TelemetryTest.client) === null || _a === void 0 ? void 0 : _a.addTelemetryProcessor(telemetryProcessor);
86
+ TelemetryTest.hasTestTelemetryProviders = true;
87
+ }
88
+ }
89
+ exports.TelemetryTest = TelemetryTest;
90
+ beforeEach(async () => {
91
+ await TelemetryTest.startTest();
92
+ });
93
+ test('setup() verify session id is valid and a common property', async () => {
94
+ const sessionId = TelemetryTest.getSessionId();
95
+ expect(sessionId).toBeDefined();
96
+ expect(sessionId).toHaveLength(32);
97
+ expect(sessionId).toBe(basePropUtils.getSessionId());
98
+ expect(sessionId).toBe(TelemetryTest.getCommonProperty('sessionId'));
99
+ });
100
+ test('setup() verify static common property values with async sources', async () => {
101
+ const props = {
102
+ deviceId: basePropUtils.deviceId,
103
+ deviceLocale: basePropUtils.deviceLocale,
104
+ };
105
+ for (const key in props) {
106
+ if (!(key in Object.prototype)) {
107
+ const value = await props[key]();
108
+ expect(value).toBeDefined();
109
+ expect(value).toBe(TelemetryTest.getCommonProperty(key));
110
+ }
111
+ }
112
+ });
113
+ test('setup() verify static common property values with sync sources', () => {
114
+ const props = {
115
+ deviceNumCPUs: () => basePropUtils.deviceNumCPUs().toString(),
116
+ deviceTotalMemory: () => basePropUtils.deviceTotalMemory().toString(),
117
+ ciCaptured: () => basePropUtils.captureCI().toString(),
118
+ ciType: () => basePropUtils.ciType(),
119
+ isMsftInternal: () => basePropUtils.isMsftInternal().toString(),
120
+ isTest: () => 'true',
121
+ };
122
+ for (const key in props) {
123
+ if (!(key in Object.prototype)) {
124
+ const value = props[key]();
125
+ expect(value).toBeDefined();
126
+ expect(value).toBe(TelemetryTest.getCommonProperty(key));
127
+ }
128
+ }
129
+ });
130
+ test('setup() verify other common property values are defined', () => {
131
+ const props = ['deviceDiskFreeSpace'];
132
+ for (const key of props) {
133
+ const value = TelemetryTest.getCommonProperty(key);
134
+ expect(value).toBeDefined();
135
+ }
136
+ });
137
+ test('setup() verify tool versions are populated', async () => {
138
+ const props = {
139
+ node: versionUtils.getNodeVersion,
140
+ npm: versionUtils.getNpmVersion,
141
+ yarn: versionUtils.getYarnVersion,
142
+ VisualStudio: versionUtils.getVisualStudioVersion,
143
+ };
144
+ for (const key in props) {
145
+ if (!(key in Object.prototype)) {
146
+ const value = await props[key]();
147
+ expect(value).toBe(TelemetryTest.getVersion(key));
148
+ }
149
+ }
150
+ });
151
+ test('tryUpdateVersionsProp() returns true for adding a new version', async () => {
152
+ const name = 'test';
153
+ const version = '1.0';
154
+ expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => version)).toBe(true);
155
+ expect(TelemetryTest.getVersion(name)).toBe(version);
156
+ });
157
+ test('tryUpdateVersionsProp() returns false for adding an existing version with refresh is false', async () => {
158
+ const name = 'test';
159
+ const version = '1.0';
160
+ expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => version)).toBe(true);
161
+ let getValueCalled = false;
162
+ expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => {
163
+ getValueCalled = true;
164
+ return version;
165
+ })).toBe(false);
166
+ expect(getValueCalled).toBe(false);
167
+ });
168
+ test('tryUpdateVersionsProp() returns true for adding an existing version with refresh is true', async () => {
169
+ const name = 'test';
170
+ const version = '1.0';
171
+ expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => version)).toBe(true);
172
+ let getValueCalled = false;
173
+ expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => {
174
+ getValueCalled = true;
175
+ return version;
176
+ }, true)).toBe(true);
177
+ expect(getValueCalled).toBe(true);
178
+ });
179
+ /** Returns the CommandStartInfo for our fake 'test-command'. */
180
+ function getTestCommandStartInfo() {
181
+ return {
182
+ commandName: 'test-command',
183
+ args: {
184
+ testArg1: 'true',
185
+ testArg2: '10',
186
+ testArg3: 'testValue',
187
+ },
188
+ options: {
189
+ testArg0: 'unsetArg',
190
+ testArg1: true,
191
+ testArg2: 10,
192
+ testArg3: 'testValue',
193
+ },
194
+ defaultOptions: {
195
+ testArg0: 'unsetArg',
196
+ testArg1: false,
197
+ testArg2: 0,
198
+ testArg3: 'defaultValue',
199
+ },
200
+ };
201
+ }
202
+ /** Returns the CommandEndInfo for our fake 'test-command'. */
203
+ function getTestCommandEndInfo(resultCode) {
204
+ return {
205
+ resultCode,
206
+ };
207
+ }
208
+ function getTestCommandProjectInfo() {
209
+ return {
210
+ id: projectUtils.getProjectId('test-app-project'),
211
+ platforms: ['windows'],
212
+ rnwLang: 'cpp',
213
+ usesTS: true,
214
+ usesRNConfig: false,
215
+ jsEngine: 'Chakra',
216
+ rnwSource: 'Source',
217
+ dependencies: [
218
+ {
219
+ id: projectUtils.getProjectId('test-module-project'),
220
+ platforms: ['android', 'windows'],
221
+ rnwLang: 'cpp',
222
+ },
223
+ ],
224
+ };
225
+ }
226
+ function getExtraProps() {
227
+ return {
228
+ extraProp1: true,
229
+ extraProp2: 1234,
230
+ extraProp3: 'test',
231
+ extraProp4: ['test'],
232
+ extraProp5: {
233
+ nestedProp1: true,
234
+ nestedProp2: 1234,
235
+ },
236
+ };
237
+ }
238
+ /** Asynchronously waits the number in ms. */
239
+ async function promiseDelay(ms) {
240
+ return new Promise((resolve) => setTimeout(resolve, ms));
241
+ }
242
+ /** The body of the fake 'test-command' which will throw the provided error. */
243
+ async function testCommandBody(errorToThrow) {
244
+ await promiseDelay(100);
245
+ if (errorToThrow) {
246
+ throw errorToThrow;
247
+ }
248
+ }
249
+ /** Runs the complete 'test-command' with the right Telemetry setup and cleanup. */
250
+ async function runTestCommandE2E(commandBody) {
251
+ TelemetryTest.startCommand(getTestCommandStartInfo());
252
+ TelemetryTest.setProjectInfo(getTestCommandProjectInfo());
253
+ let errorCode = 'Success';
254
+ let caughtError;
255
+ try {
256
+ await commandBody();
257
+ }
258
+ catch (ex) {
259
+ caughtError = ex instanceof Error ? ex : new Error(String(ex));
260
+ errorCode =
261
+ caughtError instanceof errorUtils.CodedError
262
+ ? caughtError.type
263
+ : 'Unknown';
264
+ TelemetryTest.trackException(caughtError);
265
+ }
266
+ TelemetryTest.endCommand(getTestCommandEndInfo(errorCode), getExtraProps());
267
+ }
268
+ /** Verifys the contents of events fired during the 'test-command'. */
269
+ function verifyTestCommandTelemetryProcessor(caughtErrors, expectedResultCode, expectedError) {
270
+ return (envelope, _) => {
271
+ var _a, _b, _c, _d, _e;
272
+ try {
273
+ // Processor has run, so the test can (potentially) pass
274
+ TelemetryTest.setTestTelemetryProvidersRan();
275
+ // Verify roleInstance has been removed
276
+ expect(envelope.tags['ai.cloud.roleInstance']).toBeUndefined();
277
+ const properties = (_a = envelope.data.baseData) === null || _a === void 0 ? void 0 : _a.properties;
278
+ expect(properties).toBeDefined();
279
+ // Verify basics
280
+ expect(properties.commandName).toBe('test-command');
281
+ // Verify versions info
282
+ const versions = JSON.parse(properties.versions);
283
+ expect(versions).toBeDefined();
284
+ // Verify project info
285
+ const project = JSON.parse(properties.project);
286
+ expect(project).toStrictEqual(getTestCommandProjectInfo());
287
+ expect(Object.keys(versions).length).toBeGreaterThan(0);
288
+ for (const key of Object.keys(versions)) {
289
+ expect(versions[key]).toBe(TelemetryTest.getVersion(key));
290
+ }
291
+ if (envelope.data.baseType === 'ExceptionData') {
292
+ // Verify event name
293
+ expect(properties.eventName).toBe(telemetry_1.CodedErrorEventName);
294
+ // Verify coded error info
295
+ const codedError = JSON.parse(properties.codedError);
296
+ expect(codedError).toBeDefined();
297
+ expect(codedError.type).toBe(expectedError instanceof errorUtils.CodedError
298
+ ? expectedError.type
299
+ : 'Unknown');
300
+ expect(codedError.rawErrorCode).toBe((_c = errorUtils.tryGetErrorCode((_b = expectedError === null || expectedError === void 0 ? void 0 : expectedError.message) !== null && _b !== void 0 ? _b : '')) !== null && _c !== void 0 ? _c : '');
301
+ expect(codedError.data).toStrictEqual((_d = expectedError.data) !== null && _d !== void 0 ? _d : {});
302
+ }
303
+ else {
304
+ // Verify event name
305
+ expect((_e = envelope.data.baseData) === null || _e === void 0 ? void 0 : _e.name).toBe(telemetry_1.CommandEventName);
306
+ expect(properties.eventName).toBe(telemetry_1.CommandEventName);
307
+ // Verify command info
308
+ const expectedInfo = getTestCommandStartInfo();
309
+ const command = JSON.parse(properties.command);
310
+ expect(command).toBeDefined();
311
+ expect(command.args).toStrictEqual(expectedInfo.args);
312
+ expect(command.options).toStrictEqual(expectedInfo.options);
313
+ expect(command.defaultOptions).toStrictEqual(expectedInfo.defaultOptions);
314
+ expect(command.durationInSecs).toBeGreaterThan(0);
315
+ expect(command.resultCode).toBe(expectedResultCode !== null && expectedResultCode !== void 0 ? expectedResultCode : 'Success');
316
+ // Verify extra props
317
+ const extraProps = getExtraProps();
318
+ for (const key of Object.keys(extraProps)) {
319
+ switch (typeof extraProps[key]) {
320
+ case 'object':
321
+ expect(JSON.parse(properties[key])).toStrictEqual(extraProps[key]);
322
+ break;
323
+ default:
324
+ expect(properties[key]).toBe(extraProps[key].toString());
325
+ }
326
+ }
327
+ }
328
+ }
329
+ catch (ex) {
330
+ caughtErrors.push(ex instanceof Error ? ex : new Error(String(ex)));
331
+ }
332
+ return true;
333
+ };
334
+ }
335
+ test('Telemetry run test command end to end, verify event fires', async (done) => {
336
+ // AI eats errors thrown in telemetry processors
337
+ const caughtErrors = [];
338
+ TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors));
339
+ await runTestCommandE2E(testCommandBody);
340
+ TelemetryTest.endTest(() => {
341
+ // Check if any errors were thrown
342
+ expect(caughtErrors).toHaveLength(0);
343
+ done();
344
+ });
345
+ });
346
+ test('Telemetry run test command end to end with CodedError, verify events fire', async (done) => {
347
+ const expectedError = new errorUtils.CodedError('MSBuildError', 'test error');
348
+ // AI eats errors thrown in telemetry processors
349
+ const caughtErrors = [];
350
+ TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
351
+ await runTestCommandE2E(() => testCommandBody(expectedError));
352
+ TelemetryTest.endTest(() => {
353
+ // Check if any errors were thrown
354
+ expect(caughtErrors).toHaveLength(0);
355
+ done();
356
+ });
357
+ });
358
+ test('Telemetry run test command end to end with CodedError (with error in message), verify events fire', async (done) => {
359
+ const expectedError = new errorUtils.CodedError('MSBuildError', 'error FOO2020: test error');
360
+ // AI eats errors thrown in telemetry processors
361
+ const caughtErrors = [];
362
+ TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
363
+ await runTestCommandE2E(() => testCommandBody(expectedError));
364
+ TelemetryTest.endTest(() => {
365
+ // Check if any errors were thrown
366
+ expect(caughtErrors).toHaveLength(0);
367
+ done();
368
+ });
369
+ });
370
+ test('Telemetry run test command end to end with CodedError (with data), verify events fire', async (done) => {
371
+ const expectedError = new errorUtils.CodedError('MSBuildError', 'test error', { foo: 42 });
372
+ // AI eats errors thrown in telemetry processors
373
+ const caughtErrors = [];
374
+ TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, expectedError.type, expectedError));
375
+ await runTestCommandE2E(() => testCommandBody(expectedError));
376
+ TelemetryTest.endTest(() => {
377
+ // Check if any errors were thrown
378
+ expect(caughtErrors).toHaveLength(0);
379
+ done();
380
+ });
381
+ });
382
+ test('Telemetry run test command end to end with Error, verify events fire', async (done) => {
383
+ const expectedError = new Error('error FOO2020: test error');
384
+ // AI eats errors thrown in telemetry processors
385
+ const caughtErrors = [];
386
+ TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError));
387
+ await runTestCommandE2E(() => testCommandBody(expectedError));
388
+ TelemetryTest.endTest(() => {
389
+ // Check if any errors were thrown
390
+ expect(caughtErrors).toHaveLength(0);
391
+ done();
392
+ });
393
+ });
394
+ test('Telemetry run test command end to end with Error (no message), verify events fire', async (done) => {
395
+ const expectedError = new Error();
396
+ // AI eats errors thrown in telemetry processors
397
+ const caughtErrors = [];
398
+ TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError));
399
+ await runTestCommandE2E(() => testCommandBody(expectedError));
400
+ TelemetryTest.endTest(() => {
401
+ // Check if any errors were thrown
402
+ expect(caughtErrors).toHaveLength(0);
403
+ done();
404
+ });
405
+ });
406
+ function b(s) {
407
+ throw new Error('hello ' + s);
408
+ }
409
+ function a(s) {
410
+ b(s);
411
+ }
412
+ /** Verifies the contents of an exception's message and stack frames */
413
+ function getVerifyStackTelemetryProcessor(caughtErrors, expectedError) {
414
+ return (envelope, _) => {
415
+ try {
416
+ // Processor has run, so the test can (potentially) pass
417
+ TelemetryTest.setTestTelemetryProvidersRan();
418
+ if (envelope.data.baseType === 'ExceptionData') {
419
+ const data = envelope.data.baseData;
420
+ expect(data.exceptions).toBeDefined();
421
+ expect(data.exceptions.length).toBe(1);
422
+ expect(data.exceptions[0].message).toBe(errorUtils.sanitizeErrorMessage(expectedError.message));
423
+ const stack = data.exceptions[0].parsedStack;
424
+ expect(stack).toBeDefined();
425
+ expect(stack.length).toBeGreaterThan(2);
426
+ const filename = path.relative(process.cwd(), __filename);
427
+ expect(stack[0].method).toEqual('b');
428
+ expect(stack[1].method).toEqual('a');
429
+ expect(stack[0].fileName).toEqual(`[project_dir]\\???.ts(${filename.length})`);
430
+ expect(stack[1].fileName).toEqual(`[project_dir]\\???.ts(${filename.length})`);
431
+ }
432
+ }
433
+ catch (ex) {
434
+ caughtErrors.push(ex instanceof Error ? ex : new Error(String(ex)));
435
+ }
436
+ return true;
437
+ };
438
+ }
439
+ test('Telemetry run test command end to end with Error, verify sanitized message and stack', async (done) => {
440
+ const expectedError = new Error('hello world');
441
+ // AI eats errors thrown in telemetry processors
442
+ const caughtErrors = [];
443
+ TelemetryTest.addTelemetryProcessor(getVerifyStackTelemetryProcessor(caughtErrors, expectedError));
444
+ await runTestCommandE2E(async () => {
445
+ await promiseDelay(100);
446
+ a('world');
447
+ });
448
+ TelemetryTest.endTest(() => {
449
+ // Check if any errors were thrown
450
+ expect(caughtErrors).toHaveLength(0);
451
+ done();
452
+ });
453
+ });
454
+ test('Telemetry run test command end to end with Error, verify sanitized message with path and stack', async (done) => {
455
+ const expectedError = new Error(`hello ${process.cwd()}`);
456
+ // AI eats errors thrown in telemetry processors
457
+ const caughtErrors = [];
458
+ TelemetryTest.addTelemetryProcessor(getVerifyStackTelemetryProcessor(caughtErrors, expectedError));
459
+ await runTestCommandE2E(async () => {
460
+ await promiseDelay(100);
461
+ a(process.cwd());
462
+ });
463
+ TelemetryTest.endTest(() => {
464
+ // Check if any errors were thrown
465
+ expect(caughtErrors).toHaveLength(0);
466
+ done();
467
+ });
468
+ });
469
+ //# sourceMappingURL=telemetry.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"telemetry.test.js","sourceRoot":"","sources":["../../src/test/telemetry.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,gHAAwF;AACxF,2CAA6B;AAE7B,4CAMsB;AACtB,sEAAwD;AACxD,gEAAkD;AAClD,oEAAsD;AACtD,oEAAsD;AAEtD,MAAa,aAAc,SAAQ,qBAAS;IAI1C,yCAAyC;IACzC,MAAM,CAAC,KAAK,CAAC,SAAS;QACpB,aAAa,CAAC,yBAAyB,GAAG,KAAK,CAAC;QAChD,aAAa,CAAC,yBAAyB,GAAG,KAAK,CAAC;QAEhD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,yDAAyD;QAEjF,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,EAAC,qBAAqB,EAAE,IAAI,E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AAgC,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;QACrC,IAAI,EAAE,CAAC;IACT,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\nimport CorrelationIdManager from 'applicationinsights/out/Library/CorrelationIdManager';\nimport * as path from 'path';\n\nimport {\n Telemetry,\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() {\n TelemetryTest.hasTestTelemetryProviders = false;\n TelemetryTest.testTelemetryProvidersRan = false;\n\n jest.setTimeout(10000); // These E2E tests can run longer than the default 5000ms\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({preserveErrorMessages: true});\n\n // Workaround for https://github.com/microsoft/ApplicationInsights-node.js/issues/833\n Telemetry.client!.config.correlationIdRetryIntervalMs = 500;\n CorrelationIdManager.cancelCorrelationIdQuery(\n Telemetry.client!.config,\n () => {},\n );\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 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.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 /** 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\nbeforeEach(async () => {\n await TelemetryTest.startTest();\n});\n\ntest('setup() verify session id is valid and a common property', async () => {\n const sessionId = TelemetryTest.getSessionId();\n expect(sessionId).toBeDefined();\n expect(sessionId!).toHaveLength(32);\n expect(sessionId!).toBe(basePropUtils.getSessionId());\n expect(sessionId!).toBe(TelemetryTest.getCommonProperty('sessionId'));\n});\n\ntest('setup() verify static common property values with async sources', async () => {\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 = await props[key]();\n expect(value).toBeDefined();\n expect(value).toBe(TelemetryTest.getCommonProperty(key));\n }\n }\n});\n\ntest('setup() verify static common property values with sync sources', () => {\n const props: Record<string, () => string | undefined> = {\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 = props[key]();\n expect(value).toBeDefined();\n expect(value).toBe(TelemetryTest.getCommonProperty(key));\n }\n }\n});\n\ntest('setup() verify other common property values are defined', () => {\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\ntest('setup() verify tool versions are populated', async () => {\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\ntest('tryUpdateVersionsProp() returns true for adding a new version', async () => {\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\ntest('tryUpdateVersionsProp() returns false for adding an existing version with refresh is false', async () => {\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\ntest('tryUpdateVersionsProp() returns true for adding an existing version with refresh is true', async () => {\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\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/** Verifys 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 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 expect(codedError.rawErrorCode).toBe(\n errorUtils.tryGetErrorCode(expectedError?.message ?? '') ?? '',\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 for (const key of Object.keys(extraProps)) {\n switch (typeof extraProps[key]) {\n case 'object':\n expect(JSON.parse(properties[key])).toStrictEqual(\n extraProps[key],\n );\n break;\n default:\n expect(properties[key]).toBe(extraProps[key].toString());\n }\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('Telemetry run test command end to end, verify event fires', async (done) => {\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 done();\n });\n});\n\ntest('Telemetry run test command end to end with CodedError, verify events fire', async (done) => {\n const expectedError = new errorUtils.CodedError('MSBuildError', 'test error');\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 done();\n });\n});\n\ntest('Telemetry run test command end to end with CodedError (with error in message), verify events fire', async (done) => {\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 done();\n });\n});\n\ntest('Telemetry run test command end to end with CodedError (with data), verify events fire', async (done) => {\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 done();\n });\n});\n\ntest('Telemetry run test command end to end with Error, verify events fire', async (done) => {\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(caughtErrors, 'Unknown', expectedError),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n done();\n });\n});\n\ntest('Telemetry run test command end to end with Error (no message), verify events fire', async (done) => {\n const expectedError = new Error();\n\n // AI eats errors thrown in telemetry processors\n const caughtErrors: Error[] = [];\n TelemetryTest.addTelemetryProcessor(\n verifyTestCommandTelemetryProcessor(caughtErrors, 'Unknown', expectedError),\n );\n\n await runTestCommandE2E(() => testCommandBody(expectedError));\n\n TelemetryTest.endTest(() => {\n // Check if any errors were thrown\n expect(caughtErrors).toHaveLength(0);\n done();\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).toBe(\n errorUtils.sanitizeErrorMessage(expectedError.message),\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('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 }\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 with Error, verify sanitized message and stack', async (done) => {\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 done();\n });\n});\n\ntest('Telemetry run test command end to end with Error, verify sanitized message with path and stack', async (done) => {\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 done();\n });\n});\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * @format
6
+ */
7
+ export {};