@react-native-windows/telemetry 0.69.0 → 0.70.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.
|
@@ -13,14 +13,23 @@ const child_process_1 = require("child_process");
|
|
|
13
13
|
const os_1 = require("os");
|
|
14
14
|
const ci_info_1 = __importDefault(require("ci-info"));
|
|
15
15
|
const crypto_1 = require("crypto");
|
|
16
|
-
const node_machine_id_1 = require("node-machine-id");
|
|
17
16
|
const os_locale_1 = __importDefault(require("os-locale"));
|
|
17
|
+
const DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\SQMClient';
|
|
18
|
+
const DeviceIdRegKey = 'MachineId';
|
|
18
19
|
/**
|
|
19
20
|
* Gets a telemetry-safe stable device ID.
|
|
20
21
|
* @returns A telemetry-safe stable device ID.
|
|
21
22
|
*/
|
|
22
23
|
async function deviceId() {
|
|
23
|
-
|
|
24
|
+
try {
|
|
25
|
+
const output = (0, child_process_1.execSync)(`${process.env.windir}\\System32\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`).toString();
|
|
26
|
+
const result = output.match(/\{([0-9A-Fa-f-]{36})\}/);
|
|
27
|
+
if (result && result.length > 1) {
|
|
28
|
+
return `s:${result[1]}`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (_a) { }
|
|
32
|
+
return '';
|
|
24
33
|
}
|
|
25
34
|
exports.deviceId = deviceId;
|
|
26
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basePropUtils.js","sourceRoot":"","sources":["../../src/utils/basePropUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAuC;AACvC,2BAAkD;AAElD,sDAAyB;AACzB,mCAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"basePropUtils.js","sourceRoot":"","sources":["../../src/utils/basePropUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AA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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, arch, 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 const output = execSync(\n `${process.env.windir}\\\\System32\\\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`,\n ).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 x64/arm64.\n * @returns The device architecture.\n */\nexport function deviceArchitecture(): string {\n return 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-windows/telemetry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"typings": "lib-commonjs/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"watch": "rnw-scripts watch"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@react-native-windows/fs": "0.
|
|
21
|
+
"@react-native-windows/fs": "0.70.0",
|
|
22
22
|
"@typescript-eslint/eslint-plugin": "^5.20.0",
|
|
23
23
|
"@typescript-eslint/parser": "^5.20.0",
|
|
24
24
|
"@xmldom/xmldom": "^0.7.5",
|
|
@@ -26,14 +26,13 @@
|
|
|
26
26
|
"ci-info": "^3.2.0",
|
|
27
27
|
"envinfo": "^7.8.1",
|
|
28
28
|
"lodash": "^4.17.21",
|
|
29
|
-
"node-machine-id": "^1.1.12",
|
|
30
29
|
"os-locale": "^5.0.0",
|
|
31
30
|
"xpath": "^0.0.27"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
|
-
"@rnw-scripts/eslint-config": "1.1.
|
|
35
|
-
"@rnw-scripts/jest-unittest-config": "1.2.
|
|
36
|
-
"@rnw-scripts/just-task": "2.2.
|
|
33
|
+
"@rnw-scripts/eslint-config": "1.1.13",
|
|
34
|
+
"@rnw-scripts/jest-unittest-config": "1.2.8",
|
|
35
|
+
"@rnw-scripts/just-task": "2.2.5",
|
|
37
36
|
"@rnw-scripts/ts-config": "2.0.2",
|
|
38
37
|
"@types/envinfo": "^7.8.1",
|
|
39
38
|
"@types/jest": "^26.0.20",
|
|
@@ -42,7 +41,6 @@
|
|
|
42
41
|
"babel-jest": "^26.3.0",
|
|
43
42
|
"eslint": "^7.32.0",
|
|
44
43
|
"jest": "^26.6.3",
|
|
45
|
-
"just-scripts": "^1.3.3",
|
|
46
44
|
"lookpath": "^1.2.1",
|
|
47
45
|
"prettier": "^2.4.1",
|
|
48
46
|
"semver": "^7.3.5",
|