@react-native-windows/telemetry 0.0.0-canary.9 → 0.0.0-canary.91
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 +28 -0
- package/lib-commonjs/e2etest/telemetry.test.js +497 -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 +84 -27
- package/lib-commonjs/telemetry.js +370 -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 +138 -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 +166 -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 +81 -0
- package/lib-commonjs/utils/basePropUtils.js +174 -0
- package/lib-commonjs/utils/basePropUtils.js.map +1 -0
- package/lib-commonjs/utils/errorUtils.d.ts +87 -0
- package/lib-commonjs/utils/errorUtils.js +179 -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 +82 -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 +35 -21
- package/CHANGELOG.json +0 -125
- package/CHANGELOG.md +0 -63
- package/lib-commonjs/test/sanitize.test.js +0 -220
- package/lib-commonjs/test/sanitize.test.js.map +0 -1
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
8
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.getVersionsOfNuGetPackages = exports.getVersionOfNpmPackage = exports.getVisualStudioVersion = exports.getYarnVersion = exports.getNpmVersion = exports.getNodeVersion = void 0;
|
|
12
|
+
const envinfo_1 = __importDefault(require("envinfo"));
|
|
13
|
+
const fs_1 = __importDefault(require("@react-native-windows/fs"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
const xmldom_1 = require("@xmldom/xmldom");
|
|
16
|
+
const xpath_1 = __importDefault(require("xpath"));
|
|
17
|
+
const msbuildSelect = xpath_1.default.useNamespaces({
|
|
18
|
+
msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Gets the version of node being used.
|
|
22
|
+
* @returns The version of node being used.
|
|
23
|
+
*/
|
|
24
|
+
async function getNodeVersion() {
|
|
25
|
+
return process.version.slice(1);
|
|
26
|
+
}
|
|
27
|
+
exports.getNodeVersion = getNodeVersion;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the version of npm installed, if available.
|
|
30
|
+
* @returns The version of npm installed, if available.
|
|
31
|
+
*/
|
|
32
|
+
async function getNpmVersion() {
|
|
33
|
+
try {
|
|
34
|
+
const info = await envinfo_1.default.helpers.getnpmInfo();
|
|
35
|
+
return info[1];
|
|
36
|
+
}
|
|
37
|
+
catch (_a) { }
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
exports.getNpmVersion = getNpmVersion;
|
|
41
|
+
/**
|
|
42
|
+
* Gets the version of yarn installed, if available.
|
|
43
|
+
* @returns The version of yarn installed, if available.
|
|
44
|
+
*/
|
|
45
|
+
async function getYarnVersion() {
|
|
46
|
+
try {
|
|
47
|
+
const info = await envinfo_1.default.helpers.getYarnInfo();
|
|
48
|
+
return info[1];
|
|
49
|
+
}
|
|
50
|
+
catch (_a) { }
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
exports.getYarnVersion = getYarnVersion;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the latest version of Visual Studio installed, if available.
|
|
56
|
+
* @returns The latest version of Visual Studio installed, if available.
|
|
57
|
+
*/
|
|
58
|
+
async function getVisualStudioVersion() {
|
|
59
|
+
try {
|
|
60
|
+
const info = await envinfo_1.default.helpers.getVisualStudioInfo();
|
|
61
|
+
const versions = info[1];
|
|
62
|
+
return versions.sort().slice(-1)[0].split(' ')[0];
|
|
63
|
+
}
|
|
64
|
+
catch (_a) { }
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
exports.getVisualStudioVersion = getVisualStudioVersion;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the version installed of the specified npm package.
|
|
70
|
+
* @param pkgName The npm package name.
|
|
71
|
+
* @returns The version installed, if available.
|
|
72
|
+
*/
|
|
73
|
+
async function getVersionOfNpmPackage(pkgName) {
|
|
74
|
+
try {
|
|
75
|
+
const pkgJsonPath = require.resolve(`${pkgName.trim()}/package.json`, {
|
|
76
|
+
paths: [process.cwd(), __dirname],
|
|
77
|
+
});
|
|
78
|
+
const pkgJson = await fs_1.default.readJsonFile(pkgJsonPath);
|
|
79
|
+
if (pkgJson.name === pkgName) {
|
|
80
|
+
return pkgJson.version;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (_a) { }
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
exports.getVersionOfNpmPackage = getVersionOfNpmPackage;
|
|
87
|
+
/**
|
|
88
|
+
* Reads and parses an XML file into a Document.
|
|
89
|
+
* @param filePath The path to the XML file.
|
|
90
|
+
* @returns The parsed Document.
|
|
91
|
+
*/
|
|
92
|
+
async function readXmlFile(filePath) {
|
|
93
|
+
const contents = await fs_1.default.readFile(filePath, 'utf-8');
|
|
94
|
+
return new xmldom_1.DOMParser().parseFromString(contents);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Gets the versions of the specified NuGet packages referenced in a packages.config file.
|
|
98
|
+
* @param projectDoc The XML document of the packages.config file.
|
|
99
|
+
* @param nugetPackages The NuGet package names to look for.
|
|
100
|
+
* @returns The mapping of NuGet package names and their versions.
|
|
101
|
+
*/
|
|
102
|
+
function getVersionsFromPackagesConfig(packagesConfigDoc, nugetPackages) {
|
|
103
|
+
const versions = {};
|
|
104
|
+
for (const pkgName of nugetPackages) {
|
|
105
|
+
const version = xpath_1.default.select1(`//packages/package[@id='${pkgName}']/@version`, packagesConfigDoc);
|
|
106
|
+
if (version) {
|
|
107
|
+
const versionValue = version.nodeValue;
|
|
108
|
+
if (versionValue !== null) {
|
|
109
|
+
versions[pkgName] = versionValue;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return versions;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Gets the versions of the specified NuGet packages referenced in a project file.
|
|
117
|
+
* @param projectDoc The XML document of the project file.
|
|
118
|
+
* @param nugetPackages The NuGet package names to look for.
|
|
119
|
+
* @returns The mapping of NuGet package names and their versions.
|
|
120
|
+
*/
|
|
121
|
+
function getVersionsFromProjectFile(projectDoc, nugetPackages) {
|
|
122
|
+
const versions = {};
|
|
123
|
+
for (const pkgName of nugetPackages) {
|
|
124
|
+
const version = msbuildSelect(`//msbuild:ItemGroup/msbuild:PackageReference[@Include='${pkgName}']/msbuild:Version`, projectDoc, true);
|
|
125
|
+
if (version) {
|
|
126
|
+
const versionValue = version.textContent;
|
|
127
|
+
if (versionValue !== null) {
|
|
128
|
+
versions[pkgName] = versionValue;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return versions;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Gets the versions of the specified NuGet packages referenced in a project file.
|
|
136
|
+
* @param projectFile Path to the native project file.
|
|
137
|
+
* @param nugetPackages The NuGet package names to look for.
|
|
138
|
+
* @returns The mapping of NuGet package names and their versions.
|
|
139
|
+
*/
|
|
140
|
+
async function getVersionsOfNuGetPackages(projectFile, nugetPackages) {
|
|
141
|
+
try {
|
|
142
|
+
// First check for the presence of a packages.config file
|
|
143
|
+
const packagesConfigFile = path_1.default.join(path_1.default.dirname(projectFile), 'packages.config');
|
|
144
|
+
const packagesConfigDoc = await readXmlFile(packagesConfigFile);
|
|
145
|
+
return getVersionsFromPackagesConfig(packagesConfigDoc, nugetPackages);
|
|
146
|
+
}
|
|
147
|
+
catch (_a) { }
|
|
148
|
+
try {
|
|
149
|
+
const projectDoc = await readXmlFile(projectFile);
|
|
150
|
+
return getVersionsFromProjectFile(projectDoc, nugetPackages);
|
|
151
|
+
}
|
|
152
|
+
catch (_b) { }
|
|
153
|
+
return {};
|
|
154
|
+
}
|
|
155
|
+
exports.getVersionsOfNuGetPackages = getVersionsOfNuGetPackages;
|
|
156
|
+
//# sourceMappingURL=versionUtils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versionUtils.js","sourceRoot":"","sources":["../../src/utils/versionUtils.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport envinfo from 'envinfo';\nimport fs from '@react-native-windows/fs';\nimport path from 'path';\nimport {DOMParser} from '@xmldom/xmldom';\nimport xpath from 'xpath';\n\nconst msbuildSelect = xpath.useNamespaces({\n msbuild: 'http://schemas.microsoft.com/developer/msbuild/2003',\n});\n\n/**\n * Gets the version of node being used.\n * @returns The version of node being used.\n */\nexport async function getNodeVersion(): Promise<string | null> {\n return process.version.slice(1);\n}\n\n/**\n * Gets the version of npm installed, if available.\n * @returns The version of npm installed, if available.\n */\nexport async function getNpmVersion(): Promise<string | null> {\n try {\n const info: any = await envinfo.helpers.getnpmInfo();\n return info[1] as string;\n } catch {}\n return null;\n}\n\n/**\n * Gets the version of yarn installed, if available.\n * @returns The version of yarn installed, if available.\n */\nexport async function getYarnVersion(): Promise<string | null> {\n try {\n const info: any = await envinfo.helpers.getYarnInfo();\n return info[1] as string;\n } catch {}\n return null;\n}\n\n/**\n * Gets the latest version of Visual Studio installed, if available.\n * @returns The latest version of Visual Studio installed, if available.\n */\nexport async function getVisualStudioVersion(): Promise<string | null> {\n try {\n const info: any = await envinfo.helpers.getVisualStudioInfo();\n const versions = info[1] as string[];\n return versions.sort().slice(-1)[0].split(' ')[0];\n } catch {}\n return null;\n}\n\n/**\n * Gets the version installed of the specified npm package.\n * @param pkgName The npm package name.\n * @returns The version installed, if available.\n */\nexport async function getVersionOfNpmPackage(\n pkgName: string,\n): Promise<string | null> {\n try {\n const pkgJsonPath = require.resolve(`${pkgName.trim()}/package.json`, {\n paths: [process.cwd(), __dirname],\n });\n const pkgJson = await fs.readJsonFile<{name: string; version: string}>(\n pkgJsonPath,\n );\n if (pkgJson.name === pkgName) {\n return pkgJson.version;\n }\n } catch {}\n return null;\n}\n\n/**\n * Reads and parses an XML file into a Document.\n * @param filePath The path to the XML file.\n * @returns The parsed Document.\n */\nasync function readXmlFile(filePath: string): Promise<Document> {\n const contents = await fs.readFile(filePath, 'utf-8');\n return new DOMParser().parseFromString(contents);\n}\n\n/**\n * Gets the versions of the specified NuGet packages referenced in a packages.config file.\n * @param projectDoc The XML document of the packages.config file.\n * @param nugetPackages The NuGet package names to look for.\n * @returns The mapping of NuGet package names and their versions.\n */\nfunction getVersionsFromPackagesConfig(\n packagesConfigDoc: Document,\n nugetPackages: string[],\n): Record<string, string> {\n const versions: Record<string, string> = {};\n for (const pkgName of nugetPackages) {\n const version = xpath.select1(\n `//packages/package[@id='${pkgName}']/@version`,\n packagesConfigDoc,\n );\n\n if (version) {\n const versionValue = (version as Attr).nodeValue;\n if (versionValue !== null) {\n versions[pkgName] = versionValue;\n }\n }\n }\n return versions;\n}\n\n/**\n * Gets the versions of the specified NuGet packages referenced in a project file.\n * @param projectDoc The XML document of the project file.\n * @param nugetPackages The NuGet package names to look for.\n * @returns The mapping of NuGet package names and their versions.\n */\nfunction getVersionsFromProjectFile(\n projectDoc: Document,\n nugetPackages: string[],\n): Record<string, string> {\n const versions: Record<string, string> = {};\n for (const pkgName of nugetPackages) {\n const version = msbuildSelect(\n `//msbuild:ItemGroup/msbuild:PackageReference[@Include='${pkgName}']/msbuild:Version`,\n projectDoc,\n true,\n );\n\n if (version) {\n const versionValue = (version as Node).textContent;\n if (versionValue !== null) {\n versions[pkgName] = versionValue;\n }\n }\n }\n return versions;\n}\n\n/**\n * Gets the versions of the specified NuGet packages referenced in a project file.\n * @param projectFile Path to the native project file.\n * @param nugetPackages The NuGet package names to look for.\n * @returns The mapping of NuGet package names and their versions.\n */\nexport async function getVersionsOfNuGetPackages(\n projectFile: string,\n nugetPackages: string[],\n): Promise<Record<string, string>> {\n try {\n // First check for the presence of a packages.config file\n const packagesConfigFile = path.join(\n path.dirname(projectFile),\n 'packages.config',\n );\n const packagesConfigDoc = await readXmlFile(packagesConfigFile);\n return getVersionsFromPackagesConfig(packagesConfigDoc, nugetPackages);\n } catch {}\n\n try {\n const projectDoc = await readXmlFile(projectFile);\n return getVersionsFromProjectFile(projectDoc, nugetPackages);\n } catch {}\n\n return {};\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-windows/telemetry",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.91",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"typings": "lib-commonjs/index.d.ts",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "
|
|
9
|
+
"url": "https://github.com/microsoft/react-native-windows",
|
|
10
10
|
"directory": "packages/@react-native-windows/telemetry"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
-
"clean": "
|
|
15
|
-
"lint": "
|
|
16
|
-
"lint:fix": "
|
|
17
|
-
"test": "set RNW_CLI_TEST=true&&
|
|
18
|
-
"watch": "
|
|
13
|
+
"build": "rnw-scripts build",
|
|
14
|
+
"clean": "rnw-scripts clean",
|
|
15
|
+
"lint": "rnw-scripts lint",
|
|
16
|
+
"lint:fix": "rnw-scripts lint:fix",
|
|
17
|
+
"test": "set RNW_CLI_TEST=true&&set APPLICATION_INSIGHTS_NO_STATSBEAT=true&& rnw-scripts test",
|
|
18
|
+
"watch": "rnw-scripts watch"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
21
|
+
"@azure/core-auth": "1.5.0",
|
|
22
|
+
"@react-native-windows/fs": "0.0.0-canary.40",
|
|
23
|
+
"@xmldom/xmldom": "^0.7.7",
|
|
24
|
+
"applicationinsights": "2.9.1",
|
|
25
|
+
"ci-info": "^3.2.0",
|
|
26
|
+
"envinfo": "^7.8.1",
|
|
27
|
+
"lodash": "^4.17.21",
|
|
28
|
+
"os-locale": "^5.0.0",
|
|
29
|
+
"xpath": "^0.0.27"
|
|
22
30
|
},
|
|
23
31
|
"devDependencies": {
|
|
24
|
-
"@rnw-scripts/eslint-config": "
|
|
25
|
-
"@rnw-scripts/jest-unittest-config": "
|
|
26
|
-
"@rnw-scripts/just-task": "
|
|
27
|
-
"@rnw-scripts/ts-config": "0.
|
|
28
|
-
"@types/
|
|
32
|
+
"@rnw-scripts/eslint-config": "1.2.11",
|
|
33
|
+
"@rnw-scripts/jest-unittest-config": "1.5.8",
|
|
34
|
+
"@rnw-scripts/just-task": "2.3.27",
|
|
35
|
+
"@rnw-scripts/ts-config": "2.0.5",
|
|
36
|
+
"@types/envinfo": "^7.8.1",
|
|
37
|
+
"@types/jest": "^29.2.2",
|
|
38
|
+
"@types/node": "^18.0.0",
|
|
29
39
|
"@types/semver": "^7.3.3",
|
|
30
|
-
"
|
|
31
|
-
"eslint": "
|
|
32
|
-
"jest": "^
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
|
41
|
+
"@typescript-eslint/parser": "^5.57.1",
|
|
42
|
+
"babel-jest": "^29.6.3",
|
|
43
|
+
"eslint": "^8.19.0",
|
|
44
|
+
"jest": "^29.6.3",
|
|
45
|
+
"lookpath": "^1.2.1",
|
|
46
|
+
"prettier": "2.8.8",
|
|
47
|
+
"semver": "^7.3.5",
|
|
48
|
+
"typescript": "5.0.4"
|
|
36
49
|
},
|
|
37
50
|
"files": [
|
|
38
51
|
"lib-commonjs"
|
|
@@ -45,5 +58,6 @@
|
|
|
45
58
|
"patch"
|
|
46
59
|
]
|
|
47
60
|
},
|
|
48
|
-
"promoteRelease": true
|
|
61
|
+
"promoteRelease": true,
|
|
62
|
+
"windowsOnly": true
|
|
49
63
|
}
|
package/CHANGELOG.json
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@react-native-windows/telemetry",
|
|
3
|
-
"entries": [
|
|
4
|
-
{
|
|
5
|
-
"date": "Fri, 20 Nov 2020 05:06:58 GMT",
|
|
6
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.9",
|
|
7
|
-
"version": "0.0.0-canary.9",
|
|
8
|
-
"comments": {
|
|
9
|
-
"none": [
|
|
10
|
-
{
|
|
11
|
-
"comment": "Integrate 11/18 RN Nightly Build 🎉",
|
|
12
|
-
"author": "ngerlem@microsoft.com",
|
|
13
|
-
"commit": "aba9483ea47b6d992877b325cc858a7e6309ead4",
|
|
14
|
-
"package": "@react-native-windows/telemetry"
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"date": "Mon, 16 Nov 2020 14:39:19 GMT",
|
|
21
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.8",
|
|
22
|
-
"version": "0.0.0-canary.8",
|
|
23
|
-
"comments": {
|
|
24
|
-
"prerelease": [
|
|
25
|
-
{
|
|
26
|
-
"comment": "anonymize paths with forward slashes and file shares",
|
|
27
|
-
"author": "asklar@microsoft.com",
|
|
28
|
-
"commit": "04e766ef7304d0852a06e772cbfc1982897a3808",
|
|
29
|
-
"package": "@react-native-windows/telemetry"
|
|
30
|
-
}
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"date": "Thu, 12 Nov 2020 05:05:57 GMT",
|
|
36
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.7",
|
|
37
|
-
"version": "0.0.0-canary.7",
|
|
38
|
-
"comments": {
|
|
39
|
-
"prerelease": [
|
|
40
|
-
{
|
|
41
|
-
"comment": "Disable telemetry in other CI systems",
|
|
42
|
-
"author": "asklar@microsoft.com",
|
|
43
|
-
"commit": "bcda5759d5d1bed770e7a8524e5cc3f94cbc0c6a",
|
|
44
|
-
"package": "@react-native-windows/telemetry"
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"date": "Wed, 11 Nov 2020 05:05:29 GMT",
|
|
51
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.6",
|
|
52
|
-
"version": "0.0.0-canary.6",
|
|
53
|
-
"comments": {
|
|
54
|
-
"prerelease": [
|
|
55
|
-
{
|
|
56
|
-
"comment": "Silence warnings from appinsights in production",
|
|
57
|
-
"author": "asklar@microsoft.com",
|
|
58
|
-
"commit": "1893d23fce2daedbf55ae90c5f6775141400f401",
|
|
59
|
-
"package": "@react-native-windows/telemetry"
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"date": "Sat, 07 Nov 2020 05:04:58 GMT",
|
|
66
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.5",
|
|
67
|
-
"version": "0.0.0-canary.5",
|
|
68
|
-
"comments": {
|
|
69
|
-
"prerelease": [
|
|
70
|
-
{
|
|
71
|
-
"comment": "Fix casing of msft domain",
|
|
72
|
-
"author": "asklar@microsoft.com",
|
|
73
|
-
"commit": "038cecd6638df6df39988fca433a104e82b3423e",
|
|
74
|
-
"package": "@react-native-windows/telemetry"
|
|
75
|
-
}
|
|
76
|
-
]
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"date": "Fri, 06 Nov 2020 05:06:31 GMT",
|
|
81
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.4",
|
|
82
|
-
"version": "0.0.0-canary.4",
|
|
83
|
-
"comments": {
|
|
84
|
-
"prerelease": [
|
|
85
|
-
{
|
|
86
|
-
"comment": "Remove roleInstance property",
|
|
87
|
-
"author": "asklar@microsoft.com",
|
|
88
|
-
"commit": "9254556d1726e6bec145a50c9935fae868060444",
|
|
89
|
-
"package": "@react-native-windows/telemetry"
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"date": "Thu, 05 Nov 2020 17:30:59 GMT",
|
|
96
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.3",
|
|
97
|
-
"version": "0.0.0-canary.3",
|
|
98
|
-
"comments": {
|
|
99
|
-
"prerelease": [
|
|
100
|
-
{
|
|
101
|
-
"comment": "sanitize paths in other drives too",
|
|
102
|
-
"author": "asklar@microsoft.com",
|
|
103
|
-
"commit": "10d82a2167557800fd518a13c170bdc7e7bffc14",
|
|
104
|
-
"package": "@react-native-windows/telemetry"
|
|
105
|
-
}
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"date": "Thu, 05 Nov 2020 05:05:45 GMT",
|
|
111
|
-
"tag": "@react-native-windows/telemetry_v0.0.0-canary.2",
|
|
112
|
-
"version": "0.0.0-canary.2",
|
|
113
|
-
"comments": {
|
|
114
|
-
"prerelease": [
|
|
115
|
-
{
|
|
116
|
-
"comment": "Create telemetry package",
|
|
117
|
-
"author": "asklar@microsoft.com",
|
|
118
|
-
"commit": "61cc42e7f9b4dec313597fba6e99c6f22badbf7e",
|
|
119
|
-
"package": "@react-native-windows/telemetry"
|
|
120
|
-
}
|
|
121
|
-
]
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# Change Log - @react-native-windows/telemetry
|
|
2
|
-
|
|
3
|
-
This log was last generated on Mon, 16 Nov 2020 14:39:19 GMT and should not be manually modified.
|
|
4
|
-
|
|
5
|
-
<!-- Start content -->
|
|
6
|
-
|
|
7
|
-
## 0.0.0-canary.8
|
|
8
|
-
|
|
9
|
-
Mon, 16 Nov 2020 14:39:19 GMT
|
|
10
|
-
|
|
11
|
-
### Changes
|
|
12
|
-
|
|
13
|
-
- anonymize paths with forward slashes and file shares (asklar@microsoft.com)
|
|
14
|
-
|
|
15
|
-
## 0.0.0-canary.7
|
|
16
|
-
|
|
17
|
-
Thu, 12 Nov 2020 05:05:57 GMT
|
|
18
|
-
|
|
19
|
-
### Changes
|
|
20
|
-
|
|
21
|
-
- Disable telemetry in other CI systems (asklar@microsoft.com)
|
|
22
|
-
|
|
23
|
-
## 0.0.0-canary.6
|
|
24
|
-
|
|
25
|
-
Wed, 11 Nov 2020 05:05:29 GMT
|
|
26
|
-
|
|
27
|
-
### Changes
|
|
28
|
-
|
|
29
|
-
- Silence warnings from appinsights in production (asklar@microsoft.com)
|
|
30
|
-
|
|
31
|
-
## 0.0.0-canary.5
|
|
32
|
-
|
|
33
|
-
Sat, 07 Nov 2020 05:04:58 GMT
|
|
34
|
-
|
|
35
|
-
### Changes
|
|
36
|
-
|
|
37
|
-
- Fix casing of msft domain (asklar@microsoft.com)
|
|
38
|
-
|
|
39
|
-
## 0.0.0-canary.4
|
|
40
|
-
|
|
41
|
-
Fri, 06 Nov 2020 05:06:31 GMT
|
|
42
|
-
|
|
43
|
-
### Changes
|
|
44
|
-
|
|
45
|
-
- Remove roleInstance property (asklar@microsoft.com)
|
|
46
|
-
|
|
47
|
-
## 0.0.0-canary.3
|
|
48
|
-
|
|
49
|
-
Thu, 05 Nov 2020 17:30:59 GMT
|
|
50
|
-
|
|
51
|
-
### Changes
|
|
52
|
-
|
|
53
|
-
- sanitize paths in other drives too (asklar@microsoft.com)
|
|
54
|
-
|
|
55
|
-
## 0.0.0-canary.2
|
|
56
|
-
|
|
57
|
-
Thu, 05 Nov 2020 05:05:45 GMT
|
|
58
|
-
|
|
59
|
-
### Changes
|
|
60
|
-
|
|
61
|
-
- Create telemetry package (asklar@microsoft.com)
|
|
62
|
-
|
|
63
|
-
# Change Log - @react-native-windows/telemetry
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) Microsoft Corporation.
|
|
4
|
-
* Licensed under the MIT License.
|
|
5
|
-
*
|
|
6
|
-
* @format
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const telemetry_1 = require("../telemetry");
|
|
10
|
-
const path_1 = require("path");
|
|
11
|
-
delete process.env.AGENT_NAME; // allow this test to run in Azure DevOps / GHA
|
|
12
|
-
telemetry_1.Telemetry.setup();
|
|
13
|
-
telemetry_1.Telemetry.client.config.disableAppInsights = true;
|
|
14
|
-
test('Sanitize message, no-op', () => {
|
|
15
|
-
// do stuff
|
|
16
|
-
expect(telemetry_1.sanitizeMessage('')).toEqual('');
|
|
17
|
-
expect(telemetry_1.sanitizeMessage('some text')).toEqual('some text');
|
|
18
|
-
});
|
|
19
|
-
test('Sanitize message, project_dir', () => {
|
|
20
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: '${process.cwd()}'`)).toEqual(`this is the cwd: [project_dir]\\???(${process.cwd().length})`);
|
|
21
|
-
expect(telemetry_1.sanitizeMessage(`uppercase: '${process.cwd().toUpperCase()}'`)).toEqual(`uppercase: [project_dir]\\???(${process.cwd().length})`);
|
|
22
|
-
expect(telemetry_1.sanitizeMessage(`lowercase: '${process.cwd().toLowerCase()}'`)).toEqual(`lowercase: [project_dir]\\???(${process.cwd().length})`);
|
|
23
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: '${process.cwd()}' and something else`)).toEqual(`this is the cwd: [project_dir]\\???(${process.cwd().length}) and something else`);
|
|
24
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: ${process.cwd()} and something else`)).toEqual(`this is the cwd: [project_dir]\\???(${(process.cwd() + ' and something else').length})`);
|
|
25
|
-
});
|
|
26
|
-
test('Sanitize message, node_modules', () => {
|
|
27
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: '${process.cwd()}\\node_modules'`)).toEqual(`this is the cwd: [project_dir]\\???(${(process.cwd() + '\\node_modules').length})`);
|
|
28
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: '${process.cwd()}\\node_modules\\foo'`)).toEqual('this is the cwd: node_modules\\foo');
|
|
29
|
-
expect(telemetry_1.sanitizeMessage(`uppercase: '${process.cwd().toUpperCase()}\\NODE_MODULES\\foo'`)).toEqual('uppercase: node_modules\\foo');
|
|
30
|
-
expect(telemetry_1.sanitizeMessage(`lowercase: '${process.cwd().toLowerCase()}\\NODE_MODULES\\'`)).toEqual('lowercase: node_modules\\');
|
|
31
|
-
expect(telemetry_1.sanitizeMessage(`trailing: '${process.cwd()}\\node_modules\\' and something else`)).toEqual('trailing: node_modules\\ and something else');
|
|
32
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: ${process.cwd()}\\node_modules and something else that could be part of the path`)).toEqual(`this is the cwd: [project_dir]\\???(${(process.cwd() +
|
|
33
|
-
'\\node_modules and something else that could be part of the path').length})`);
|
|
34
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: ${process.cwd()}\\node_modules\\ a file under nm`)).toEqual(`this is the cwd: node_modules\\ a file under nm`);
|
|
35
|
-
});
|
|
36
|
-
test('Sanitize message, other path', () => {
|
|
37
|
-
expect(telemetry_1.sanitizeMessage(`this is another path: 'A:\\foo\\bar\\baz'`)).toEqual(`this is another path: [path]`);
|
|
38
|
-
expect(telemetry_1.sanitizeMessage(`this is another path: A:\\foo\\bar\\baz`)).toEqual(`this is another path: [path]`);
|
|
39
|
-
expect(telemetry_1.sanitizeMessage(`Cannot find module 'react-native/package.json'
|
|
40
|
-
Require stack:
|
|
41
|
-
- ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\lib-commonjs\\Cli.js
|
|
42
|
-
- ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\bin.js`)).toEqual(`Cannot find module react-native/package.json
|
|
43
|
-
Require stack:
|
|
44
|
-
- [AppData]\\???(${(process.env.AppData +
|
|
45
|
-
'\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\lib-commonjs\\Cli.js').length})
|
|
46
|
-
- [AppData]\\???(${(process.env.AppData +
|
|
47
|
-
'\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\bin.js').length})`);
|
|
48
|
-
});
|
|
49
|
-
test('Sanitize message, forward slashes', () => {
|
|
50
|
-
expect(telemetry_1.sanitizeMessage(`EPERM: operation not permitted, scandir ${process.env.UserProfile.replace(/\\/g, '/')}/source/repos/rn2/wintest/windows/packages/boost.1.72.0.0/lib/native/include`)).toEqual(`EPERM: operation not permitted, scandir [UserProfile]\\???(${(process.env.UserProfile +
|
|
51
|
-
'/source/repos/rn2/wintest/windows/packages/boost.1.72.0.0/lib/native/include').length})`);
|
|
52
|
-
});
|
|
53
|
-
test('Sanitize message, file share path', () => {
|
|
54
|
-
expect(telemetry_1.sanitizeMessage(`\\\\server\\share`)).toEqual('[path]');
|
|
55
|
-
});
|
|
56
|
-
test('Sanitize message, with cpu/thread id', () => {
|
|
57
|
-
expect(telemetry_1.sanitizeMessage('5>This is an error')).toEqual('This is an error');
|
|
58
|
-
expect(telemetry_1.sanitizeMessage('5:42>This is an error')).toEqual('This is an error');
|
|
59
|
-
});
|
|
60
|
-
test('Error code', () => {
|
|
61
|
-
expect(telemetry_1.tryGetErrorCode('foo bar error FOO2020: the thing')).toEqual('FOO2020');
|
|
62
|
-
});
|
|
63
|
-
test('Sanitize stack frame', () => {
|
|
64
|
-
const emptyFrame = {
|
|
65
|
-
level: 0,
|
|
66
|
-
method: '',
|
|
67
|
-
fileName: '',
|
|
68
|
-
assembly: 'asdf',
|
|
69
|
-
line: 0,
|
|
70
|
-
};
|
|
71
|
-
telemetry_1.sanitizeFrame(emptyFrame);
|
|
72
|
-
expect(emptyFrame).toEqual({
|
|
73
|
-
level: 0,
|
|
74
|
-
assembly: '',
|
|
75
|
-
fileName: '.',
|
|
76
|
-
method: '',
|
|
77
|
-
line: 0,
|
|
78
|
-
});
|
|
79
|
-
const frame1 = {
|
|
80
|
-
method: '',
|
|
81
|
-
fileName: `${process.cwd()}\\foo.js`,
|
|
82
|
-
assembly: 'asdf',
|
|
83
|
-
level: 0,
|
|
84
|
-
line: 0,
|
|
85
|
-
};
|
|
86
|
-
telemetry_1.sanitizeFrame(frame1);
|
|
87
|
-
expect(frame1).toEqual({
|
|
88
|
-
assembly: '',
|
|
89
|
-
fileName: 'telemetry\\foo.js',
|
|
90
|
-
method: '',
|
|
91
|
-
level: 0,
|
|
92
|
-
line: 0,
|
|
93
|
-
});
|
|
94
|
-
const frame2 = {
|
|
95
|
-
method: `myMethod (something ${process.cwd()}`,
|
|
96
|
-
fileName: `${process.cwd()}\\foo.js`,
|
|
97
|
-
assembly: 'asdf',
|
|
98
|
-
level: 1,
|
|
99
|
-
line: 42,
|
|
100
|
-
};
|
|
101
|
-
telemetry_1.sanitizeFrame(frame2);
|
|
102
|
-
expect(frame2).toEqual({
|
|
103
|
-
assembly: '',
|
|
104
|
-
fileName: 'telemetry\\foo.js',
|
|
105
|
-
method: 'myMethod',
|
|
106
|
-
level: 1,
|
|
107
|
-
line: 42,
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
test('basic setup', () => {
|
|
111
|
-
expect(telemetry_1.Telemetry.client.commonProperties.sessionId).toBeDefined();
|
|
112
|
-
expect(telemetry_1.Telemetry.client.commonProperties.sessionId.length).toBeGreaterThanOrEqual(32);
|
|
113
|
-
expect(telemetry_1.Telemetry.client.commonProperties.isTest).toEqual('true');
|
|
114
|
-
});
|
|
115
|
-
function b(s) {
|
|
116
|
-
throw new Error('hello ' + s);
|
|
117
|
-
}
|
|
118
|
-
function a(s) {
|
|
119
|
-
b(s);
|
|
120
|
-
}
|
|
121
|
-
test('thrown exception a->b, hello world', done => {
|
|
122
|
-
let pass = false;
|
|
123
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
|
|
124
|
-
if (envelope.data.baseType === 'ExceptionData') {
|
|
125
|
-
const data = envelope.data.baseData;
|
|
126
|
-
expect(data.exceptions).toBeDefined();
|
|
127
|
-
expect(data.exceptions.length).toEqual(1);
|
|
128
|
-
expect(data.exceptions[0].message).toEqual('hello world');
|
|
129
|
-
const stack = data.exceptions[0].parsedStack;
|
|
130
|
-
expect(stack).toBeDefined();
|
|
131
|
-
expect(stack.length).toBeGreaterThan(5);
|
|
132
|
-
const filename = path_1.basename(__filename);
|
|
133
|
-
expect(stack[0].method).toEqual('b');
|
|
134
|
-
expect(stack[1].method).toEqual('b');
|
|
135
|
-
expect(stack[2].method).toEqual('Object.a');
|
|
136
|
-
expect(stack[0].fileName).toEqual(`test\\${filename}`);
|
|
137
|
-
expect(stack[1].fileName).toEqual(`test\\${filename}`);
|
|
138
|
-
expect(stack[2].fileName).toEqual(`test\\${filename}`);
|
|
139
|
-
pass = true;
|
|
140
|
-
}
|
|
141
|
-
return true;
|
|
142
|
-
});
|
|
143
|
-
try {
|
|
144
|
-
a('world');
|
|
145
|
-
}
|
|
146
|
-
catch (e) {
|
|
147
|
-
telemetry_1.Telemetry.client.trackException({ exception: e });
|
|
148
|
-
}
|
|
149
|
-
telemetry_1.Telemetry.client.flush();
|
|
150
|
-
expect(pass).toBeTruthy();
|
|
151
|
-
telemetry_1.Telemetry.client.clearTelemetryProcessors();
|
|
152
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor(telemetry_1.sanitizeEnvelope);
|
|
153
|
-
done();
|
|
154
|
-
});
|
|
155
|
-
test('throw exception with error code', done => {
|
|
156
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
|
|
157
|
-
const data = envelope.data.baseData;
|
|
158
|
-
expect(data.properties.errorCode).toEqual('FOO2020');
|
|
159
|
-
return true;
|
|
160
|
-
});
|
|
161
|
-
try {
|
|
162
|
-
throw new Error('hello from an error FOO2020: the error string');
|
|
163
|
-
}
|
|
164
|
-
catch (e) {
|
|
165
|
-
telemetry_1.Telemetry.client.trackException({ exception: e });
|
|
166
|
-
telemetry_1.Telemetry.client.flush();
|
|
167
|
-
}
|
|
168
|
-
telemetry_1.Telemetry.client.clearTelemetryProcessors();
|
|
169
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor(telemetry_1.sanitizeEnvelope);
|
|
170
|
-
done();
|
|
171
|
-
});
|
|
172
|
-
test('thrown exception a->b, hello path', done => {
|
|
173
|
-
let pass = false;
|
|
174
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
|
|
175
|
-
if (envelope.data.baseType === 'ExceptionData') {
|
|
176
|
-
const data = envelope.data.baseData;
|
|
177
|
-
expect(data.exceptions).toBeDefined();
|
|
178
|
-
expect(data.exceptions.length).toEqual(1);
|
|
179
|
-
expect(data.exceptions[0].message).toEqual(`hello [project_dir]\\???(${process.cwd().length})`);
|
|
180
|
-
const stack = data.exceptions[0].parsedStack;
|
|
181
|
-
expect(stack).toBeDefined();
|
|
182
|
-
expect(stack.length).toBeGreaterThan(5);
|
|
183
|
-
const filename = path_1.basename(__filename);
|
|
184
|
-
expect(stack[0].method).toEqual('b');
|
|
185
|
-
expect(stack[1].method).toEqual('b');
|
|
186
|
-
expect(stack[2].method).toEqual('Object.a');
|
|
187
|
-
expect(stack[0].fileName).toEqual(`test\\${filename}`);
|
|
188
|
-
expect(stack[1].fileName).toEqual(`test\\${filename}`);
|
|
189
|
-
expect(stack[2].fileName).toEqual(`test\\${filename}`);
|
|
190
|
-
pass = true;
|
|
191
|
-
}
|
|
192
|
-
return true;
|
|
193
|
-
});
|
|
194
|
-
try {
|
|
195
|
-
a(process.cwd());
|
|
196
|
-
}
|
|
197
|
-
catch (e) {
|
|
198
|
-
telemetry_1.Telemetry.client.trackException({ exception: e });
|
|
199
|
-
}
|
|
200
|
-
telemetry_1.Telemetry.client.flush();
|
|
201
|
-
expect(pass).toBeTruthy();
|
|
202
|
-
expect(pass).toBeTruthy();
|
|
203
|
-
telemetry_1.Telemetry.client.clearTelemetryProcessors();
|
|
204
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor(telemetry_1.sanitizeEnvelope);
|
|
205
|
-
done();
|
|
206
|
-
});
|
|
207
|
-
test('trackEvent should not identify roleInstance', () => {
|
|
208
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
|
|
209
|
-
expect(envelope.tags['ai.cloud.roleInstance']).toBeUndefined();
|
|
210
|
-
return true;
|
|
211
|
-
});
|
|
212
|
-
telemetry_1.Telemetry.client.trackEvent({
|
|
213
|
-
name: 'test',
|
|
214
|
-
properties: {},
|
|
215
|
-
});
|
|
216
|
-
telemetry_1.Telemetry.client.flush();
|
|
217
|
-
telemetry_1.Telemetry.client.clearTelemetryProcessors();
|
|
218
|
-
telemetry_1.Telemetry.client.addTelemetryProcessor(telemetry_1.sanitizeEnvelope);
|
|
219
|
-
});
|
|
220
|
-
//# sourceMappingURL=sanitize.test.js.map
|