@react-native-windows/telemetry 0.76.0-preview.1 → 0.76.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.
- package/lib-commonjs/e2etest/telemetry.test.d.ts +2 -4
- package/lib-commonjs/e2etest/telemetry.test.js +58 -66
- package/lib-commonjs/e2etest/telemetry.test.js.map +1 -1
- package/lib-commonjs/telemetry.d.ts +10 -20
- package/lib-commonjs/telemetry.js +173 -139
- package/lib-commonjs/telemetry.js.map +1 -1
- package/lib-commonjs/test/basePropUtils.test.js +14 -7
- package/lib-commonjs/test/basePropUtils.test.js.map +1 -1
- package/lib-commonjs/test/errorUtils.test.js +33 -39
- package/lib-commonjs/test/errorUtils.test.js.map +1 -1
- package/lib-commonjs/utils/basePropUtils.d.ts +18 -7
- package/lib-commonjs/utils/basePropUtils.js +60 -17
- package/lib-commonjs/utils/basePropUtils.js.map +1 -1
- package/lib-commonjs/utils/errorUtils.d.ts +7 -2
- package/lib-commonjs/utils/errorUtils.js +13 -10
- package/lib-commonjs/utils/errorUtils.js.map +1 -1
- package/lib-commonjs/utils/sanitizeUtils.d.ts +1 -1
- package/lib-commonjs/utils/sanitizeUtils.js +3 -0
- package/lib-commonjs/utils/sanitizeUtils.js.map +1 -1
- package/package.json +8 -7
|
@@ -29,12 +29,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
31
|
exports.Telemetry = exports.NuGetPackagesWeTrack = exports.NpmPackagesWeTrack = exports.EventNamesWeTrack = exports.CodedErrorEventName = exports.CommandEventName = void 0;
|
|
32
|
-
const
|
|
32
|
+
const coreOneDS = __importStar(require("@microsoft/1ds-core-js"));
|
|
33
|
+
const _1ds_post_js_1 = require("@microsoft/1ds-post-js");
|
|
33
34
|
const basePropUtils = __importStar(require("./utils/basePropUtils"));
|
|
34
35
|
const versionUtils = __importStar(require("./utils/versionUtils"));
|
|
35
36
|
const errorUtils = __importStar(require("./utils/errorUtils"));
|
|
36
|
-
//
|
|
37
|
-
const
|
|
37
|
+
// 1DS instrumentation key
|
|
38
|
+
const RNW_1DS_INSTRUMENTATION_KEY = '49ff6d3ef12f4578a7b75a2573d9dba8-026332b2-2d50-452f-ad0d-50f921c97a9d-7145';
|
|
38
39
|
// Environment variable to override the default setup string
|
|
39
40
|
const ENV_SETUP_OVERRIDE = 'RNW_TELEMETRY_SETUP';
|
|
40
41
|
// Environment variable to override the http proxy (such as http://localhost:8888 for Fiddler debugging)
|
|
@@ -70,13 +71,13 @@ class Telemetry {
|
|
|
70
71
|
static getDefaultSetupString() {
|
|
71
72
|
var _a;
|
|
72
73
|
// Enable overriding the default setup string via an environment variable
|
|
73
|
-
return (_a = process.env[ENV_SETUP_OVERRIDE]) !== null && _a !== void 0 ? _a :
|
|
74
|
+
return (_a = process.env[ENV_SETUP_OVERRIDE]) !== null && _a !== void 0 ? _a : RNW_1DS_INSTRUMENTATION_KEY;
|
|
74
75
|
}
|
|
75
76
|
static reset() {
|
|
76
77
|
// Reset client
|
|
77
|
-
if (Telemetry.
|
|
78
|
-
Telemetry.
|
|
79
|
-
Telemetry.
|
|
78
|
+
if (Telemetry.appInsightsCore) {
|
|
79
|
+
Telemetry.appInsightsCore.flush();
|
|
80
|
+
Telemetry.appInsightsCore = undefined;
|
|
80
81
|
}
|
|
81
82
|
// Reset local members
|
|
82
83
|
Telemetry.options = {
|
|
@@ -89,140 +90,94 @@ class Telemetry {
|
|
|
89
90
|
Telemetry.projectProp = undefined;
|
|
90
91
|
}
|
|
91
92
|
static isEnabled() {
|
|
92
|
-
return Telemetry.
|
|
93
|
+
return Telemetry.appInsightsCore !== undefined;
|
|
93
94
|
}
|
|
94
95
|
static getSessionId() {
|
|
95
96
|
return basePropUtils.getSessionId();
|
|
96
97
|
}
|
|
97
98
|
/** Sets up the Telemetry static to be used elsewhere. */
|
|
98
99
|
static async setup(options) {
|
|
99
|
-
if (Telemetry.
|
|
100
|
+
if (Telemetry.appInsightsCore) {
|
|
100
101
|
// Bail since we've already setup
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
// Bail if we're in CI and not capturing CI
|
|
104
|
-
if (!
|
|
105
|
+
if (!Telemetry.isTestEnvironment &&
|
|
106
|
+
basePropUtils.isCI() &&
|
|
107
|
+
!basePropUtils.captureCI()) {
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
107
110
|
// Save off options for later
|
|
108
111
|
Object.assign(Telemetry.options, options);
|
|
109
112
|
Telemetry.setupClient();
|
|
110
113
|
await Telemetry.setupBaseProperties();
|
|
111
|
-
Telemetry.setupTelemetryProcessors();
|
|
112
114
|
}
|
|
113
|
-
|
|
115
|
+
static basicTelemetryInitializer(envelope) {
|
|
116
|
+
// Filter out "legacy" events from older stable branches
|
|
117
|
+
if (envelope.name && exports.EventNamesWeTrack.includes(envelope.name)) {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
/** Sets up Telemetry.appInsightsCore. */
|
|
114
123
|
static setupClient() {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
const postChannel = new _1ds_post_js_1.PostChannel();
|
|
125
|
+
const coreConfiguration = {
|
|
126
|
+
instrumentationKey: Telemetry.getDefaultSetupString(),
|
|
127
|
+
};
|
|
128
|
+
const postChannelConfig = {
|
|
129
|
+
eventsLimitInMem: 5000,
|
|
130
|
+
};
|
|
131
|
+
coreConfiguration.extensionConfig = {};
|
|
132
|
+
coreConfiguration.extensionConfig[postChannel.identifier] =
|
|
133
|
+
postChannelConfig;
|
|
134
|
+
// Allow overriding the endpoint URL via an environment variable.
|
|
135
|
+
if (process.env[ENV_PROXY_OVERRIDE] !== undefined) {
|
|
136
|
+
coreConfiguration.endpointUrl = process.env[ENV_PROXY_OVERRIDE];
|
|
123
137
|
}
|
|
124
|
-
Telemetry.
|
|
125
|
-
Telemetry.
|
|
126
|
-
|
|
127
|
-
// So we want to disable it, and despite the method's typing, getStatsbeat() _can_ return undefined
|
|
128
|
-
(_a = Telemetry.client.getStatsbeat()) === null || _a === void 0 ? void 0 : _a.enable(false);
|
|
129
|
-
Telemetry.client.channel.setUseDiskRetryCaching(!Telemetry.isTest);
|
|
138
|
+
Telemetry.appInsightsCore = new coreOneDS.AppInsightsCore();
|
|
139
|
+
Telemetry.appInsightsCore.initialize(coreConfiguration, [postChannel] /* extensions */);
|
|
140
|
+
Telemetry.appInsightsCore.addTelemetryInitializer(Telemetry.basicTelemetryInitializer);
|
|
130
141
|
}
|
|
131
142
|
/** Sets up any base properties that all telemetry events require. */
|
|
132
143
|
static async setupBaseProperties() {
|
|
133
|
-
Telemetry.
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
Telemetry.commonProperties.deviceId = await basePropUtils.deviceId();
|
|
145
|
+
Telemetry.commonProperties.fullBuildInfo =
|
|
146
|
+
await basePropUtils.fullBuildInfo();
|
|
147
|
+
Telemetry.commonProperties.deviceArchitecture =
|
|
136
148
|
basePropUtils.deviceArchitecture();
|
|
137
|
-
Telemetry.
|
|
149
|
+
Telemetry.commonProperties.nodeArchitecture =
|
|
138
150
|
basePropUtils.nodeArchitecture();
|
|
139
|
-
Telemetry.
|
|
140
|
-
|
|
141
|
-
Telemetry.
|
|
151
|
+
Telemetry.commonProperties.nodePlatform = basePropUtils.nodePlatform();
|
|
152
|
+
Telemetry.commonProperties.deviceClass = basePropUtils.deviceClass();
|
|
153
|
+
Telemetry.commonProperties.deviceLocale =
|
|
142
154
|
await basePropUtils.deviceLocale();
|
|
143
|
-
Telemetry.
|
|
155
|
+
Telemetry.commonProperties.deviceNumCPUs = basePropUtils
|
|
144
156
|
.deviceNumCPUs()
|
|
145
157
|
.toString();
|
|
146
|
-
Telemetry.
|
|
158
|
+
Telemetry.commonProperties.deviceTotalMemory = basePropUtils
|
|
147
159
|
.deviceTotalMemory()
|
|
148
160
|
.toString();
|
|
149
|
-
Telemetry.
|
|
161
|
+
Telemetry.commonProperties.deviceDiskFreeSpace = basePropUtils
|
|
150
162
|
.deviceDiskFreeSpace()
|
|
151
163
|
.toString();
|
|
152
|
-
Telemetry.
|
|
164
|
+
Telemetry.commonProperties.ciCaptured = basePropUtils
|
|
153
165
|
.captureCI()
|
|
154
166
|
.toString();
|
|
155
|
-
Telemetry.
|
|
156
|
-
Telemetry.
|
|
167
|
+
Telemetry.commonProperties.ciType = basePropUtils.ciType();
|
|
168
|
+
Telemetry.commonProperties.isMsftInternal = basePropUtils
|
|
157
169
|
.isMsftInternal()
|
|
158
170
|
.toString();
|
|
159
|
-
Telemetry.
|
|
160
|
-
|
|
161
|
-
.toString();
|
|
162
|
-
Telemetry.client.commonProperties.isTest = Telemetry.isTest.toString();
|
|
163
|
-
Telemetry.client.commonProperties.sessionId = Telemetry.getSessionId();
|
|
164
|
-
Telemetry.client.config.samplingPercentage = basePropUtils.sampleRate();
|
|
171
|
+
Telemetry.commonProperties.isTest = Telemetry.isTestEnvironment.toString();
|
|
172
|
+
Telemetry.commonProperties.sessionId = Telemetry.getSessionId();
|
|
165
173
|
await Telemetry.populateToolsVersions();
|
|
166
174
|
if (Telemetry.options.populateNpmPackageVersions) {
|
|
167
175
|
await Telemetry.populateNpmPackageVersions();
|
|
168
176
|
}
|
|
169
177
|
}
|
|
170
|
-
/** Sets up any telemetry processors. */
|
|
171
|
-
static setupTelemetryProcessors() {
|
|
172
|
-
Telemetry.client.addTelemetryProcessor(Telemetry.basicTelemetryProcessor);
|
|
173
|
-
Telemetry.client.addTelemetryProcessor(Telemetry.errorTelemetryProcessor);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Performs the processing necessary (mostly PII sanitization) for all events.
|
|
177
|
-
* @param envelope The ApplicationInsights event envelope.
|
|
178
|
-
* @param _contextObjects An optional context object.
|
|
179
|
-
* @returns Whether to kee
|
|
180
|
-
*/
|
|
181
|
-
static basicTelemetryProcessor(envelope, _contextObjects) {
|
|
182
|
-
var _a;
|
|
183
|
-
delete envelope.tags['ai.cloud.roleInstance'];
|
|
184
|
-
// Filter out "legacy" events from older stable branches
|
|
185
|
-
const properties = (_a = envelope.data.baseData) === null || _a === void 0 ? void 0 : _a.properties;
|
|
186
|
-
if ((properties === null || properties === void 0 ? void 0 : properties.eventName) &&
|
|
187
|
-
exports.EventNamesWeTrack.includes(properties.eventName)) {
|
|
188
|
-
return true;
|
|
189
|
-
}
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Performs the processing necessary (mostly PII sanitization) for error events.
|
|
194
|
-
* @param envelope
|
|
195
|
-
* @param _contextObjects
|
|
196
|
-
* @returns
|
|
197
|
-
*/
|
|
198
|
-
static errorTelemetryProcessor(envelope, _contextObjects) {
|
|
199
|
-
if (envelope.data.baseType === 'ExceptionData') {
|
|
200
|
-
const data = envelope.data.baseData;
|
|
201
|
-
if (data === null || data === void 0 ? void 0 : data.exceptions) {
|
|
202
|
-
for (const exception of data.exceptions) {
|
|
203
|
-
for (const frame of exception.parsedStack) {
|
|
204
|
-
errorUtils.sanitizeErrorStackFrame(frame);
|
|
205
|
-
}
|
|
206
|
-
// Exception message must never be blank, or AI will reject it
|
|
207
|
-
exception.message = exception.message || '[None]';
|
|
208
|
-
// CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.
|
|
209
|
-
// The message may contain PII information. This can be sanitized, but for now delete it.
|
|
210
|
-
// Note that the type of data.exceptions[0] is always going to be ExceptionDetails. It is not the original thrown exception.
|
|
211
|
-
// https://github.com/microsoft/ApplicationInsights-node.js/issues/707
|
|
212
|
-
if (Telemetry.options.preserveErrorMessages) {
|
|
213
|
-
exception.message = errorUtils.sanitizeErrorMessage(exception.message);
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
exception.message = '[Removed]';
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
return true;
|
|
222
|
-
}
|
|
223
178
|
/** Tries to update the version of the named package/tool by calling getValue(). */
|
|
224
179
|
static async tryUpdateVersionsProp(name, getValue, forceRefresh) {
|
|
225
|
-
if (!Telemetry.
|
|
180
|
+
if (!Telemetry.appInsightsCore) {
|
|
226
181
|
return true;
|
|
227
182
|
}
|
|
228
183
|
if (forceRefresh === true || !Telemetry.versionsProp[name]) {
|
|
@@ -255,27 +210,29 @@ class Telemetry {
|
|
|
255
210
|
}
|
|
256
211
|
}
|
|
257
212
|
static setProjectInfo(info) {
|
|
258
|
-
if (!Telemetry.
|
|
213
|
+
if (!Telemetry.appInsightsCore) {
|
|
259
214
|
return;
|
|
260
215
|
}
|
|
261
216
|
Telemetry.projectProp = info;
|
|
262
217
|
}
|
|
263
218
|
static startCommand(info) {
|
|
264
|
-
if (!Telemetry.
|
|
219
|
+
if (!Telemetry.appInsightsCore) {
|
|
265
220
|
return;
|
|
266
221
|
}
|
|
222
|
+
// startCommand() was called before invoking endCommand(), bail out.
|
|
267
223
|
if (Telemetry.commandInfo.startInfo) {
|
|
268
224
|
return;
|
|
269
225
|
}
|
|
270
226
|
Telemetry.commandInfo.startTime = Date.now();
|
|
271
227
|
Telemetry.commandInfo.startInfo = info;
|
|
272
228
|
// Set common command props
|
|
273
|
-
Telemetry.
|
|
229
|
+
Telemetry.commonProperties.commandName = info.commandName;
|
|
274
230
|
}
|
|
275
231
|
static endCommand(info, extraProps) {
|
|
276
|
-
if (!Telemetry.
|
|
232
|
+
if (!Telemetry.appInsightsCore) {
|
|
277
233
|
return;
|
|
278
234
|
}
|
|
235
|
+
// startCommand() wasn't called, bail out.
|
|
279
236
|
if (!Telemetry.commandInfo.startInfo) {
|
|
280
237
|
return;
|
|
281
238
|
}
|
|
@@ -283,13 +240,52 @@ class Telemetry {
|
|
|
283
240
|
Telemetry.commandInfo.endInfo = info;
|
|
284
241
|
Telemetry.trackCommandEvent(extraProps);
|
|
285
242
|
}
|
|
243
|
+
static trackEvent(telemetryItem) {
|
|
244
|
+
// Populate Part A
|
|
245
|
+
telemetryItem.ver = '4.0'; // Current Common Schema version
|
|
246
|
+
telemetryItem.time = new Date().toISOString();
|
|
247
|
+
telemetryItem.iKey = RNW_1DS_INSTRUMENTATION_KEY;
|
|
248
|
+
// Populate Part A extensions
|
|
249
|
+
telemetryItem.ext = {};
|
|
250
|
+
telemetryItem.ext.device = {
|
|
251
|
+
id: Telemetry.commonProperties.deviceId,
|
|
252
|
+
deviceClass: Telemetry.commonProperties.deviceClass,
|
|
253
|
+
};
|
|
254
|
+
telemetryItem.ext.os = {
|
|
255
|
+
locale: Telemetry.commonProperties.deviceLocale,
|
|
256
|
+
ver: Telemetry.commonProperties.fullBuildInfo,
|
|
257
|
+
};
|
|
258
|
+
// Populate most of "common" properties into Part B.
|
|
259
|
+
telemetryItem.baseData = {
|
|
260
|
+
common: {
|
|
261
|
+
device: {
|
|
262
|
+
architecture: Telemetry.commonProperties.deviceArchitecture,
|
|
263
|
+
numCPUs: Telemetry.commonProperties.numCPUs,
|
|
264
|
+
totalMemory: Telemetry.commonProperties.totalMemory,
|
|
265
|
+
diskFreeSpace: Telemetry.commonProperties.deviceDiskFreeSpace,
|
|
266
|
+
},
|
|
267
|
+
nodePlatform: Telemetry.commonProperties.nodePlatform,
|
|
268
|
+
nodeArchitecture: Telemetry.commonProperties.nodeArchitecture,
|
|
269
|
+
ciCaptured: Telemetry.commonProperties.ciCaptured,
|
|
270
|
+
ciType: Telemetry.commonProperties.ciType,
|
|
271
|
+
isMsftInternal: Telemetry.commonProperties.isMsftInternal,
|
|
272
|
+
isCliTest: Telemetry.commonProperties.isTest,
|
|
273
|
+
sessionId: Telemetry.commonProperties.sessionId,
|
|
274
|
+
commandName: Telemetry.commonProperties.commandName,
|
|
275
|
+
},
|
|
276
|
+
// Set project and versions props, belonging to Part B.
|
|
277
|
+
project: Telemetry.projectProp,
|
|
278
|
+
versions: Telemetry.versionsProp,
|
|
279
|
+
};
|
|
280
|
+
// Send and post the telemetry event!
|
|
281
|
+
Telemetry.appInsightsCore.track(telemetryItem);
|
|
282
|
+
Telemetry.appInsightsCore.flush();
|
|
283
|
+
}
|
|
286
284
|
static trackCommandEvent(extraProps) {
|
|
287
285
|
var _a, _b, _c, _d;
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
// Set command props
|
|
292
|
-
props.command = {
|
|
286
|
+
const telemetryItem = { name: exports.CommandEventName };
|
|
287
|
+
// This is logged in Part C.
|
|
288
|
+
const command = {
|
|
293
289
|
options: (_a = Telemetry.commandInfo.startInfo) === null || _a === void 0 ? void 0 : _a.options,
|
|
294
290
|
defaultOptions: (_b = Telemetry.commandInfo.startInfo) === null || _b === void 0 ? void 0 : _b.defaultOptions,
|
|
295
291
|
args: (_c = Telemetry.commandInfo.startInfo) === null || _c === void 0 ? void 0 : _c.args,
|
|
@@ -297,41 +293,38 @@ class Telemetry {
|
|
|
297
293
|
1000,
|
|
298
294
|
resultCode: (_d = Telemetry.commandInfo.endInfo) === null || _d === void 0 ? void 0 : _d.resultCode,
|
|
299
295
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
//
|
|
307
|
-
Telemetry.
|
|
308
|
-
Telemetry.client.flush();
|
|
296
|
+
telemetryItem.data = {
|
|
297
|
+
command: command,
|
|
298
|
+
};
|
|
299
|
+
if (extraProps) {
|
|
300
|
+
telemetryItem.data.additionalData = extraProps;
|
|
301
|
+
}
|
|
302
|
+
// Populate common properties and fire event
|
|
303
|
+
Telemetry.trackEvent(telemetryItem);
|
|
309
304
|
}
|
|
310
305
|
static trackException(error, extraProps) {
|
|
311
306
|
var _a, _b;
|
|
312
|
-
if (!Telemetry.
|
|
307
|
+
if (!Telemetry.appInsightsCore) {
|
|
313
308
|
return;
|
|
314
309
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
};
|
|
318
|
-
// Save off CodedError info
|
|
310
|
+
const telemetryItem = { name: exports.CodedErrorEventName };
|
|
311
|
+
// Save off CodedError info in Part C.
|
|
319
312
|
const codedError = error instanceof errorUtils.CodedError
|
|
320
313
|
? error
|
|
321
314
|
: null;
|
|
322
|
-
|
|
315
|
+
const codedErrorStruct = {
|
|
323
316
|
type: (_a = codedError === null || codedError === void 0 ? void 0 : codedError.type) !== null && _a !== void 0 ? _a : 'Unknown',
|
|
324
317
|
data: (_b = codedError === null || codedError === void 0 ? void 0 : codedError.data) !== null && _b !== void 0 ? _b : {},
|
|
325
318
|
};
|
|
326
319
|
// Copy msBuildErrorMessages into the codedError.data object
|
|
327
320
|
if (error.msBuildErrorMessages) {
|
|
328
321
|
// Always grab MSBuild error codes if possible
|
|
329
|
-
|
|
322
|
+
codedErrorStruct.data.msBuildErrors = error.msBuildErrorMessages
|
|
330
323
|
.map(errorUtils.tryGetErrorCode)
|
|
331
324
|
.filter((msg) => msg);
|
|
332
325
|
// Grab sanitized MSBuild error messages if we're preserving them
|
|
333
326
|
if (Telemetry.options.preserveErrorMessages) {
|
|
334
|
-
|
|
327
|
+
codedErrorStruct.data.msBuildErrorMessages = error.msBuildErrorMessages
|
|
335
328
|
.map(errorUtils.sanitizeErrorMessage)
|
|
336
329
|
.filter((msg) => msg);
|
|
337
330
|
}
|
|
@@ -340,32 +333,73 @@ class Telemetry {
|
|
|
340
333
|
const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];
|
|
341
334
|
for (const f of syscallExceptionFieldsToCopy) {
|
|
342
335
|
if (error[f]) {
|
|
343
|
-
|
|
336
|
+
codedErrorStruct.data.codedError.data[f] = error[f];
|
|
344
337
|
}
|
|
345
338
|
}
|
|
346
|
-
//
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
339
|
+
// Break down TS Error object into Exception Data
|
|
340
|
+
const exceptionData = Telemetry.convertErrorIntoExceptionData(error);
|
|
341
|
+
telemetryItem.data = {
|
|
342
|
+
codedError: codedErrorStruct,
|
|
343
|
+
exceptionData: exceptionData,
|
|
344
|
+
};
|
|
345
|
+
Telemetry.trackEvent(telemetryItem);
|
|
346
|
+
}
|
|
347
|
+
static convertErrorIntoExceptionData(error) {
|
|
348
|
+
var _a;
|
|
349
|
+
const exceptionData = {
|
|
350
|
+
hasFullStack: false,
|
|
351
|
+
message: error.message,
|
|
352
|
+
parsedStack: {},
|
|
353
|
+
};
|
|
354
|
+
exceptionData.message = exceptionData.message || '[None]';
|
|
355
|
+
// CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.
|
|
356
|
+
// The message may contain PII information. This can be sanitized, but for now delete it.
|
|
357
|
+
if (Telemetry.options.preserveErrorMessages) {
|
|
358
|
+
exceptionData.message = errorUtils.sanitizeErrorMessage(exceptionData.message);
|
|
359
|
+
}
|
|
360
|
+
else {
|
|
361
|
+
exceptionData.message = '[Removed]';
|
|
362
|
+
}
|
|
363
|
+
const lines = (_a = error.stack) === null || _a === void 0 ? void 0 : _a.split('\n');
|
|
364
|
+
const parsedStack = lines === null || lines === void 0 ? void 0 : lines.slice(1).map(line => {
|
|
365
|
+
const errorStackFrame = {};
|
|
366
|
+
const match = line
|
|
367
|
+
.trim()
|
|
368
|
+
.match(/^\s*at\s+(?:(.*?)\s+\((.*):(\d+):(\d+)\)|(.*):(\d+):(\d+))$/);
|
|
369
|
+
if (match) {
|
|
370
|
+
errorStackFrame.functionName = match[1] || 'N/A'; // Use a default value if no function name
|
|
371
|
+
errorStackFrame.filePath = match[2] || match[5];
|
|
372
|
+
errorStackFrame.lineNumber =
|
|
373
|
+
parseInt(match[3], 10) || parseInt(match[6], 10);
|
|
374
|
+
errorStackFrame.columnNumber =
|
|
375
|
+
parseInt(match[4], 10) || parseInt(match[7], 10);
|
|
376
|
+
}
|
|
377
|
+
return errorStackFrame;
|
|
356
378
|
});
|
|
357
|
-
|
|
379
|
+
if (parsedStack) {
|
|
380
|
+
parsedStack.filter(Boolean);
|
|
381
|
+
// Sanitize parsed error stack frames
|
|
382
|
+
for (const frame of parsedStack) {
|
|
383
|
+
errorUtils.sanitizeErrorStackFrame(frame);
|
|
384
|
+
}
|
|
385
|
+
exceptionData.hasFullStack = true;
|
|
386
|
+
exceptionData.parsedStack = parsedStack;
|
|
387
|
+
}
|
|
388
|
+
return exceptionData;
|
|
358
389
|
}
|
|
359
390
|
}
|
|
360
|
-
Telemetry.
|
|
391
|
+
Telemetry.appInsightsCore = undefined;
|
|
361
392
|
Telemetry.options = {
|
|
362
393
|
setupString: Telemetry.getDefaultSetupString(),
|
|
363
394
|
preserveErrorMessages: false,
|
|
364
395
|
populateNpmPackageVersions: true,
|
|
365
396
|
};
|
|
366
|
-
Telemetry.
|
|
397
|
+
Telemetry.isTestEnvironment = basePropUtils.isCliTest();
|
|
367
398
|
Telemetry.commandInfo = {};
|
|
399
|
+
// Stores the version of a list of packages used by the RNW app project.
|
|
368
400
|
Telemetry.versionsProp = {};
|
|
369
401
|
Telemetry.projectProp = undefined;
|
|
402
|
+
// Store "Common Properties" in a single object. This will be logged in all telemetry events.
|
|
403
|
+
Telemetry.commonProperties = {};
|
|
370
404
|
exports.Telemetry = Telemetry;
|
|
371
405
|
//# sourceMappingURL=telemetry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,iEAAmD;AAEnD,qEAAuD;AACvD,mEAAqD;AACrD,+DAAiD;AA2BjD,sCAAsC;AACtC,MAAM,cAAc,GAAG,sCAAsC,CAAC;AAE9D,4DAA4D;AAC5D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD,wGAAwG;AACxG,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEpC,QAAA,gBAAgB,GAAG,gBAAgB,CAAC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xC,8BAAS","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\n\nimport * as basePropUtils from './utils/basePropUtils';\nimport * as versionUtils from './utils/versionUtils';\nimport * as errorUtils from './utils/errorUtils';\nimport * as projectUtils from './utils/projectUtils';\n\nexport interface TelemetryOptions {\n setupString: string;\n preserveErrorMessages: boolean;\n populateNpmPackageVersions: boolean;\n}\n\nexport interface CommandStartInfo {\n commandName: string;\n args: Record<string, any>;\n options: Record<string, any>;\n defaultOptions: Record<string, any>;\n}\n\nexport interface CommandEndInfo {\n resultCode: errorUtils.CodedErrorType;\n}\n\ninterface CommandInfo {\n startTime?: number;\n endTime?: number;\n startInfo?: CommandStartInfo;\n endInfo?: CommandEndInfo;\n}\n\n// This is our key with the AI backend\nconst RNWSetupString = '795006ca-cf54-40ee-8bc6-03deb91401c3';\n\n// Environment variable to override the default setup string\nconst ENV_SETUP_OVERRIDE = 'RNW_TELEMETRY_SETUP';\n\n// Environment variable to override the http proxy (such as http://localhost:8888 for Fiddler debugging)\nconst ENV_PROXY_OVERRIDE = 'RNW_TELEMETRY_PROXY';\n\nexport const CommandEventName = 'RNWCLI.Command';\nexport const CodedErrorEventName = 'RNWCLI.CodedError';\n\n// These are the event names we're tracking\nexport const EventNamesWeTrack: string[] = [\n CommandEventName,\n CodedErrorEventName,\n];\n\n// These are NPM packages we care about, in terms of capturing versions used\n// and getting more details about when reporting errors\nexport const NpmPackagesWeTrack: string[] = [\n '@react-native-community/cli',\n '@react-native-windows/cli',\n '@react-native-windows/telemetry',\n 'react',\n 'react-native',\n 'react-native-windows',\n 'react-native-windows-init',\n];\n\n// These are NPM packages we care about, in terms of capturing versions used\nexport const NuGetPackagesWeTrack: string[] = [\n 'Microsoft.UI.Xaml',\n 'Microsoft.Windows.CppWinRT',\n 'Microsoft.WinUI',\n];\n\n/**\n * The Telemetry class is responsible for reporting telemetry for RNW CLI.\n */\nexport class Telemetry {\n protected static client?: appInsights.TelemetryClient = undefined;\n protected static options: TelemetryOptions = {\n setupString: Telemetry.getDefaultSetupString(), // We default to our AI key, but callers can easily override it in setup\n preserveErrorMessages: false,\n populateNpmPackageVersions: true,\n };\n\n protected static isTest: boolean = basePropUtils.isCliTest();\n protected static commandInfo: CommandInfo = {};\n protected static versionsProp: Record<string, string> = {};\n protected static projectProp?:\n | projectUtils.AppProjectInfo\n | projectUtils.DependencyProjectInfo = undefined;\n\n protected static getDefaultSetupString(): string {\n // Enable overriding the default setup string via an environment variable\n return process.env[ENV_SETUP_OVERRIDE] ?? RNWSetupString;\n }\n\n protected static reset(): void {\n // Reset client\n if (Telemetry.client) {\n Telemetry.client.flush();\n Telemetry.client = undefined;\n }\n\n // Reset local members\n Telemetry.options = {\n setupString: Telemetry.getDefaultSetupString(),\n preserveErrorMessages: false,\n populateNpmPackageVersions: true,\n };\n Telemetry.commandInfo = {};\n Telemetry.versionsProp = {};\n Telemetry.projectProp = undefined;\n }\n\n static isEnabled(): boolean {\n return Telemetry.client !== undefined;\n }\n\n static getSessionId(): string {\n return basePropUtils.getSessionId();\n }\n\n /** Sets up the Telemetry static to be used elsewhere. */\n static async setup(options?: Partial<TelemetryOptions>) {\n if (Telemetry.client) {\n // Bail since we've already setup\n return;\n }\n\n // Bail if we're in CI and not capturing CI\n if (!this.isTest && basePropUtils.isCI() && !basePropUtils.captureCI()) {\n return;\n }\n\n // Save off options for later\n Object.assign(Telemetry.options, options);\n\n Telemetry.setupClient();\n\n await Telemetry.setupBaseProperties();\n\n Telemetry.setupTelemetryProcessors();\n }\n\n /** Sets up Telemetry.client. */\n private static setupClient() {\n appInsights.Configuration.setInternalLogging(false, false);\n\n Telemetry.client = new appInsights.TelemetryClient(\n Telemetry.options.setupString,\n );\n\n // Allow overriding the proxy server via an environment variable\n const proxyServer = process.env[ENV_PROXY_OVERRIDE];\n if (proxyServer) {\n Telemetry.client.config.proxyHttpUrl = proxyServer;\n Telemetry.client.config.proxyHttpsUrl = proxyServer;\n }\n\n Telemetry.client.config.disableAppInsights = Telemetry.isTest;\n Telemetry.client.config.disableStatsbeat = true;\n\n // Despite trying to disable the statsbeat, it might still be running: https://github.com/microsoft/ApplicationInsights-node.js/issues/943\n // So we want to disable it, and despite the method's typing, getStatsbeat() _can_ return undefined\n\n Telemetry.client.getStatsbeat()?.enable(false);\n\n Telemetry.client.channel.setUseDiskRetryCaching(!Telemetry.isTest);\n }\n\n /** Sets up any base properties that all telemetry events require. */\n private static async setupBaseProperties() {\n Telemetry.client!.commonProperties.deviceId =\n await basePropUtils.deviceId();\n Telemetry.client!.commonProperties.deviceArchitecture =\n basePropUtils.deviceArchitecture();\n Telemetry.client!.commonProperties.nodeArchitecture =\n basePropUtils.nodeArchitecture();\n Telemetry.client!.commonProperties.devicePlatform =\n basePropUtils.devicePlatform();\n Telemetry.client!.commonProperties.deviceLocale =\n await basePropUtils.deviceLocale();\n Telemetry.client!.commonProperties.deviceNumCPUs = basePropUtils\n .deviceNumCPUs()\n .toString();\n Telemetry.client!.commonProperties.deviceTotalMemory = basePropUtils\n .deviceTotalMemory()\n .toString();\n Telemetry.client!.commonProperties.deviceDiskFreeSpace = basePropUtils\n .deviceDiskFreeSpace()\n .toString();\n Telemetry.client!.commonProperties.ciCaptured = basePropUtils\n .captureCI()\n .toString();\n Telemetry.client!.commonProperties.ciType = basePropUtils.ciType();\n Telemetry.client!.commonProperties.isMsftInternal = basePropUtils\n .isMsftInternal()\n .toString();\n Telemetry.client!.commonProperties.sampleRate = basePropUtils\n .sampleRate()\n .toString();\n Telemetry.client!.commonProperties.isTest = Telemetry.isTest.toString();\n Telemetry.client!.commonProperties.sessionId = Telemetry.getSessionId();\n\n Telemetry.client!.config.samplingPercentage = basePropUtils.sampleRate();\n\n await Telemetry.populateToolsVersions();\n if (Telemetry.options.populateNpmPackageVersions) {\n await Telemetry.populateNpmPackageVersions();\n }\n }\n\n /** Sets up any telemetry processors. */\n private static setupTelemetryProcessors() {\n Telemetry.client!.addTelemetryProcessor(Telemetry.basicTelemetryProcessor);\n Telemetry.client!.addTelemetryProcessor(Telemetry.errorTelemetryProcessor);\n }\n\n /**\n * Performs the processing necessary (mostly PII sanitization) for all events.\n * @param envelope The ApplicationInsights event envelope.\n * @param _contextObjects An optional context object.\n * @returns Whether to kee\n */\n private static basicTelemetryProcessor(\n envelope: appInsights.Contracts.EnvelopeTelemetry,\n _contextObjects?: {\n [name: string]: any;\n },\n ): boolean {\n delete envelope.tags['ai.cloud.roleInstance'];\n\n // Filter out \"legacy\" events from older stable branches\n const properties = envelope.data.baseData?.properties;\n if (\n properties?.eventName &&\n EventNamesWeTrack.includes(properties.eventName)\n ) {\n return true;\n }\n\n return false;\n }\n\n /**\n * Performs the processing necessary (mostly PII sanitization) for error events.\n * @param envelope\n * @param _contextObjects\n * @returns\n */\n private static errorTelemetryProcessor(\n envelope: appInsights.Contracts.EnvelopeTelemetry,\n _contextObjects?: {\n [name: string]: any;\n },\n ): boolean {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = envelope.data.baseData;\n if (data?.exceptions) {\n for (const exception of data.exceptions) {\n for (const frame of exception.parsedStack) {\n errorUtils.sanitizeErrorStackFrame(frame);\n }\n\n // Exception message must never be blank, or AI will reject it\n exception.message = exception.message || '[None]';\n\n // CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.\n // The message may contain PII information. This can be sanitized, but for now delete it.\n // Note that the type of data.exceptions[0] is always going to be ExceptionDetails. It is not the original thrown exception.\n // https://github.com/microsoft/ApplicationInsights-node.js/issues/707\n if (Telemetry.options.preserveErrorMessages) {\n exception.message = errorUtils.sanitizeErrorMessage(\n exception.message,\n );\n } else {\n exception.message = '[Removed]';\n }\n }\n }\n }\n return true;\n }\n\n /** Tries to update the version of the named package/tool by calling getValue(). */\n static async tryUpdateVersionsProp(\n name: string,\n getValue: () => Promise<string | null>,\n forceRefresh?: boolean,\n ): Promise<boolean> {\n if (!Telemetry.client) {\n return true;\n }\n\n if (forceRefresh === true || !Telemetry.versionsProp[name]) {\n const value = await getValue();\n if (value) {\n Telemetry.versionsProp[name] = value;\n return true;\n }\n }\n return false;\n }\n\n /** Populates the versions property of tools we care to track. */\n static async populateToolsVersions(refresh?: boolean) {\n await Telemetry.tryUpdateVersionsProp(\n 'node',\n versionUtils.getNodeVersion,\n refresh,\n );\n await Telemetry.tryUpdateVersionsProp(\n 'npm',\n versionUtils.getNpmVersion,\n refresh,\n );\n await Telemetry.tryUpdateVersionsProp(\n 'yarn',\n versionUtils.getYarnVersion,\n refresh,\n );\n await Telemetry.tryUpdateVersionsProp(\n 'VisualStudio',\n versionUtils.getVisualStudioVersion,\n refresh,\n );\n }\n\n /** Populates the versions property of npm packages we care to track. */\n static async populateNpmPackageVersions(refresh?: boolean) {\n for (const npmPackage of NpmPackagesWeTrack) {\n await Telemetry.tryUpdateVersionsProp(\n npmPackage,\n async () => await versionUtils.getVersionOfNpmPackage(npmPackage),\n refresh,\n );\n }\n }\n\n /** Populates the versions property of nuget packages we care to track. */\n static async populateNuGetPackageVersions(\n projectFile: string,\n refresh?: boolean,\n ) {\n const nugetVersions = await versionUtils.getVersionsOfNuGetPackages(\n projectFile,\n NuGetPackagesWeTrack,\n );\n\n for (const nugetPackage of NuGetPackagesWeTrack) {\n await Telemetry.tryUpdateVersionsProp(\n nugetPackage,\n async () => nugetVersions[nugetPackage],\n refresh,\n );\n }\n }\n\n static setProjectInfo(\n info: projectUtils.AppProjectInfo | projectUtils.DependencyProjectInfo,\n ) {\n if (!Telemetry.client) {\n return;\n }\n\n Telemetry.projectProp = info;\n }\n\n static startCommand(info: CommandStartInfo) {\n if (!Telemetry.client) {\n return;\n }\n\n if (Telemetry.commandInfo.startInfo) {\n return;\n }\n\n Telemetry.commandInfo.startTime = Date.now();\n Telemetry.commandInfo.startInfo = info;\n\n // Set common command props\n Telemetry.client!.commonProperties.commandName = info.commandName;\n }\n\n static endCommand(info: CommandEndInfo, extraProps?: Record<string, any>) {\n if (!Telemetry.client) {\n return;\n }\n\n if (!Telemetry.commandInfo.startInfo) {\n return;\n }\n\n Telemetry.commandInfo.endTime = Date.now();\n Telemetry.commandInfo.endInfo = info;\n\n Telemetry.trackCommandEvent(extraProps);\n }\n\n private static trackCommandEvent(extraProps?: Record<string, any>) {\n const props: Record<string, any> = {\n eventName: CommandEventName,\n };\n\n // Set command props\n props.command = {\n options: Telemetry.commandInfo.startInfo?.options,\n defaultOptions: Telemetry.commandInfo.startInfo?.defaultOptions,\n args: Telemetry.commandInfo.startInfo?.args,\n durationInSecs:\n (Telemetry.commandInfo.endTime! - Telemetry.commandInfo.startTime!) /\n 1000,\n resultCode: Telemetry.commandInfo.endInfo?.resultCode,\n };\n\n // Set remaining common props\n props.project = Telemetry.projectProp;\n props.versions = Telemetry.versionsProp;\n\n // Set extra props\n props.extraProps = {};\n Object.assign(props.extraProps, extraProps);\n\n // Fire event\n Telemetry.client!.trackEvent({name: props.eventName, properties: props});\n Telemetry.client!.flush();\n }\n\n static trackException(error: Error, extraProps?: Record<string, any>) {\n if (!Telemetry.client) {\n return;\n }\n\n const props: Record<string, any> = {\n eventName: CodedErrorEventName,\n };\n\n // Save off CodedError info\n const codedError =\n error instanceof errorUtils.CodedError\n ? (error as errorUtils.CodedError)\n : null;\n props.codedError = {\n type: codedError?.type ?? 'Unknown',\n data: codedError?.data ?? {},\n };\n\n // Copy msBuildErrorMessages into the codedError.data object\n if ((error as any).msBuildErrorMessages) {\n // Always grab MSBuild error codes if possible\n props.codedError.data.msBuildErrors = (error as any).msBuildErrorMessages\n .map(errorUtils.tryGetErrorCode)\n .filter((msg: string | undefined) => msg);\n\n // Grab sanitized MSBuild error messages if we're preserving them\n if (Telemetry.options.preserveErrorMessages) {\n props.codedError.data.msBuildErrorMessages = (\n error as any\n ).msBuildErrorMessages\n .map(errorUtils.sanitizeErrorMessage)\n .filter((msg: string) => msg);\n }\n }\n\n // Copy miscellaneous system error fields into the codedError.data object\n const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];\n for (const f of syscallExceptionFieldsToCopy) {\n if ((error as any)[f]) {\n props.codedError.data[f] = (error as any)[f];\n }\n }\n\n // Set remaining common props\n props.project = Telemetry.projectProp;\n props.versions = Telemetry.versionsProp;\n\n // Set extra props\n props.extraProps = {};\n Object.assign(props.extraProps, extraProps);\n\n // Fire event\n Telemetry.client!.trackException({\n exception: error,\n properties: props,\n });\n Telemetry.client!.flush();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAoD;AACpD,yDAA0E;AAE1E,qEAAuD;AACvD,mEAAqD;AACrD,+DAAiD;AA2BjD,0BAA0B;AAC1B,MAAM,2BAA2B,GAC/B,4EAA4E,CAAC;AAE/E,4DAA4D;AAC5D,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEjD,wGAAwG;AACxG,MAAM,kBAAkB,GAAG,qBAAqB,CAAC;AAEpC,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AACpC,QAAA,mBAAmB,GAAG,mBAAmB,CAAC;AAEvD,2CAA2C;AAC9B,QAAA,iBAAiB,GAAa;IACzC,wBAAgB;IAChB,2BAAmB;CACpB,CAAC;AAEF,4EAA4E;AAC5E,uDAAuD;AAC1C,QAAA,kBAAkB,GAAa;IAC1C,6BAA6B;IAC7B,2BAA2B;IAC3B,iCAAiC;IACjC,OAAO;IACP,cAAc;IACd,sBAAsB;IACtB,2BAA2B;CAC5B,CAAC;AAEF,4EAA4E;AAC/D,QAAA,oBAAoB,GAAa;IAC5C,mBAAmB;IACnB,4BAA4B;IAC5B,iBAAiB;CAClB,CAAC;AAEF;;GAEG;AACH,MAAa,SAAS;IAuBV,MAAM,CAAC,qBAAqB;;QACpC,yEAAyE;QACzE,OAAO,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,mCAAI,2BAA2B,CAAC;IACxE,CAAC;I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AE,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;aACpD;YAED,OAAO,eAAe,CAAC;QACzB,CAAC,CAAC,CAAC;QAEH,IAAI,WAAW,EAAE;YACf,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAE5B,qCAAqC;YACrC,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE;gBAC/B,UAAU,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC;aAC3C;YAED,aAAa,CAAC,YAAY,GAAG,IAAI,CAAC;YAClC,aAAa,CAAC,WAAW,GAAG,WAAW,CAAC;SACzC;QAED,OAAO,aAAa,CAAC;IACvB,CAAC;;AApcgB,yBAAe,GAA+B,SAAS,CAAC;AAExD,iBAAO,GAAqB;IAC3C,WAAW,EAAE,SAAS,CAAC,qBAAqB,EAAE;IAC9C,qBAAqB,EAAE,KAAK;IAC5B,0BAA0B,EAAE,IAAI;CACjC,CAAC;AAEe,2BAAiB,GAAY,aAAa,CAAC,SAAS,EAAE,CAAC;AAEvD,qBAAW,GAAgB,EAAE,CAAC;AAE/C,wEAAwE;AACvD,sBAAY,GAA2B,EAAE,CAAC;AAE1C,qBAAW,GAEa,SAAS,CAAC;AAEnD,6FAA6F;AAC5E,0BAAgB,GAA4B,EAAE,CAAC;AArBrD,8BAAS","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport * as coreOneDS from '@microsoft/1ds-core-js';\nimport {PostChannel, IChannelConfiguration} from '@microsoft/1ds-post-js';\n\nimport * as basePropUtils from './utils/basePropUtils';\nimport * as versionUtils from './utils/versionUtils';\nimport * as errorUtils from './utils/errorUtils';\nimport * as projectUtils from './utils/projectUtils';\n\nexport interface TelemetryOptions {\n setupString: string;\n preserveErrorMessages: boolean;\n populateNpmPackageVersions: boolean;\n}\n\nexport interface CommandStartInfo {\n commandName: string;\n args: Record<string, any>;\n options: Record<string, any>;\n defaultOptions: Record<string, any>;\n}\n\nexport interface CommandEndInfo {\n resultCode: errorUtils.CodedErrorType;\n}\n\ninterface CommandInfo {\n startTime?: number;\n endTime?: number;\n startInfo?: CommandStartInfo;\n endInfo?: CommandEndInfo;\n}\n\n// 1DS instrumentation key\nconst RNW_1DS_INSTRUMENTATION_KEY =\n '49ff6d3ef12f4578a7b75a2573d9dba8-026332b2-2d50-452f-ad0d-50f921c97a9d-7145';\n\n// Environment variable to override the default setup string\nconst ENV_SETUP_OVERRIDE = 'RNW_TELEMETRY_SETUP';\n\n// Environment variable to override the http proxy (such as http://localhost:8888 for Fiddler debugging)\nconst ENV_PROXY_OVERRIDE = 'RNW_TELEMETRY_PROXY';\n\nexport const CommandEventName = 'RNWCLI.Command';\nexport const CodedErrorEventName = 'RNWCLI.CodedError';\n\n// These are the event names we're tracking\nexport const EventNamesWeTrack: string[] = [\n CommandEventName,\n CodedErrorEventName,\n];\n\n// These are NPM packages we care about, in terms of capturing versions used\n// and getting more details about when reporting errors\nexport const NpmPackagesWeTrack: string[] = [\n '@react-native-community/cli',\n '@react-native-windows/cli',\n '@react-native-windows/telemetry',\n 'react',\n 'react-native',\n 'react-native-windows',\n 'react-native-windows-init',\n];\n\n// These are NPM packages we care about, in terms of capturing versions used\nexport const NuGetPackagesWeTrack: string[] = [\n 'Microsoft.UI.Xaml',\n 'Microsoft.Windows.CppWinRT',\n 'Microsoft.WinUI',\n];\n\n/**\n * The Telemetry class is responsible for reporting telemetry for RNW CLI.\n */\nexport class Telemetry {\n protected static appInsightsCore?: coreOneDS.AppInsightsCore = undefined;\n\n protected static options: TelemetryOptions = {\n setupString: Telemetry.getDefaultSetupString(), // We default to our 1DS instrumentation key, but callers can easily override it in setup.\n preserveErrorMessages: false,\n populateNpmPackageVersions: true,\n };\n\n protected static isTestEnvironment: boolean = basePropUtils.isCliTest();\n\n protected static commandInfo: CommandInfo = {};\n\n // Stores the version of a list of packages used by the RNW app project.\n protected static versionsProp: Record<string, string> = {};\n\n protected static projectProp?:\n | projectUtils.AppProjectInfo\n | projectUtils.DependencyProjectInfo = undefined;\n\n // Store \"Common Properties\" in a single object. This will be logged in all telemetry events.\n protected static commonProperties: {[key: string]: string} = {};\n\n protected static getDefaultSetupString(): string {\n // Enable overriding the default setup string via an environment variable\n return process.env[ENV_SETUP_OVERRIDE] ?? RNW_1DS_INSTRUMENTATION_KEY;\n }\n\n protected static reset(): void {\n // Reset client\n if (Telemetry.appInsightsCore) {\n Telemetry.appInsightsCore.flush();\n Telemetry.appInsightsCore = undefined;\n }\n\n // Reset local members\n Telemetry.options = {\n setupString: Telemetry.getDefaultSetupString(),\n preserveErrorMessages: false,\n populateNpmPackageVersions: true,\n };\n Telemetry.commandInfo = {};\n Telemetry.versionsProp = {};\n Telemetry.projectProp = undefined;\n }\n\n static isEnabled(): boolean {\n return Telemetry.appInsightsCore !== undefined;\n }\n\n static getSessionId(): string {\n return basePropUtils.getSessionId();\n }\n\n /** Sets up the Telemetry static to be used elsewhere. */\n static async setup(options?: Partial<TelemetryOptions>) {\n if (Telemetry.appInsightsCore) {\n // Bail since we've already setup\n return;\n }\n\n // Bail if we're in CI and not capturing CI\n if (\n !Telemetry.isTestEnvironment &&\n basePropUtils.isCI() &&\n !basePropUtils.captureCI()\n ) {\n return;\n }\n\n // Save off options for later\n Object.assign(Telemetry.options, options);\n\n Telemetry.setupClient();\n\n await Telemetry.setupBaseProperties();\n }\n\n private static basicTelemetryInitializer(\n envelope: coreOneDS.ITelemetryItem,\n ): boolean {\n // Filter out \"legacy\" events from older stable branches\n if (envelope.name && EventNamesWeTrack.includes(envelope.name)) {\n return true;\n }\n\n return false;\n }\n\n /** Sets up Telemetry.appInsightsCore. */\n private static setupClient() {\n const postChannel: PostChannel = new PostChannel();\n\n const coreConfiguration: coreOneDS.IExtendedConfiguration = {\n instrumentationKey: Telemetry.getDefaultSetupString(),\n };\n\n const postChannelConfig: IChannelConfiguration = {\n eventsLimitInMem: 5000,\n };\n\n coreConfiguration.extensionConfig = {};\n coreConfiguration.extensionConfig[postChannel.identifier] =\n postChannelConfig;\n\n // Allow overriding the endpoint URL via an environment variable.\n if (process.env[ENV_PROXY_OVERRIDE] !== undefined) {\n coreConfiguration.endpointUrl = process.env[ENV_PROXY_OVERRIDE];\n }\n\n Telemetry.appInsightsCore = new coreOneDS.AppInsightsCore();\n Telemetry.appInsightsCore.initialize(\n coreConfiguration,\n [postChannel] /* extensions */,\n );\n\n Telemetry.appInsightsCore.addTelemetryInitializer(\n Telemetry.basicTelemetryInitializer,\n );\n }\n\n /** Sets up any base properties that all telemetry events require. */\n private static async setupBaseProperties() {\n Telemetry.commonProperties.deviceId = await basePropUtils.deviceId();\n Telemetry.commonProperties.fullBuildInfo =\n await basePropUtils.fullBuildInfo();\n Telemetry.commonProperties.deviceArchitecture =\n basePropUtils.deviceArchitecture();\n Telemetry.commonProperties.nodeArchitecture =\n basePropUtils.nodeArchitecture();\n Telemetry.commonProperties.nodePlatform = basePropUtils.nodePlatform();\n Telemetry.commonProperties.deviceClass = basePropUtils.deviceClass();\n Telemetry.commonProperties.deviceLocale =\n await basePropUtils.deviceLocale();\n Telemetry.commonProperties.deviceNumCPUs = basePropUtils\n .deviceNumCPUs()\n .toString();\n Telemetry.commonProperties.deviceTotalMemory = basePropUtils\n .deviceTotalMemory()\n .toString();\n Telemetry.commonProperties.deviceDiskFreeSpace = basePropUtils\n .deviceDiskFreeSpace()\n .toString();\n Telemetry.commonProperties.ciCaptured = basePropUtils\n .captureCI()\n .toString();\n Telemetry.commonProperties.ciType = basePropUtils.ciType();\n Telemetry.commonProperties.isMsftInternal = basePropUtils\n .isMsftInternal()\n .toString();\n Telemetry.commonProperties.isTest = Telemetry.isTestEnvironment.toString();\n Telemetry.commonProperties.sessionId = Telemetry.getSessionId();\n\n await Telemetry.populateToolsVersions();\n if (Telemetry.options.populateNpmPackageVersions) {\n await Telemetry.populateNpmPackageVersions();\n }\n }\n\n /** Tries to update the version of the named package/tool by calling getValue(). */\n static async tryUpdateVersionsProp(\n name: string,\n getValue: () => Promise<string | null>,\n forceRefresh?: boolean,\n ): Promise<boolean> {\n if (!Telemetry.appInsightsCore) {\n return true;\n }\n\n if (forceRefresh === true || !Telemetry.versionsProp[name]) {\n const value = await getValue();\n if (value) {\n Telemetry.versionsProp[name] = value;\n return true;\n }\n }\n return false;\n }\n\n /** Populates the versions property of tools we care to track. */\n static async populateToolsVersions(refresh?: boolean) {\n await Telemetry.tryUpdateVersionsProp(\n 'node',\n versionUtils.getNodeVersion,\n refresh,\n );\n await Telemetry.tryUpdateVersionsProp(\n 'npm',\n versionUtils.getNpmVersion,\n refresh,\n );\n await Telemetry.tryUpdateVersionsProp(\n 'yarn',\n versionUtils.getYarnVersion,\n refresh,\n );\n await Telemetry.tryUpdateVersionsProp(\n 'VisualStudio',\n versionUtils.getVisualStudioVersion,\n refresh,\n );\n }\n\n /** Populates the versions property of npm packages we care to track. */\n static async populateNpmPackageVersions(refresh?: boolean) {\n for (const npmPackage of NpmPackagesWeTrack) {\n await Telemetry.tryUpdateVersionsProp(\n npmPackage,\n async () => await versionUtils.getVersionOfNpmPackage(npmPackage),\n refresh,\n );\n }\n }\n\n /** Populates the versions property of nuget packages we care to track. */\n static async populateNuGetPackageVersions(\n projectFile: string,\n refresh?: boolean,\n ) {\n const nugetVersions = await versionUtils.getVersionsOfNuGetPackages(\n projectFile,\n NuGetPackagesWeTrack,\n );\n\n for (const nugetPackage of NuGetPackagesWeTrack) {\n await Telemetry.tryUpdateVersionsProp(\n nugetPackage,\n async () => nugetVersions[nugetPackage],\n refresh,\n );\n }\n }\n\n static setProjectInfo(\n info: projectUtils.AppProjectInfo | projectUtils.DependencyProjectInfo,\n ) {\n if (!Telemetry.appInsightsCore) {\n return;\n }\n\n Telemetry.projectProp = info;\n }\n\n static startCommand(info: CommandStartInfo) {\n if (!Telemetry.appInsightsCore) {\n return;\n }\n\n // startCommand() was called before invoking endCommand(), bail out.\n if (Telemetry.commandInfo.startInfo) {\n return;\n }\n\n Telemetry.commandInfo.startTime = Date.now();\n Telemetry.commandInfo.startInfo = info;\n\n // Set common command props\n Telemetry.commonProperties.commandName = info.commandName;\n }\n\n static endCommand(info: CommandEndInfo, extraProps?: Record<string, any>) {\n if (!Telemetry.appInsightsCore) {\n return;\n }\n\n // startCommand() wasn't called, bail out.\n if (!Telemetry.commandInfo.startInfo) {\n return;\n }\n\n Telemetry.commandInfo.endTime = Date.now();\n Telemetry.commandInfo.endInfo = info;\n\n Telemetry.trackCommandEvent(extraProps);\n }\n\n private static trackEvent(telemetryItem: coreOneDS.ITelemetryItem) {\n // Populate Part A\n telemetryItem.ver = '4.0'; // Current Common Schema version\n telemetryItem.time = new Date().toISOString();\n telemetryItem.iKey = RNW_1DS_INSTRUMENTATION_KEY;\n\n // Populate Part A extensions\n telemetryItem.ext = {};\n telemetryItem.ext.device = {\n id: Telemetry.commonProperties.deviceId,\n deviceClass: Telemetry.commonProperties.deviceClass,\n };\n telemetryItem.ext.os = {\n locale: Telemetry.commonProperties.deviceLocale,\n ver: Telemetry.commonProperties.fullBuildInfo,\n };\n\n // Populate most of \"common\" properties into Part B.\n telemetryItem.baseData = {\n common: {\n device: {\n architecture: Telemetry.commonProperties.deviceArchitecture,\n numCPUs: Telemetry.commonProperties.numCPUs,\n totalMemory: Telemetry.commonProperties.totalMemory,\n diskFreeSpace: Telemetry.commonProperties.deviceDiskFreeSpace,\n },\n nodePlatform: Telemetry.commonProperties.nodePlatform,\n nodeArchitecture: Telemetry.commonProperties.nodeArchitecture,\n ciCaptured: Telemetry.commonProperties.ciCaptured,\n ciType: Telemetry.commonProperties.ciType,\n isMsftInternal: Telemetry.commonProperties.isMsftInternal,\n isCliTest: Telemetry.commonProperties.isTest,\n sessionId: Telemetry.commonProperties.sessionId,\n commandName: Telemetry.commonProperties.commandName,\n },\n // Set project and versions props, belonging to Part B.\n project: Telemetry.projectProp,\n versions: Telemetry.versionsProp,\n };\n\n // Send and post the telemetry event!\n Telemetry.appInsightsCore!.track(telemetryItem);\n Telemetry.appInsightsCore!.flush();\n }\n\n private static trackCommandEvent(extraProps?: Record<string, any>) {\n const telemetryItem: coreOneDS.ITelemetryItem = {name: CommandEventName};\n\n // This is logged in Part C.\n const command = {\n options: Telemetry.commandInfo.startInfo?.options,\n defaultOptions: Telemetry.commandInfo.startInfo?.defaultOptions,\n args: Telemetry.commandInfo.startInfo?.args,\n durationInSecs:\n (Telemetry.commandInfo.endTime! - Telemetry.commandInfo.startTime!) /\n 1000,\n resultCode: Telemetry.commandInfo.endInfo?.resultCode,\n };\n\n telemetryItem.data = {\n command: command,\n };\n\n if (extraProps) {\n telemetryItem.data.additionalData = extraProps;\n }\n\n // Populate common properties and fire event\n Telemetry.trackEvent(telemetryItem);\n }\n\n static trackException(error: Error, extraProps?: Record<string, any>) {\n if (!Telemetry.appInsightsCore) {\n return;\n }\n\n const telemetryItem: coreOneDS.ITelemetryItem = {name: CodedErrorEventName};\n\n // Save off CodedError info in Part C.\n const codedError =\n error instanceof errorUtils.CodedError\n ? (error as errorUtils.CodedError)\n : null;\n\n const codedErrorStruct = {\n type: codedError?.type ?? 'Unknown',\n data: codedError?.data ?? {},\n };\n\n // Copy msBuildErrorMessages into the codedError.data object\n if ((error as any).msBuildErrorMessages) {\n // Always grab MSBuild error codes if possible\n codedErrorStruct.data.msBuildErrors = (error as any).msBuildErrorMessages\n .map(errorUtils.tryGetErrorCode)\n .filter((msg: string | undefined) => msg);\n\n // Grab sanitized MSBuild error messages if we're preserving them\n if (Telemetry.options.preserveErrorMessages) {\n codedErrorStruct.data.msBuildErrorMessages = (\n error as any\n ).msBuildErrorMessages\n .map(errorUtils.sanitizeErrorMessage)\n .filter((msg: string) => msg);\n }\n }\n\n // Copy miscellaneous system error fields into the codedError.data object\n const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];\n for (const f of syscallExceptionFieldsToCopy) {\n if ((error as any)[f]) {\n codedErrorStruct.data.codedError.data[f] = (error as any)[f];\n }\n }\n\n // Break down TS Error object into Exception Data\n const exceptionData = Telemetry.convertErrorIntoExceptionData(error);\n\n telemetryItem.data = {\n codedError: codedErrorStruct,\n exceptionData: exceptionData,\n };\n\n Telemetry.trackEvent(telemetryItem);\n }\n\n static convertErrorIntoExceptionData(error: Error): Record<string, any> {\n const exceptionData = {\n hasFullStack: false,\n message: error.message,\n parsedStack: {},\n };\n\n exceptionData.message = exceptionData.message || '[None]';\n\n // CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.\n // The message may contain PII information. This can be sanitized, but for now delete it.\n if (Telemetry.options.preserveErrorMessages) {\n exceptionData.message = errorUtils.sanitizeErrorMessage(\n exceptionData.message,\n );\n } else {\n exceptionData.message = '[Removed]';\n }\n\n const lines = error.stack?.split('\\n');\n\n const parsedStack = lines?.slice(1).map(line => {\n const errorStackFrame: errorUtils.ErrorStackFrame = {};\n\n const match = line\n .trim()\n .match(/^\\s*at\\s+(?:(.*?)\\s+\\((.*):(\\d+):(\\d+)\\)|(.*):(\\d+):(\\d+))$/);\n if (match) {\n errorStackFrame.functionName = match[1] || 'N/A'; // Use a default value if no function name\n errorStackFrame.filePath = match[2] || match[5];\n errorStackFrame.lineNumber =\n parseInt(match[3], 10) || parseInt(match[6], 10);\n errorStackFrame.columnNumber =\n parseInt(match[4], 10) || parseInt(match[7], 10);\n }\n\n return errorStackFrame;\n });\n\n if (parsedStack) {\n parsedStack.filter(Boolean);\n\n // Sanitize parsed error stack frames\n for (const frame of parsedStack) {\n errorUtils.sanitizeErrorStackFrame(frame);\n }\n\n exceptionData.hasFullStack = true;\n exceptionData.parsedStack = parsedStack;\n }\n\n return exceptionData;\n }\n}\n"]}
|
|
@@ -51,8 +51,14 @@ test('nodeArchitecture() is valid', () => {
|
|
|
51
51
|
expect(value).not.toBe('');
|
|
52
52
|
expect(value).not.toBeNull();
|
|
53
53
|
});
|
|
54
|
-
test('
|
|
55
|
-
const value = basePropUtils.
|
|
54
|
+
test('deviceClass() is valid', () => {
|
|
55
|
+
const value = basePropUtils.deviceClass();
|
|
56
|
+
expect(value).toBeDefined();
|
|
57
|
+
expect(value).not.toBe('');
|
|
58
|
+
expect(value).not.toBeNull();
|
|
59
|
+
});
|
|
60
|
+
test('nodePlatform() is valid', () => {
|
|
61
|
+
const value = basePropUtils.nodePlatform();
|
|
56
62
|
expect(value).toBeDefined();
|
|
57
63
|
expect(value).not.toBe('');
|
|
58
64
|
expect(value).not.toBeNull();
|
|
@@ -78,11 +84,6 @@ test('deviceDiskFreeSpace() is valid', () => {
|
|
|
78
84
|
const value = basePropUtils.deviceDiskFreeSpace();
|
|
79
85
|
expect(value).toBeGreaterThanOrEqual(0);
|
|
80
86
|
});
|
|
81
|
-
test('sampleRate() is within valid range', () => {
|
|
82
|
-
const value = basePropUtils.sampleRate();
|
|
83
|
-
expect(value).toBeGreaterThanOrEqual(0);
|
|
84
|
-
expect(value).toBeLessThanOrEqual(100);
|
|
85
|
-
});
|
|
86
87
|
test('ciType() is valid', () => {
|
|
87
88
|
const value = basePropUtils.ciType();
|
|
88
89
|
expect(value).toBeDefined();
|
|
@@ -135,4 +136,10 @@ test('getSessionId() is a guid', () => {
|
|
|
135
136
|
test('getSessionId() does not change', () => {
|
|
136
137
|
expect(basePropUtils.getSessionId()).toBe(basePropUtils.getSessionId());
|
|
137
138
|
});
|
|
139
|
+
test('fullBuildInfo() is valid', () => {
|
|
140
|
+
const value = basePropUtils.fullBuildInfo();
|
|
141
|
+
expect(value).toBeDefined();
|
|
142
|
+
expect(value).not.toBe('');
|
|
143
|
+
expect(value).not.toBeNull();
|
|
144
|
+
});
|
|
138
145
|
//# sourceMappingURL=basePropUtils.test.js.map
|