@react-native-windows/telemetry 0.0.0-canary.20 → 0.0.0-canary.24
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/CHANGELOG.json +125 -1
- package/CHANGELOG.md +49 -6
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/telemetry.js +3 -3
- package/lib-commonjs/telemetry.js.map +1 -1
- package/lib-commonjs/test/sanitize.test.js +32 -31
- package/lib-commonjs/test/sanitize.test.js.map +1 -1
- package/package.json +11 -7
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,131 @@
|
|
|
2
2
|
"name": "@react-native-windows/telemetry",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "
|
|
5
|
+
"date": "Thu, 21 Oct 2021 05:07:06 GMT",
|
|
6
|
+
"tag": "@react-native-windows/telemetry_v0.0.0-canary.24",
|
|
7
|
+
"version": "0.0.0-canary.24",
|
|
8
|
+
"comments": {
|
|
9
|
+
"prerelease": [
|
|
10
|
+
{
|
|
11
|
+
"author": "30809111+acoates-ms@users.noreply.github.com",
|
|
12
|
+
"package": "@react-native-windows/telemetry",
|
|
13
|
+
"comment": "Update to typescript 4",
|
|
14
|
+
"commit": "8a0ffecdcf5e68d950f20380fdf62295edb352b6"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 08 Sep 2021 05:08:53 GMT",
|
|
21
|
+
"tag": "@react-native-windows/telemetry_v0.0.0-canary.23",
|
|
22
|
+
"version": "0.0.0-canary.23",
|
|
23
|
+
"comments": {
|
|
24
|
+
"prerelease": [
|
|
25
|
+
{
|
|
26
|
+
"comment": "Set consistent node requirements on our packages",
|
|
27
|
+
"author": "ngerlem@microsoft.com",
|
|
28
|
+
"commit": "2974ea0ab58b546264b8d9a4a7c12ceeb0a02851",
|
|
29
|
+
"package": "@react-native-windows/telemetry"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"patch": [
|
|
33
|
+
{
|
|
34
|
+
"comment": "Bump @rnw-scripts/jest-unittest-config to v1.2.4",
|
|
35
|
+
"author": "ngerlem@microsoft.com",
|
|
36
|
+
"commit": "2974ea0ab58b546264b8d9a4a7c12ceeb0a02851",
|
|
37
|
+
"package": "@react-native-windows/telemetry"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"comment": "Bump @rnw-scripts/just-task to v2.2.1",
|
|
41
|
+
"author": "ngerlem@microsoft.com",
|
|
42
|
+
"commit": "2974ea0ab58b546264b8d9a4a7c12ceeb0a02851",
|
|
43
|
+
"package": "@react-native-windows/telemetry"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"comment": "Bump @rnw-scripts/ts-config to v2.0.1",
|
|
47
|
+
"author": "ngerlem@microsoft.com",
|
|
48
|
+
"commit": "2974ea0ab58b546264b8d9a4a7c12ceeb0a02851",
|
|
49
|
+
"package": "@react-native-windows/telemetry"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"comment": "Bump @rnw-scripts/eslint-config to v1.1.8",
|
|
53
|
+
"author": "ngerlem@microsoft.com",
|
|
54
|
+
"commit": "2974ea0ab58b546264b8d9a4a7c12ceeb0a02851",
|
|
55
|
+
"package": "@react-native-windows/telemetry"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"date": "Sat, 24 Jul 2021 05:05:52 GMT",
|
|
62
|
+
"tag": "@react-native-windows/telemetry_v0.0.0-canary.22",
|
|
63
|
+
"version": "0.0.0-canary.22",
|
|
64
|
+
"comments": {
|
|
65
|
+
"none": [
|
|
66
|
+
{
|
|
67
|
+
"comment": "Bump @rnw-scripts/just-task to v2.2.0",
|
|
68
|
+
"author": "4123478+tido64@users.noreply.github.com",
|
|
69
|
+
"commit": "a311022ebc0c1d8070d7e54312197f486c470d33",
|
|
70
|
+
"package": "@react-native-windows/telemetry"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"date": "Tue, 29 Jun 2021 05:06:48 GMT",
|
|
77
|
+
"tag": "@react-native-windows/telemetry_v0.0.0-canary.22",
|
|
78
|
+
"version": "0.0.0-canary.22",
|
|
79
|
+
"comments": {
|
|
80
|
+
"none": [
|
|
81
|
+
{
|
|
82
|
+
"comment": "Deduplicate lockfile",
|
|
83
|
+
"author": "ngerlem@microsoft.com",
|
|
84
|
+
"commit": "2646cb69f4e031799d04ecd5453aa9d44b48b261",
|
|
85
|
+
"package": "@react-native-windows/telemetry"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"date": "Sat, 26 Jun 2021 05:06:48 GMT",
|
|
92
|
+
"tag": "@react-native-windows/telemetry_v0.0.0-canary.22",
|
|
93
|
+
"version": "0.0.0-canary.22",
|
|
94
|
+
"comments": {
|
|
95
|
+
"prerelease": [
|
|
96
|
+
{
|
|
97
|
+
"comment": "Upgrade to boost 1.76.0.0",
|
|
98
|
+
"author": "julio.rocha@microsoft.com",
|
|
99
|
+
"commit": "50e13c8cc7938d38bb19ca96225b5a85955c5ae5",
|
|
100
|
+
"package": "@react-native-windows/telemetry"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"date": "Fri, 11 Jun 2021 05:08:55 GMT",
|
|
107
|
+
"tag": "@react-native-windows/telemetry_v0.0.0-canary.21",
|
|
108
|
+
"version": "0.0.0-canary.21",
|
|
109
|
+
"comments": {
|
|
110
|
+
"prerelease": [
|
|
111
|
+
{
|
|
112
|
+
"comment": "Mark windowsOnly",
|
|
113
|
+
"author": "ngerlem@microsoft.com",
|
|
114
|
+
"commit": "3d7c8d8fcf14a3cbda83a93c85b0bcf1e4e4f829",
|
|
115
|
+
"package": "@react-native-windows/telemetry"
|
|
116
|
+
}
|
|
117
|
+
],
|
|
118
|
+
"patch": [
|
|
119
|
+
{
|
|
120
|
+
"comment": "Bump @rnw-scripts/just-task to v2.2.0",
|
|
121
|
+
"author": "ngerlem@microsoft.com",
|
|
122
|
+
"commit": "3d7c8d8fcf14a3cbda83a93c85b0bcf1e4e4f829",
|
|
123
|
+
"package": "@react-native-windows/telemetry"
|
|
124
|
+
}
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"date": "Wed, 09 Jun 2021 05:10:07 GMT",
|
|
6
130
|
"tag": "@react-native-windows/telemetry_v0.0.0-canary.20",
|
|
7
131
|
"version": "0.0.0-canary.20",
|
|
8
132
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,61 @@
|
|
|
1
1
|
# Change Log - @react-native-windows/telemetry
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 21 Oct 2021 05:07:06 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 0.0.0-canary.
|
|
7
|
+
## 0.0.0-canary.24
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Thu, 21 Oct 2021 05:07:06 GMT
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Changes
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
- Bump @rnw-scripts/jest-unittest-config to v1.2.3 (igklemen@microsoft.com)
|
|
13
|
+
- Update to typescript 4 (30809111+acoates-ms@users.noreply.github.com)
|
|
15
14
|
|
|
15
|
+
## 0.0.0-canary.23
|
|
16
|
+
|
|
17
|
+
Wed, 08 Sep 2021 05:08:53 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- Bump @rnw-scripts/jest-unittest-config to v1.2.4 (ngerlem@microsoft.com)
|
|
22
|
+
- Bump @rnw-scripts/just-task to v2.2.1 (ngerlem@microsoft.com)
|
|
23
|
+
- Bump @rnw-scripts/ts-config to v2.0.1 (ngerlem@microsoft.com)
|
|
24
|
+
- Bump @rnw-scripts/eslint-config to v1.1.8 (ngerlem@microsoft.com)
|
|
25
|
+
|
|
26
|
+
### Changes
|
|
27
|
+
|
|
28
|
+
- Set consistent node requirements on our packages (ngerlem@microsoft.com)
|
|
29
|
+
|
|
30
|
+
## 0.0.0-canary.22
|
|
31
|
+
|
|
32
|
+
Sat, 26 Jun 2021 05:06:48 GMT
|
|
33
|
+
|
|
34
|
+
### Changes
|
|
35
|
+
|
|
36
|
+
- Upgrade to boost 1.76.0.0 (julio.rocha@microsoft.com)
|
|
37
|
+
|
|
38
|
+
## 0.0.0-canary.21
|
|
39
|
+
|
|
40
|
+
Fri, 11 Jun 2021 05:08:55 GMT
|
|
41
|
+
|
|
42
|
+
### Patches
|
|
43
|
+
|
|
44
|
+
- Bump @rnw-scripts/just-task to v2.2.0 (ngerlem@microsoft.com)
|
|
45
|
+
|
|
46
|
+
### Changes
|
|
47
|
+
|
|
48
|
+
- Mark windowsOnly (ngerlem@microsoft.com)
|
|
49
|
+
|
|
50
|
+
## 0.0.0-canary.20
|
|
51
|
+
|
|
52
|
+
Wed, 09 Jun 2021 05:10:07 GMT
|
|
53
|
+
|
|
54
|
+
### Patches
|
|
55
|
+
|
|
56
|
+
- Bump @rnw-scripts/just-task to v2.1.3 (igklemen@microsoft.com)
|
|
57
|
+
- Bump @rnw-scripts/jest-unittest-config to v1.2.3 (igklemen@microsoft.com)
|
|
58
|
+
|
|
16
59
|
## 0.0.0-canary.19
|
|
17
60
|
|
|
18
61
|
Thu, 03 Jun 2021 05:09:47 GMT
|
package/lib-commonjs/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @format
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.CodedErrors = exports.CodedError = exports.getDiskFreeSpace = exports.isMSFTInternal = exports.Telemetry = void 0;
|
|
8
9
|
var telemetry_1 = require("./telemetry");
|
|
9
10
|
Object.defineProperty(exports, "Telemetry", { enumerable: true, get: function () { return telemetry_1.Telemetry; } });
|
|
10
11
|
Object.defineProperty(exports, "isMSFTInternal", { enumerable: true, get: function () { return telemetry_1.isMSFTInternal; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,yCAAwE;AAAhE,sGAAA,SAAS,OAAA;AAAE,2GAAA,cAAc,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AACnD,2CAAqE;AAA7D,wGAAA,UAAU,OAAA;AAAkB,yGAAA,WAAW,OAAA","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nexport {Telemetry, isMSFTInternal, getDiskFreeSpace} from './telemetry';\nexport {CodedError, CodedErrorType, CodedErrors} from './CodedError';\n"]}
|
|
@@ -19,7 +19,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
19
19
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
20
|
if (mod && mod.__esModule) return mod;
|
|
21
21
|
var result = {};
|
|
22
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
23
|
__setModuleDefault(result, mod);
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
@@ -61,7 +61,7 @@ class Telemetry {
|
|
|
61
61
|
Telemetry.client.commonProperties.isTest = process.env.RNW_CLI_TEST;
|
|
62
62
|
}
|
|
63
63
|
if (!Telemetry.client.commonProperties.sessionId) {
|
|
64
|
-
Telemetry.client.commonProperties.sessionId = crypto_1.randomBytes(16).toString('hex');
|
|
64
|
+
Telemetry.client.commonProperties.sessionId = (0, crypto_1.randomBytes)(16).toString('hex');
|
|
65
65
|
Telemetry.client.addTelemetryProcessor(sanitizeEnvelope);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -210,7 +210,7 @@ function isMSFTInternal() {
|
|
|
210
210
|
}
|
|
211
211
|
exports.isMSFTInternal = isMSFTInternal;
|
|
212
212
|
function getDiskFreeSpace(drivePath) {
|
|
213
|
-
const out = child_process_1.execSync(`dir /-C ${drivePath}`)
|
|
213
|
+
const out = (0, child_process_1.execSync)(`dir /-C ${drivePath}`)
|
|
214
214
|
.toString()
|
|
215
215
|
.split('\r\n');
|
|
216
216
|
const line = out[out.length - 2];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AACxB,mCAAmC;AACnC,iEAAmD;AACnD,iDAAuC;AACvC,6CAAwC;AAExC,MAAa,SAAS;IAGpB,MAAM,CAAC,OAAO;QACZ,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC;SACnD;QACD,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,gBAA0B;QACrC,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE;YACpB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO;SACR;QACD,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,OAAO;SACR;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;YAC7B,WAAW,CAAC,a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,MAAM,CAAC,CAAC;IACjB,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAChD,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;QAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;KAC1B;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AAVD,4CAUC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\nimport {randomBytes} from 'crypto';\nimport * as appInsights from 'applicationinsights';\nimport {execSync} from 'child_process';\nimport {CodedError} from './CodedError';\n\nexport class Telemetry {\n static client?: appInsights.TelemetryClient | undefined = undefined;\n\n static disable() {\n if (Telemetry.client) {\n Telemetry.client.config.disableAppInsights = true;\n }\n Telemetry.shouldDisable = true;\n }\n\n static setup(preserveMessages?: boolean) {\n if (Telemetry.isCI()) {\n this.disable();\n return;\n }\n if (Telemetry.client) {\n return;\n }\n if (!process.env.RNW_CLI_TEST) {\n appInsights.Configuration.setInternalLogging(false, false);\n }\n appInsights.setup('795006ca-cf54-40ee-8bc6-03deb91401c3');\n Telemetry.client = appInsights.defaultClient;\n\n if (Telemetry.shouldDisable) {\n Telemetry.disable();\n }\n Telemetry.preserveMessages = preserveMessages ? true : false;\n\n if (process.env.RNW_CLI_TEST) {\n Telemetry.client.commonProperties.isTest = process.env.RNW_CLI_TEST;\n }\n if (!Telemetry.client.commonProperties.sessionId) {\n Telemetry.client.commonProperties.sessionId = randomBytes(16).toString(\n 'hex',\n );\n Telemetry.client.addTelemetryProcessor(sanitizeEnvelope);\n }\n }\n\n static isCI(): boolean {\n return (\n process.env.AGENT_NAME !== undefined || // Azure DevOps\n process.env.CIRCLECI === 'true' || // CircleCI\n process.env.TRAVIS === 'true' || // Travis\n process.env.CI === 'true' // other CIs\n );\n }\n\n static trackException(e: Error, properties?: Record<string, any>) {\n const props: Record<string, any> = {};\n if (e instanceof CodedError) {\n Object.assign(props, (e as CodedError).data);\n }\n\n const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];\n for (const f of syscallExceptionFieldsToCopy) {\n if ((e as any)[f]) {\n props[f] = [f];\n }\n }\n Object.assign(props, props, properties);\n Telemetry.client?.trackException({\n exception: e,\n properties: props,\n });\n }\n\n static shouldDisable: boolean = false;\n static preserveMessages: boolean = false;\n}\n\nfunction getAnonymizedPath(filepath: string): string {\n const projectRoot = process.cwd().toLowerCase();\n filepath = filepath.replace(/\\//g, '\\\\');\n const knownPathsVars = ['AppData', 'LocalAppData', 'UserProfile'];\n if (filepath.toLowerCase().startsWith(projectRoot)) {\n const ext = path.extname(filepath);\n const rest = filepath.slice(projectRoot.length);\n const nodeModules = '\\\\node_modules\\\\';\n // this is in the project dir but not under node_modules\n if (rest.toLowerCase().startsWith('\\\\windows\\\\')) {\n return `[windows]\\\\???${ext}(${filepath.length})`;\n } else if (rest.toLowerCase().startsWith(nodeModules)) {\n return 'node_modules' + rest.slice(nodeModules.length - 1);\n } else {\n return `[project_dir]\\\\???${ext}(${filepath.length})`;\n }\n } else {\n for (const knownPath of knownPathsVars) {\n if (\n process.env[knownPath] &&\n filepath.toLowerCase().startsWith(process.env[knownPath]!.toLowerCase())\n ) {\n return `[${knownPath}]\\\\???(${filepath.length})`;\n }\n }\n }\n return '[path]';\n}\n/**\n * Sanitize any paths that appear between quotes (''), brackets ([]), or double quotes (\"\").\n * @param msg the string to sanitize\n */\nexport function sanitizeMessage(msg: string): string {\n const cpuThreadId = /^\\d+(:\\d+)?>/g;\n msg = msg.replace(cpuThreadId, '');\n const parts = msg.split(/['[\\]\"]/g);\n const clean = [];\n const pathRegEx = /([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 getAnonymizedPath(matches[0]);\n last = matches!.index + matches![0].length;\n }\n clean.push(noPath);\n } else if (part !== '') {\n clean.push(part);\n }\n }\n return clean.join(' ').trim();\n}\n\nexport function sanitizeFrame(frame: any): 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 // preserve only the last_directory/filename\n frame.fileName = path.join(\n path.basename(path.dirname(frame.fileName)),\n path.basename(frame.fileName),\n );\n frame.assembly = '';\n}\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 * Remove PII from exceptions' stack traces and messages\n * @param envelope the telemetry envelope. Provided by AppInsights.\n */\nexport function sanitizeEnvelope(envelope: any /*context: any*/): boolean {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = envelope.data.baseData;\n for (const exception of data.exceptions || []) {\n for (const frame of exception.parsedStack) {\n sanitizeFrame(frame);\n }\n const errorCode = tryGetErrorCode(exception.message);\n data.properties.errorCode = errorCode;\n // CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.\n // The message may contain PII information. This can be sanitized, but for now delete it.\n // Note that the type of data.exceptions[0] is always going to be ExceptionDetails. It is not the original thrown exception.\n // https://github.com/microsoft/ApplicationInsights-node.js/issues/707\n if (Telemetry.preserveMessages) {\n exception.message = sanitizeMessage(exception.message);\n } else {\n delete exception.message;\n }\n }\n }\n delete envelope.tags['ai.cloud.roleInstance'];\n return true;\n}\n\nexport function isMSFTInternal(): boolean {\n return (\n process.env.UserDNSDomain !== undefined &&\n process.env.UserDNSDomain.toLowerCase().endsWith('.microsoft.com')\n );\n}\n\nexport function getDiskFreeSpace(drivePath: string | null): number {\n const out = execSync(`dir /-C ${drivePath}`)\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 return -1;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gDAAwB;AACxB,mCAAmC;AACnC,iEAAmD;AACnD,iDAAuC;AACvC,6CAAwC;AAExC,MAAa,SAAS;IAGpB,MAAM,CAAC,OAAO;QACZ,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC;SACnD;QACD,SAAS,CAAC,aAAa,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,gBAA0B;QACrC,IAAI,SAAS,CAAC,IAAI,EAAE,EAAE;YACpB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO;SACR;QACD,IAAI,SAAS,CAAC,MAAM,EAAE;YACpB,OAAO;SACR;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE;YAC7B,WAAW,CAAC,aAAa,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;SAC5D;QACD,WAAW,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,SAAS,CAAC,MAAM,GAAG,WAAW,CAAC,aAAa,CAAC;QAE7C,IAAI,SAAS,CAAC,aAAa,EAAE;YAC3B,SAAS,CAAC,OAAO,EAAE,CAAC;SACrB;QACD,SAAS,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CA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ACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AAVD,4CAUC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\nimport {randomBytes} from 'crypto';\nimport * as appInsights from 'applicationinsights';\nimport {execSync} from 'child_process';\nimport {CodedError} from './CodedError';\n\nexport class Telemetry {\n static client?: appInsights.TelemetryClient | undefined = undefined;\n\n static disable() {\n if (Telemetry.client) {\n Telemetry.client.config.disableAppInsights = true;\n }\n Telemetry.shouldDisable = true;\n }\n\n static setup(preserveMessages?: boolean) {\n if (Telemetry.isCI()) {\n this.disable();\n return;\n }\n if (Telemetry.client) {\n return;\n }\n if (!process.env.RNW_CLI_TEST) {\n appInsights.Configuration.setInternalLogging(false, false);\n }\n appInsights.setup('795006ca-cf54-40ee-8bc6-03deb91401c3');\n Telemetry.client = appInsights.defaultClient;\n\n if (Telemetry.shouldDisable) {\n Telemetry.disable();\n }\n Telemetry.preserveMessages = preserveMessages ? true : false;\n\n if (process.env.RNW_CLI_TEST) {\n Telemetry.client.commonProperties.isTest = process.env.RNW_CLI_TEST;\n }\n if (!Telemetry.client.commonProperties.sessionId) {\n Telemetry.client.commonProperties.sessionId = randomBytes(16).toString(\n 'hex',\n );\n Telemetry.client.addTelemetryProcessor(sanitizeEnvelope);\n }\n }\n\n static isCI(): boolean {\n return (\n process.env.AGENT_NAME !== undefined || // Azure DevOps\n process.env.CIRCLECI === 'true' || // CircleCI\n process.env.TRAVIS === 'true' || // Travis\n process.env.CI === 'true' // other CIs\n );\n }\n\n static trackException(e: Error, properties?: Record<string, any>) {\n const props: Record<string, any> = {};\n if (e instanceof CodedError) {\n Object.assign(props, (e as CodedError).data);\n }\n\n const syscallExceptionFieldsToCopy = ['errno', 'syscall', 'code'];\n for (const f of syscallExceptionFieldsToCopy) {\n if ((e as any)[f]) {\n props[f] = [f];\n }\n }\n Object.assign(props, props, properties);\n Telemetry.client?.trackException({\n exception: e,\n properties: props,\n });\n }\n\n static shouldDisable: boolean = false;\n static preserveMessages: boolean = false;\n}\n\nfunction getAnonymizedPath(filepath: string): string {\n const projectRoot = process.cwd().toLowerCase();\n filepath = filepath.replace(/\\//g, '\\\\');\n const knownPathsVars = ['AppData', 'LocalAppData', 'UserProfile'];\n if (filepath.toLowerCase().startsWith(projectRoot)) {\n const ext = path.extname(filepath);\n const rest = filepath.slice(projectRoot.length);\n const nodeModules = '\\\\node_modules\\\\';\n // this is in the project dir but not under node_modules\n if (rest.toLowerCase().startsWith('\\\\windows\\\\')) {\n return `[windows]\\\\???${ext}(${filepath.length})`;\n } else if (rest.toLowerCase().startsWith(nodeModules)) {\n return 'node_modules' + rest.slice(nodeModules.length - 1);\n } else {\n return `[project_dir]\\\\???${ext}(${filepath.length})`;\n }\n } else {\n for (const knownPath of knownPathsVars) {\n if (\n process.env[knownPath] &&\n filepath.toLowerCase().startsWith(process.env[knownPath]!.toLowerCase())\n ) {\n return `[${knownPath}]\\\\???(${filepath.length})`;\n }\n }\n }\n return '[path]';\n}\n/**\n * Sanitize any paths that appear between quotes (''), brackets ([]), or double quotes (\"\").\n * @param msg the string to sanitize\n */\nexport function sanitizeMessage(msg: string): string {\n const cpuThreadId = /^\\d+(:\\d+)?>/g;\n msg = msg.replace(cpuThreadId, '');\n const parts = msg.split(/['[\\]\"]/g);\n const clean = [];\n const pathRegEx = /([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 getAnonymizedPath(matches[0]);\n last = matches!.index + matches![0].length;\n }\n clean.push(noPath);\n } else if (part !== '') {\n clean.push(part);\n }\n }\n return clean.join(' ').trim();\n}\n\nexport function sanitizeFrame(frame: any): 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 // preserve only the last_directory/filename\n frame.fileName = path.join(\n path.basename(path.dirname(frame.fileName)),\n path.basename(frame.fileName),\n );\n frame.assembly = '';\n}\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 * Remove PII from exceptions' stack traces and messages\n * @param envelope the telemetry envelope. Provided by AppInsights.\n */\nexport function sanitizeEnvelope(envelope: any /*context: any*/): boolean {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = envelope.data.baseData;\n for (const exception of data.exceptions || []) {\n for (const frame of exception.parsedStack) {\n sanitizeFrame(frame);\n }\n const errorCode = tryGetErrorCode(exception.message);\n data.properties.errorCode = errorCode;\n // CodedError has non-PII information in its 'type' member, plus optionally some more info in its 'data'.\n // The message may contain PII information. This can be sanitized, but for now delete it.\n // Note that the type of data.exceptions[0] is always going to be ExceptionDetails. It is not the original thrown exception.\n // https://github.com/microsoft/ApplicationInsights-node.js/issues/707\n if (Telemetry.preserveMessages) {\n exception.message = sanitizeMessage(exception.message);\n } else {\n delete exception.message;\n }\n }\n }\n delete envelope.tags['ai.cloud.roleInstance'];\n return true;\n}\n\nexport function isMSFTInternal(): boolean {\n return (\n process.env.UserDNSDomain !== undefined &&\n process.env.UserDNSDomain.toLowerCase().endsWith('.microsoft.com')\n );\n}\n\nexport function getDiskFreeSpace(drivePath: string | null): number {\n const out = execSync(`dir /-C ${drivePath}`)\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 return -1;\n}\n"]}
|
|
@@ -14,30 +14,30 @@ telemetry_1.Telemetry.setup(true);
|
|
|
14
14
|
telemetry_1.Telemetry.client.config.disableAppInsights = true;
|
|
15
15
|
test('Sanitize message, no-op', () => {
|
|
16
16
|
// do stuff
|
|
17
|
-
expect(telemetry_1.sanitizeMessage('')).toEqual('');
|
|
18
|
-
expect(telemetry_1.sanitizeMessage('some text')).toEqual('some text');
|
|
17
|
+
expect((0, telemetry_1.sanitizeMessage)('')).toEqual('');
|
|
18
|
+
expect((0, telemetry_1.sanitizeMessage)('some text')).toEqual('some text');
|
|
19
19
|
});
|
|
20
20
|
test('Sanitize message, project_dir', () => {
|
|
21
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: '${process.cwd()}'`)).toEqual(`this is the cwd: [project_dir]\\???(${process.cwd().length})`);
|
|
22
|
-
expect(telemetry_1.sanitizeMessage(`uppercase: '${process.cwd().toUpperCase()}'`)).toEqual(`uppercase: [project_dir]\\???(${process.cwd().length})`);
|
|
23
|
-
expect(telemetry_1.sanitizeMessage(`lowercase: '${process.cwd().toLowerCase()}'`)).toEqual(`lowercase: [project_dir]\\???(${process.cwd().length})`);
|
|
24
|
-
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`);
|
|
25
|
-
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})`);
|
|
21
|
+
expect((0, telemetry_1.sanitizeMessage)(`this is the cwd: '${process.cwd()}'`)).toEqual(`this is the cwd: [project_dir]\\???(${process.cwd().length})`);
|
|
22
|
+
expect((0, telemetry_1.sanitizeMessage)(`uppercase: '${process.cwd().toUpperCase()}'`)).toEqual(`uppercase: [project_dir]\\???(${process.cwd().length})`);
|
|
23
|
+
expect((0, telemetry_1.sanitizeMessage)(`lowercase: '${process.cwd().toLowerCase()}'`)).toEqual(`lowercase: [project_dir]\\???(${process.cwd().length})`);
|
|
24
|
+
expect((0, 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`);
|
|
25
|
+
expect((0, 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})`);
|
|
26
26
|
});
|
|
27
27
|
test('Sanitize message, node_modules', () => {
|
|
28
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: '${process.cwd()}\\node_modules'`)).toEqual(`this is the cwd: [project_dir]\\???(${(process.cwd() + '\\node_modules').length})`);
|
|
29
|
-
expect(telemetry_1.sanitizeMessage(`this is the cwd: '${process.cwd()}\\node_modules\\foo'`)).toEqual('this is the cwd: node_modules\\foo');
|
|
30
|
-
expect(telemetry_1.sanitizeMessage(`uppercase: '${process.cwd().toUpperCase()}\\NODE_MODULES\\foo'`)).toEqual('uppercase: node_modules\\foo');
|
|
31
|
-
expect(telemetry_1.sanitizeMessage(`lowercase: '${process.cwd().toLowerCase()}\\NODE_MODULES\\'`)).toEqual('lowercase: node_modules\\');
|
|
32
|
-
expect(telemetry_1.sanitizeMessage(`trailing: '${process.cwd()}\\node_modules\\' and something else`)).toEqual('trailing: node_modules\\ and something else');
|
|
33
|
-
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() +
|
|
28
|
+
expect((0, telemetry_1.sanitizeMessage)(`this is the cwd: '${process.cwd()}\\node_modules'`)).toEqual(`this is the cwd: [project_dir]\\???(${(process.cwd() + '\\node_modules').length})`);
|
|
29
|
+
expect((0, telemetry_1.sanitizeMessage)(`this is the cwd: '${process.cwd()}\\node_modules\\foo'`)).toEqual('this is the cwd: node_modules\\foo');
|
|
30
|
+
expect((0, telemetry_1.sanitizeMessage)(`uppercase: '${process.cwd().toUpperCase()}\\NODE_MODULES\\foo'`)).toEqual('uppercase: node_modules\\foo');
|
|
31
|
+
expect((0, telemetry_1.sanitizeMessage)(`lowercase: '${process.cwd().toLowerCase()}\\NODE_MODULES\\'`)).toEqual('lowercase: node_modules\\');
|
|
32
|
+
expect((0, telemetry_1.sanitizeMessage)(`trailing: '${process.cwd()}\\node_modules\\' and something else`)).toEqual('trailing: node_modules\\ and something else');
|
|
33
|
+
expect((0, 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() +
|
|
34
34
|
'\\node_modules and something else that could be part of the path').length})`);
|
|
35
|
-
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
|
+
expect((0, 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`);
|
|
36
36
|
});
|
|
37
37
|
test('Sanitize message, other 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(`this is another path: A:\\foo\\bar\\baz`)).toEqual(`this is another path: [path]`);
|
|
40
|
-
expect(telemetry_1.sanitizeMessage(`Cannot find module 'react-native/package.json'
|
|
38
|
+
expect((0, telemetry_1.sanitizeMessage)(`this is another path: 'A:\\foo\\bar\\baz'`)).toEqual(`this is another path: [path]`);
|
|
39
|
+
expect((0, telemetry_1.sanitizeMessage)(`this is another path: A:\\foo\\bar\\baz`)).toEqual(`this is another path: [path]`);
|
|
40
|
+
expect((0, telemetry_1.sanitizeMessage)(`Cannot find module 'react-native/package.json'
|
|
41
41
|
Require stack:
|
|
42
42
|
- ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\lib-commonjs\\Cli.js
|
|
43
43
|
- ${process.env.AppData}\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\bin.js`)).toEqual(`Cannot find module react-native/package.json
|
|
@@ -48,18 +48,18 @@ test('Sanitize message, other path', () => {
|
|
|
48
48
|
'\\npm-cache\\_npx\\1384\\node_modules\\react-native-windows-init\\bin.js').length})`);
|
|
49
49
|
});
|
|
50
50
|
test('Sanitize message, forward slashes', () => {
|
|
51
|
-
expect(telemetry_1.sanitizeMessage(`EPERM: operation not permitted, scandir ${process.env.UserProfile.replace(/\\/g, '/')}/source/repos/rn2/wintest/windows/packages/boost.1.
|
|
52
|
-
'/source/repos/rn2/wintest/windows/packages/boost.1.
|
|
51
|
+
expect((0, telemetry_1.sanitizeMessage)(`EPERM: operation not permitted, scandir ${process.env.UserProfile.replace(/\\/g, '/')}/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include`)).toEqual(`EPERM: operation not permitted, scandir [UserProfile]\\???(${(process.env.UserProfile +
|
|
52
|
+
'/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include').length})`);
|
|
53
53
|
});
|
|
54
54
|
test('Sanitize message, file share path', () => {
|
|
55
|
-
expect(telemetry_1.sanitizeMessage(`\\\\server\\share`)).toEqual('[path]');
|
|
55
|
+
expect((0, telemetry_1.sanitizeMessage)(`\\\\server\\share`)).toEqual('[path]');
|
|
56
56
|
});
|
|
57
57
|
test('Sanitize message, with cpu/thread id', () => {
|
|
58
|
-
expect(telemetry_1.sanitizeMessage('5>This is an error')).toEqual('This is an error');
|
|
59
|
-
expect(telemetry_1.sanitizeMessage('5:42>This is an error')).toEqual('This is an error');
|
|
58
|
+
expect((0, telemetry_1.sanitizeMessage)('5>This is an error')).toEqual('This is an error');
|
|
59
|
+
expect((0, telemetry_1.sanitizeMessage)('5:42>This is an error')).toEqual('This is an error');
|
|
60
60
|
});
|
|
61
61
|
test('Error code', () => {
|
|
62
|
-
expect(telemetry_1.tryGetErrorCode('foo bar error FOO2020: the thing')).toEqual('FOO2020');
|
|
62
|
+
expect((0, telemetry_1.tryGetErrorCode)('foo bar error FOO2020: the thing')).toEqual('FOO2020');
|
|
63
63
|
});
|
|
64
64
|
test('Sanitize stack frame', () => {
|
|
65
65
|
const emptyFrame = {
|
|
@@ -69,7 +69,7 @@ test('Sanitize stack frame', () => {
|
|
|
69
69
|
assembly: 'asdf',
|
|
70
70
|
line: 0,
|
|
71
71
|
};
|
|
72
|
-
telemetry_1.sanitizeFrame(emptyFrame);
|
|
72
|
+
(0, telemetry_1.sanitizeFrame)(emptyFrame);
|
|
73
73
|
expect(emptyFrame).toEqual({
|
|
74
74
|
level: 0,
|
|
75
75
|
assembly: '',
|
|
@@ -84,7 +84,7 @@ test('Sanitize stack frame', () => {
|
|
|
84
84
|
level: 0,
|
|
85
85
|
line: 0,
|
|
86
86
|
};
|
|
87
|
-
telemetry_1.sanitizeFrame(frame1);
|
|
87
|
+
(0, telemetry_1.sanitizeFrame)(frame1);
|
|
88
88
|
expect(frame1).toEqual({
|
|
89
89
|
assembly: '',
|
|
90
90
|
fileName: 'telemetry\\foo.js',
|
|
@@ -99,7 +99,7 @@ test('Sanitize stack frame', () => {
|
|
|
99
99
|
level: 1,
|
|
100
100
|
line: 42,
|
|
101
101
|
};
|
|
102
|
-
telemetry_1.sanitizeFrame(frame2);
|
|
102
|
+
(0, telemetry_1.sanitizeFrame)(frame2);
|
|
103
103
|
expect(frame2).toEqual({
|
|
104
104
|
assembly: '',
|
|
105
105
|
fileName: 'telemetry\\foo.js',
|
|
@@ -119,7 +119,8 @@ function b(s) {
|
|
|
119
119
|
function a(s) {
|
|
120
120
|
b(s);
|
|
121
121
|
}
|
|
122
|
-
test
|
|
122
|
+
// #7903: This test assumes exact structure of stack trace, which can be flaky or implementation dependent
|
|
123
|
+
test.skip('thrown exception a->b, hello world', () => {
|
|
123
124
|
let pass = false;
|
|
124
125
|
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
|
|
125
126
|
if (envelope.data.baseType === 'ExceptionData') {
|
|
@@ -130,7 +131,7 @@ test('thrown exception a->b, hello world', done => {
|
|
|
130
131
|
const stack = data.exceptions[0].parsedStack;
|
|
131
132
|
expect(stack).toBeDefined();
|
|
132
133
|
expect(stack.length).toBeGreaterThan(5);
|
|
133
|
-
const filename = path_1.basename(__filename);
|
|
134
|
+
const filename = (0, path_1.basename)(__filename);
|
|
134
135
|
expect(stack[0].method).toEqual('b');
|
|
135
136
|
expect(stack[1].method).toEqual('b');
|
|
136
137
|
expect(stack[2].method).toEqual('Object.a');
|
|
@@ -151,7 +152,6 @@ test('thrown exception a->b, hello world', done => {
|
|
|
151
152
|
expect(pass).toBeTruthy();
|
|
152
153
|
telemetry_1.Telemetry.client.clearTelemetryProcessors();
|
|
153
154
|
telemetry_1.Telemetry.client.addTelemetryProcessor(telemetry_1.sanitizeEnvelope);
|
|
154
|
-
done();
|
|
155
155
|
});
|
|
156
156
|
test('throw exception with error code', done => {
|
|
157
157
|
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
|
|
@@ -170,7 +170,8 @@ test('throw exception with error code', done => {
|
|
|
170
170
|
telemetry_1.Telemetry.client.addTelemetryProcessor(telemetry_1.sanitizeEnvelope);
|
|
171
171
|
done();
|
|
172
172
|
});
|
|
173
|
-
test
|
|
173
|
+
// #7903: This test assumes exact structure of stack trace, which can be flaky or implementation dependent
|
|
174
|
+
test.skip('thrown exception a->b, hello path', done => {
|
|
174
175
|
let pass = false;
|
|
175
176
|
telemetry_1.Telemetry.client.addTelemetryProcessor((envelope, _) => {
|
|
176
177
|
if (envelope.data.baseType === 'ExceptionData') {
|
|
@@ -181,7 +182,7 @@ test('thrown exception a->b, hello path', done => {
|
|
|
181
182
|
const stack = data.exceptions[0].parsedStack;
|
|
182
183
|
expect(stack).toBeDefined();
|
|
183
184
|
expect(stack.length).toBeGreaterThan(5);
|
|
184
|
-
const filename = path_1.basename(__filename);
|
|
185
|
+
const filename = (0, path_1.basename)(__filename);
|
|
185
186
|
expect(stack[0].method).toEqual('b');
|
|
186
187
|
expect(stack[1].method).toEqual('b');
|
|
187
188
|
expect(stack[2].method).toEqual('Object.a');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitize.test.js","sourceRoot":"","sources":["../../src/test/sanitize.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,4CAMsB;AAEtB,+BAA8B;AAC9B,8CAAyC;AAEzC,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,+CAA+C;AAC9E,qBAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtB,qBAAS,CAAC,MAAO,CAAC,MAAM,CAAC,kBAAkB,GAAG,IAAI,CAAC;AAEnD,IAAI,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACnC,WAAW;IACX,MAAM,CAAC,2BAAe,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,CAAC,2BAAe,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAC5D,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;IACzC,MAAM,CAAC,2BAAe,CAAC,qBAAqB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CACpE,wCAAwC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,CAChE,CAAC;IACF,MAAM,CACJ,2BAAe,CAAC,eAAe,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC,CAC/D,CAAC,OAAO,CAAC,kCAAkC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IACrE,MAAM,CACJ,2BAAe,CAAC,eAAe,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,GAAG,CAAC,CAC/D,CAAC,OAAO,CAAC,kCAAkC,OAAO,CAAC,GAAG,EAAE,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AC,OAAO,CAAC,EAAE,CAAC,CAAC;YACtD,IAAI,GAAG,IAAI,CAAC;SACb;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,IAAI;QACF,MAAM,IAAI,uBAAU,CAAC,cAAc,EAAE,kBAAkB,EAAE;YACvD,GAAG,EAAE,EAAE;SACR,CAAC,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,qBAAS,CAAC,MAAO,CAAC,cAAc,CAAC;YAC/B,SAAS,EAAE,CAAC;YACZ,UAAU,EAAG,CAAgB,CAAC,IAAI;SACnC,CAAC,CAAC;QACH,qBAAS,CAAC,MAAO,CAAC,KAAK,EAAE,CAAC;KAC3B;IAED,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,qBAAS,CAAC,MAAO,CAAC,wBAAwB,EAAE,CAAC;IAC7C,qBAAS,CAAC,MAAO,CAAC,qBAAqB,CAAC,4BAAgB,CAAC,CAAC;IAC1D,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport {\n Telemetry,\n sanitizeMessage,\n sanitizeEnvelope,\n sanitizeFrame,\n tryGetErrorCode,\n} from '../telemetry';\nimport * as appInsights from 'applicationinsights';\nimport {basename} from 'path';\nimport {CodedError} from '../CodedError';\n\ndelete process.env.AGENT_NAME; // allow this test to run in Azure DevOps / GHA\nTelemetry.setup(true);\nTelemetry.client!.config.disableAppInsights = true;\n\ntest('Sanitize message, no-op', () => {\n // do stuff\n expect(sanitizeMessage('')).toEqual('');\n expect(sanitizeMessage('some text')).toEqual('some text');\n});\n\ntest('Sanitize message, project_dir', () => {\n expect(sanitizeMessage(`this is the cwd: '${process.cwd()}'`)).toEqual(\n `this is the cwd: [project_dir]\\\\???(${process.cwd().length})`,\n );\n expect(\n sanitizeMessage(`uppercase: '${process.cwd().toUpperCase()}'`),\n ).toEqual(`uppercase: [project_dir]\\\\???(${process.cwd().length})`);\n expect(\n sanitizeMessage(`lowercase: '${process.cwd().toLowerCase()}'`),\n ).toEqual(`lowercase: [project_dir]\\\\???(${process.cwd().length})`);\n expect(\n sanitizeMessage(`this is the cwd: '${process.cwd()}' and something else`),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n process.cwd().length\n }) and something else`,\n );\n expect(\n sanitizeMessage(`this is the cwd: ${process.cwd()} and something else`),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n (process.cwd() + ' and something else').length\n })`,\n );\n});\n\ntest('Sanitize message, node_modules', () => {\n expect(\n sanitizeMessage(`this is the cwd: '${process.cwd()}\\\\node_modules'`),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n (process.cwd() + '\\\\node_modules').length\n })`,\n );\n expect(\n sanitizeMessage(`this is the cwd: '${process.cwd()}\\\\node_modules\\\\foo'`),\n ).toEqual('this is the cwd: node_modules\\\\foo');\n expect(\n sanitizeMessage(\n `uppercase: '${process.cwd().toUpperCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toEqual('uppercase: node_modules\\\\foo');\n expect(\n sanitizeMessage(\n `lowercase: '${process.cwd().toLowerCase()}\\\\NODE_MODULES\\\\'`,\n ),\n ).toEqual('lowercase: node_modules\\\\');\n expect(\n sanitizeMessage(\n `trailing: '${process.cwd()}\\\\node_modules\\\\' and something else`,\n ),\n ).toEqual('trailing: node_modules\\\\ and something else');\n expect(\n sanitizeMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules and something else that could be part of the path`,\n ),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n (\n process.cwd() +\n '\\\\node_modules and something else that could be part of the path'\n ).length\n })`,\n );\n expect(\n sanitizeMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules\\\\ a file under nm`,\n ),\n ).toEqual(`this is the cwd: node_modules\\\\ a file under nm`);\n});\n\ntest('Sanitize message, other path', () => {\n expect(sanitizeMessage(`this is another path: 'A:\\\\foo\\\\bar\\\\baz'`)).toEqual(\n `this is another path: [path]`,\n );\n\n expect(sanitizeMessage(`this is another path: A:\\\\foo\\\\bar\\\\baz`)).toEqual(\n `this is another path: [path]`,\n );\n\n expect(\n sanitizeMessage(\n `Cannot find module 'react-native/package.json'\n Require stack:\n - ${process.env.AppData}\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js\n - ${process.env.AppData}\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\bin.js`,\n ),\n ).toEqual(`Cannot find module react-native/package.json \n Require stack:\n - [AppData]\\\\???(${\n (\n process.env.AppData +\n '\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js'\n ).length\n })\n - [AppData]\\\\???(${\n (\n process.env.AppData +\n '\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\bin.js'\n ).length\n })`);\n});\n\ntest('Sanitize message, forward slashes', () => {\n expect(\n sanitizeMessage(\n `EPERM: operation not permitted, scandir ${process.env.UserProfile!.replace(\n /\\\\/g,\n '/',\n )}/source/repos/rn2/wintest/windows/packages/boost.1.72.0.0/lib/native/include`,\n ),\n ).toEqual(\n `EPERM: operation not permitted, scandir [UserProfile]\\\\???(${\n (\n process.env.UserProfile +\n '/source/repos/rn2/wintest/windows/packages/boost.1.72.0.0/lib/native/include'\n ).length\n })`,\n );\n});\n\ntest('Sanitize message, file share path', () => {\n expect(sanitizeMessage(`\\\\\\\\server\\\\share`)).toEqual('[path]');\n});\n\ntest('Sanitize message, with cpu/thread id', () => {\n expect(sanitizeMessage('5>This is an error')).toEqual('This is an error');\n\n expect(sanitizeMessage('5:42>This is an error')).toEqual('This is an error');\n});\n\ntest('Error code', () => {\n expect(tryGetErrorCode('foo bar error FOO2020: the thing')).toEqual(\n 'FOO2020',\n );\n});\n\ntest('Sanitize stack frame', () => {\n const emptyFrame: appInsights.Contracts.StackFrame = {\n level: 0,\n method: '',\n fileName: '',\n assembly: 'asdf',\n line: 0,\n };\n sanitizeFrame(emptyFrame);\n expect(emptyFrame).toEqual({\n level: 0,\n assembly: '',\n fileName: '.',\n method: '',\n line: 0,\n });\n\n const frame1: appInsights.Contracts.StackFrame = {\n method: '',\n fileName: `${process.cwd()}\\\\foo.js`,\n assembly: 'asdf',\n level: 0,\n line: 0,\n };\n sanitizeFrame(frame1);\n expect(frame1).toEqual({\n assembly: '',\n fileName: 'telemetry\\\\foo.js',\n method: '',\n level: 0,\n line: 0,\n });\n\n const frame2: appInsights.Contracts.StackFrame = {\n method: `myMethod (something ${process.cwd()}`,\n fileName: `${process.cwd()}\\\\foo.js`,\n assembly: 'asdf',\n level: 1,\n line: 42,\n };\n sanitizeFrame(frame2);\n expect(frame2).toEqual({\n assembly: '',\n fileName: 'telemetry\\\\foo.js',\n method: 'myMethod',\n level: 1,\n line: 42,\n });\n});\n\ntest('basic setup', () => {\n expect(Telemetry.client!.commonProperties.sessionId).toBeDefined();\n\n expect(\n Telemetry.client!.commonProperties.sessionId.length,\n ).toBeGreaterThanOrEqual(32);\n\n expect(Telemetry.client!.commonProperties.isTest).toEqual('true');\n});\n\nfunction b(s: string) {\n throw new Error('hello ' + s);\n}\nfunction a(s: string) {\n b(s);\n}\n\ntest('thrown exception a->b, hello world', done => {\n let pass = false;\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = (envelope.data as any).baseData;\n expect(data.exceptions).toBeDefined();\n expect(data.exceptions.length).toEqual(1);\n expect(data.exceptions[0].message).toEqual('hello world');\n\n const stack = data.exceptions[0].parsedStack;\n expect(stack).toBeDefined();\n expect(stack.length).toBeGreaterThan(5);\n\n const filename = basename(__filename);\n expect(stack[0].method).toEqual('b');\n expect(stack[1].method).toEqual('b');\n expect(stack[2].method).toEqual('Object.a');\n expect(stack[0].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[1].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[2].fileName).toEqual(`test\\\\${filename}`);\n pass = true;\n }\n return true;\n });\n try {\n a('world');\n } catch (e) {\n Telemetry.client!.trackException({exception: e});\n }\n Telemetry.client!.flush();\n\n expect(pass).toBeTruthy();\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n done();\n});\n\ntest('throw exception with error code', done => {\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n const data = (envelope.data as any).baseData;\n expect(data.properties.errorCode).toEqual('FOO2020');\n return true;\n });\n\n try {\n throw new Error('hello from an error FOO2020: the error string');\n } catch (e) {\n Telemetry.client!.trackException({exception: e});\n Telemetry.client!.flush();\n }\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n done();\n});\n\ntest('thrown exception a->b, hello path', done => {\n let pass = false;\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = (envelope.data as any).baseData;\n expect(data.exceptions).toBeDefined();\n expect(data.exceptions.length).toEqual(1);\n expect(data.exceptions[0].message).toEqual(\n `hello [project_dir]\\\\???(${process.cwd().length})`,\n );\n\n const stack = data.exceptions[0].parsedStack;\n expect(stack).toBeDefined();\n expect(stack.length).toBeGreaterThan(5);\n\n const filename = basename(__filename);\n expect(stack[0].method).toEqual('b');\n expect(stack[1].method).toEqual('b');\n expect(stack[2].method).toEqual('Object.a');\n expect(stack[0].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[1].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[2].fileName).toEqual(`test\\\\${filename}`);\n pass = true;\n }\n return true;\n });\n try {\n a(process.cwd());\n } catch (e) {\n Telemetry.client!.trackException({exception: e});\n }\n Telemetry.client!.flush();\n\n expect(pass).toBeTruthy();\n expect(pass).toBeTruthy();\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n done();\n});\n\ntest('trackEvent should not identify roleInstance', () => {\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n expect(envelope.tags['ai.cloud.roleInstance']).toBeUndefined();\n return true;\n });\n Telemetry.client!.trackEvent({\n name: 'test',\n properties: {},\n });\n Telemetry.client!.flush();\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n});\n\n/////////////////////////\n// CodedError tests\ntest('No message', done => {\n Telemetry.preserveMessages = false;\n let pass = false;\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = (envelope.data as any).baseData;\n expect(data.exceptions).toBeDefined();\n expect(data.exceptions.length).toEqual(1);\n expect(data.exceptions[0].message).toBeUndefined();\n expect(data.exceptions[0].typeName).toEqual('MSBuildError');\n // This should be 42, but instead it is '42'\n // https://github.com/microsoft/ApplicationInsights-node.js/issues/708\n expect(data.properties.foo).toBeDefined();\n expect(parseInt(data.properties.foo, 10)).toEqual(42);\n pass = true;\n }\n return true;\n });\n\n try {\n throw new CodedError('MSBuildError', 'Something secret', {\n foo: 42,\n });\n } catch (e) {\n Telemetry.client!.trackException({\n exception: e,\n properties: (e as CodedError).data,\n });\n Telemetry.client!.flush();\n }\n\n expect(pass).toEqual(true);\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n done();\n});\n"]}
|
|
1
|
+
{"version":3,"file":"sanitize.test.js","sourceRoot":"","sources":["../../src/test/sanitize.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,4CAMsB;AAEtB,+BAA8B;AAC9B,8CAAyC;AAEzC,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,+CAA+C;AAC9E,qBAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AACtB,qBAAS,CAAC,MAAO,CA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CAAC,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,qBAAS,CAAC,MAAO,CAAC,cAAc,CAAC;YAC/B,SAAS,EAAE,CAAU;YACrB,UAAU,EAAG,CAAgB,CAAC,IAAI;SACnC,CAAC,CAAC;QACH,qBAAS,CAAC,MAAO,CAAC,KAAK,EAAE,CAAC;KAC3B;IAED,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,qBAAS,CAAC,MAAO,CAAC,wBAAwB,EAAE,CAAC;IAC7C,qBAAS,CAAC,MAAO,CAAC,qBAAqB,CAAC,4BAAgB,CAAC,CAAC;IAC1D,IAAI,EAAE,CAAC;AACT,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport {\n Telemetry,\n sanitizeMessage,\n sanitizeEnvelope,\n sanitizeFrame,\n tryGetErrorCode,\n} from '../telemetry';\nimport * as appInsights from 'applicationinsights';\nimport {basename} from 'path';\nimport {CodedError} from '../CodedError';\n\ndelete process.env.AGENT_NAME; // allow this test to run in Azure DevOps / GHA\nTelemetry.setup(true);\nTelemetry.client!.config.disableAppInsights = true;\n\ntest('Sanitize message, no-op', () => {\n // do stuff\n expect(sanitizeMessage('')).toEqual('');\n expect(sanitizeMessage('some text')).toEqual('some text');\n});\n\ntest('Sanitize message, project_dir', () => {\n expect(sanitizeMessage(`this is the cwd: '${process.cwd()}'`)).toEqual(\n `this is the cwd: [project_dir]\\\\???(${process.cwd().length})`,\n );\n expect(\n sanitizeMessage(`uppercase: '${process.cwd().toUpperCase()}'`),\n ).toEqual(`uppercase: [project_dir]\\\\???(${process.cwd().length})`);\n expect(\n sanitizeMessage(`lowercase: '${process.cwd().toLowerCase()}'`),\n ).toEqual(`lowercase: [project_dir]\\\\???(${process.cwd().length})`);\n expect(\n sanitizeMessage(`this is the cwd: '${process.cwd()}' and something else`),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n process.cwd().length\n }) and something else`,\n );\n expect(\n sanitizeMessage(`this is the cwd: ${process.cwd()} and something else`),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n (process.cwd() + ' and something else').length\n })`,\n );\n});\n\ntest('Sanitize message, node_modules', () => {\n expect(\n sanitizeMessage(`this is the cwd: '${process.cwd()}\\\\node_modules'`),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n (process.cwd() + '\\\\node_modules').length\n })`,\n );\n expect(\n sanitizeMessage(`this is the cwd: '${process.cwd()}\\\\node_modules\\\\foo'`),\n ).toEqual('this is the cwd: node_modules\\\\foo');\n expect(\n sanitizeMessage(\n `uppercase: '${process.cwd().toUpperCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toEqual('uppercase: node_modules\\\\foo');\n expect(\n sanitizeMessage(\n `lowercase: '${process.cwd().toLowerCase()}\\\\NODE_MODULES\\\\'`,\n ),\n ).toEqual('lowercase: node_modules\\\\');\n expect(\n sanitizeMessage(\n `trailing: '${process.cwd()}\\\\node_modules\\\\' and something else`,\n ),\n ).toEqual('trailing: node_modules\\\\ and something else');\n expect(\n sanitizeMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules and something else that could be part of the path`,\n ),\n ).toEqual(\n `this is the cwd: [project_dir]\\\\???(${\n (\n process.cwd() +\n '\\\\node_modules and something else that could be part of the path'\n ).length\n })`,\n );\n expect(\n sanitizeMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules\\\\ a file under nm`,\n ),\n ).toEqual(`this is the cwd: node_modules\\\\ a file under nm`);\n});\n\ntest('Sanitize message, other path', () => {\n expect(sanitizeMessage(`this is another path: 'A:\\\\foo\\\\bar\\\\baz'`)).toEqual(\n `this is another path: [path]`,\n );\n\n expect(sanitizeMessage(`this is another path: A:\\\\foo\\\\bar\\\\baz`)).toEqual(\n `this is another path: [path]`,\n );\n\n expect(\n sanitizeMessage(\n `Cannot find module 'react-native/package.json'\n Require stack:\n - ${process.env.AppData}\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js\n - ${process.env.AppData}\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\bin.js`,\n ),\n ).toEqual(`Cannot find module react-native/package.json \n Require stack:\n - [AppData]\\\\???(${\n (\n process.env.AppData +\n '\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js'\n ).length\n })\n - [AppData]\\\\???(${\n (\n process.env.AppData +\n '\\\\npm-cache\\\\_npx\\\\1384\\\\node_modules\\\\react-native-windows-init\\\\bin.js'\n ).length\n })`);\n});\n\ntest('Sanitize message, forward slashes', () => {\n expect(\n sanitizeMessage(\n `EPERM: operation not permitted, scandir ${process.env.UserProfile!.replace(\n /\\\\/g,\n '/',\n )}/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include`,\n ),\n ).toEqual(\n `EPERM: operation not permitted, scandir [UserProfile]\\\\???(${\n (\n process.env.UserProfile +\n '/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include'\n ).length\n })`,\n );\n});\n\ntest('Sanitize message, file share path', () => {\n expect(sanitizeMessage(`\\\\\\\\server\\\\share`)).toEqual('[path]');\n});\n\ntest('Sanitize message, with cpu/thread id', () => {\n expect(sanitizeMessage('5>This is an error')).toEqual('This is an error');\n\n expect(sanitizeMessage('5:42>This is an error')).toEqual('This is an error');\n});\n\ntest('Error code', () => {\n expect(tryGetErrorCode('foo bar error FOO2020: the thing')).toEqual(\n 'FOO2020',\n );\n});\n\ntest('Sanitize stack frame', () => {\n const emptyFrame: appInsights.Contracts.StackFrame = {\n level: 0,\n method: '',\n fileName: '',\n assembly: 'asdf',\n line: 0,\n };\n sanitizeFrame(emptyFrame);\n expect(emptyFrame).toEqual({\n level: 0,\n assembly: '',\n fileName: '.',\n method: '',\n line: 0,\n });\n\n const frame1: appInsights.Contracts.StackFrame = {\n method: '',\n fileName: `${process.cwd()}\\\\foo.js`,\n assembly: 'asdf',\n level: 0,\n line: 0,\n };\n sanitizeFrame(frame1);\n expect(frame1).toEqual({\n assembly: '',\n fileName: 'telemetry\\\\foo.js',\n method: '',\n level: 0,\n line: 0,\n });\n\n const frame2: appInsights.Contracts.StackFrame = {\n method: `myMethod (something ${process.cwd()}`,\n fileName: `${process.cwd()}\\\\foo.js`,\n assembly: 'asdf',\n level: 1,\n line: 42,\n };\n sanitizeFrame(frame2);\n expect(frame2).toEqual({\n assembly: '',\n fileName: 'telemetry\\\\foo.js',\n method: 'myMethod',\n level: 1,\n line: 42,\n });\n});\n\ntest('basic setup', () => {\n expect(Telemetry.client!.commonProperties.sessionId).toBeDefined();\n\n expect(\n Telemetry.client!.commonProperties.sessionId.length,\n ).toBeGreaterThanOrEqual(32);\n\n expect(Telemetry.client!.commonProperties.isTest).toEqual('true');\n});\n\nfunction b(s: string) {\n throw new Error('hello ' + s);\n}\nfunction a(s: string) {\n b(s);\n}\n\n// #7903: This test assumes exact structure of stack trace, which can be flaky or implementation dependent\ntest.skip('thrown exception a->b, hello world', () => {\n let pass = false;\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = (envelope.data as any).baseData;\n expect(data.exceptions).toBeDefined();\n expect(data.exceptions.length).toEqual(1);\n expect(data.exceptions[0].message).toEqual('hello world');\n\n const stack = data.exceptions[0].parsedStack;\n expect(stack).toBeDefined();\n expect(stack.length).toBeGreaterThan(5);\n\n const filename = basename(__filename);\n expect(stack[0].method).toEqual('b');\n expect(stack[1].method).toEqual('b');\n expect(stack[2].method).toEqual('Object.a');\n expect(stack[0].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[1].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[2].fileName).toEqual(`test\\\\${filename}`);\n pass = true;\n }\n return true;\n });\n try {\n a('world');\n } catch (e) {\n Telemetry.client!.trackException({exception: e as Error});\n }\n Telemetry.client!.flush();\n\n expect(pass).toBeTruthy();\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n});\n\ntest('throw exception with error code', done => {\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n const data = (envelope.data as any).baseData;\n expect(data.properties.errorCode).toEqual('FOO2020');\n return true;\n });\n\n try {\n throw new Error('hello from an error FOO2020: the error string');\n } catch (e) {\n Telemetry.client!.trackException({exception: e as Error});\n Telemetry.client!.flush();\n }\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n done();\n});\n\n// #7903: This test assumes exact structure of stack trace, which can be flaky or implementation dependent\ntest.skip('thrown exception a->b, hello path', done => {\n let pass = false;\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = (envelope.data as any).baseData;\n expect(data.exceptions).toBeDefined();\n expect(data.exceptions.length).toEqual(1);\n expect(data.exceptions[0].message).toEqual(\n `hello [project_dir]\\\\???(${process.cwd().length})`,\n );\n\n const stack = data.exceptions[0].parsedStack;\n expect(stack).toBeDefined();\n expect(stack.length).toBeGreaterThan(5);\n\n const filename = basename(__filename);\n expect(stack[0].method).toEqual('b');\n expect(stack[1].method).toEqual('b');\n expect(stack[2].method).toEqual('Object.a');\n expect(stack[0].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[1].fileName).toEqual(`test\\\\${filename}`);\n expect(stack[2].fileName).toEqual(`test\\\\${filename}`);\n pass = true;\n }\n return true;\n });\n try {\n a(process.cwd());\n } catch (e) {\n Telemetry.client!.trackException({exception: e as Error});\n }\n Telemetry.client!.flush();\n\n expect(pass).toBeTruthy();\n expect(pass).toBeTruthy();\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n done();\n});\n\ntest('trackEvent should not identify roleInstance', () => {\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n expect(envelope.tags['ai.cloud.roleInstance']).toBeUndefined();\n return true;\n });\n Telemetry.client!.trackEvent({\n name: 'test',\n properties: {},\n });\n Telemetry.client!.flush();\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n});\n\n/////////////////////////\n// CodedError tests\ntest('No message', done => {\n Telemetry.preserveMessages = false;\n let pass = false;\n Telemetry.client!.addTelemetryProcessor((envelope, _) => {\n if (envelope.data.baseType === 'ExceptionData') {\n const data = (envelope.data as any).baseData;\n expect(data.exceptions).toBeDefined();\n expect(data.exceptions.length).toEqual(1);\n expect(data.exceptions[0].message).toBeUndefined();\n expect(data.exceptions[0].typeName).toEqual('MSBuildError');\n // This should be 42, but instead it is '42'\n // https://github.com/microsoft/ApplicationInsights-node.js/issues/708\n expect(data.properties.foo).toBeDefined();\n expect(parseInt(data.properties.foo, 10)).toEqual(42);\n pass = true;\n }\n return true;\n });\n\n try {\n throw new CodedError('MSBuildError', 'Something secret', {\n foo: 42,\n });\n } catch (e) {\n Telemetry.client!.trackException({\n exception: e as Error,\n properties: (e as CodedError).data,\n });\n Telemetry.client!.flush();\n }\n\n expect(pass).toEqual(true);\n Telemetry.client!.clearTelemetryProcessors();\n Telemetry.client!.addTelemetryProcessor(sanitizeEnvelope);\n done();\n});\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-windows/telemetry",
|
|
3
|
-
"version": "0.0.0-canary.
|
|
3
|
+
"version": "0.0.0-canary.24",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"typings": "lib-commonjs/index.d.ts",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"applicationinsights": "^1.8.8"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@rnw-scripts/eslint-config": "1.1.
|
|
25
|
-
"@rnw-scripts/jest-unittest-config": "1.2.
|
|
26
|
-
"@rnw-scripts/just-task": "2.1
|
|
27
|
-
"@rnw-scripts/ts-config": "2.0.
|
|
24
|
+
"@rnw-scripts/eslint-config": "1.1.8",
|
|
25
|
+
"@rnw-scripts/jest-unittest-config": "1.2.4",
|
|
26
|
+
"@rnw-scripts/just-task": "2.2.1",
|
|
27
|
+
"@rnw-scripts/ts-config": "2.0.1",
|
|
28
28
|
"@types/jest": "^26.0.20",
|
|
29
29
|
"@types/node": "^14.14.22",
|
|
30
30
|
"@types/semver": "^7.3.3",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"jest": "^26.6.3",
|
|
34
34
|
"just-scripts": "^1.3.3",
|
|
35
35
|
"prettier": "1.19.1",
|
|
36
|
-
"typescript": "^
|
|
36
|
+
"typescript": "^4.4.4"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
39
|
"lib-commonjs"
|
|
@@ -46,5 +46,9 @@
|
|
|
46
46
|
"patch"
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
|
-
"promoteRelease": true
|
|
49
|
+
"promoteRelease": true,
|
|
50
|
+
"windowsOnly": true,
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">= 12.0.0"
|
|
53
|
+
}
|
|
50
54
|
}
|