@react-native-windows/telemetry 0.68.0 → 0.69.0-preview.1
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.
- package/lib-commonjs/{test → e2etest}/telemetry.test.d.ts +5 -3
- package/lib-commonjs/{test → e2etest}/telemetry.test.js +84 -50
- package/lib-commonjs/e2etest/telemetry.test.js.map +1 -0
- package/lib-commonjs/telemetry.js +44 -14
- package/lib-commonjs/telemetry.js.map +1 -1
- package/lib-commonjs/test/basePropUtils.test.js +17 -1
- package/lib-commonjs/test/basePropUtils.test.js.map +1 -1
- package/lib-commonjs/test/errorUtils.test.js +8 -1
- package/lib-commonjs/test/errorUtils.test.js.map +1 -1
- package/lib-commonjs/test/projectUtils.test.js +5 -1
- package/lib-commonjs/test/projectUtils.test.js.map +1 -1
- package/lib-commonjs/test/sanitizeUtils.test.js +5 -1
- package/lib-commonjs/test/sanitizeUtils.test.js.map +1 -1
- package/lib-commonjs/test/versionUtils.test.js +6 -2
- package/lib-commonjs/test/versionUtils.test.js.map +1 -1
- package/lib-commonjs/utils/basePropUtils.d.ts +10 -0
- package/lib-commonjs/utils/basePropUtils.js +17 -1
- package/lib-commonjs/utils/basePropUtils.js.map +1 -1
- package/lib-commonjs/utils/errorUtils.js +7 -1
- package/lib-commonjs/utils/errorUtils.js.map +1 -1
- package/lib-commonjs/utils/projectUtils.js +1 -1
- package/lib-commonjs/utils/projectUtils.js.map +1 -1
- package/lib-commonjs/utils/sanitizeUtils.js +1 -1
- package/lib-commonjs/utils/sanitizeUtils.js.map +1 -1
- package/package.json +12 -10
- package/lib-commonjs/test/telemetry.test.js.map +0 -1
|
@@ -5,20 +5,22 @@
|
|
|
5
5
|
* @format
|
|
6
6
|
*/
|
|
7
7
|
import * as appInsights from 'applicationinsights';
|
|
8
|
-
import { Telemetry } from '../telemetry';
|
|
8
|
+
import { Telemetry, TelemetryOptions } from '../telemetry';
|
|
9
9
|
export declare class TelemetryTest extends Telemetry {
|
|
10
10
|
protected static hasTestTelemetryProviders: boolean;
|
|
11
11
|
protected static testTelemetryProvidersRan: boolean;
|
|
12
12
|
/** Run at the beginning of each test. */
|
|
13
|
-
static startTest(): Promise<void>;
|
|
13
|
+
static startTest(options?: Partial<TelemetryOptions>): Promise<void>;
|
|
14
14
|
/** Run at the end of each test where telemetry was fired. */
|
|
15
|
-
static endTest(finalCallback
|
|
15
|
+
static endTest(finalCallback?: () => void): void;
|
|
16
16
|
/** Sets that the telemetry provider has run. */
|
|
17
17
|
static setTestTelemetryProvidersRan(): void;
|
|
18
18
|
/** Retrieves the value of a common property.*/
|
|
19
19
|
static getCommonProperty(key: string): string | undefined;
|
|
20
20
|
/** Retrieves the version of the specified tool/package. */
|
|
21
21
|
static getVersion(key: string): string | null;
|
|
22
|
+
/** Retrieves the value of the preserveErrorMessages option. */
|
|
23
|
+
static getPreserveErrorMessages(): boolean;
|
|
22
24
|
/** Adds a telemetry processor, usually for verifying the envelope. */
|
|
23
25
|
static addTelemetryProcessor(telemetryProcessor: (envelope: appInsights.Contracts.EnvelopeTelemetry, contextObjects?: {
|
|
24
26
|
[name: string]: any;
|
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
*/
|
|
8
8
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
9
|
if (k2 === undefined) k2 = k;
|
|
10
|
-
Object.
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
11
15
|
}) : (function(o, m, k, k2) {
|
|
12
16
|
if (k2 === undefined) k2 = k;
|
|
13
17
|
o[k2] = m[k];
|
|
@@ -24,12 +28,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
28
|
__setModuleDefault(result, mod);
|
|
25
29
|
return result;
|
|
26
30
|
};
|
|
27
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
-
};
|
|
30
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
32
|
exports.TelemetryTest = void 0;
|
|
32
|
-
const CorrelationIdManager_1 = __importDefault(require("applicationinsights/out/Library/CorrelationIdManager"));
|
|
33
33
|
const path = __importStar(require("path"));
|
|
34
34
|
const telemetry_1 = require("../telemetry");
|
|
35
35
|
const basePropUtils = __importStar(require("../utils/basePropUtils"));
|
|
@@ -38,29 +38,27 @@ const projectUtils = __importStar(require("../utils/projectUtils"));
|
|
|
38
38
|
const versionUtils = __importStar(require("../utils/versionUtils"));
|
|
39
39
|
class TelemetryTest extends telemetry_1.Telemetry {
|
|
40
40
|
/** Run at the beginning of each test. */
|
|
41
|
-
static async startTest() {
|
|
41
|
+
static async startTest(options) {
|
|
42
42
|
TelemetryTest.hasTestTelemetryProviders = false;
|
|
43
43
|
TelemetryTest.testTelemetryProvidersRan = false;
|
|
44
|
-
jest.setTimeout(10000); // These E2E tests can run longer than the default 5000ms
|
|
45
44
|
if (TelemetryTest.isEnabled()) {
|
|
46
45
|
telemetry_1.Telemetry.reset();
|
|
47
46
|
}
|
|
48
47
|
// Ensure that we don't actually fire events when testing
|
|
49
48
|
telemetry_1.Telemetry.isTest = true;
|
|
50
|
-
await telemetry_1.Telemetry.setup(
|
|
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, () => { });
|
|
49
|
+
await telemetry_1.Telemetry.setup(options);
|
|
54
50
|
}
|
|
55
51
|
/** Run at the end of each test where telemetry was fired. */
|
|
56
52
|
static endTest(finalCallback) {
|
|
57
53
|
var _a;
|
|
58
54
|
(_a = telemetry_1.Telemetry.client) === null || _a === void 0 ? void 0 : _a.flush({
|
|
59
|
-
callback:
|
|
55
|
+
callback: _ => {
|
|
60
56
|
if (TelemetryTest.hasTestTelemetryProviders) {
|
|
61
57
|
expect(TelemetryTest.testTelemetryProvidersRan).toBe(true);
|
|
62
58
|
}
|
|
63
|
-
finalCallback
|
|
59
|
+
if (finalCallback) {
|
|
60
|
+
finalCallback();
|
|
61
|
+
}
|
|
64
62
|
},
|
|
65
63
|
});
|
|
66
64
|
}
|
|
@@ -79,6 +77,10 @@ class TelemetryTest extends telemetry_1.Telemetry {
|
|
|
79
77
|
? TelemetryTest.versionsProp[key]
|
|
80
78
|
: null;
|
|
81
79
|
}
|
|
80
|
+
/** Retrieves the value of the preserveErrorMessages option. */
|
|
81
|
+
static getPreserveErrorMessages() {
|
|
82
|
+
return TelemetryTest.options.preserveErrorMessages;
|
|
83
|
+
}
|
|
82
84
|
/** Adds a telemetry processor, usually for verifying the envelope. */
|
|
83
85
|
static addTelemetryProcessor(telemetryProcessor) {
|
|
84
86
|
var _a;
|
|
@@ -87,54 +89,63 @@ class TelemetryTest extends telemetry_1.Telemetry {
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
exports.TelemetryTest = TelemetryTest;
|
|
90
|
-
|
|
92
|
+
test('setup() verify session id is valid and a common property', async (done) => {
|
|
91
93
|
await TelemetryTest.startTest();
|
|
92
|
-
});
|
|
93
|
-
test('setup() verify session id is valid and a common property', async () => {
|
|
94
94
|
const sessionId = TelemetryTest.getSessionId();
|
|
95
95
|
expect(sessionId).toBeDefined();
|
|
96
96
|
expect(sessionId).toHaveLength(32);
|
|
97
97
|
expect(sessionId).toBe(basePropUtils.getSessionId());
|
|
98
|
-
expect(
|
|
98
|
+
expect(TelemetryTest.getCommonProperty('sessionId')).toBe(sessionId);
|
|
99
|
+
TelemetryTest.endTest(done);
|
|
99
100
|
});
|
|
100
|
-
test('setup() verify static common property values with async sources', async () => {
|
|
101
|
+
test('setup() verify static common property values with async sources', async (done) => {
|
|
102
|
+
await TelemetryTest.startTest();
|
|
101
103
|
const props = {
|
|
102
104
|
deviceId: basePropUtils.deviceId,
|
|
103
105
|
deviceLocale: basePropUtils.deviceLocale,
|
|
104
106
|
};
|
|
105
107
|
for (const key in props) {
|
|
106
108
|
if (!(key in Object.prototype)) {
|
|
107
|
-
const value =
|
|
109
|
+
const value = TelemetryTest.getCommonProperty(key);
|
|
108
110
|
expect(value).toBeDefined();
|
|
109
|
-
expect(value).toBe(
|
|
111
|
+
expect(value).toBe(await props[key]());
|
|
110
112
|
}
|
|
111
113
|
}
|
|
114
|
+
TelemetryTest.endTest(done);
|
|
112
115
|
});
|
|
113
|
-
test('setup() verify static common property values with sync sources', () => {
|
|
116
|
+
test('setup() verify static common property values with sync sources', async (done) => {
|
|
117
|
+
await TelemetryTest.startTest();
|
|
114
118
|
const props = {
|
|
119
|
+
deviceArchitecture: () => basePropUtils.deviceArchitecture(),
|
|
120
|
+
devicePlatform: () => basePropUtils.devicePlatform(),
|
|
115
121
|
deviceNumCPUs: () => basePropUtils.deviceNumCPUs().toString(),
|
|
116
122
|
deviceTotalMemory: () => basePropUtils.deviceTotalMemory().toString(),
|
|
117
123
|
ciCaptured: () => basePropUtils.captureCI().toString(),
|
|
118
124
|
ciType: () => basePropUtils.ciType(),
|
|
119
125
|
isMsftInternal: () => basePropUtils.isMsftInternal().toString(),
|
|
126
|
+
sampleRate: () => basePropUtils.sampleRate().toString(),
|
|
120
127
|
isTest: () => 'true',
|
|
121
128
|
};
|
|
122
129
|
for (const key in props) {
|
|
123
130
|
if (!(key in Object.prototype)) {
|
|
124
|
-
const value =
|
|
131
|
+
const value = TelemetryTest.getCommonProperty(key);
|
|
125
132
|
expect(value).toBeDefined();
|
|
126
|
-
expect(value).toBe(
|
|
133
|
+
expect(value).toBe(props[key]());
|
|
127
134
|
}
|
|
128
135
|
}
|
|
136
|
+
TelemetryTest.endTest(done);
|
|
129
137
|
});
|
|
130
|
-
test('setup() verify other common property values are defined', () => {
|
|
138
|
+
test('setup() verify other common property values are defined', async (done) => {
|
|
139
|
+
await TelemetryTest.startTest();
|
|
131
140
|
const props = ['deviceDiskFreeSpace'];
|
|
132
141
|
for (const key of props) {
|
|
133
142
|
const value = TelemetryTest.getCommonProperty(key);
|
|
134
143
|
expect(value).toBeDefined();
|
|
135
144
|
}
|
|
145
|
+
TelemetryTest.endTest(done);
|
|
136
146
|
});
|
|
137
|
-
test('setup() verify tool versions are populated', async () => {
|
|
147
|
+
test('setup() verify tool versions are populated', async (done) => {
|
|
148
|
+
await TelemetryTest.startTest();
|
|
138
149
|
const props = {
|
|
139
150
|
node: versionUtils.getNodeVersion,
|
|
140
151
|
npm: versionUtils.getNpmVersion,
|
|
@@ -147,14 +158,18 @@ test('setup() verify tool versions are populated', async () => {
|
|
|
147
158
|
expect(value).toBe(TelemetryTest.getVersion(key));
|
|
148
159
|
}
|
|
149
160
|
}
|
|
161
|
+
TelemetryTest.endTest(done);
|
|
150
162
|
});
|
|
151
|
-
test('tryUpdateVersionsProp() returns true for adding a new version', async () => {
|
|
163
|
+
test('tryUpdateVersionsProp() returns true for adding a new version', async (done) => {
|
|
164
|
+
await TelemetryTest.startTest();
|
|
152
165
|
const name = 'test';
|
|
153
166
|
const version = '1.0';
|
|
154
167
|
expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => version)).toBe(true);
|
|
155
168
|
expect(TelemetryTest.getVersion(name)).toBe(version);
|
|
169
|
+
TelemetryTest.endTest(done);
|
|
156
170
|
});
|
|
157
|
-
test('tryUpdateVersionsProp() returns false for adding an existing version with refresh is false', async () => {
|
|
171
|
+
test('tryUpdateVersionsProp() returns false for adding an existing version with refresh is false', async (done) => {
|
|
172
|
+
await TelemetryTest.startTest();
|
|
158
173
|
const name = 'test';
|
|
159
174
|
const version = '1.0';
|
|
160
175
|
expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => version)).toBe(true);
|
|
@@ -164,8 +179,10 @@ test('tryUpdateVersionsProp() returns false for adding an existing version with
|
|
|
164
179
|
return version;
|
|
165
180
|
})).toBe(false);
|
|
166
181
|
expect(getValueCalled).toBe(false);
|
|
182
|
+
TelemetryTest.endTest(done);
|
|
167
183
|
});
|
|
168
|
-
test('tryUpdateVersionsProp() returns true for adding an existing version with refresh is true', async () => {
|
|
184
|
+
test('tryUpdateVersionsProp() returns true for adding an existing version with refresh is true', async (done) => {
|
|
185
|
+
await TelemetryTest.startTest();
|
|
169
186
|
const name = 'test';
|
|
170
187
|
const version = '1.0';
|
|
171
188
|
expect(await TelemetryTest.tryUpdateVersionsProp(name, async () => version)).toBe(true);
|
|
@@ -175,6 +192,7 @@ test('tryUpdateVersionsProp() returns true for adding an existing version with r
|
|
|
175
192
|
return version;
|
|
176
193
|
}, true)).toBe(true);
|
|
177
194
|
expect(getValueCalled).toBe(true);
|
|
195
|
+
TelemetryTest.endTest(done);
|
|
178
196
|
});
|
|
179
197
|
/** Returns the CommandStartInfo for our fake 'test-command'. */
|
|
180
198
|
function getTestCommandStartInfo() {
|
|
@@ -237,7 +255,7 @@ function getExtraProps() {
|
|
|
237
255
|
}
|
|
238
256
|
/** Asynchronously waits the number in ms. */
|
|
239
257
|
async function promiseDelay(ms) {
|
|
240
|
-
return new Promise(
|
|
258
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
241
259
|
}
|
|
242
260
|
/** The body of the fake 'test-command' which will throw the provided error. */
|
|
243
261
|
async function testCommandBody(errorToThrow) {
|
|
@@ -268,7 +286,7 @@ async function runTestCommandE2E(commandBody) {
|
|
|
268
286
|
/** Verifys the contents of events fired during the 'test-command'. */
|
|
269
287
|
function verifyTestCommandTelemetryProcessor(caughtErrors, expectedResultCode, expectedError) {
|
|
270
288
|
return (envelope, _) => {
|
|
271
|
-
var _a, _b, _c, _d
|
|
289
|
+
var _a, _b, _c, _d;
|
|
272
290
|
try {
|
|
273
291
|
// Processor has run, so the test can (potentially) pass
|
|
274
292
|
TelemetryTest.setTestTelemetryProvidersRan();
|
|
@@ -291,18 +309,26 @@ function verifyTestCommandTelemetryProcessor(caughtErrors, expectedResultCode, e
|
|
|
291
309
|
if (envelope.data.baseType === 'ExceptionData') {
|
|
292
310
|
// Verify event name
|
|
293
311
|
expect(properties.eventName).toBe(telemetry_1.CodedErrorEventName);
|
|
312
|
+
// 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()
|
|
319
|
+
? errorUtils.sanitizeErrorMessage((expectedError === null || expectedError === void 0 ? void 0 : expectedError.message) || 'None')
|
|
320
|
+
: '[Removed]');
|
|
294
321
|
// Verify coded error info
|
|
295
322
|
const codedError = JSON.parse(properties.codedError);
|
|
296
323
|
expect(codedError).toBeDefined();
|
|
297
324
|
expect(codedError.type).toBe(expectedError instanceof errorUtils.CodedError
|
|
298
325
|
? expectedError.type
|
|
299
326
|
: 'Unknown');
|
|
300
|
-
expect(codedError.
|
|
301
|
-
expect(codedError.data).toStrictEqual((_d = expectedError.data) !== null && _d !== void 0 ? _d : {});
|
|
327
|
+
expect(codedError.data).toStrictEqual((_c = expectedError.data) !== null && _c !== void 0 ? _c : {});
|
|
302
328
|
}
|
|
303
329
|
else {
|
|
304
330
|
// Verify event name
|
|
305
|
-
expect((
|
|
331
|
+
expect((_d = envelope.data.baseData) === null || _d === void 0 ? void 0 : _d.name).toBe(telemetry_1.CommandEventName);
|
|
306
332
|
expect(properties.eventName).toBe(telemetry_1.CommandEventName);
|
|
307
333
|
// Verify command info
|
|
308
334
|
const expectedInfo = getTestCommandStartInfo();
|
|
@@ -315,15 +341,7 @@ function verifyTestCommandTelemetryProcessor(caughtErrors, expectedResultCode, e
|
|
|
315
341
|
expect(command.resultCode).toBe(expectedResultCode !== null && expectedResultCode !== void 0 ? expectedResultCode : 'Success');
|
|
316
342
|
// Verify extra props
|
|
317
343
|
const extraProps = getExtraProps();
|
|
318
|
-
|
|
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
|
-
}
|
|
344
|
+
expect(JSON.parse(properties.extraProps)).toStrictEqual(extraProps);
|
|
327
345
|
}
|
|
328
346
|
}
|
|
329
347
|
catch (ex) {
|
|
@@ -333,6 +351,7 @@ function verifyTestCommandTelemetryProcessor(caughtErrors, expectedResultCode, e
|
|
|
333
351
|
};
|
|
334
352
|
}
|
|
335
353
|
test('Telemetry run test command end to end, verify event fires', async (done) => {
|
|
354
|
+
await TelemetryTest.startTest();
|
|
336
355
|
// AI eats errors thrown in telemetry processors
|
|
337
356
|
const caughtErrors = [];
|
|
338
357
|
TelemetryTest.addTelemetryProcessor(verifyTestCommandTelemetryProcessor(caughtErrors));
|
|
@@ -343,7 +362,12 @@ test('Telemetry run test command end to end, verify event fires', async (done) =
|
|
|
343
362
|
done();
|
|
344
363
|
});
|
|
345
364
|
});
|
|
346
|
-
|
|
365
|
+
const testTelemetryOptions = [
|
|
366
|
+
{ preserveErrorMessages: false },
|
|
367
|
+
{ preserveErrorMessages: true },
|
|
368
|
+
];
|
|
369
|
+
test.each(testTelemetryOptions)('Telemetry run test command end to end with CodedError, verify events fire %s', async (options, done) => {
|
|
370
|
+
await TelemetryTest.startTest(options);
|
|
347
371
|
const expectedError = new errorUtils.CodedError('MSBuildError', 'test error');
|
|
348
372
|
// AI eats errors thrown in telemetry processors
|
|
349
373
|
const caughtErrors = [];
|
|
@@ -355,7 +379,8 @@ test('Telemetry run test command end to end with CodedError, verify events fire'
|
|
|
355
379
|
done();
|
|
356
380
|
});
|
|
357
381
|
});
|
|
358
|
-
test('Telemetry run test command end to end with CodedError (with error in message), verify events fire', async (done) => {
|
|
382
|
+
test.each(testTelemetryOptions)('Telemetry run test command end to end with CodedError (with error in message), verify events fire %s', async (options, done) => {
|
|
383
|
+
await TelemetryTest.startTest(options);
|
|
359
384
|
const expectedError = new errorUtils.CodedError('MSBuildError', 'error FOO2020: test error');
|
|
360
385
|
// AI eats errors thrown in telemetry processors
|
|
361
386
|
const caughtErrors = [];
|
|
@@ -367,7 +392,8 @@ test('Telemetry run test command end to end with CodedError (with error in messa
|
|
|
367
392
|
done();
|
|
368
393
|
});
|
|
369
394
|
});
|
|
370
|
-
test('Telemetry run test command end to end with CodedError (with data), verify events fire', async (done) => {
|
|
395
|
+
test.each(testTelemetryOptions)('Telemetry run test command end to end with CodedError (with data), verify events fire %s', async (options, done) => {
|
|
396
|
+
await TelemetryTest.startTest(options);
|
|
371
397
|
const expectedError = new errorUtils.CodedError('MSBuildError', 'test error', { foo: 42 });
|
|
372
398
|
// AI eats errors thrown in telemetry processors
|
|
373
399
|
const caughtErrors = [];
|
|
@@ -379,7 +405,8 @@ test('Telemetry run test command end to end with CodedError (with data), verify
|
|
|
379
405
|
done();
|
|
380
406
|
});
|
|
381
407
|
});
|
|
382
|
-
test('Telemetry run test command end to end with Error, verify events fire', async (done) => {
|
|
408
|
+
test.each(testTelemetryOptions)('Telemetry run test command end to end with Error, verify events fire %s', async (options, done) => {
|
|
409
|
+
await TelemetryTest.startTest(options);
|
|
383
410
|
const expectedError = new Error('error FOO2020: test error');
|
|
384
411
|
// AI eats errors thrown in telemetry processors
|
|
385
412
|
const caughtErrors = [];
|
|
@@ -391,7 +418,8 @@ test('Telemetry run test command end to end with Error, verify events fire', asy
|
|
|
391
418
|
done();
|
|
392
419
|
});
|
|
393
420
|
});
|
|
394
|
-
test('Telemetry run test command end to end with Error (no message), verify events fire', async (done) => {
|
|
421
|
+
test.each(testTelemetryOptions)('Telemetry run test command end to end with Error (no message), verify events fire %s', async (options, done) => {
|
|
422
|
+
await TelemetryTest.startTest(options);
|
|
395
423
|
const expectedError = new Error();
|
|
396
424
|
// AI eats errors thrown in telemetry processors
|
|
397
425
|
const caughtErrors = [];
|
|
@@ -419,7 +447,11 @@ function getVerifyStackTelemetryProcessor(caughtErrors, expectedError) {
|
|
|
419
447
|
const data = envelope.data.baseData;
|
|
420
448
|
expect(data.exceptions).toBeDefined();
|
|
421
449
|
expect(data.exceptions.length).toBe(1);
|
|
422
|
-
expect(data.exceptions[0].message).
|
|
450
|
+
expect(data.exceptions[0].message).toBeDefined();
|
|
451
|
+
expect(data.exceptions[0].message).not.toBe('');
|
|
452
|
+
expect(data.exceptions[0].message).toBe(TelemetryTest.getPreserveErrorMessages()
|
|
453
|
+
? errorUtils.sanitizeErrorMessage(expectedError.message || 'None')
|
|
454
|
+
: '[Removed]');
|
|
423
455
|
const stack = data.exceptions[0].parsedStack;
|
|
424
456
|
expect(stack).toBeDefined();
|
|
425
457
|
expect(stack.length).toBeGreaterThan(2);
|
|
@@ -436,7 +468,8 @@ function getVerifyStackTelemetryProcessor(caughtErrors, expectedError) {
|
|
|
436
468
|
return true;
|
|
437
469
|
};
|
|
438
470
|
}
|
|
439
|
-
test('Telemetry run test command end to end with Error, verify sanitized message and stack', async (done) => {
|
|
471
|
+
test.each(testTelemetryOptions)('Telemetry run test command end to end with Error, verify sanitized message and stack %s', async (options, done) => {
|
|
472
|
+
await TelemetryTest.startTest(options);
|
|
440
473
|
const expectedError = new Error('hello world');
|
|
441
474
|
// AI eats errors thrown in telemetry processors
|
|
442
475
|
const caughtErrors = [];
|
|
@@ -451,7 +484,8 @@ test('Telemetry run test command end to end with Error, verify sanitized message
|
|
|
451
484
|
done();
|
|
452
485
|
});
|
|
453
486
|
});
|
|
454
|
-
test('Telemetry run test command end to end with Error, verify sanitized message with path and stack', async (done) => {
|
|
487
|
+
test.each(testTelemetryOptions)('Telemetry run test command end to end with Error, verify sanitized message with path and stack %s', async (options, done) => {
|
|
488
|
+
await TelemetryTest.startTest(options);
|
|
455
489
|
const expectedError = new Error(`hello ${process.cwd()}`);
|
|
456
490
|
// AI eats errors thrown in telemetry processors
|
|
457
491
|
const caughtErrors = [];
|
|
@@ -0,0 +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,EAAE;gBACZ,IAAI,aAAa,CAAC,yBAAyB,EAAE;oBAC3C,MAAM,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC5D;gBACD,IAAI,aAAa,EAAE;oBACjB,aAAa,EAAE,CAAC;iBACjB;YACH,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,gDAAgD;IAChD,MAAM,CAAC,4BAA4B;QACjC,aAAa,CAAC,yBAAyB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H,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,CACF,CAAC;AAEF,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAC7B,mGAAmG,EACnG,KAAK,EAAE,OAAO,EAAE,IAAS,EAAE,EAAE;IAC3B,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;QACrC,IAAI,EAAE,CAAC;IACT,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 done => {\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(done);\n});\n\ntest('setup() verify static common property values with async sources', async done => {\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(done);\n});\n\ntest('setup() verify static common property values with sync sources', async done => {\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(done);\n});\n\ntest('setup() verify other common property values are defined', async done => {\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(done);\n});\n\ntest('setup() verify tool versions are populated', async done => {\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(done);\n});\n\ntest('tryUpdateVersionsProp() returns true for adding a new version', async done => {\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(done);\n});\n\ntest('tryUpdateVersionsProp() returns false for adding an existing version with refresh is false', async done => {\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(done);\n});\n\ntest('tryUpdateVersionsProp() returns true for adding an existing version with refresh is true', async done => {\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(done);\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 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 done => {\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 done();\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, done: any) => {\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 done();\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, done: any) => {\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 done();\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, done: any) => {\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 done();\n });\n },\n);\n\ntest.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify events fire %s',\n async (options, done: any) => {\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 done();\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, done: any) => {\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 done();\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('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.each(testTelemetryOptions)(\n 'Telemetry run test command end to end with Error, verify sanitized message and stack %s',\n async (options, done: any) => {\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 done();\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, done: any) => {\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 done();\n });\n },\n);\n"]}
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
*/
|
|
7
7
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
8
|
if (k2 === undefined) k2 = k;
|
|
9
|
-
Object.
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
10
14
|
}) : (function(o, m, k, k2) {
|
|
11
15
|
if (k2 === undefined) k2 = k;
|
|
12
16
|
o[k2] = m[k];
|
|
@@ -108,7 +112,8 @@ class Telemetry {
|
|
|
108
112
|
}
|
|
109
113
|
/** Sets up Telemetry.client. */
|
|
110
114
|
static setupClient() {
|
|
111
|
-
|
|
115
|
+
var _a;
|
|
116
|
+
appInsights.Configuration.setInternalLogging(false, false);
|
|
112
117
|
Telemetry.client = new appInsights.TelemetryClient(Telemetry.options.setupString);
|
|
113
118
|
// Allow overriding the proxy server via an environment variable
|
|
114
119
|
const proxyServer = process.env[ENV_PROXY_OVERRIDE];
|
|
@@ -117,12 +122,21 @@ class Telemetry {
|
|
|
117
122
|
Telemetry.client.config.proxyHttpsUrl = proxyServer;
|
|
118
123
|
}
|
|
119
124
|
Telemetry.client.config.disableAppInsights = Telemetry.isTest;
|
|
125
|
+
Telemetry.client.config.disableStatsbeat = true;
|
|
126
|
+
// Despite trying to disable the statsbeat, it might still be running: https://github.com/microsoft/ApplicationInsights-node.js/issues/943
|
|
127
|
+
// So we want to disable it, and despite the method's typing, getStatsbeat() _can_ return undefined
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
129
|
+
(_a = Telemetry.client.getStatsbeat()) === null || _a === void 0 ? void 0 : _a.enable(false);
|
|
120
130
|
Telemetry.client.channel.setUseDiskRetryCaching(!Telemetry.isTest);
|
|
121
131
|
}
|
|
122
132
|
/** Sets up any base properties that all telemetry events require. */
|
|
123
133
|
static async setupBaseProperties() {
|
|
124
134
|
Telemetry.client.commonProperties.deviceId =
|
|
125
135
|
await basePropUtils.deviceId();
|
|
136
|
+
Telemetry.client.commonProperties.deviceArchitecture =
|
|
137
|
+
basePropUtils.deviceArchitecture();
|
|
138
|
+
Telemetry.client.commonProperties.devicePlatform =
|
|
139
|
+
basePropUtils.devicePlatform();
|
|
126
140
|
Telemetry.client.commonProperties.deviceLocale =
|
|
127
141
|
await basePropUtils.deviceLocale();
|
|
128
142
|
Telemetry.client.commonProperties.deviceNumCPUs = basePropUtils
|
|
@@ -141,11 +155,12 @@ class Telemetry {
|
|
|
141
155
|
Telemetry.client.commonProperties.isMsftInternal = basePropUtils
|
|
142
156
|
.isMsftInternal()
|
|
143
157
|
.toString();
|
|
144
|
-
Telemetry.client.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
158
|
+
Telemetry.client.commonProperties.sampleRate = basePropUtils
|
|
159
|
+
.sampleRate()
|
|
160
|
+
.toString();
|
|
161
|
+
Telemetry.client.commonProperties.isTest = Telemetry.isTest.toString();
|
|
148
162
|
Telemetry.client.commonProperties.sessionId = Telemetry.getSessionId();
|
|
163
|
+
Telemetry.client.config.samplingPercentage = basePropUtils.sampleRate();
|
|
149
164
|
await Telemetry.populateToolsVersions();
|
|
150
165
|
if (Telemetry.options.populateNpmPackageVersions) {
|
|
151
166
|
await Telemetry.populateNpmPackageVersions();
|
|
@@ -187,6 +202,8 @@ class Telemetry {
|
|
|
187
202
|
for (const frame of exception.parsedStack) {
|
|
188
203
|
errorUtils.sanitizeErrorStackFrame(frame);
|
|
189
204
|
}
|
|
205
|
+
// Exception message must never be blank, or AI will reject it
|
|
206
|
+
exception.message = exception.message || '[None]';
|
|
190
207
|
// CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.
|
|
191
208
|
// The message may contain PII information. This can be sanitized, but for now delete it.
|
|
192
209
|
// Note that the type of data.exceptions[0] is always going to be ExceptionDetails. It is not the original thrown exception.
|
|
@@ -195,7 +212,7 @@ class Telemetry {
|
|
|
195
212
|
exception.message = errorUtils.sanitizeErrorMessage(exception.message);
|
|
196
213
|
}
|
|
197
214
|
else {
|
|
198
|
-
|
|
215
|
+
exception.message = '[Removed]';
|
|
199
216
|
}
|
|
200
217
|
}
|
|
201
218
|
}
|
|
@@ -280,15 +297,17 @@ class Telemetry {
|
|
|
280
297
|
resultCode: (_d = Telemetry.commandInfo.endInfo) === null || _d === void 0 ? void 0 : _d.resultCode,
|
|
281
298
|
};
|
|
282
299
|
// Set remaining common props
|
|
283
|
-
Object.assign(props, extraProps);
|
|
284
300
|
props.project = Telemetry.projectProp;
|
|
285
301
|
props.versions = Telemetry.versionsProp;
|
|
302
|
+
// Set extra props
|
|
303
|
+
props.extraProps = {};
|
|
304
|
+
Object.assign(props.extraProps, extraProps);
|
|
286
305
|
// Fire event
|
|
287
306
|
Telemetry.client.trackEvent({ name: props.eventName, properties: props });
|
|
288
307
|
Telemetry.client.flush();
|
|
289
308
|
}
|
|
290
309
|
static trackException(error, extraProps) {
|
|
291
|
-
var _a, _b
|
|
310
|
+
var _a, _b;
|
|
292
311
|
if (!Telemetry.client) {
|
|
293
312
|
return;
|
|
294
313
|
}
|
|
@@ -301,11 +320,20 @@ class Telemetry {
|
|
|
301
320
|
: null;
|
|
302
321
|
props.codedError = {
|
|
303
322
|
type: (_a = codedError === null || codedError === void 0 ? void 0 : codedError.type) !== null && _a !== void 0 ? _a : 'Unknown',
|
|
304
|
-
|
|
305
|
-
data: (_c = codedError === null || codedError === void 0 ? void 0 : codedError.data) !== null && _c !== void 0 ? _c : {},
|
|
323
|
+
data: (_b = codedError === null || codedError === void 0 ? void 0 : codedError.data) !== null && _b !== void 0 ? _b : {},
|
|
306
324
|
};
|
|
307
|
-
|
|
308
|
-
|
|
325
|
+
// Copy msBuildErrorMessages into the codedError.data object
|
|
326
|
+
if (error.msBuildErrorMessages) {
|
|
327
|
+
// Always grab MSBuild error codes if possible
|
|
328
|
+
props.codedError.data.msBuildErrors = error.msBuildErrorMessages
|
|
329
|
+
.map(errorUtils.tryGetErrorCode)
|
|
330
|
+
.filter((msg) => msg);
|
|
331
|
+
// Grab sanitized MSBuild error messages if we're preserving them
|
|
332
|
+
if (Telemetry.options.preserveErrorMessages) {
|
|
333
|
+
props.codedError.data.msBuildErrorMessages = error.msBuildErrorMessages
|
|
334
|
+
.map(errorUtils.sanitizeErrorMessage)
|
|
335
|
+
.filter((msg) => msg);
|
|
336
|
+
}
|
|
309
337
|
}
|
|
310
338
|
// Copy miscellaneous system error fields into the codedError.data object
|
|
311
339
|
const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];
|
|
@@ -315,9 +343,11 @@ class Telemetry {
|
|
|
315
343
|
}
|
|
316
344
|
}
|
|
317
345
|
// Set remaining common props
|
|
318
|
-
Object.assign(props, extraProps);
|
|
319
346
|
props.project = Telemetry.projectProp;
|
|
320
347
|
props.versions = Telemetry.versionsProp;
|
|
348
|
+
// Set extra props
|
|
349
|
+
props.extraProps = {};
|
|
350
|
+
Object.assign(props.extraProps, extraProps);
|
|
321
351
|
// Fire event
|
|
322
352
|
Telemetry.client.trackException({
|
|
323
353
|
exception: error,
|