@react-native-windows/telemetry 0.0.0-canary.11 → 0.0.0-canary.111
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 +26 -0
- package/lib-commonjs/e2etest/telemetry.test.js +489 -0
- package/lib-commonjs/e2etest/telemetry.test.js.map +1 -0
- package/lib-commonjs/index.d.ts +11 -6
- package/lib-commonjs/index.js +26 -11
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/telemetry.d.ts +74 -27
- package/lib-commonjs/telemetry.js +404 -171
- package/lib-commonjs/telemetry.js.map +1 -1
- package/lib-commonjs/test/{sanitize.test.d.ts → basePropUtils.test.d.ts} +7 -7
- package/lib-commonjs/test/basePropUtils.test.js +145 -0
- package/lib-commonjs/test/basePropUtils.test.js.map +1 -0
- package/lib-commonjs/test/errorUtils.test.d.ts +7 -0
- package/lib-commonjs/test/errorUtils.test.js +160 -0
- package/lib-commonjs/test/errorUtils.test.js.map +1 -0
- package/lib-commonjs/test/projectUtils.test.d.ts +7 -0
- package/lib-commonjs/test/projectUtils.test.js +88 -0
- package/lib-commonjs/test/projectUtils.test.js.map +1 -0
- package/lib-commonjs/test/sanitizeUtils.test.d.ts +7 -0
- package/lib-commonjs/test/sanitizeUtils.test.js +98 -0
- package/lib-commonjs/test/sanitizeUtils.test.js.map +1 -0
- package/lib-commonjs/test/versionUtils.test.d.ts +7 -0
- package/lib-commonjs/test/versionUtils.test.js +115 -0
- package/lib-commonjs/test/versionUtils.test.js.map +1 -0
- package/lib-commonjs/utils/basePropUtils.d.ts +92 -0
- package/lib-commonjs/utils/basePropUtils.js +217 -0
- package/lib-commonjs/utils/basePropUtils.js.map +1 -0
- package/lib-commonjs/utils/errorUtils.d.ts +93 -0
- package/lib-commonjs/utils/errorUtils.js +183 -0
- package/lib-commonjs/utils/errorUtils.js.map +1 -0
- package/lib-commonjs/utils/optionUtils.d.ts +45 -0
- package/lib-commonjs/utils/optionUtils.js +96 -0
- package/lib-commonjs/utils/optionUtils.js.map +1 -0
- package/lib-commonjs/utils/projectUtils.d.ts +50 -0
- package/lib-commonjs/utils/projectUtils.js +187 -0
- package/lib-commonjs/utils/projectUtils.js.map +1 -0
- package/lib-commonjs/utils/sanitizeUtils.d.ts +12 -0
- package/lib-commonjs/utils/sanitizeUtils.js +85 -0
- package/lib-commonjs/utils/sanitizeUtils.js.map +1 -0
- package/lib-commonjs/utils/versionUtils.d.ts +38 -0
- package/lib-commonjs/utils/versionUtils.js +156 -0
- package/lib-commonjs/utils/versionUtils.js.map +1 -0
- package/package.json +40 -22
- package/CHANGELOG.json +0 -155
- package/CHANGELOG.md +0 -79
- package/lib-commonjs/test/sanitize.test.js +0 -220
- package/lib-commonjs/test/sanitize.test.js.map +0 -1
|
@@ -1,172 +1,405 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
* @format
|
|
6
|
-
*/
|
|
7
|
-
Object.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
exports.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.Telemetry = exports.NuGetPackagesWeTrack = exports.NpmPackagesWeTrack = exports.EventNamesWeTrack = exports.CodedErrorEventName = exports.CommandEventName = void 0;
|
|
32
|
+
const coreOneDS = __importStar(require("@microsoft/1ds-core-js"));
|
|
33
|
+
const _1ds_post_js_1 = require("@microsoft/1ds-post-js");
|
|
34
|
+
const basePropUtils = __importStar(require("./utils/basePropUtils"));
|
|
35
|
+
const versionUtils = __importStar(require("./utils/versionUtils"));
|
|
36
|
+
const errorUtils = __importStar(require("./utils/errorUtils"));
|
|
37
|
+
// 1DS instrumentation key
|
|
38
|
+
const RNW_1DS_INSTRUMENTATION_KEY = '';
|
|
39
|
+
// Environment variable to override the default setup string
|
|
40
|
+
const ENV_SETUP_OVERRIDE = 'RNW_TELEMETRY_SETUP';
|
|
41
|
+
// Environment variable to override the http proxy (such as http://localhost:8888 for Fiddler debugging)
|
|
42
|
+
const ENV_PROXY_OVERRIDE = 'RNW_TELEMETRY_PROXY';
|
|
43
|
+
exports.CommandEventName = 'RNWCLI.Command';
|
|
44
|
+
exports.CodedErrorEventName = 'RNWCLI.CodedError';
|
|
45
|
+
// These are the event names we're tracking
|
|
46
|
+
exports.EventNamesWeTrack = [
|
|
47
|
+
exports.CommandEventName,
|
|
48
|
+
exports.CodedErrorEventName,
|
|
49
|
+
];
|
|
50
|
+
// These are NPM packages we care about, in terms of capturing versions used
|
|
51
|
+
// and getting more details about when reporting errors
|
|
52
|
+
exports.NpmPackagesWeTrack = [
|
|
53
|
+
'@react-native-community/cli',
|
|
54
|
+
'@react-native-windows/cli',
|
|
55
|
+
'@react-native-windows/telemetry',
|
|
56
|
+
'react',
|
|
57
|
+
'react-native',
|
|
58
|
+
'react-native-windows',
|
|
59
|
+
'react-native-windows-init',
|
|
60
|
+
];
|
|
61
|
+
// These are NPM packages we care about, in terms of capturing versions used
|
|
62
|
+
exports.NuGetPackagesWeTrack = [
|
|
63
|
+
'Microsoft.UI.Xaml',
|
|
64
|
+
'Microsoft.Windows.CppWinRT',
|
|
65
|
+
'Microsoft.WinUI',
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* The Telemetry class is responsible for reporting telemetry for RNW CLI.
|
|
69
|
+
*/
|
|
70
|
+
class Telemetry {
|
|
71
|
+
static getDefaultSetupString() {
|
|
72
|
+
var _a;
|
|
73
|
+
// Enable overriding the default setup string via an environment variable
|
|
74
|
+
return (_a = process.env[ENV_SETUP_OVERRIDE]) !== null && _a !== void 0 ? _a : RNW_1DS_INSTRUMENTATION_KEY;
|
|
75
|
+
}
|
|
76
|
+
static reset() {
|
|
77
|
+
// Reset client
|
|
78
|
+
if (Telemetry.appInsightsCore) {
|
|
79
|
+
Telemetry.appInsightsCore.flush();
|
|
80
|
+
Telemetry.appInsightsCore = undefined;
|
|
81
|
+
}
|
|
82
|
+
// Reset local members
|
|
83
|
+
Telemetry.options = {
|
|
84
|
+
setupString: Telemetry.getDefaultSetupString(),
|
|
85
|
+
preserveErrorMessages: false,
|
|
86
|
+
populateNpmPackageVersions: true,
|
|
87
|
+
};
|
|
88
|
+
Telemetry.commandInfo = {};
|
|
89
|
+
Telemetry.versionsProp = {};
|
|
90
|
+
Telemetry.projectProp = undefined;
|
|
91
|
+
}
|
|
92
|
+
static isEnabled() {
|
|
93
|
+
return Telemetry.appInsightsCore !== undefined;
|
|
94
|
+
}
|
|
95
|
+
static getSessionId() {
|
|
96
|
+
return basePropUtils.getSessionId();
|
|
97
|
+
}
|
|
98
|
+
/** Sets up the Telemetry static to be used elsewhere. */
|
|
99
|
+
static async setup(options) {
|
|
100
|
+
if (Telemetry.appInsightsCore) {
|
|
101
|
+
// Bail since we've already setup
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
// Bail if we're in CI and not capturing CI
|
|
105
|
+
if (!Telemetry.isTestEnvironment &&
|
|
106
|
+
basePropUtils.isCI() &&
|
|
107
|
+
!basePropUtils.captureCI()) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
// Save off options for later
|
|
111
|
+
Object.assign(Telemetry.options, options);
|
|
112
|
+
Telemetry.setupClient();
|
|
113
|
+
await Telemetry.setupBaseProperties();
|
|
114
|
+
}
|
|
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. */
|
|
123
|
+
static setupClient() {
|
|
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];
|
|
137
|
+
}
|
|
138
|
+
Telemetry.appInsightsCore = new coreOneDS.AppInsightsCore();
|
|
139
|
+
Telemetry.appInsightsCore.initialize(coreConfiguration, [postChannel] /* extensions */);
|
|
140
|
+
Telemetry.appInsightsCore.addTelemetryInitializer(Telemetry.basicTelemetryInitializer);
|
|
141
|
+
}
|
|
142
|
+
/** Sets up any base properties that all telemetry events require. */
|
|
143
|
+
static async setupBaseProperties() {
|
|
144
|
+
Telemetry.commonProperties.deviceId = await basePropUtils.deviceId();
|
|
145
|
+
Telemetry.commonProperties.fullBuildInfo =
|
|
146
|
+
await basePropUtils.fullBuildInfo();
|
|
147
|
+
Telemetry.commonProperties.deviceArchitecture =
|
|
148
|
+
basePropUtils.deviceArchitecture();
|
|
149
|
+
Telemetry.commonProperties.nodeArchitecture =
|
|
150
|
+
basePropUtils.nodeArchitecture();
|
|
151
|
+
Telemetry.commonProperties.nodePlatform = basePropUtils.nodePlatform();
|
|
152
|
+
Telemetry.commonProperties.deviceClass = basePropUtils.deviceClass();
|
|
153
|
+
Telemetry.commonProperties.deviceLocale =
|
|
154
|
+
await basePropUtils.deviceLocale();
|
|
155
|
+
Telemetry.commonProperties.deviceNumCPUs = basePropUtils
|
|
156
|
+
.deviceNumCPUs()
|
|
157
|
+
.toString();
|
|
158
|
+
Telemetry.commonProperties.deviceTotalMemory = basePropUtils
|
|
159
|
+
.deviceTotalMemory()
|
|
160
|
+
.toString();
|
|
161
|
+
Telemetry.commonProperties.deviceDiskFreeSpace = basePropUtils
|
|
162
|
+
.deviceDiskFreeSpace()
|
|
163
|
+
.toString();
|
|
164
|
+
Telemetry.commonProperties.ciCaptured = basePropUtils
|
|
165
|
+
.captureCI()
|
|
166
|
+
.toString();
|
|
167
|
+
Telemetry.commonProperties.ciType = basePropUtils.ciType();
|
|
168
|
+
Telemetry.commonProperties.isMsftInternal = basePropUtils
|
|
169
|
+
.isMsftInternal()
|
|
170
|
+
.toString();
|
|
171
|
+
Telemetry.commonProperties.isTest = Telemetry.isTestEnvironment.toString();
|
|
172
|
+
Telemetry.commonProperties.sessionId = Telemetry.getSessionId();
|
|
173
|
+
await Telemetry.populateToolsVersions();
|
|
174
|
+
if (Telemetry.options.populateNpmPackageVersions) {
|
|
175
|
+
await Telemetry.populateNpmPackageVersions();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/** Tries to update the version of the named package/tool by calling getValue(). */
|
|
179
|
+
static async tryUpdateVersionsProp(name, getValue, forceRefresh) {
|
|
180
|
+
if (!Telemetry.appInsightsCore) {
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
if (forceRefresh === true || !Telemetry.versionsProp[name]) {
|
|
184
|
+
const value = await getValue();
|
|
185
|
+
if (value) {
|
|
186
|
+
Telemetry.versionsProp[name] = value;
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
/** Populates the versions property of tools we care to track. */
|
|
193
|
+
static async populateToolsVersions(refresh) {
|
|
194
|
+
await Telemetry.tryUpdateVersionsProp('node', versionUtils.getNodeVersion, refresh);
|
|
195
|
+
await Telemetry.tryUpdateVersionsProp('npm', versionUtils.getNpmVersion, refresh);
|
|
196
|
+
await Telemetry.tryUpdateVersionsProp('yarn', versionUtils.getYarnVersion, refresh);
|
|
197
|
+
await Telemetry.tryUpdateVersionsProp('VisualStudio', versionUtils.getVisualStudioVersion, refresh);
|
|
198
|
+
}
|
|
199
|
+
/** Populates the versions property of npm packages we care to track. */
|
|
200
|
+
static async populateNpmPackageVersions(refresh) {
|
|
201
|
+
for (const npmPackage of exports.NpmPackagesWeTrack) {
|
|
202
|
+
await Telemetry.tryUpdateVersionsProp(npmPackage, async () => await versionUtils.getVersionOfNpmPackage(npmPackage), refresh);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/** Populates the versions property of nuget packages we care to track. */
|
|
206
|
+
static async populateNuGetPackageVersions(projectFile, refresh) {
|
|
207
|
+
const nugetVersions = await versionUtils.getVersionsOfNuGetPackages(projectFile, exports.NuGetPackagesWeTrack);
|
|
208
|
+
for (const nugetPackage of exports.NuGetPackagesWeTrack) {
|
|
209
|
+
await Telemetry.tryUpdateVersionsProp(nugetPackage, async () => nugetVersions[nugetPackage], refresh);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
static setProjectInfo(info) {
|
|
213
|
+
if (!Telemetry.appInsightsCore) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
Telemetry.projectProp = info;
|
|
217
|
+
}
|
|
218
|
+
static startCommand(info) {
|
|
219
|
+
if (!Telemetry.appInsightsCore) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
// startCommand() was called before invoking endCommand(), bail out.
|
|
223
|
+
if (Telemetry.commandInfo.startInfo) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
Telemetry.commandInfo.startTime = Date.now();
|
|
227
|
+
Telemetry.commandInfo.startInfo = info;
|
|
228
|
+
// Set common command props
|
|
229
|
+
Telemetry.commonProperties.commandName = info.commandName;
|
|
230
|
+
}
|
|
231
|
+
static endCommand(info, extraProps) {
|
|
232
|
+
if (!Telemetry.appInsightsCore) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
// startCommand() wasn't called, bail out.
|
|
236
|
+
if (!Telemetry.commandInfo.startInfo) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
Telemetry.commandInfo.endTime = Date.now();
|
|
240
|
+
Telemetry.commandInfo.endInfo = info;
|
|
241
|
+
Telemetry.trackCommandEvent(extraProps);
|
|
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
|
+
}
|
|
284
|
+
static trackCommandEvent(extraProps) {
|
|
285
|
+
var _a, _b, _c, _d;
|
|
286
|
+
const telemetryItem = { name: exports.CommandEventName };
|
|
287
|
+
// This is logged in Part C.
|
|
288
|
+
const command = {
|
|
289
|
+
options: (_a = Telemetry.commandInfo.startInfo) === null || _a === void 0 ? void 0 : _a.options,
|
|
290
|
+
defaultOptions: (_b = Telemetry.commandInfo.startInfo) === null || _b === void 0 ? void 0 : _b.defaultOptions,
|
|
291
|
+
args: (_c = Telemetry.commandInfo.startInfo) === null || _c === void 0 ? void 0 : _c.args,
|
|
292
|
+
durationInSecs: (Telemetry.commandInfo.endTime - Telemetry.commandInfo.startTime) /
|
|
293
|
+
1000,
|
|
294
|
+
resultCode: (_d = Telemetry.commandInfo.endInfo) === null || _d === void 0 ? void 0 : _d.resultCode,
|
|
295
|
+
};
|
|
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);
|
|
304
|
+
}
|
|
305
|
+
static trackException(error, extraProps) {
|
|
306
|
+
var _a, _b;
|
|
307
|
+
if (!Telemetry.appInsightsCore) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const telemetryItem = { name: exports.CodedErrorEventName };
|
|
311
|
+
// Save off CodedError info in Part C.
|
|
312
|
+
const codedError = error instanceof errorUtils.CodedError
|
|
313
|
+
? error
|
|
314
|
+
: null;
|
|
315
|
+
const codedErrorStruct = {
|
|
316
|
+
type: (_a = codedError === null || codedError === void 0 ? void 0 : codedError.type) !== null && _a !== void 0 ? _a : 'Unknown',
|
|
317
|
+
data: (_b = codedError === null || codedError === void 0 ? void 0 : codedError.data) !== null && _b !== void 0 ? _b : {},
|
|
318
|
+
};
|
|
319
|
+
// Copy msBuildErrorMessages into the codedError.data object
|
|
320
|
+
if (error.msBuildErrorMessages) {
|
|
321
|
+
// Always grab MSBuild error codes if possible
|
|
322
|
+
codedErrorStruct.data.msBuildErrors = error.msBuildErrorMessages
|
|
323
|
+
.map(errorUtils.tryGetErrorCode)
|
|
324
|
+
.filter((msg) => msg);
|
|
325
|
+
// Grab sanitized MSBuild error messages if we're preserving them
|
|
326
|
+
if (Telemetry.options.preserveErrorMessages) {
|
|
327
|
+
codedErrorStruct.data.msBuildErrorMessages = error.msBuildErrorMessages
|
|
328
|
+
.map(errorUtils.sanitizeErrorMessage)
|
|
329
|
+
.filter((msg) => msg);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
// Copy miscellaneous system error fields into the codedError.data object
|
|
333
|
+
const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];
|
|
334
|
+
for (const f of syscallExceptionFieldsToCopy) {
|
|
335
|
+
if (error[f]) {
|
|
336
|
+
codedErrorStruct.data.codedError.data[f] = error[f];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
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;
|
|
378
|
+
});
|
|
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;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
Telemetry.appInsightsCore = undefined;
|
|
392
|
+
Telemetry.options = {
|
|
393
|
+
setupString: Telemetry.getDefaultSetupString(),
|
|
394
|
+
preserveErrorMessages: false,
|
|
395
|
+
populateNpmPackageVersions: true,
|
|
396
|
+
};
|
|
397
|
+
Telemetry.isTestEnvironment = basePropUtils.isCliTest();
|
|
398
|
+
Telemetry.commandInfo = {};
|
|
399
|
+
// Stores the version of a list of packages used by the RNW app project.
|
|
400
|
+
Telemetry.versionsProp = {};
|
|
401
|
+
Telemetry.projectProp = undefined;
|
|
402
|
+
// Store "Common Properties" in a single object. This will be logged in all telemetry events.
|
|
403
|
+
Telemetry.commonProperties = {};
|
|
404
|
+
exports.Telemetry = Telemetry;
|
|
172
405
|
//# sourceMappingURL=telemetry.js.map
|