@react-native-windows/telemetry 0.75.3 → 0.75.5

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.
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.getSessionId = exports.isCliTest = exports.isMsftInternal = exports.ciType = exports.isCI = exports.captureCI = exports.sampleRate = exports.deviceDiskFreeSpace = exports.deviceTotalMemory = exports.deviceNumCPUs = exports.deviceLocale = exports.devicePlatform = exports.nodeArchitecture = exports.deviceArchitecture = exports.deviceId = void 0;
11
+ exports.getSessionId = exports.isCliTest = exports.isMsftInternal = exports.ciType = exports.isCI = exports.captureCI = exports.deviceDiskFreeSpace = exports.deviceTotalMemory = exports.deviceNumCPUs = exports.deviceLocale = exports.deviceClass = exports.nodePlatform = exports.nodeArchitecture = exports.deviceArchitecture = exports.fullBuildInfo = exports.deviceId = exports.getValueFromRegistry = void 0;
12
12
  const child_process_1 = require("child_process");
13
13
  const os_1 = require("os");
14
14
  const ci_info_1 = __importDefault(require("ci-info"));
@@ -16,19 +16,34 @@ const crypto_1 = require("crypto");
16
16
  const os_locale_1 = __importDefault(require("os-locale"));
17
17
  const DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\SQMClient';
18
18
  const DeviceIdRegKey = 'MachineId';
19
+ const DeviceIdBuildPath = '"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"';
20
+ const DeviceIdBuildKey = 'BuildLabEx';
19
21
  /**
20
- * Gets a telemetry-safe stable device ID.
21
- * @returns A telemetry-safe stable device ID.
22
+ * Given a path and a key, retrieves the value from the Registry.
23
+ * @returns If the path and key exist, the requested value from the Registry; empty string otherwise.
22
24
  */
23
- async function deviceId() {
25
+ async function getValueFromRegistry(path, key) {
24
26
  try {
25
- let regCommand = `${process.env.windir}\\System32\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`;
27
+ let regCommand = `${process.env.windir}\\System32\\reg.exe query ${path} /v ${key}`;
26
28
  if (deviceArchitecture() === 'x64') {
27
29
  // Ensure we query the correct registry
28
30
  regCommand += ' /reg:64';
29
31
  }
30
32
  const output = (0, child_process_1.execSync)(regCommand).toString();
31
- const result = output.match(/\{([0-9A-Fa-f-]{36})\}/);
33
+ return output;
34
+ }
35
+ catch (_a) { }
36
+ return '';
37
+ }
38
+ exports.getValueFromRegistry = getValueFromRegistry;
39
+ /**
40
+ * Gets a telemetry-safe stable device ID.
41
+ * @returns A telemetry-safe stable device ID.
42
+ */
43
+ async function deviceId() {
44
+ try {
45
+ const deviceIdValue = await getValueFromRegistry(DeviceIdRegPath, DeviceIdRegKey);
46
+ const result = deviceIdValue.match(/\{([0-9A-Fa-f-]{36})\}/);
32
47
  if (result && result.length > 1) {
33
48
  return `s:${result[1]}`;
34
49
  }
@@ -37,6 +52,24 @@ async function deviceId() {
37
52
  return '';
38
53
  }
39
54
  exports.deviceId = deviceId;
55
+ /**
56
+ * Gets the Windows build name, number and architecture.
57
+ * @returns A string containing the Windows build name, number and architecture.
58
+ * e.g. 19569.1000.amd64fre.rs_prerelease.200214-1419
59
+ */
60
+ async function fullBuildInfo() {
61
+ try {
62
+ const fullBuildValue = await getValueFromRegistry(DeviceIdBuildPath, DeviceIdBuildKey);
63
+ // Retrieve the build info
64
+ const match = fullBuildValue.match(/BuildLabEx\s+REG_SZ\s+([^\r\n]+)/);
65
+ if (match && match.length > 1) {
66
+ return match[1];
67
+ }
68
+ }
69
+ catch (_a) { }
70
+ return '';
71
+ }
72
+ exports.fullBuildInfo = fullBuildInfo;
40
73
  /**
41
74
  * Gets the device architecture, like x86/x64/arm64.
42
75
  * @returns The device architecture.
@@ -59,13 +92,31 @@ function nodeArchitecture() {
59
92
  }
60
93
  exports.nodeArchitecture = nodeArchitecture;
61
94
  /**
62
- * Gets the device platform, like darwin/linux/win32.
95
+ * Gets the node platform, like darwin/linux/win32.
63
96
  * @returns The device platform.
64
97
  */
65
- function devicePlatform() {
98
+ function nodePlatform() {
66
99
  return (0, os_1.platform)();
67
100
  }
68
- exports.devicePlatform = devicePlatform;
101
+ exports.nodePlatform = nodePlatform;
102
+ /**
103
+ * Gets the OS name, to be filled in the PartA device.deviceClass field.
104
+ * @returns The device class.
105
+ */
106
+ function deviceClass() {
107
+ const node = nodePlatform();
108
+ switch (node) {
109
+ case 'darwin':
110
+ return 'Mac';
111
+ case 'linux':
112
+ return 'Linux';
113
+ case 'win32':
114
+ return 'Windows';
115
+ default:
116
+ return node;
117
+ }
118
+ }
119
+ exports.deviceClass = deviceClass;
69
120
  /**
70
121
  * Gets the device locale.
71
122
  * @returns The device locale.
@@ -110,14 +161,6 @@ function deviceDiskFreeSpace(drivePath) {
110
161
  return -1;
111
162
  }
112
163
  exports.deviceDiskFreeSpace = deviceDiskFreeSpace;
113
- /**
114
- * Gets the telemetry sample rate.
115
- * @returns The telemetry sample rate.
116
- */
117
- function sampleRate() {
118
- return 100;
119
- }
120
- exports.sampleRate = sampleRate;
121
164
  /**
122
165
  * Gets whether or not telemetry events are captured when running in CI.
123
166
  * @returns Whether or not telemetry events are captured when running in CI.
@@ -1 +1 @@
1
- {"version":3,"file":"basePropUtils.js","sourceRoot":"","sources":["../../src/utils/basePropUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAuC;AACvC,2BAA4C;AAE5C,sDAAyB;AACzB,mCAAmC;AACnC,0DAAiC;AAEjC,MAAM,eAAe,GAAG,oDAAoD,CAAC;AAC7E,MAAM,cAAc,GAAG,WAAW,CAAC;AAEnC;;;GAGG;AACI,KAAK,UAAU,QAAQ;IAC5B,IAAI;QACF,IAAI,UAAU,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,6BAA6B,eAAe,OAAO,cAAc,EAAE,CAAC;QAC1G,IAAI,kBAAkB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oB,CAAC,CACvE,CAAC;AACJ,CAAC;AALD,wCAKC;AAED;;;GAGG;AACH,SAAgB,SAAS;IACvB,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS;QACtC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,MAAM,CACzD,CAAC;AACJ,CAAC;AALD,8BAKC;AAED,IAAI,SAA6B,CAAC;AAElC;;;GAGG;AACH,SAAgB,YAAY;IAC1B,OAAO,CACL,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,SAAS,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC;AAJD,oCAIC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {execSync} from 'child_process';\nimport {totalmem, cpus, platform} from 'os';\n\nimport ci from 'ci-info';\nimport {randomBytes} from 'crypto';\nimport osLocale from 'os-locale';\n\nconst DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\SQMClient';\nconst DeviceIdRegKey = 'MachineId';\n\n/**\n * Gets a telemetry-safe stable device ID.\n * @returns A telemetry-safe stable device ID.\n */\nexport async function deviceId(): Promise<string> {\n try {\n let regCommand = `${process.env.windir}\\\\System32\\\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`;\n if (deviceArchitecture() === 'x64') {\n // Ensure we query the correct registry\n regCommand += ' /reg:64';\n }\n const output = execSync(regCommand).toString();\n\n const result = output.match(/\\{([0-9A-Fa-f-]{36})\\}/);\n if (result && result.length > 1) {\n return `s:${result[1]}`;\n }\n } catch {}\n return '';\n}\n\n/**\n * Gets the device architecture, like x86/x64/arm64.\n * @returns The device architecture.\n */\nexport function deviceArchitecture(): string {\n const nodeArch = nodeArchitecture();\n\n // Check if we're running x86 node on x64 hardware\n if (nodeArch === 'x86' && process.env.PROCESSOR_ARCHITEW6432 === 'AMD64') {\n return 'x64';\n }\n\n return nodeArch;\n}\n\n/**\n * Gets the node architecture, like x86/x64/arm64.\n * @returns The node architecture.\n */\nexport function nodeArchitecture(): string {\n return process.arch === 'ia32' ? 'x86' : process.arch;\n}\n\n/**\n * Gets the device platform, like darwin/linux/win32.\n * @returns The device platform.\n */\nexport function devicePlatform(): string {\n return platform();\n}\n\n/**\n * Gets the device locale.\n * @returns The device locale.\n */\nexport async function deviceLocale(): Promise<string> {\n return await osLocale();\n}\n\n/**\n * Gets the device's number of CPUs.\n * @returns The device's number of CPUs.\n */\nexport function deviceNumCPUs(): number {\n return cpus().length;\n}\n\n/**\n * Gets the device's total memory in bytes.\n * @returns The device's total memory in bytes.\n */\nexport function deviceTotalMemory(): number {\n return totalmem();\n}\n\n/**\n * Gets the free space of the give drive in bytes.\n * @param drivePath A path on the drive to check.\n * @returns The free space of the give drive in bytes.\n */\nexport function deviceDiskFreeSpace(drivePath?: string | null): number {\n try {\n const out = execSync(`dir /-C ${drivePath ?? process.cwd()}`)\n .toString()\n .split('\\r\\n');\n const line = out[out.length - 2];\n const result = line.match(/(\\d+) [^\\d]+(\\d+) /);\n if (result && result.length > 2) {\n return Number(result[2]);\n }\n } catch {}\n return -1;\n}\n\n/**\n * Gets the telemetry sample rate.\n * @returns The telemetry sample rate.\n */\nexport function sampleRate(): number {\n return 100;\n}\n\n/**\n * Gets whether or not telemetry events are captured when running in CI.\n * @returns Whether or not telemetry events are captured when running in CI.\n */\nexport function captureCI(): boolean {\n // Only capture events in CI if running tests\n return isCliTest();\n}\n\n/**\n * Gets the whether the process is currently running in CI.\n * @returns Whether the process is currently running in CI.\n */\nexport function isCI(): boolean {\n return ci.isCI;\n}\n\n/**\n * Gets the type of CI the process is running under.\n * @returns The type of CI the process is running under.\n */\nexport function ciType(): string {\n return ci.isCI ? ci.name ?? 'Unknown' : 'None';\n}\n\n/**\n * Gets whether the process is running on a Microsoft owned machine.\n * @returns Whether the process is running on a Microsoft owned machine.\n */\nexport function isMsftInternal(): boolean {\n return (\n process.env.UserDNSDomain !== undefined &&\n process.env.UserDNSDomain.toLowerCase().endsWith('corp.microsoft.com')\n );\n}\n\n/**\n * Gets whether the process is running as part of our CLI tests.\n * @returns Whether the process is running as part of our CLI tests.\n */\nexport function isCliTest(): boolean {\n return (\n process.env.RNW_CLI_TEST !== undefined &&\n process.env.RNW_CLI_TEST.toLowerCase().trim() === 'true'\n );\n}\n\nlet sessionId: string | undefined;\n\n/**\n * Gets a stable session ID for correlating telemetry events.\n * @returns A stable session ID for correlating telemetry events.\n */\nexport function getSessionId(): string {\n return (\n sessionId ?? (sessionId = randomBytes(16).toString('hex').padStart(32, '0'))\n );\n}\n"]}
1
+ {"version":3,"file":"basePropUtils.js","sourceRoot":"","sources":["../../src/utils/basePropUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAuC;AACvC,2BAA4C;AAE5C,sDAAyB;AACzB,mCAAmC;AACnC,0DAAiC;AAEjC,MAAM,eAAe,GAAG,oDAAoD,CAAC;AAC7E,MAAM,cAAc,GAAG,WAAW,CAAC;AAEnC,MAAM,iBAAiB,GACrB,uEAAuE,CAAC;AAC1E,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAEtC;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CACxC,IAAY,EACZ,GAAW;IAEX,IAAI;QACF,IAAI,UAAU,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,6BAA6B,IAAI,OAAO,GAAG,EAAE,CAAC;QACpF,IAAI,kBAAkB,EAAE,KAAK,KAAK,EAAE;YAClC,uCAAuC;YACvC,UAAU,IAAI,UAAU,CAAC;SAC1B;QAED,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC/C,OAAO,MAAM,CAAC;K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n\nimport {execSync} from 'child_process';\nimport {totalmem, cpus, platform} from 'os';\n\nimport ci from 'ci-info';\nimport {randomBytes} from 'crypto';\nimport osLocale from 'os-locale';\n\nconst DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\SQMClient';\nconst DeviceIdRegKey = 'MachineId';\n\nconst DeviceIdBuildPath =\n '\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\"';\nconst DeviceIdBuildKey = 'BuildLabEx';\n\n/**\n * Given a path and a key, retrieves the value from the Registry.\n * @returns If the path and key exist, the requested value from the Registry; empty string otherwise.\n */\nexport async function getValueFromRegistry(\n path: string,\n key: string,\n): Promise<string> {\n try {\n let regCommand = `${process.env.windir}\\\\System32\\\\reg.exe query ${path} /v ${key}`;\n if (deviceArchitecture() === 'x64') {\n // Ensure we query the correct registry\n regCommand += ' /reg:64';\n }\n\n const output = execSync(regCommand).toString();\n return output;\n } catch {}\n\n return '';\n}\n\n/**\n * Gets a telemetry-safe stable device ID.\n * @returns A telemetry-safe stable device ID.\n */\nexport async function deviceId(): Promise<string> {\n try {\n const deviceIdValue = await getValueFromRegistry(\n DeviceIdRegPath,\n DeviceIdRegKey,\n );\n\n const result = deviceIdValue.match(/\\{([0-9A-Fa-f-]{36})\\}/);\n if (result && result.length > 1) {\n return `s:${result[1]}`;\n }\n } catch {}\n return '';\n}\n\n/**\n * Gets the Windows build name, number and architecture.\n * @returns A string containing the Windows build name, number and architecture.\n * e.g. 19569.1000.amd64fre.rs_prerelease.200214-1419\n */\nexport async function fullBuildInfo(): Promise<string> {\n try {\n const fullBuildValue = await getValueFromRegistry(\n DeviceIdBuildPath,\n DeviceIdBuildKey,\n );\n\n // Retrieve the build info\n const match = fullBuildValue.match(/BuildLabEx\\s+REG_SZ\\s+([^\\r\\n]+)/);\n if (match && match.length > 1) {\n return match[1];\n }\n } catch {}\n return '';\n}\n\n/**\n * Gets the device architecture, like x86/x64/arm64.\n * @returns The device architecture.\n */\nexport function deviceArchitecture(): string {\n const nodeArch = nodeArchitecture();\n\n // Check if we're running x86 node on x64 hardware\n if (nodeArch === 'x86' && process.env.PROCESSOR_ARCHITEW6432 === 'AMD64') {\n return 'x64';\n }\n\n return nodeArch;\n}\n\n/**\n * Gets the node architecture, like x86/x64/arm64.\n * @returns The node architecture.\n */\nexport function nodeArchitecture(): string {\n return process.arch === 'ia32' ? 'x86' : process.arch;\n}\n\n/**\n * Gets the node platform, like darwin/linux/win32.\n * @returns The device platform.\n */\nexport function nodePlatform(): string {\n return platform();\n}\n\n/**\n * Gets the OS name, to be filled in the PartA device.deviceClass field.\n * @returns The device class.\n */\nexport function deviceClass(): string {\n const node = nodePlatform();\n\n switch (node) {\n case 'darwin':\n return 'Mac';\n case 'linux':\n return 'Linux';\n case 'win32':\n return 'Windows';\n default:\n return node;\n }\n}\n\n/**\n * Gets the device locale.\n * @returns The device locale.\n */\nexport async function deviceLocale(): Promise<string> {\n return await osLocale();\n}\n\n/**\n * Gets the device's number of CPUs.\n * @returns The device's number of CPUs.\n */\nexport function deviceNumCPUs(): number {\n return cpus().length;\n}\n\n/**\n * Gets the device's total memory in bytes.\n * @returns The device's total memory in bytes.\n */\nexport function deviceTotalMemory(): number {\n return totalmem();\n}\n\n/**\n * Gets the free space of the give drive in bytes.\n * @param drivePath A path on the drive to check.\n * @returns The free space of the give drive in bytes.\n */\nexport function deviceDiskFreeSpace(drivePath?: string | null): number {\n try {\n const out = execSync(`dir /-C ${drivePath ?? process.cwd()}`)\n .toString()\n .split('\\r\\n');\n const line = out[out.length - 2];\n const result = line.match(/(\\d+) [^\\d]+(\\d+) /);\n if (result && result.length > 2) {\n return Number(result[2]);\n }\n } catch {}\n return -1;\n}\n\n/**\n * Gets whether or not telemetry events are captured when running in CI.\n * @returns Whether or not telemetry events are captured when running in CI.\n */\nexport function captureCI(): boolean {\n // Only capture events in CI if running tests\n return isCliTest();\n}\n\n/**\n * Gets the whether the process is currently running in CI.\n * @returns Whether the process is currently running in CI.\n */\nexport function isCI(): boolean {\n return ci.isCI;\n}\n\n/**\n * Gets the type of CI the process is running under.\n * @returns The type of CI the process is running under.\n */\nexport function ciType(): string {\n return ci.isCI ? ci.name ?? 'Unknown' : 'None';\n}\n\n/**\n * Gets whether the process is running on a Microsoft owned machine.\n * @returns Whether the process is running on a Microsoft owned machine.\n */\nexport function isMsftInternal(): boolean {\n return (\n process.env.UserDNSDomain !== undefined &&\n process.env.UserDNSDomain.toLowerCase().endsWith('corp.microsoft.com')\n );\n}\n\n/**\n * Gets whether the process is running as part of our CLI tests.\n * @returns Whether the process is running as part of our CLI tests.\n */\nexport function isCliTest(): boolean {\n return (\n process.env.RNW_CLI_TEST !== undefined &&\n process.env.RNW_CLI_TEST.toLowerCase().trim() === 'true'\n );\n}\n\nlet sessionId: string | undefined;\n\n/**\n * Gets a stable session ID for correlating telemetry events.\n * @returns A stable session ID for correlating telemetry events.\n */\nexport function getSessionId(): string {\n return (\n sessionId ?? (sessionId = randomBytes(16).toString('hex').padStart(32, '0'))\n );\n}\n"]}
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  * @format
5
5
  */
6
- import * as appInsights from 'applicationinsights';
7
6
  export declare const CodedErrors: {
8
7
  Success: number;
9
8
  Unknown: number;
@@ -69,6 +68,12 @@ export declare class CodedError extends Error {
69
68
  readonly data?: Record<string, any> | undefined;
70
69
  constructor(type: CodedErrorType, message: string, data?: Record<string, any> | undefined);
71
70
  }
71
+ export interface ErrorStackFrame {
72
+ functionName?: string;
73
+ filePath?: string;
74
+ lineNumber?: number;
75
+ columnNumber?: number;
76
+ }
72
77
  /**
73
78
  * Tries to parse an error code out of an error message.
74
79
  * @param msg An error message to process.
@@ -85,4 +90,4 @@ export declare function sanitizeErrorMessage(msg: string): string;
85
90
  * Sanitizes an error stack frame.
86
91
  * @param frame
87
92
  */
88
- export declare function sanitizeErrorStackFrame(frame: appInsights.Contracts.StackFrame): void;
93
+ export declare function sanitizeErrorStackFrame(frame: ErrorStackFrame): void;
@@ -164,17 +164,20 @@ exports.sanitizeErrorMessage = sanitizeErrorMessage;
164
164
  * @param frame
165
165
  */
166
166
  function sanitizeErrorStackFrame(frame) {
167
- const parens = frame.method.indexOf('(');
168
- if (parens !== -1) {
169
- // case 1: method === 'methodName (rootOfThePath'
170
- frame.method = frame.method.substr(0, parens).trim();
171
- }
172
- else {
173
- // case 2: method === <no_method> or something without '(', fileName is full path
167
+ if (frame.functionName) {
168
+ const leftParenthesisIndex = frame.functionName.indexOf('(');
169
+ if (leftParenthesisIndex !== -1) {
170
+ // case 1: method === 'methodName (rootOfThePath'
171
+ frame.functionName = frame.functionName
172
+ .substr(0, leftParenthesisIndex)
173
+ .trim();
174
+ }
175
+ else {
176
+ // case 2: method === <no_method> or something without '(', fileName is full path
177
+ }
174
178
  }
175
- // anonymize the filename
176
- frame.fileName = sanitizeUtils.getAnonymizedPath(frame.fileName);
177
- frame.assembly = '';
179
+ // anonymize the filePath
180
+ frame.filePath = sanitizeUtils.getAnonymizedPath(frame.filePath);
178
181
  }
179
182
  exports.sanitizeErrorStackFrame = sanitizeErrorStackFrame;
180
183
  //# sourceMappingURL=errorUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../../src/utils/errorUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,+DAAiD;AAEjD,6EAA6E;AAC7E,iEAAiE;AACjE,yEAAyE;AACzE,iEAAiE;AAEpD,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC,CAAC;IAEX,4BAA4B;IAC5B,6BAA6B,EAAE,IAAI;IACnC,UAAU,EAAE,IAAI;IAChB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,IAAI;IACnB,0BAA0B,EAAE,IAAI;IAChC,gCAAgC,EAAE,IAAI;IACtC,mBAAmB,EA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ACvC,MAAM;oBACJ,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;wBACxC,aAAa,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,GAAG,OAAQ,CAAC,KAAK,GAAG,OAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;aAC5C;YACD,IAAI,MAAM,KAAK,EAAE,EAAE;gBACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACpB;SACF;aAAM,IAAI,IAAI,KAAK,EAAE,EAAE;YACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAClB;KACF;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC/B,CAAC;AAhCD,oDAgCC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CACrC,KAAuC;IAEvC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,MAAM,KAAK,CAAC,CAAC,EAAE;QACjB,iDAAiD;QACjD,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;KACtD;SAAM;QACL,iFAAiF;KAClF;IACD,yBAAyB;IACzB,KAAK,CAAC,QAAQ,GAAG,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjE,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC;AACtB,CAAC;AAbD,0DAaC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\n\nimport * as sanitizeUtils from './sanitizeUtils';\n\n// Note: All CLI commands will set process.exitCode to the numerical value of\n// a thrown CodedError. However node reserves codes 1-192 as per:\n// https://nodejs.org/api/process.html#process_exit_codes so we shouldn't\n// override those as other tools may be monitoring the error code\n\nexport const CodedErrors = {\n Success: 0,\n Unknown: -1,\n\n // react-native-windows-init\n UnsupportedReactNativeVersion: 1000,\n UserCancel: 1001,\n NoReactNativeFound: 1002,\n NoPackageJson: 1003,\n NoLatestReactNativeWindows: 1004,\n NoAutoMatchingReactNativeWindows: 1005,\n IncompatibleOptions: 1006,\n NoReactNativeDependencies: 1007,\n NoMatchingPackageVersion: 1008,\n\n // run-windows\n NoSolution: 2000,\n // Project generation\n NoPropertyInProject: 2100,\n CopyProjectTemplateNoSourcePath: 2101,\n CopyProjectTemplateNoDestPath: 2102,\n CopyProjectTemplateNoProjectName: 2103,\n // SDK requirements\n MinSDKVersionNotMet: 2200,\n BadSDKVersionFormat: 2201,\n NoSDK: 2202,\n // Build\n NoMSBuild: 2300,\n NoVSWhere: 2301,\n MSBuildError: 2302,\n // Deploy\n NoAppPackage: 2400,\n NoAppxManifest: 2401,\n NoDevice: 2402,\n AppDidNotDeploy: 2403,\n InvalidDevicesOutput: 2404,\n RemoveOldAppVersionFailure: 2405,\n EnableDevModeFailure: 2406,\n InstallAppFailure: 2407,\n InstallAppDependenciesFailure: 2408,\n CheckNetIsolationFailure: 2409,\n InstallAppToDeviceFailure: 2410,\n UninstallAppOnDeviceFailure: 2411,\n DeployRecipeFailure: 2412,\n // Launch\n AppStartupFailure: 2500,\n\n // autolink-windows\n NoWindowsConfig: 3000,\n IncompleteConfig: 3001,\n InvalidConfig: 3002,\n NeedAutolinking: 3003,\n AddProjectToSolution: 3004,\n Autolinking: 3005,\n\n // codegen-windows\n NeedCodegen: 4000,\n InvalidCodegenConfig: 4001,\n\n // init-windows\n NoTemplatesFound: 5000,\n NoDefaultTemplate: 5001,\n InvalidTemplateName: 5002,\n NoProjectName: 5003,\n InvalidProjectName: 5004,\n InvalidProjectNamespace: 5005,\n};\n\nexport type CodedErrorType = keyof typeof CodedErrors;\n\n/**\n * Represents an error whose message might contain user-originating content,\n * therefore when transmitting telemetry, only the type should be sent.\n * @param type a stable ID identifying the type of error.\n * @param message the error text. This should only be used for display to the user.\n * @param data any additional metadata that is safe to collect for telemetry purposes.\n */\nexport class CodedError extends Error {\n constructor(\n public readonly type: CodedErrorType,\n message: string,\n public readonly data?: Record<string, any>,\n ) {\n super(message);\n this.name = type;\n }\n}\n\n/**\n * Tries to parse an error code out of an error message.\n * @param msg An error message to process.\n * @returns The parsed error code.\n */\nexport function tryGetErrorCode(msg: string): string | undefined {\n const errorRegEx = /error (\\w+\\d+):/gi;\n const m = errorRegEx.exec(msg);\n return m ? m[1] : undefined;\n}\n\n/**\n * Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes (\"\").\n * @param msg The error message to sanitize.\n * @return The message with any paths anonymized.\n */\nexport function sanitizeErrorMessage(msg: string): string {\n const msBuildErrorMessage =\n /^\\d+:\\d+>(.*)(\\(\\d+,\\d+\\)): error (\\w+\\d+): (.*)/g;\n msg = msg.replace(msBuildErrorMessage, '[$1]$2: error $3: $4');\n\n const cpuThreadId = /^\\d+(:\\d+)?>/g;\n msg = msg.replace(cpuThreadId, '');\n\n const parts = msg.split(/['[\\]\"]/g);\n const clean = [];\n const pathRegEx =\n /(['[\"]?)([A-Za-z]:|\\\\)[\\\\/]([^<>:;,?\"*\\t\\r\\n|/\\\\]+[\\\\/])+([^<>:;,?\"*\\t\\r\\n|]+\\/?(['[\"]?))/gi;\n for (const part of parts) {\n if (pathRegEx.test(part)) {\n pathRegEx.lastIndex = -1;\n let matches: RegExpExecArray | null;\n let noPath = '';\n let last = 0;\n while ((matches = pathRegEx.exec(part))) {\n noPath +=\n part.substr(last, matches!.index - last) +\n sanitizeUtils.getAnonymizedPath(matches[0]);\n last = matches!.index + matches![0].length;\n }\n if (noPath !== '') {\n clean.push(noPath);\n }\n } else if (part !== '') {\n clean.push(part);\n }\n }\n return clean.join('').trim();\n}\n\n/**\n * Sanitizes an error stack frame.\n * @param frame\n */\nexport function sanitizeErrorStackFrame(\n frame: appInsights.Contracts.StackFrame,\n): void {\n const parens = frame.method.indexOf('(');\n if (parens !== -1) {\n // case 1: method === 'methodName (rootOfThePath'\n frame.method = frame.method.substr(0, parens).trim();\n } else {\n // case 2: method === <no_method> or something without '(', fileName is full path\n }\n // anonymize the filename\n frame.fileName = sanitizeUtils.getAnonymizedPath(frame.fileName);\n frame.assembly = '';\n}\n"]}
1
+ {"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../../src/utils/errorUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAAiD;AAEjD,6EAA6E;AAC7E,iEAAiE;AACjE,yEAAyE;AACzE,iEAAiE;AAEpD,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC,CAAC;IAEX,4BAA4B;IAC5B,6BAA6B,EAAE,IAAI;IACnC,UAAU,EAAE,IAAI;IAChB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,IAAI;IACnB,0BAA0B,EAAE,IAAI;IAChC,gCAAgC,EAAE,IAAI;IACtC,mBAAmB,EAAE,IAAI;IACzB,yBAAyB,EAAE,IAAI;IAC/B,wBAAwB,EAAE,IAAI;IAE9B,cAAc;IACd,UAAU,EAAE,IAAI;IAChB,qBAAqB;IACrB,mBAAmB,EAAE,IAAI;IACzB,+BAA+B,EAAE,IAAI;IACrC,6BAA6B,EAAE,IAAI;IACnC,gCAAgC,EAAE,IAAI;IACtC,mBAAmB;IACnB,mBAAmB,EAAE,IAAI;IACzB,mBAAmB,EAAE,IAAI;IACzB,KAAK,EAAE,IAAI;IACX,QAAQ;IACR,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,YAAY,EAAE,IAAI;IAClB,SAAS;IACT,YAAY,EAAE,IAAI;IAClB,cAAc,EAAE,IAAI;IACpB,QAAQ,EAAE,IAAI;IACd,eAAe,EAAE,IAAI;IACrB,o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EAAE,CAAC;AAC/B,CAAC;AAhCD,oDAgCC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,KAAsB;IAC5D,IAAI,KAAK,CAAC,YAAY,EAAE;QACtB,MAAM,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7D,IAAI,oBAAoB,KAAK,CAAC,CAAC,EAAE;YAC/B,iDAAiD;YACjD,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY;iBACpC,MAAM,CAAC,CAAC,EAAE,oBAAoB,CAAC;iBAC/B,IAAI,EAAE,CAAC;SACX;aAAM;YACL,iFAAiF;SAClF;KACF;IAED,yBAAyB;IACzB,KAAK,CAAC,QAAQ,GAAG,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACnE,CAAC;AAfD,0DAeC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport * as sanitizeUtils from './sanitizeUtils';\n\n// Note: All CLI commands will set process.exitCode to the numerical value of\n// a thrown CodedError. However node reserves codes 1-192 as per:\n// https://nodejs.org/api/process.html#process_exit_codes so we shouldn't\n// override those as other tools may be monitoring the error code\n\nexport const CodedErrors = {\n Success: 0,\n Unknown: -1,\n\n // react-native-windows-init\n UnsupportedReactNativeVersion: 1000,\n UserCancel: 1001,\n NoReactNativeFound: 1002,\n NoPackageJson: 1003,\n NoLatestReactNativeWindows: 1004,\n NoAutoMatchingReactNativeWindows: 1005,\n IncompatibleOptions: 1006,\n NoReactNativeDependencies: 1007,\n NoMatchingPackageVersion: 1008,\n\n // run-windows\n NoSolution: 2000,\n // Project generation\n NoPropertyInProject: 2100,\n CopyProjectTemplateNoSourcePath: 2101,\n CopyProjectTemplateNoDestPath: 2102,\n CopyProjectTemplateNoProjectName: 2103,\n // SDK requirements\n MinSDKVersionNotMet: 2200,\n BadSDKVersionFormat: 2201,\n NoSDK: 2202,\n // Build\n NoMSBuild: 2300,\n NoVSWhere: 2301,\n MSBuildError: 2302,\n // Deploy\n NoAppPackage: 2400,\n NoAppxManifest: 2401,\n NoDevice: 2402,\n AppDidNotDeploy: 2403,\n InvalidDevicesOutput: 2404,\n RemoveOldAppVersionFailure: 2405,\n EnableDevModeFailure: 2406,\n InstallAppFailure: 2407,\n InstallAppDependenciesFailure: 2408,\n CheckNetIsolationFailure: 2409,\n InstallAppToDeviceFailure: 2410,\n UninstallAppOnDeviceFailure: 2411,\n DeployRecipeFailure: 2412,\n // Launch\n AppStartupFailure: 2500,\n\n // autolink-windows\n NoWindowsConfig: 3000,\n IncompleteConfig: 3001,\n InvalidConfig: 3002,\n NeedAutolinking: 3003,\n AddProjectToSolution: 3004,\n Autolinking: 3005,\n\n // codegen-windows\n NeedCodegen: 4000,\n InvalidCodegenConfig: 4001,\n\n // init-windows\n NoTemplatesFound: 5000,\n NoDefaultTemplate: 5001,\n InvalidTemplateName: 5002,\n NoProjectName: 5003,\n InvalidProjectName: 5004,\n InvalidProjectNamespace: 5005,\n};\n\nexport type CodedErrorType = keyof typeof CodedErrors;\n\n/**\n * Represents an error whose message might contain user-originating content,\n * therefore when transmitting telemetry, only the type should be sent.\n * @param type a stable ID identifying the type of error.\n * @param message the error text. This should only be used for display to the user.\n * @param data any additional metadata that is safe to collect for telemetry purposes.\n */\nexport class CodedError extends Error {\n constructor(\n public readonly type: CodedErrorType,\n message: string,\n public readonly data?: Record<string, any>,\n ) {\n super(message);\n this.name = type;\n }\n}\n\nexport interface ErrorStackFrame {\n functionName?: string;\n filePath?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\n/**\n * Tries to parse an error code out of an error message.\n * @param msg An error message to process.\n * @returns The parsed error code.\n */\nexport function tryGetErrorCode(msg: string): string | undefined {\n const errorRegEx = /error (\\w+\\d+):/gi;\n const m = errorRegEx.exec(msg);\n return m ? m[1] : undefined;\n}\n\n/**\n * Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes (\"\").\n * @param msg The error message to sanitize.\n * @return The message with any paths anonymized.\n */\nexport function sanitizeErrorMessage(msg: string): string {\n const msBuildErrorMessage =\n /^\\d+:\\d+>(.*)(\\(\\d+,\\d+\\)): error (\\w+\\d+): (.*)/g;\n msg = msg.replace(msBuildErrorMessage, '[$1]$2: error $3: $4');\n\n const cpuThreadId = /^\\d+(:\\d+)?>/g;\n msg = msg.replace(cpuThreadId, '');\n\n const parts = msg.split(/['[\\]\"]/g);\n const clean = [];\n const pathRegEx =\n /(['[\"]?)([A-Za-z]:|\\\\)[\\\\/]([^<>:;,?\"*\\t\\r\\n|/\\\\]+[\\\\/])+([^<>:;,?\"*\\t\\r\\n|]+\\/?(['[\"]?))/gi;\n for (const part of parts) {\n if (pathRegEx.test(part)) {\n pathRegEx.lastIndex = -1;\n let matches: RegExpExecArray | null;\n let noPath = '';\n let last = 0;\n while ((matches = pathRegEx.exec(part))) {\n noPath +=\n part.substr(last, matches!.index - last) +\n sanitizeUtils.getAnonymizedPath(matches[0]);\n last = matches!.index + matches![0].length;\n }\n if (noPath !== '') {\n clean.push(noPath);\n }\n } else if (part !== '') {\n clean.push(part);\n }\n }\n return clean.join('').trim();\n}\n\n/**\n * Sanitizes an error stack frame.\n * @param frame\n */\nexport function sanitizeErrorStackFrame(frame: ErrorStackFrame): void {\n if (frame.functionName) {\n const leftParenthesisIndex = frame.functionName.indexOf('(');\n if (leftParenthesisIndex !== -1) {\n // case 1: method === 'methodName (rootOfThePath'\n frame.functionName = frame.functionName\n .substr(0, leftParenthesisIndex)\n .trim();\n } else {\n // case 2: method === <no_method> or something without '(', fileName is full path\n }\n }\n\n // anonymize the filePath\n frame.filePath = sanitizeUtils.getAnonymizedPath(frame.filePath);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ * @format
5
+ */
6
+ export declare function isValidTelemetryPackageName(name: string): boolean;
7
+ export declare function cleanTelemetryPackageName(str: string): string;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ * Licensed under the MIT License.
5
+ * @format
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.cleanTelemetryPackageName = exports.isValidTelemetryPackageName = void 0;
9
+ function isValidTelemetryPackageName(name) {
10
+ // Accepted characters: alphanumeric, underscore, dot, starts with letter.
11
+ // Size: 1-100 characters.
12
+ if (name.match(/^[a-zA-Z][a-zA-Z0-9_.]{0,99}$/gi)) {
13
+ return true;
14
+ }
15
+ return false;
16
+ }
17
+ exports.isValidTelemetryPackageName = isValidTelemetryPackageName;
18
+ function cleanTelemetryPackageName(str) {
19
+ return str.replace(/[^a-zA-Z0-9_.]/g, '_').slice(0, 100);
20
+ }
21
+ exports.cleanTelemetryPackageName = cleanTelemetryPackageName;
22
+ //# sourceMappingURL=nameUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nameUtils.js","sourceRoot":"","sources":["../../src/utils/nameUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,SAAgB,2BAA2B,CAAC,IAAY;IACtD,0EAA0E;IAC1E,0BAA0B;IAC1B,IAAI,IAAI,CAAC,KAAK,CAAC,iCAAiC,CAAC,EAAE;QACjD,OAAO,IAAI,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAPD,kEAOC;AAED,SAAgB,yBAAyB,CAAC,GAAW;IACnD,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAFD,8DAEC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nexport function isValidTelemetryPackageName(name: string): boolean {\n // Accepted characters: alphanumeric, underscore, dot, starts with letter.\n // Size: 1-100 characters.\n if (name.match(/^[a-zA-Z][a-zA-Z0-9_.]{0,99}$/gi)) {\n return true;\n }\n return false;\n}\n\nexport function cleanTelemetryPackageName(str: string): string {\n return str.replace(/[^a-zA-Z0-9_.]/g, '_').slice(0, 100);\n}\n"]}
@@ -9,4 +9,4 @@
9
9
  * @param projectRoot Optional root path for the project. Defaults to process.cwd().
10
10
  * @returns The anonymized path.
11
11
  */
12
- export declare function getAnonymizedPath(filepath: string, projectRoot?: string): string;
12
+ export declare function getAnonymizedPath(filepath: string | undefined, projectRoot?: string): string;
@@ -25,6 +25,9 @@ const knownEnvironmentVariablePaths = [
25
25
  * @returns The anonymized path.
26
26
  */
27
27
  function getAnonymizedPath(filepath, projectRoot) {
28
+ if (filepath === undefined) {
29
+ return '[path]';
30
+ }
28
31
  projectRoot = (projectRoot !== null && projectRoot !== void 0 ? projectRoot : process.cwd())
29
32
  .replace(/\//g, '\\')
30
33
  .toLowerCase();
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeUtils.js","sourceRoot":"","sources":["../../src/utils/sanitizeUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AAExB,4CAAgD;AAEhD,MAAM,WAAW,GAAG,kBAAkB,CAAC;AACvC,MAAM,OAAO,GAAG,aAAa,CAAC;AAE9B,MAAM,6BAA6B,GAAG;IACpC,SAAS;IACT,cAAc;IACd,aAAa;CACd,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,QAAgB,EAChB,WAAoB;IAEpB,WAAW,GAAG,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,OAAO,CAAC,GAAG,EAAE,CAAC;SACzC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;SACpB,WAAW,EAAE,CAAC;IACjB,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC;QACtC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1B,CAAC,CAAC,WAAW,CAAC;IAChB,QA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AAI,IAAI,KAAK,IAAI,EAAE;gBAChC,OAAO,eAAe,CAAC;aACxB;iBAAM;gBACL,OAAO,qBAAqB,GAAG,IAC7B,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC9C,GAAG,CAAC;aACL;SACF;KACF;IAED,2DAA2D;IAC3D,KAAK,MAAM,SAAS,IAAI,6BAA6B,EAAE;QACrD,IACE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;YACtB,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,WAAW,EAAE,CAAC,EACxE;YACA,OAAO,IAAI,SAAS,UAClB,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,MAC5C,GAAG,CAAC;SACL;KACF;IAED,+CAA+C;IAC/C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAzED,8CAyEC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\n\nimport {NpmPackagesWeTrack} from '../telemetry';\n\nconst nodeModules = '\\\\node_modules\\\\';\nconst windows = '\\\\windows\\\\';\n\nconst knownEnvironmentVariablePaths = [\n 'AppData',\n 'LocalAppData',\n 'UserProfile',\n];\n\n/**\n * Gets an anonymized version of the given path, suitable for Telemetry.\n * @param filepath The path to anonymize.\n * @param projectRoot Optional root path for the project. Defaults to process.cwd().\n * @returns The anonymized path.\n */\nexport function getAnonymizedPath(\n filepath: string,\n projectRoot?: string,\n): string {\n projectRoot = (projectRoot ?? process.cwd())\n .replace(/\\//g, '\\\\')\n .toLowerCase();\n projectRoot = projectRoot.endsWith('\\\\')\n ? projectRoot.slice(0, -1)\n : projectRoot;\n filepath = filepath.replace(/\\//g, '\\\\');\n\n const ext = path.extname(filepath);\n\n // Check if we're under node_modules\n const nodeModulesIndex = filepath.toLowerCase().lastIndexOf(nodeModules);\n if (nodeModulesIndex >= 0) {\n // We are under node_modules\n\n // Check if it's an npm package we're tracking\n for (const trackedNpmPackage of NpmPackagesWeTrack) {\n const startIndex = filepath\n .toLowerCase()\n .lastIndexOf(\n nodeModules + trackedNpmPackage.replace(/\\//g, '\\\\') + '\\\\',\n );\n if (startIndex >= 0) {\n // We are under node_modules within an npm package we're tracking, anonymize by removing root\n return (\n '[node_modules]\\\\' + filepath.slice(startIndex + nodeModules.length)\n );\n }\n }\n\n // It's an npm package we're not tracking, anonymize with [node_modules]\n return `[node_modules]\\\\???${ext}(${\n filepath.slice(nodeModulesIndex).length - nodeModules.length\n })`;\n }\n\n // Check if we're under the projectRoot\n if (filepath.toLowerCase().startsWith(projectRoot)) {\n // We are under the projectRoot\n const rest = filepath.slice(projectRoot.length);\n if (rest.toLowerCase().startsWith(windows)) {\n // We are under the windows path, anonymize with [windows]\n return `[windows]\\\\???${ext}(${rest.length - windows.length})`;\n } else {\n // We are just within the projectRoot, anonymize with [project_dir]\n if (rest === '' || rest === '\\\\') {\n return '[project_dir]';\n } else {\n return `[project_dir]\\\\???${ext}(${\n rest.length - (rest.startsWith('\\\\') ? 1 : 0)\n })`;\n }\n }\n }\n\n // Check if we're under a known environmental variable path\n for (const knownPath of knownEnvironmentVariablePaths) {\n if (\n process.env[knownPath] &&\n filepath.toLowerCase().startsWith(process.env[knownPath]!.toLowerCase())\n ) {\n return `[${knownPath}]\\\\???(${\n filepath.length - process.env[knownPath]!.length\n })`;\n }\n }\n\n // We are somewhere else, anonymize with [path]\n return '[path]';\n}\n"]}
1
+ {"version":3,"file":"sanitizeUtils.js","sourceRoot":"","sources":["../../src/utils/sanitizeUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AAExB,4CAAgD;AAEhD,MAAM,WAAW,GAAG,kBAAkB,CAAC;AACvC,MAAM,OAAO,GAAG,aAAa,CAA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.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\n\nimport {NpmPackagesWeTrack} from '../telemetry';\n\nconst nodeModules = '\\\\node_modules\\\\';\nconst windows = '\\\\windows\\\\';\n\nconst knownEnvironmentVariablePaths = [\n 'AppData',\n 'LocalAppData',\n 'UserProfile',\n];\n\n/**\n * Gets an anonymized version of the given path, suitable for Telemetry.\n * @param filepath The path to anonymize.\n * @param projectRoot Optional root path for the project. Defaults to process.cwd().\n * @returns The anonymized path.\n */\nexport function getAnonymizedPath(\n filepath: string | undefined,\n projectRoot?: string,\n): string {\n if (filepath === undefined) {\n return '[path]';\n }\n\n projectRoot = (projectRoot ?? process.cwd())\n .replace(/\\//g, '\\\\')\n .toLowerCase();\n projectRoot = projectRoot.endsWith('\\\\')\n ? projectRoot.slice(0, -1)\n : projectRoot;\n filepath = filepath.replace(/\\//g, '\\\\');\n\n const ext = path.extname(filepath);\n\n // Check if we're under node_modules\n const nodeModulesIndex = filepath.toLowerCase().lastIndexOf(nodeModules);\n if (nodeModulesIndex >= 0) {\n // We are under node_modules\n\n // Check if it's an npm package we're tracking\n for (const trackedNpmPackage of NpmPackagesWeTrack) {\n const startIndex = filepath\n .toLowerCase()\n .lastIndexOf(\n nodeModules + trackedNpmPackage.replace(/\\//g, '\\\\') + '\\\\',\n );\n if (startIndex >= 0) {\n // We are under node_modules within an npm package we're tracking, anonymize by removing root\n return (\n '[node_modules]\\\\' + filepath.slice(startIndex + nodeModules.length)\n );\n }\n }\n\n // It's an npm package we're not tracking, anonymize with [node_modules]\n return `[node_modules]\\\\???${ext}(${\n filepath.slice(nodeModulesIndex).length - nodeModules.length\n })`;\n }\n\n // Check if we're under the projectRoot\n if (filepath.toLowerCase().startsWith(projectRoot)) {\n // We are under the projectRoot\n const rest = filepath.slice(projectRoot.length);\n if (rest.toLowerCase().startsWith(windows)) {\n // We are under the windows path, anonymize with [windows]\n return `[windows]\\\\???${ext}(${rest.length - windows.length})`;\n } else {\n // We are just within the projectRoot, anonymize with [project_dir]\n if (rest === '' || rest === '\\\\') {\n return '[project_dir]';\n } else {\n return `[project_dir]\\\\???${ext}(${\n rest.length - (rest.startsWith('\\\\') ? 1 : 0)\n })`;\n }\n }\n }\n\n // Check if we're under a known environmental variable path\n for (const knownPath of knownEnvironmentVariablePaths) {\n if (\n process.env[knownPath] &&\n filepath.toLowerCase().startsWith(process.env[knownPath]!.toLowerCase())\n ) {\n return `[${knownPath}]\\\\???(${\n filepath.length - process.env[knownPath]!.length\n })`;\n }\n }\n\n // We are somewhere else, anonymize with [path]\n return '[path]';\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-windows/telemetry",
3
- "version": "0.75.3",
3
+ "version": "0.75.5",
4
4
  "license": "MIT",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "typings": "lib-commonjs/index.d.ts",
@@ -18,10 +18,10 @@
18
18
  "watch": "rnw-scripts watch"
19
19
  },
20
20
  "dependencies": {
21
- "@azure/core-auth": "1.5.0",
21
+ "@microsoft/1ds-core-js": "^4.3.0",
22
+ "@microsoft/1ds-post-js": "^4.3.0",
22
23
  "@react-native-windows/fs": "0.75.2",
23
24
  "@xmldom/xmldom": "^0.7.7",
24
- "applicationinsights": "2.9.1",
25
25
  "ci-info": "^3.2.0",
26
26
  "envinfo": "^7.8.1",
27
27
  "lodash": "^4.17.21",
@@ -41,10 +41,10 @@
41
41
  "@typescript-eslint/parser": "^7.1.1",
42
42
  "babel-jest": "^29.6.3",
43
43
  "eslint": "^8.19.0",
44
- "jest": "^29.6.3",
44
+ "jest": "^29.7.0",
45
45
  "lookpath": "^1.2.1",
46
46
  "prettier": "2.8.8",
47
- "semver": "^7.3.5",
47
+ "semver": "^7.6.3",
48
48
  "typescript": "5.0.4"
49
49
  },
50
50
  "files": [