@react-native-windows/telemetry 0.76.0-preview.1 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"basePropUtils.test.js","sourceRoot":"","sources":["../../src/test/basePropUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sEAAwD;AAExD,IAAI,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACrC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;IAC7C,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,+BAA+B,EAAE,GAAG,EAAE;IACzC,MAAM,KAAK,GAAG,aAAa,CAAC,kBAAkB,EAAE,CAAC;IACjD,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,6BAA6B,EAAE,GAAG,EAAE;IACvC,MAAM,KAAK,GAAG,aAAa,CAAC,gBAAgB,EAA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IAC3C,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;IAC7B,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACpC,MAAM,KAAK,GAAG,aAAa,CAAC,YAAY,EAAE,CAAC;IAC3C,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;IAE/B,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;AAClC,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC1C,MAAM,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as basePropUtils from '../utils/basePropUtils';\n\ntest('deviceId() is valid', async () => {\n const value = await basePropUtils.deviceId();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceId() does not change', async () => {\n expect(await basePropUtils.deviceId()).toBe(await basePropUtils.deviceId());\n});\n\ntest('deviceArchitecture() is valid', () => {\n const value = basePropUtils.deviceArchitecture();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('nodeArchitecture() is valid', () => {\n const value = basePropUtils.nodeArchitecture();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('devicePlatform() is valid', () => {\n const value = basePropUtils.devicePlatform();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceLocale() is valid', async () => {\n const value = await basePropUtils.deviceLocale();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceLocale() does not change', async () => {\n expect(await basePropUtils.deviceLocale()).toBe(\n await basePropUtils.deviceLocale(),\n );\n});\n\ntest('deviceNumCPUs() is valid', () => {\n const value = basePropUtils.deviceNumCPUs();\n expect(value).toBeGreaterThan(0);\n});\n\ntest('deviceTotalMemory() is valid', () => {\n const value = basePropUtils.deviceTotalMemory();\n expect(value).toBeGreaterThan(0);\n});\n\ntest('deviceDiskFreeSpace() is valid', () => {\n const value = basePropUtils.deviceDiskFreeSpace();\n expect(value).toBeGreaterThanOrEqual(0);\n});\n\ntest('sampleRate() is within valid range', () => {\n const value = basePropUtils.sampleRate();\n expect(value).toBeGreaterThanOrEqual(0);\n expect(value).toBeLessThanOrEqual(100);\n});\n\ntest('ciType() is valid', () => {\n const value = basePropUtils.ciType();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('ciType() is None when not in CI', () => {\n if (basePropUtils.isCI()) {\n expect(basePropUtils.ciType()).not.toBe('None');\n } else {\n expect(basePropUtils.ciType()).toBe('None');\n }\n});\n\ntest('isMsftInternal() is false with no domain', () => {\n delete process.env.UserDNSDomain;\n expect(basePropUtils.isMsftInternal()).toBe(false);\n});\n\ntest('isMsftInternal() is false with example.com domain', () => {\n process.env.UserDNSDomain = 'example.com';\n expect(basePropUtils.isMsftInternal()).toBe(false);\n});\n\ntest('isMsftInternal() is true with Msft domain', () => {\n process.env.UserDNSDomain = 'test.corp.microsoft.com';\n expect(basePropUtils.isMsftInternal()).toBe(true);\n});\n\ntest('isCliTest() is true if RNW_CLI_TEST env variable is set', () => {\n process.env.RNW_CLI_TEST = 'true';\n expect(basePropUtils.isCliTest()).toBe(true);\n});\n\ntest('isCliTest() is false if no RNW_CLI_TEST variable', () => {\n delete process.env.RNW_CLI_TEST;\n expect(basePropUtils.isCliTest()).toBe(false);\n});\n\ntest('getSessionId() is valid', () => {\n const value = basePropUtils.getSessionId();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n expect(value).toHaveLength(32);\n});\n\ntest('getSessionId() is a guid', () => {\n const value = basePropUtils.getSessionId();\n expect(value).toHaveLength(32);\n\n const parseGuid = () => {\n parseInt(value, 16);\n };\n\n expect(parseGuid).not.toThrow();\n});\n\ntest('getSessionId() does not change', () => {\n expect(basePropUtils.getSessionId()).toBe(basePropUtils.getSessionId());\n});\n"]}
1
+ {"version":3,"file":"basePropUtils.test.js","sourceRoot":"","sources":["../../src/test/basePropUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,sEAAwD;AAExD,IAAI,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACrC,MAAM,KAAK,GAAG,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC;IAC7C,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC9E,CAAC,CAAC,CAAC;AAEH,IAAI,CAA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,CAAC,aAAa,CAAC,YAAY,EAAE,CAAC,CAAC;AAC1E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACpC,MAAM,KAAK,GAAG,aAAa,CAAC,aAAa,EAAE,CAAC;IAC5C,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as basePropUtils from '../utils/basePropUtils';\n\ntest('deviceId() is valid', async () => {\n const value = await basePropUtils.deviceId();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceId() does not change', async () => {\n expect(await basePropUtils.deviceId()).toBe(await basePropUtils.deviceId());\n});\n\ntest('deviceArchitecture() is valid', () => {\n const value = basePropUtils.deviceArchitecture();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('nodeArchitecture() is valid', () => {\n const value = basePropUtils.nodeArchitecture();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceClass() is valid', () => {\n const value = basePropUtils.deviceClass();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('nodePlatform() is valid', () => {\n const value = basePropUtils.nodePlatform();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceLocale() is valid', async () => {\n const value = await basePropUtils.deviceLocale();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('deviceLocale() does not change', async () => {\n expect(await basePropUtils.deviceLocale()).toBe(\n await basePropUtils.deviceLocale(),\n );\n});\n\ntest('deviceNumCPUs() is valid', () => {\n const value = basePropUtils.deviceNumCPUs();\n expect(value).toBeGreaterThan(0);\n});\n\ntest('deviceTotalMemory() is valid', () => {\n const value = basePropUtils.deviceTotalMemory();\n expect(value).toBeGreaterThan(0);\n});\n\ntest('deviceDiskFreeSpace() is valid', () => {\n const value = basePropUtils.deviceDiskFreeSpace();\n expect(value).toBeGreaterThanOrEqual(0);\n});\n\ntest('ciType() is valid', () => {\n const value = basePropUtils.ciType();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n\ntest('ciType() is None when not in CI', () => {\n if (basePropUtils.isCI()) {\n expect(basePropUtils.ciType()).not.toBe('None');\n } else {\n expect(basePropUtils.ciType()).toBe('None');\n }\n});\n\ntest('isMsftInternal() is false with no domain', () => {\n delete process.env.UserDNSDomain;\n expect(basePropUtils.isMsftInternal()).toBe(false);\n});\n\ntest('isMsftInternal() is false with example.com domain', () => {\n process.env.UserDNSDomain = 'example.com';\n expect(basePropUtils.isMsftInternal()).toBe(false);\n});\n\ntest('isMsftInternal() is true with Msft domain', () => {\n process.env.UserDNSDomain = 'test.corp.microsoft.com';\n expect(basePropUtils.isMsftInternal()).toBe(true);\n});\n\ntest('isCliTest() is true if RNW_CLI_TEST env variable is set', () => {\n process.env.RNW_CLI_TEST = 'true';\n expect(basePropUtils.isCliTest()).toBe(true);\n});\n\ntest('isCliTest() is false if no RNW_CLI_TEST variable', () => {\n delete process.env.RNW_CLI_TEST;\n expect(basePropUtils.isCliTest()).toBe(false);\n});\n\ntest('getSessionId() is valid', () => {\n const value = basePropUtils.getSessionId();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n expect(value).toHaveLength(32);\n});\n\ntest('getSessionId() is a guid', () => {\n const value = basePropUtils.getSessionId();\n expect(value).toHaveLength(32);\n\n const parseGuid = () => {\n parseInt(value, 16);\n };\n\n expect(parseGuid).not.toThrow();\n});\n\ntest('getSessionId() does not change', () => {\n expect(basePropUtils.getSessionId()).toBe(basePropUtils.getSessionId());\n});\n\ntest('fullBuildInfo() is valid', () => {\n const value = basePropUtils.fullBuildInfo();\n expect(value).toBeDefined();\n expect(value).not.toBe('');\n expect(value).not.toBeNull();\n});\n"]}
@@ -113,54 +113,48 @@ test('sanitizeErrorMessage() with standard MSBuild error', () => {
113
113
  expect(errorUtils.sanitizeErrorMessage(`2:6>C:\\Program Files (x86)\\Windows Kits\\10\\bin\\10.0.22621.0\\XamlCompiler\\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The "CompileXaml" task returned false but did not log an error. [${process.cwd()}\\windows\\teltest68\\teltest68.csproj]`)).toEqual(`[path](486,5): error MSB4181: The CompileXaml task returned false but did not log an error. [windows]\\???.csproj(${'teltest68\\teltest68.csproj'.length})`);
114
114
  });
115
115
  test('sanitizeErrorStackFrame() with empty frame', () => {
116
- const emptyFrame = {
117
- level: 0,
118
- method: '',
119
- fileName: '',
120
- assembly: 'asdf',
121
- line: 0,
116
+ const stackFrame = {
117
+ functionName: '',
118
+ filePath: '',
119
+ lineNumber: 0,
120
+ columnNumber: 0,
122
121
  };
123
- errorUtils.sanitizeErrorStackFrame(emptyFrame);
124
- expect(emptyFrame).toEqual({
125
- level: 0,
126
- assembly: '',
127
- fileName: '[path]',
128
- method: '',
129
- line: 0,
122
+ errorUtils.sanitizeErrorStackFrame(stackFrame);
123
+ expect(stackFrame).toEqual({
124
+ functionName: '',
125
+ filePath: '[path]',
126
+ lineNumber: 0,
127
+ columnNumber: 0,
130
128
  });
131
129
  });
132
130
  test('sanitizeErrorStackFrame() with assembly name', () => {
133
- const frame1 = {
134
- method: '',
135
- fileName: `${process.cwd()}\\foo.js`,
136
- assembly: 'asdf',
137
- level: 0,
138
- line: 0,
131
+ const stackFrame = {
132
+ functionName: '',
133
+ filePath: `${process.cwd()}\\foo.js`,
134
+ lineNumber: 10,
135
+ columnNumber: 14,
139
136
  };
140
- errorUtils.sanitizeErrorStackFrame(frame1);
141
- expect(frame1).toEqual({
142
- assembly: '',
143
- fileName: '[project_dir]\\???.js(6)',
144
- method: '',
145
- level: 0,
146
- line: 0,
137
+ errorUtils.sanitizeErrorStackFrame(stackFrame);
138
+ expect(stackFrame).toEqual({
139
+ functionName: '',
140
+ filePath: '[project_dir]\\???.js(6)',
141
+ lineNumber: 10,
142
+ columnNumber: 14,
147
143
  });
148
144
  });
149
145
  test('sanitizeErrorStackFrame() with method name', () => {
150
- const frame2 = {
151
- method: `myMethod (something ${process.cwd()}`,
152
- fileName: `${process.cwd()}\\telemetry\\foo.js`,
153
- assembly: 'asdf',
154
- level: 1,
155
- line: 42,
146
+ const stackFrame = {
147
+ functionName: `myMethod (something ${process.cwd()}`,
148
+ filePath: `${process.cwd()}\\telemetry\\foo.js`,
149
+ lineNumber: 10,
150
+ columnNumber: 14,
156
151
  };
157
- errorUtils.sanitizeErrorStackFrame(frame2);
158
- expect(frame2).toEqual({
159
- assembly: '',
160
- fileName: '[project_dir]\\???.js(16)',
161
- method: 'myMethod',
162
- level: 1,
163
- line: 42,
152
+ errorUtils.sanitizeErrorStackFrame(stackFrame);
153
+ expect(stackFrame).toEqual({
154
+ functionName: 'myMethod',
155
+ filePath: '[project_dir]\\???.js(16)',
156
+ lineNumber: 10,
157
+ columnNumber: 14,
164
158
  });
165
159
  });
166
160
  //# sourceMappingURL=errorUtils.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorUtils.test.js","sourceRoot":"","sources":["../../src/test/errorUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;AAIH,gEAAkD;AAElD,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACnD,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,kCAAkC,CAAC,CAAC,CAAC,IAAI,CACzE,SAAS,CACV,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,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E;KACT,CAAC;IACF,UAAU,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;QACrB,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,2BAA2B;QACrC,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,EAAE;KACT,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\n\nimport * as errorUtils from '../utils/errorUtils';\n\ntest('tryGetErrorCode() with valid error code', () => {\n expect(errorUtils.tryGetErrorCode('foo bar error FOO2020: the thing')).toBe(\n 'FOO2020',\n );\n});\n\ntest('tryGetErrorCode() without valid error code', () => {\n expect(errorUtils.tryGetErrorCode('foo bar the thing')).toBeUndefined();\n});\n\ntest('tryGetErrorCode() with word error but no code', () => {\n expect(errorUtils.tryGetErrorCode('test error')).toBeUndefined();\n});\n\ntest('sanitizeErrorMessage() no-op on empty string', () => {\n expect(errorUtils.sanitizeErrorMessage('')).toBe('');\n});\n\ntest('sanitizeErrorMessage() no-op on test string', () => {\n expect(errorUtils.sanitizeErrorMessage('some text')).toBe('some text');\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}'`),\n ).toBe(`this is the cwd: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' uppercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `uppercase: '${process.cwd().toUpperCase()}'`,\n ),\n ).toBe(`uppercase: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' lowercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `lowercase: '${process.cwd().toLowerCase()}'`,\n ),\n ).toBe(`lowercase: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' and something else\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}' and something else`,\n ),\n ).toBe(`this is the cwd: [project_dir] and something else`);\n});\n\ntest('sanitizeErrorMessage() project_dir and something else', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()} and something else`,\n ),\n ).toBe(\n `this is the cwd: [project_dir]\\\\???(${' and something else'.length})`,\n );\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}\\\\node_modules'`,\n ),\n ).toBe(`this is the cwd: [project_dir]\\\\???(${'node_modules'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}\\\\node_modules\\\\foo'`,\n ),\n ).toBe(`this is the cwd: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo' uppercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `uppercase: '${process.cwd().toUpperCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toBe(`uppercase: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo' lowercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `lowercase: '${process.cwd().toLowerCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toBe(`lowercase: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\' and something else\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `trailing: '${process.cwd()}\\\\node_modules\\\\' and something else`,\n ),\n ).toBe(`trailing: [node_modules]\\\\???(0) and something else`);\n});\n\ntest('sanitizeErrorMessage() node_modules and something else that could be part of the path', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules and something else that could be part of the path`,\n ),\n ).toBe(\n `this is the cwd: [project_dir]\\\\???(${\n 'node_modules and something else that could be part of the path'.length\n })`,\n );\n});\n\ntest('sanitizeErrorMessage() \\\\node_modules\\\\ a file under nm', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules\\\\ a file under nm`,\n ),\n ).toBe(`this is the cwd: [node_modules]\\\\???(${' a file under nm'.length})`);\n});\n\ntest('sanitizeErrorMessage() other path', () => {\n expect(\n errorUtils.sanitizeErrorMessage(`this is another path: A:\\\\foo\\\\bar\\\\baz`),\n ).toBe(`this is another path: [path]`);\n});\n\ntest(\"sanitizeErrorMessage() 'other path'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is another path: 'A:\\\\foo\\\\bar\\\\baz'`,\n ),\n ).toBe(`this is another path: [path]`);\n});\n\ntest('sanitizeErrorMessage() tracked packages in the npx cache', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\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 ).toBe(`Cannot find module react-native/package.json\n Require stack:\n - [node_modules]\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js\n - [node_modules]\\\\react-native-windows-init\\\\bin.js`);\n});\n\ntest('sanitizeErrorMessage() forward slashes', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\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 ).toBe(\n `EPERM: operation not permitted, scandir [UserProfile]\\\\???(${\n '/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include'\n .length\n })`,\n );\n});\n\ntest('sanitizeErrorMessage() file share path', () => {\n expect(errorUtils.sanitizeErrorMessage(`file here: \\\\\\\\server\\\\share`)).toBe(\n 'file here: [path]',\n );\n});\n\ntest('sanitizeErrorMessage() with cpu id', () => {\n expect(errorUtils.sanitizeErrorMessage('5>This is an error')).toBe(\n 'This is an error',\n );\n});\n\ntest('sanitizeErrorMessage() with cpu/thread id', () => {\n expect(errorUtils.sanitizeErrorMessage('5:42>This is an error')).toEqual(\n 'This is an error',\n );\n});\n\ntest('sanitizeErrorMessage() with standard MSBuild error', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `2:6>C:\\\\Program Files (x86)\\\\Windows Kits\\\\10\\\\bin\\\\10.0.22621.0\\\\XamlCompiler\\\\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The \"CompileXaml\" task returned false but did not log an error. [${process.cwd()}\\\\windows\\\\teltest68\\\\teltest68.csproj]`,\n ),\n ).toEqual(\n `[path](486,5): error MSB4181: The CompileXaml task returned false but did not log an error. [windows]\\\\???.csproj(${\n 'teltest68\\\\teltest68.csproj'.length\n })`,\n );\n});\n\ntest('sanitizeErrorStackFrame() with empty frame', () => {\n const emptyFrame: appInsights.Contracts.StackFrame = {\n level: 0,\n method: '',\n fileName: '',\n assembly: 'asdf',\n line: 0,\n };\n errorUtils.sanitizeErrorStackFrame(emptyFrame);\n expect(emptyFrame).toEqual({\n level: 0,\n assembly: '',\n fileName: '[path]',\n method: '',\n line: 0,\n });\n});\n\ntest('sanitizeErrorStackFrame() with assembly name', () => {\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 errorUtils.sanitizeErrorStackFrame(frame1);\n expect(frame1).toEqual({\n assembly: '',\n fileName: '[project_dir]\\\\???.js(6)',\n method: '',\n level: 0,\n line: 0,\n });\n});\n\ntest('sanitizeErrorStackFrame() with method name', () => {\n const frame2: appInsights.Contracts.StackFrame = {\n method: `myMethod (something ${process.cwd()}`,\n fileName: `${process.cwd()}\\\\telemetry\\\\foo.js`,\n assembly: 'asdf',\n level: 1,\n line: 42,\n };\n errorUtils.sanitizeErrorStackFrame(frame2);\n expect(frame2).toEqual({\n assembly: '',\n fileName: '[project_dir]\\\\???.js(16)',\n method: 'myMethod',\n level: 1,\n line: 42,\n });\n});\n"]}
1
+ {"version":3,"file":"errorUtils.test.js","sourceRoot":"","sources":["../../src/test/errorUtils.test.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gEAAkD;AAElD,IAAI,CAAC,yCAAyC,EAAE,GAAG,EAAE;IACnD,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,kCAAkC,CAAC,CAAC,CAAC,IAAI,CACzE,SAAS,CACV,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACtD,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,mBAAmB,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;AAC1E,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,+CAA+C,EAAE,GAAG,EAAE;IACzD,MAAM,CAAC,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;AACnE,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,8CAA8C,EAAE,GAAG,EAAE;IACxD,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,6CAA6C,EAAE,GAAG,EAAE;IACvD,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC;AAEH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AAC;IACF,UAAU,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QACzB,YAAY,EAAE,EAAE;QAChB,QAAQ,EAAE,0BAA0B;QACpC,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACtD,MAAM,UAAU,GAAG;QACjB,YAAY,EAAE,uBAAuB,OAAO,CAAC,GAAG,EAAE,EAAE;QACpD,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,qBAAqB;QAC/C,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB,CAAC;IACF,UAAU,CAAC,uBAAuB,CAAC,UAAU,CAAC,CAAC;IAC/C,MAAM,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC;QACzB,YAAY,EAAE,UAAU;QACxB,QAAQ,EAAE,2BAA2B;QACrC,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;KACjB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n *\n * @format\n */\n\nimport * as errorUtils from '../utils/errorUtils';\n\ntest('tryGetErrorCode() with valid error code', () => {\n expect(errorUtils.tryGetErrorCode('foo bar error FOO2020: the thing')).toBe(\n 'FOO2020',\n );\n});\n\ntest('tryGetErrorCode() without valid error code', () => {\n expect(errorUtils.tryGetErrorCode('foo bar the thing')).toBeUndefined();\n});\n\ntest('tryGetErrorCode() with word error but no code', () => {\n expect(errorUtils.tryGetErrorCode('test error')).toBeUndefined();\n});\n\ntest('sanitizeErrorMessage() no-op on empty string', () => {\n expect(errorUtils.sanitizeErrorMessage('')).toBe('');\n});\n\ntest('sanitizeErrorMessage() no-op on test string', () => {\n expect(errorUtils.sanitizeErrorMessage('some text')).toBe('some text');\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(`this is the cwd: '${process.cwd()}'`),\n ).toBe(`this is the cwd: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' uppercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `uppercase: '${process.cwd().toUpperCase()}'`,\n ),\n ).toBe(`uppercase: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' lowercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `lowercase: '${process.cwd().toLowerCase()}'`,\n ),\n ).toBe(`lowercase: [project_dir]`);\n});\n\ntest(\"sanitizeErrorMessage() 'project_dir' and something else\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}' and something else`,\n ),\n ).toBe(`this is the cwd: [project_dir] and something else`);\n});\n\ntest('sanitizeErrorMessage() project_dir and something else', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()} and something else`,\n ),\n ).toBe(\n `this is the cwd: [project_dir]\\\\???(${' and something else'.length})`,\n );\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}\\\\node_modules'`,\n ),\n ).toBe(`this is the cwd: [project_dir]\\\\???(${'node_modules'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: '${process.cwd()}\\\\node_modules\\\\foo'`,\n ),\n ).toBe(`this is the cwd: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo' uppercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `uppercase: '${process.cwd().toUpperCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toBe(`uppercase: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\foo' lowercase\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `lowercase: '${process.cwd().toLowerCase()}\\\\NODE_MODULES\\\\foo'`,\n ),\n ).toBe(`lowercase: [node_modules]\\\\???(${'foo'.length})`);\n});\n\ntest(\"sanitizeErrorMessage() 'node_modules\\\\' and something else\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `trailing: '${process.cwd()}\\\\node_modules\\\\' and something else`,\n ),\n ).toBe(`trailing: [node_modules]\\\\???(0) and something else`);\n});\n\ntest('sanitizeErrorMessage() node_modules and something else that could be part of the path', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules and something else that could be part of the path`,\n ),\n ).toBe(\n `this is the cwd: [project_dir]\\\\???(${\n 'node_modules and something else that could be part of the path'.length\n })`,\n );\n});\n\ntest('sanitizeErrorMessage() \\\\node_modules\\\\ a file under nm', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is the cwd: ${process.cwd()}\\\\node_modules\\\\ a file under nm`,\n ),\n ).toBe(`this is the cwd: [node_modules]\\\\???(${' a file under nm'.length})`);\n});\n\ntest('sanitizeErrorMessage() other path', () => {\n expect(\n errorUtils.sanitizeErrorMessage(`this is another path: A:\\\\foo\\\\bar\\\\baz`),\n ).toBe(`this is another path: [path]`);\n});\n\ntest(\"sanitizeErrorMessage() 'other path'\", () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `this is another path: 'A:\\\\foo\\\\bar\\\\baz'`,\n ),\n ).toBe(`this is another path: [path]`);\n});\n\ntest('sanitizeErrorMessage() tracked packages in the npx cache', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\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 ).toBe(`Cannot find module react-native/package.json\n Require stack:\n - [node_modules]\\\\react-native-windows-init\\\\lib-commonjs\\\\Cli.js\n - [node_modules]\\\\react-native-windows-init\\\\bin.js`);\n});\n\ntest('sanitizeErrorMessage() forward slashes', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\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 ).toBe(\n `EPERM: operation not permitted, scandir [UserProfile]\\\\???(${\n '/source/repos/rn2/wintest/windows/packages/boost.1.76.0.0/lib/native/include'\n .length\n })`,\n );\n});\n\ntest('sanitizeErrorMessage() file share path', () => {\n expect(errorUtils.sanitizeErrorMessage(`file here: \\\\\\\\server\\\\share`)).toBe(\n 'file here: [path]',\n );\n});\n\ntest('sanitizeErrorMessage() with cpu id', () => {\n expect(errorUtils.sanitizeErrorMessage('5>This is an error')).toBe(\n 'This is an error',\n );\n});\n\ntest('sanitizeErrorMessage() with cpu/thread id', () => {\n expect(errorUtils.sanitizeErrorMessage('5:42>This is an error')).toEqual(\n 'This is an error',\n );\n});\n\ntest('sanitizeErrorMessage() with standard MSBuild error', () => {\n expect(\n errorUtils.sanitizeErrorMessage(\n `2:6>C:\\\\Program Files (x86)\\\\Windows Kits\\\\10\\\\bin\\\\10.0.22621.0\\\\XamlCompiler\\\\Microsoft.Windows.UI.Xaml.Common.targets(486,5): error MSB4181: The \"CompileXaml\" task returned false but did not log an error. [${process.cwd()}\\\\windows\\\\teltest68\\\\teltest68.csproj]`,\n ),\n ).toEqual(\n `[path](486,5): error MSB4181: The CompileXaml task returned false but did not log an error. [windows]\\\\???.csproj(${\n 'teltest68\\\\teltest68.csproj'.length\n })`,\n );\n});\n\ntest('sanitizeErrorStackFrame() with empty frame', () => {\n const stackFrame = {\n functionName: '',\n filePath: '',\n lineNumber: 0,\n columnNumber: 0,\n };\n errorUtils.sanitizeErrorStackFrame(stackFrame);\n expect(stackFrame).toEqual({\n functionName: '',\n filePath: '[path]',\n lineNumber: 0,\n columnNumber: 0,\n });\n});\n\ntest('sanitizeErrorStackFrame() with assembly name', () => {\n const stackFrame = {\n functionName: '',\n filePath: `${process.cwd()}\\\\foo.js`,\n lineNumber: 10,\n columnNumber: 14,\n };\n errorUtils.sanitizeErrorStackFrame(stackFrame);\n expect(stackFrame).toEqual({\n functionName: '',\n filePath: '[project_dir]\\\\???.js(6)',\n lineNumber: 10,\n columnNumber: 14,\n });\n});\n\ntest('sanitizeErrorStackFrame() with method name', () => {\n const stackFrame = {\n functionName: `myMethod (something ${process.cwd()}`,\n filePath: `${process.cwd()}\\\\telemetry\\\\foo.js`,\n lineNumber: 10,\n columnNumber: 14,\n };\n errorUtils.sanitizeErrorStackFrame(stackFrame);\n expect(stackFrame).toEqual({\n functionName: 'myMethod',\n filePath: '[project_dir]\\\\???.js(16)',\n lineNumber: 10,\n columnNumber: 14,\n });\n});\n"]}
@@ -3,11 +3,22 @@
3
3
  * Licensed under the MIT License.
4
4
  * @format
5
5
  */
6
+ /**
7
+ * Given a path and a key, retrieves the value from the Registry.
8
+ * @returns If the path and key exist, the requested value from the Registry; empty string otherwise.
9
+ */
10
+ export declare function getValueFromRegistry(path: string, key: string): Promise<string>;
6
11
  /**
7
12
  * Gets a telemetry-safe stable device ID.
8
13
  * @returns A telemetry-safe stable device ID.
9
14
  */
10
15
  export declare function deviceId(): Promise<string>;
16
+ /**
17
+ * Gets the Windows build name, number and architecture.
18
+ * @returns A string containing the Windows build name, number and architecture.
19
+ * e.g. 19569.1000.amd64fre.rs_prerelease.200214-1419
20
+ */
21
+ export declare function fullBuildInfo(): Promise<string>;
11
22
  /**
12
23
  * Gets the device architecture, like x86/x64/arm64.
13
24
  * @returns The device architecture.
@@ -19,10 +30,15 @@ export declare function deviceArchitecture(): string;
19
30
  */
20
31
  export declare function nodeArchitecture(): string;
21
32
  /**
22
- * Gets the device platform, like darwin/linux/win32.
33
+ * Gets the node platform, like darwin/linux/win32.
23
34
  * @returns The device platform.
24
35
  */
25
- export declare function devicePlatform(): string;
36
+ export declare function nodePlatform(): string;
37
+ /**
38
+ * Gets the OS name, to be filled in the PartA device.deviceClass field.
39
+ * @returns The device class.
40
+ */
41
+ export declare function deviceClass(): string;
26
42
  /**
27
43
  * Gets the device locale.
28
44
  * @returns The device locale.
@@ -44,11 +60,6 @@ export declare function deviceTotalMemory(): number;
44
60
  * @returns The free space of the give drive in bytes.
45
61
  */
46
62
  export declare function deviceDiskFreeSpace(drivePath?: string | null): number;
47
- /**
48
- * Gets the telemetry sample rate.
49
- * @returns The telemetry sample rate.
50
- */
51
- export declare function sampleRate(): number;
52
63
  /**
53
64
  * Gets whether or not telemetry events are captured when running in CI.
54
65
  * @returns Whether or not telemetry events are captured when running in CI.
@@ -8,7 +8,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
9
9
  };
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.getSessionId = exports.isCliTest = exports.isMsftInternal = exports.ciType = exports.isCI = exports.captureCI = exports.sampleRate = exports.deviceDiskFreeSpace = exports.deviceTotalMemory = exports.deviceNumCPUs = exports.deviceLocale = exports.devicePlatform = exports.nodeArchitecture = exports.deviceArchitecture = exports.deviceId = void 0;
11
+ exports.getSessionId = exports.isCliTest = exports.isMsftInternal = exports.ciType = exports.isCI = exports.captureCI = exports.deviceDiskFreeSpace = exports.deviceTotalMemory = exports.deviceNumCPUs = exports.deviceLocale = exports.deviceClass = exports.nodePlatform = exports.nodeArchitecture = exports.deviceArchitecture = exports.fullBuildInfo = exports.deviceId = exports.getValueFromRegistry = void 0;
12
12
  const child_process_1 = require("child_process");
13
13
  const os_1 = require("os");
14
14
  const ci_info_1 = __importDefault(require("ci-info"));
@@ -16,19 +16,34 @@ const crypto_1 = require("crypto");
16
16
  const os_locale_1 = __importDefault(require("os-locale"));
17
17
  const DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\SQMClient';
18
18
  const DeviceIdRegKey = 'MachineId';
19
+ const DeviceIdBuildPath = '"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"';
20
+ const DeviceIdBuildKey = 'BuildLabEx';
19
21
  /**
20
- * Gets a telemetry-safe stable device ID.
21
- * @returns A telemetry-safe stable device ID.
22
+ * Given a path and a key, retrieves the value from the Registry.
23
+ * @returns If the path and key exist, the requested value from the Registry; empty string otherwise.
22
24
  */
23
- async function deviceId() {
25
+ async function getValueFromRegistry(path, key) {
24
26
  try {
25
- let regCommand = `${process.env.windir}\\System32\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`;
27
+ let regCommand = `${process.env.windir}\\System32\\reg.exe query ${path} /v ${key}`;
26
28
  if (deviceArchitecture() === 'x64') {
27
29
  // Ensure we query the correct registry
28
30
  regCommand += ' /reg:64';
29
31
  }
30
32
  const output = (0, child_process_1.execSync)(regCommand).toString();
31
- const result = output.match(/\{([0-9A-Fa-f-]{36})\}/);
33
+ return output;
34
+ }
35
+ catch (_a) { }
36
+ return '';
37
+ }
38
+ exports.getValueFromRegistry = getValueFromRegistry;
39
+ /**
40
+ * Gets a telemetry-safe stable device ID.
41
+ * @returns A telemetry-safe stable device ID.
42
+ */
43
+ async function deviceId() {
44
+ try {
45
+ const deviceIdValue = await getValueFromRegistry(DeviceIdRegPath, DeviceIdRegKey);
46
+ const result = deviceIdValue.match(/\{([0-9A-Fa-f-]{36})\}/);
32
47
  if (result && result.length > 1) {
33
48
  return `s:${result[1]}`;
34
49
  }
@@ -37,6 +52,24 @@ async function deviceId() {
37
52
  return '';
38
53
  }
39
54
  exports.deviceId = deviceId;
55
+ /**
56
+ * Gets the Windows build name, number and architecture.
57
+ * @returns A string containing the Windows build name, number and architecture.
58
+ * e.g. 19569.1000.amd64fre.rs_prerelease.200214-1419
59
+ */
60
+ async function fullBuildInfo() {
61
+ try {
62
+ const fullBuildValue = await getValueFromRegistry(DeviceIdBuildPath, DeviceIdBuildKey);
63
+ // Retrieve the build info
64
+ const match = fullBuildValue.match(/BuildLabEx\s+REG_SZ\s+([^\r\n]+)/);
65
+ if (match && match.length > 1) {
66
+ return match[1];
67
+ }
68
+ }
69
+ catch (_a) { }
70
+ return '';
71
+ }
72
+ exports.fullBuildInfo = fullBuildInfo;
40
73
  /**
41
74
  * Gets the device architecture, like x86/x64/arm64.
42
75
  * @returns The device architecture.
@@ -59,13 +92,31 @@ function nodeArchitecture() {
59
92
  }
60
93
  exports.nodeArchitecture = nodeArchitecture;
61
94
  /**
62
- * Gets the device platform, like darwin/linux/win32.
95
+ * Gets the node platform, like darwin/linux/win32.
63
96
  * @returns The device platform.
64
97
  */
65
- function devicePlatform() {
98
+ function nodePlatform() {
66
99
  return (0, os_1.platform)();
67
100
  }
68
- exports.devicePlatform = devicePlatform;
101
+ exports.nodePlatform = nodePlatform;
102
+ /**
103
+ * Gets the OS name, to be filled in the PartA device.deviceClass field.
104
+ * @returns The device class.
105
+ */
106
+ function deviceClass() {
107
+ const node = nodePlatform();
108
+ switch (node) {
109
+ case 'darwin':
110
+ return 'Mac';
111
+ case 'linux':
112
+ return 'Linux';
113
+ case 'win32':
114
+ return 'Windows';
115
+ default:
116
+ return node;
117
+ }
118
+ }
119
+ exports.deviceClass = deviceClass;
69
120
  /**
70
121
  * Gets the device locale.
71
122
  * @returns The device locale.
@@ -110,14 +161,6 @@ function deviceDiskFreeSpace(drivePath) {
110
161
  return -1;
111
162
  }
112
163
  exports.deviceDiskFreeSpace = deviceDiskFreeSpace;
113
- /**
114
- * Gets the telemetry sample rate.
115
- * @returns The telemetry sample rate.
116
- */
117
- function sampleRate() {
118
- return 100;
119
- }
120
- exports.sampleRate = sampleRate;
121
164
  /**
122
165
  * Gets whether or not telemetry events are captured when running in CI.
123
166
  * @returns Whether or not telemetry events are captured when running in CI.
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;;GAGG;AACH,SAAgB,IAAI;IAClB,OAAO,iBAAE,CAAC,IAAI,CAAC;AACjB,CAAC;AAFD,oBAEC;AAED;;;GAGG;AACH,SAAgB,MAAM;;IACpB,OAAO,iBAAE,CAAC,IAAI,CAAC,CAAC,CAAC,MAAA,iBAAE,CAAC,IAAI,mCAAI,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC;AACjD,CAAC;AAFD,wBAEC;AAED;;;GAGG;AACH,SAAgB,cAAc;IAC5B,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,aAAa,KAAK,SAAS;QACvC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CACvE,CAAC;AACJ,CAAC;AALD,wCAKC;AAED;;;GAGG;AACH,SAAgB,SAAS;IACvB,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS;QACtC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,MAAM,CACzD,CAAC;AACJ,CAAC;AALD,8BAKC;AAED,IAAI,SAA6B,CAAC;AAElC;;;GAGG;AACH,SAAgB,YAAY;IAC1B,OAAO,CACL,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,SAAS,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC;AAJD,oCAIC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {execSync} from 'child_process';\nimport {totalmem, cpus, platform} from 'os';\n\nimport ci from 'ci-info';\nimport {randomBytes} from 'crypto';\nimport osLocale from 'os-locale';\n\nconst DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\SQMClient';\nconst DeviceIdRegKey = 'MachineId';\n\n/**\n * Gets a telemetry-safe stable device ID.\n * @returns A telemetry-safe stable device ID.\n */\nexport async function deviceId(): Promise<string> {\n try {\n let regCommand = `${process.env.windir}\\\\System32\\\\reg.exe query ${DeviceIdRegPath} /v ${DeviceIdRegKey}`;\n if (deviceArchitecture() === 'x64') {\n // Ensure we query the correct registry\n regCommand += ' /reg:64';\n }\n const output = execSync(regCommand).toString();\n\n const result = output.match(/\\{([0-9A-Fa-f-]{36})\\}/);\n if (result && result.length > 1) {\n return `s:${result[1]}`;\n }\n } catch {}\n return '';\n}\n\n/**\n * Gets the device architecture, like x86/x64/arm64.\n * @returns The device architecture.\n */\nexport function deviceArchitecture(): string {\n const nodeArch = nodeArchitecture();\n\n // Check if we're running x86 node on x64 hardware\n if (nodeArch === 'x86' && process.env.PROCESSOR_ARCHITEW6432 === 'AMD64') {\n return 'x64';\n }\n\n return nodeArch;\n}\n\n/**\n * Gets the node architecture, like x86/x64/arm64.\n * @returns The node architecture.\n */\nexport function nodeArchitecture(): string {\n return process.arch === 'ia32' ? 'x86' : process.arch;\n}\n\n/**\n * Gets the device platform, like darwin/linux/win32.\n * @returns The device platform.\n */\nexport function devicePlatform(): string {\n return platform();\n}\n\n/**\n * Gets the device locale.\n * @returns The device locale.\n */\nexport async function deviceLocale(): Promise<string> {\n return await osLocale();\n}\n\n/**\n * Gets the device's number of CPUs.\n * @returns The device's number of CPUs.\n */\nexport function deviceNumCPUs(): number {\n return cpus().length;\n}\n\n/**\n * Gets the device's total memory in bytes.\n * @returns The device's total memory in bytes.\n */\nexport function deviceTotalMemory(): number {\n return totalmem();\n}\n\n/**\n * Gets the free space of the give drive in bytes.\n * @param drivePath A path on the drive to check.\n * @returns The free space of the give drive in bytes.\n */\nexport function deviceDiskFreeSpace(drivePath?: string | null): number {\n try {\n const out = execSync(`dir /-C ${drivePath ?? process.cwd()}`)\n .toString()\n .split('\\r\\n');\n const line = out[out.length - 2];\n const result = line.match(/(\\d+) [^\\d]+(\\d+) /);\n if (result && result.length > 2) {\n return Number(result[2]);\n }\n } catch {}\n return -1;\n}\n\n/**\n * Gets the telemetry sample rate.\n * @returns The telemetry sample rate.\n */\nexport function sampleRate(): number {\n return 100;\n}\n\n/**\n * Gets whether or not telemetry events are captured when running in CI.\n * @returns Whether or not telemetry events are captured when running in CI.\n */\nexport function captureCI(): boolean {\n // Only capture events in CI if running tests\n return isCliTest();\n}\n\n/**\n * Gets the whether the process is currently running in CI.\n * @returns Whether the process is currently running in CI.\n */\nexport function isCI(): boolean {\n return ci.isCI;\n}\n\n/**\n * Gets the type of CI the process is running under.\n * @returns The type of CI the process is running under.\n */\nexport function ciType(): string {\n return ci.isCI ? ci.name ?? 'Unknown' : 'None';\n}\n\n/**\n * Gets whether the process is running on a Microsoft owned machine.\n * @returns Whether the process is running on a Microsoft owned machine.\n */\nexport function isMsftInternal(): boolean {\n return (\n process.env.UserDNSDomain !== undefined &&\n process.env.UserDNSDomain.toLowerCase().endsWith('corp.microsoft.com')\n );\n}\n\n/**\n * Gets whether the process is running as part of our CLI tests.\n * @returns Whether the process is running as part of our CLI tests.\n */\nexport function isCliTest(): boolean {\n return (\n process.env.RNW_CLI_TEST !== undefined &&\n process.env.RNW_CLI_TEST.toLowerCase().trim() === 'true'\n );\n}\n\nlet sessionId: string | undefined;\n\n/**\n * Gets a stable session ID for correlating telemetry events.\n * @returns A stable session ID for correlating telemetry events.\n */\nexport function getSessionId(): string {\n return (\n sessionId ?? (sessionId = randomBytes(16).toString('hex').padStart(32, '0'))\n );\n}\n"]}
1
+ {"version":3,"file":"basePropUtils.js","sourceRoot":"","sources":["../../src/utils/basePropUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,iDAAuC;AACvC,2BAA4C;AAE5C,sDAAyB;AACzB,mCAAmC;AACnC,0DAAiC;AAEjC,MAAM,eAAe,GAAG,oDAAoD,CAAC;AAC7E,MAAM,cAAc,GAAG,WAAW,CAAC;AAEnC,MAAM,iBAAiB,GACr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,YAAY,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,MAAM,CACzD,CAAC;AACJ,CAAC;AALD,8BAKC;AAED,IAAI,SAA6B,CAAC;AAElC;;;GAGG;AACH,SAAgB,YAAY;IAC1B,OAAO,CACL,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,CAAC,SAAS,GAAG,IAAA,oBAAW,EAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC,CAC7E,CAAC;AACJ,CAAC;AAJD,oCAIC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport {execSync} from 'child_process';\nimport {totalmem, cpus, platform} from 'os';\n\nimport ci from 'ci-info';\nimport {randomBytes} from 'crypto';\nimport osLocale from 'os-locale';\n\nconst DeviceIdRegPath = 'HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\SQMClient';\nconst DeviceIdRegKey = 'MachineId';\n\nconst DeviceIdBuildPath =\n '\"HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\"';\nconst DeviceIdBuildKey = 'BuildLabEx';\n\n/**\n * Given a path and a key, retrieves the value from the Registry.\n * @returns If the path and key exist, the requested value from the Registry; empty string otherwise.\n */\nexport async function getValueFromRegistry(\n path: string,\n key: string,\n): Promise<string> {\n try {\n let regCommand = `${process.env.windir}\\\\System32\\\\reg.exe query ${path} /v ${key}`;\n if (deviceArchitecture() === 'x64') {\n // Ensure we query the correct registry\n regCommand += ' /reg:64';\n }\n\n const output = execSync(regCommand).toString();\n return output;\n } catch {}\n\n return '';\n}\n\n/**\n * Gets a telemetry-safe stable device ID.\n * @returns A telemetry-safe stable device ID.\n */\nexport async function deviceId(): Promise<string> {\n try {\n const deviceIdValue = await getValueFromRegistry(\n DeviceIdRegPath,\n DeviceIdRegKey,\n );\n\n const result = deviceIdValue.match(/\\{([0-9A-Fa-f-]{36})\\}/);\n if (result && result.length > 1) {\n return `s:${result[1]}`;\n }\n } catch {}\n return '';\n}\n\n/**\n * Gets the Windows build name, number and architecture.\n * @returns A string containing the Windows build name, number and architecture.\n * e.g. 19569.1000.amd64fre.rs_prerelease.200214-1419\n */\nexport async function fullBuildInfo(): Promise<string> {\n try {\n const fullBuildValue = await getValueFromRegistry(\n DeviceIdBuildPath,\n DeviceIdBuildKey,\n );\n\n // Retrieve the build info\n const match = fullBuildValue.match(/BuildLabEx\\s+REG_SZ\\s+([^\\r\\n]+)/);\n if (match && match.length > 1) {\n return match[1];\n }\n } catch {}\n return '';\n}\n\n/**\n * Gets the device architecture, like x86/x64/arm64.\n * @returns The device architecture.\n */\nexport function deviceArchitecture(): string {\n const nodeArch = nodeArchitecture();\n\n // Check if we're running x86 node on x64 hardware\n if (nodeArch === 'x86' && process.env.PROCESSOR_ARCHITEW6432 === 'AMD64') {\n return 'x64';\n }\n\n return nodeArch;\n}\n\n/**\n * Gets the node architecture, like x86/x64/arm64.\n * @returns The node architecture.\n */\nexport function nodeArchitecture(): string {\n return process.arch === 'ia32' ? 'x86' : process.arch;\n}\n\n/**\n * Gets the node platform, like darwin/linux/win32.\n * @returns The device platform.\n */\nexport function nodePlatform(): string {\n return platform();\n}\n\n/**\n * Gets the OS name, to be filled in the PartA device.deviceClass field.\n * @returns The device class.\n */\nexport function deviceClass(): string {\n const node = nodePlatform();\n\n switch (node) {\n case 'darwin':\n return 'Mac';\n case 'linux':\n return 'Linux';\n case 'win32':\n return 'Windows';\n default:\n return node;\n }\n}\n\n/**\n * Gets the device locale.\n * @returns The device locale.\n */\nexport async function deviceLocale(): Promise<string> {\n return await osLocale();\n}\n\n/**\n * Gets the device's number of CPUs.\n * @returns The device's number of CPUs.\n */\nexport function deviceNumCPUs(): number {\n return cpus().length;\n}\n\n/**\n * Gets the device's total memory in bytes.\n * @returns The device's total memory in bytes.\n */\nexport function deviceTotalMemory(): number {\n return totalmem();\n}\n\n/**\n * Gets the free space of the give drive in bytes.\n * @param drivePath A path on the drive to check.\n * @returns The free space of the give drive in bytes.\n */\nexport function deviceDiskFreeSpace(drivePath?: string | null): number {\n try {\n const out = execSync(`dir /-C ${drivePath ?? process.cwd()}`)\n .toString()\n .split('\\r\\n');\n const line = out[out.length - 2];\n const result = line.match(/(\\d+) [^\\d]+(\\d+) /);\n if (result && result.length > 2) {\n return Number(result[2]);\n }\n } catch {}\n return -1;\n}\n\n/**\n * Gets whether or not telemetry events are captured when running in CI.\n * @returns Whether or not telemetry events are captured when running in CI.\n */\nexport function captureCI(): boolean {\n // Only capture events in CI if running tests\n return isCliTest();\n}\n\n/**\n * Gets the whether the process is currently running in CI.\n * @returns Whether the process is currently running in CI.\n */\nexport function isCI(): boolean {\n return ci.isCI;\n}\n\n/**\n * Gets the type of CI the process is running under.\n * @returns The type of CI the process is running under.\n */\nexport function ciType(): string {\n return ci.isCI ? ci.name ?? 'Unknown' : 'None';\n}\n\n/**\n * Gets whether the process is running on a Microsoft owned machine.\n * @returns Whether the process is running on a Microsoft owned machine.\n */\nexport function isMsftInternal(): boolean {\n return (\n process.env.UserDNSDomain !== undefined &&\n process.env.UserDNSDomain.toLowerCase().endsWith('corp.microsoft.com')\n );\n}\n\n/**\n * Gets whether the process is running as part of our CLI tests.\n * @returns Whether the process is running as part of our CLI tests.\n */\nexport function isCliTest(): boolean {\n return (\n process.env.RNW_CLI_TEST !== undefined &&\n process.env.RNW_CLI_TEST.toLowerCase().trim() === 'true'\n );\n}\n\nlet sessionId: string | undefined;\n\n/**\n * Gets a stable session ID for correlating telemetry events.\n * @returns A stable session ID for correlating telemetry events.\n */\nexport function getSessionId(): string {\n return (\n sessionId ?? (sessionId = randomBytes(16).toString('hex').padStart(32, '0'))\n );\n}\n"]}
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  * @format
5
5
  */
6
- import * as appInsights from 'applicationinsights';
7
6
  export declare const CodedErrors: {
8
7
  Success: number;
9
8
  Unknown: number;
@@ -69,6 +68,12 @@ export declare class CodedError extends Error {
69
68
  readonly data?: Record<string, any> | undefined;
70
69
  constructor(type: CodedErrorType, message: string, data?: Record<string, any> | undefined);
71
70
  }
71
+ export interface ErrorStackFrame {
72
+ functionName?: string;
73
+ filePath?: string;
74
+ lineNumber?: number;
75
+ columnNumber?: number;
76
+ }
72
77
  /**
73
78
  * Tries to parse an error code out of an error message.
74
79
  * @param msg An error message to process.
@@ -85,4 +90,4 @@ export declare function sanitizeErrorMessage(msg: string): string;
85
90
  * Sanitizes an error stack frame.
86
91
  * @param frame
87
92
  */
88
- export declare function sanitizeErrorStackFrame(frame: appInsights.Contracts.StackFrame): void;
93
+ export declare function sanitizeErrorStackFrame(frame: ErrorStackFrame): void;
@@ -164,17 +164,20 @@ exports.sanitizeErrorMessage = sanitizeErrorMessage;
164
164
  * @param frame
165
165
  */
166
166
  function sanitizeErrorStackFrame(frame) {
167
- const parens = frame.method.indexOf('(');
168
- if (parens !== -1) {
169
- // case 1: method === 'methodName (rootOfThePath'
170
- frame.method = frame.method.substr(0, parens).trim();
171
- }
172
- else {
173
- // case 2: method === <no_method> or something without '(', fileName is full path
167
+ if (frame.functionName) {
168
+ const leftParenthesisIndex = frame.functionName.indexOf('(');
169
+ if (leftParenthesisIndex !== -1) {
170
+ // case 1: method === 'methodName (rootOfThePath'
171
+ frame.functionName = frame.functionName
172
+ .substr(0, leftParenthesisIndex)
173
+ .trim();
174
+ }
175
+ else {
176
+ // case 2: method === <no_method> or something without '(', fileName is full path
177
+ }
174
178
  }
175
- // anonymize the filename
176
- frame.fileName = sanitizeUtils.getAnonymizedPath(frame.fileName);
177
- frame.assembly = '';
179
+ // anonymize the filePath
180
+ frame.filePath = sanitizeUtils.getAnonymizedPath(frame.filePath);
178
181
  }
179
182
  exports.sanitizeErrorStackFrame = sanitizeErrorStackFrame;
180
183
  //# sourceMappingURL=errorUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorUtils.js","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AAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;KACtD;SAAM;QACL,iFAAiF;KAClF;IACD,yBAAyB;IACzB,KAAK,CAAC,QAAQ,GAAG,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjE,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC;AACtB,CAAC;AAbD,0DAaC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport * as appInsights from 'applicationinsights';\n\nimport * as sanitizeUtils from './sanitizeUtils';\n\n// Note: All CLI commands will set process.exitCode to the numerical value of\n// a thrown CodedError. However node reserves codes 1-192 as per:\n// https://nodejs.org/api/process.html#process_exit_codes so we shouldn't\n// override those as other tools may be monitoring the error code\n\nexport const CodedErrors = {\n Success: 0,\n Unknown: -1,\n\n // react-native-windows-init\n UnsupportedReactNativeVersion: 1000,\n UserCancel: 1001,\n NoReactNativeFound: 1002,\n NoPackageJson: 1003,\n NoLatestReactNativeWindows: 1004,\n NoAutoMatchingReactNativeWindows: 1005,\n IncompatibleOptions: 1006,\n NoReactNativeDependencies: 1007,\n NoMatchingPackageVersion: 1008,\n\n // run-windows\n NoSolution: 2000,\n // Project generation\n NoPropertyInProject: 2100,\n CopyProjectTemplateNoSourcePath: 2101,\n CopyProjectTemplateNoDestPath: 2102,\n CopyProjectTemplateNoProjectName: 2103,\n // SDK requirements\n MinSDKVersionNotMet: 2200,\n BadSDKVersionFormat: 2201,\n NoSDK: 2202,\n // Build\n NoMSBuild: 2300,\n NoVSWhere: 2301,\n MSBuildError: 2302,\n // Deploy\n NoAppPackage: 2400,\n NoAppxManifest: 2401,\n NoDevice: 2402,\n AppDidNotDeploy: 2403,\n InvalidDevicesOutput: 2404,\n RemoveOldAppVersionFailure: 2405,\n EnableDevModeFailure: 2406,\n InstallAppFailure: 2407,\n InstallAppDependenciesFailure: 2408,\n CheckNetIsolationFailure: 2409,\n InstallAppToDeviceFailure: 2410,\n UninstallAppOnDeviceFailure: 2411,\n DeployRecipeFailure: 2412,\n // Launch\n AppStartupFailure: 2500,\n\n // autolink-windows\n NoWindowsConfig: 3000,\n IncompleteConfig: 3001,\n InvalidConfig: 3002,\n NeedAutolinking: 3003,\n AddProjectToSolution: 3004,\n Autolinking: 3005,\n\n // codegen-windows\n NeedCodegen: 4000,\n InvalidCodegenConfig: 4001,\n\n // init-windows\n NoTemplatesFound: 5000,\n NoDefaultTemplate: 5001,\n InvalidTemplateName: 5002,\n NoProjectName: 5003,\n InvalidProjectName: 5004,\n InvalidProjectNamespace: 5005,\n};\n\nexport type CodedErrorType = keyof typeof CodedErrors;\n\n/**\n * Represents an error whose message might contain user-originating content,\n * therefore when transmitting telemetry, only the type should be sent.\n * @param type a stable ID identifying the type of error.\n * @param message the error text. This should only be used for display to the user.\n * @param data any additional metadata that is safe to collect for telemetry purposes.\n */\nexport class CodedError extends Error {\n constructor(\n public readonly type: CodedErrorType,\n message: string,\n public readonly data?: Record<string, any>,\n ) {\n super(message);\n this.name = type;\n }\n}\n\n/**\n * Tries to parse an error code out of an error message.\n * @param msg An error message to process.\n * @returns The parsed error code.\n */\nexport function tryGetErrorCode(msg: string): string | undefined {\n const errorRegEx = /error (\\w+\\d+):/gi;\n const m = errorRegEx.exec(msg);\n return m ? m[1] : undefined;\n}\n\n/**\n * Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes (\"\").\n * @param msg The error message to sanitize.\n * @return The message with any paths anonymized.\n */\nexport function sanitizeErrorMessage(msg: string): string {\n const msBuildErrorMessage =\n /^\\d+:\\d+>(.*)(\\(\\d+,\\d+\\)): error (\\w+\\d+): (.*)/g;\n msg = msg.replace(msBuildErrorMessage, '[$1]$2: error $3: $4');\n\n const cpuThreadId = /^\\d+(:\\d+)?>/g;\n msg = msg.replace(cpuThreadId, '');\n\n const parts = msg.split(/['[\\]\"]/g);\n const clean = [];\n const pathRegEx =\n /(['[\"]?)([A-Za-z]:|\\\\)[\\\\/]([^<>:;,?\"*\\t\\r\\n|/\\\\]+[\\\\/])+([^<>:;,?\"*\\t\\r\\n|]+\\/?(['[\"]?))/gi;\n for (const part of parts) {\n if (pathRegEx.test(part)) {\n pathRegEx.lastIndex = -1;\n let matches: RegExpExecArray | null;\n let noPath = '';\n let last = 0;\n while ((matches = pathRegEx.exec(part))) {\n noPath +=\n part.substr(last, matches!.index - last) +\n sanitizeUtils.getAnonymizedPath(matches[0]);\n last = matches!.index + matches![0].length;\n }\n if (noPath !== '') {\n clean.push(noPath);\n }\n } else if (part !== '') {\n clean.push(part);\n }\n }\n return clean.join('').trim();\n}\n\n/**\n * Sanitizes an error stack frame.\n * @param frame\n */\nexport function sanitizeErrorStackFrame(\n frame: appInsights.Contracts.StackFrame,\n): void {\n const parens = frame.method.indexOf('(');\n if (parens !== -1) {\n // case 1: method === 'methodName (rootOfThePath'\n frame.method = frame.method.substr(0, parens).trim();\n } else {\n // case 2: method === <no_method> or something without '(', fileName is full path\n }\n // anonymize the filename\n frame.fileName = sanitizeUtils.getAnonymizedPath(frame.fileName);\n frame.assembly = '';\n}\n"]}
1
+ {"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../../src/utils/errorUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,+DAAiD;AAEjD,6EAA6E;AAC7E,iEAAiE;AACjE,yEAAyE;AACzE,iEAAiE;AAEpD,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC,CAAC;IAEX,4BAA4B;IAC5B,6BAA6B,EAAE,IAAI;IACnC,UAAU,EAAE,IAAI;IAChB,kBAAkB,EAAE,IAAI;IACxB,aAAa,EAAE,IAAI;IACnB,0BAA0B,EAAE,IAAI;IAChC,gCAAgC,EAAE,IAAI;IACtC,mBAAmB,EAAE,IAAI;IACzB,yBAAyB,EAAE,IAAI;IAC/B,wBAAwB,EAAE,IAAI;IAE9B,c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,GAAG,IAAI,CAAC;wBACxC,aAAa,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9C,IAAI,GAAG,OAAQ,CAAC,KAAK,GAAG,OAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;aAC5C;YACD,IAAI,MAAM,KAAK,EAAE,EAAE;gBACjB,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aACpB;SACF;aAAM,IAAI,IAAI,KAAK,EAAE,EAAE;YACtB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAClB;KACF;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAC/B,CAAC;AAhCD,oDAgCC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CAAC,KAAsB;IAC5D,IAAI,KAAK,CAAC,YAAY,EAAE;QACtB,MAAM,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7D,IAAI,oBAAoB,KAAK,CAAC,CAAC,EAAE;YAC/B,iDAAiD;YACjD,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY;iBACpC,MAAM,CAAC,CAAC,EAAE,oBAAoB,CAAC;iBAC/B,IAAI,EAAE,CAAC;SACX;aAAM;YACL,iFAAiF;SAClF;KACF;IAED,yBAAyB;IACzB,KAAK,CAAC,QAAQ,GAAG,aAAa,CAAC,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACnE,CAAC;AAfD,0DAeC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport * as sanitizeUtils from './sanitizeUtils';\n\n// Note: All CLI commands will set process.exitCode to the numerical value of\n// a thrown CodedError. However node reserves codes 1-192 as per:\n// https://nodejs.org/api/process.html#process_exit_codes so we shouldn't\n// override those as other tools may be monitoring the error code\n\nexport const CodedErrors = {\n Success: 0,\n Unknown: -1,\n\n // react-native-windows-init\n UnsupportedReactNativeVersion: 1000,\n UserCancel: 1001,\n NoReactNativeFound: 1002,\n NoPackageJson: 1003,\n NoLatestReactNativeWindows: 1004,\n NoAutoMatchingReactNativeWindows: 1005,\n IncompatibleOptions: 1006,\n NoReactNativeDependencies: 1007,\n NoMatchingPackageVersion: 1008,\n\n // run-windows\n NoSolution: 2000,\n // Project generation\n NoPropertyInProject: 2100,\n CopyProjectTemplateNoSourcePath: 2101,\n CopyProjectTemplateNoDestPath: 2102,\n CopyProjectTemplateNoProjectName: 2103,\n // SDK requirements\n MinSDKVersionNotMet: 2200,\n BadSDKVersionFormat: 2201,\n NoSDK: 2202,\n // Build\n NoMSBuild: 2300,\n NoVSWhere: 2301,\n MSBuildError: 2302,\n // Deploy\n NoAppPackage: 2400,\n NoAppxManifest: 2401,\n NoDevice: 2402,\n AppDidNotDeploy: 2403,\n InvalidDevicesOutput: 2404,\n RemoveOldAppVersionFailure: 2405,\n EnableDevModeFailure: 2406,\n InstallAppFailure: 2407,\n InstallAppDependenciesFailure: 2408,\n CheckNetIsolationFailure: 2409,\n InstallAppToDeviceFailure: 2410,\n UninstallAppOnDeviceFailure: 2411,\n DeployRecipeFailure: 2412,\n // Launch\n AppStartupFailure: 2500,\n\n // autolink-windows\n NoWindowsConfig: 3000,\n IncompleteConfig: 3001,\n InvalidConfig: 3002,\n NeedAutolinking: 3003,\n AddProjectToSolution: 3004,\n Autolinking: 3005,\n\n // codegen-windows\n NeedCodegen: 4000,\n InvalidCodegenConfig: 4001,\n\n // init-windows\n NoTemplatesFound: 5000,\n NoDefaultTemplate: 5001,\n InvalidTemplateName: 5002,\n NoProjectName: 5003,\n InvalidProjectName: 5004,\n InvalidProjectNamespace: 5005,\n};\n\nexport type CodedErrorType = keyof typeof CodedErrors;\n\n/**\n * Represents an error whose message might contain user-originating content,\n * therefore when transmitting telemetry, only the type should be sent.\n * @param type a stable ID identifying the type of error.\n * @param message the error text. This should only be used for display to the user.\n * @param data any additional metadata that is safe to collect for telemetry purposes.\n */\nexport class CodedError extends Error {\n constructor(\n public readonly type: CodedErrorType,\n message: string,\n public readonly data?: Record<string, any>,\n ) {\n super(message);\n this.name = type;\n }\n}\n\nexport interface ErrorStackFrame {\n functionName?: string;\n filePath?: string;\n lineNumber?: number;\n columnNumber?: number;\n}\n\n/**\n * Tries to parse an error code out of an error message.\n * @param msg An error message to process.\n * @returns The parsed error code.\n */\nexport function tryGetErrorCode(msg: string): string | undefined {\n const errorRegEx = /error (\\w+\\d+):/gi;\n const m = errorRegEx.exec(msg);\n return m ? m[1] : undefined;\n}\n\n/**\n * Sanitize an error message by anonymizing any paths that appear between quotes (''), brackets ([]), or double quotes (\"\").\n * @param msg The error message to sanitize.\n * @return The message with any paths anonymized.\n */\nexport function sanitizeErrorMessage(msg: string): string {\n const msBuildErrorMessage =\n /^\\d+:\\d+>(.*)(\\(\\d+,\\d+\\)): error (\\w+\\d+): (.*)/g;\n msg = msg.replace(msBuildErrorMessage, '[$1]$2: error $3: $4');\n\n const cpuThreadId = /^\\d+(:\\d+)?>/g;\n msg = msg.replace(cpuThreadId, '');\n\n const parts = msg.split(/['[\\]\"]/g);\n const clean = [];\n const pathRegEx =\n /(['[\"]?)([A-Za-z]:|\\\\)[\\\\/]([^<>:;,?\"*\\t\\r\\n|/\\\\]+[\\\\/])+([^<>:;,?\"*\\t\\r\\n|]+\\/?(['[\"]?))/gi;\n for (const part of parts) {\n if (pathRegEx.test(part)) {\n pathRegEx.lastIndex = -1;\n let matches: RegExpExecArray | null;\n let noPath = '';\n let last = 0;\n while ((matches = pathRegEx.exec(part))) {\n noPath +=\n part.substr(last, matches!.index - last) +\n sanitizeUtils.getAnonymizedPath(matches[0]);\n last = matches!.index + matches![0].length;\n }\n if (noPath !== '') {\n clean.push(noPath);\n }\n } else if (part !== '') {\n clean.push(part);\n }\n }\n return clean.join('').trim();\n}\n\n/**\n * Sanitizes an error stack frame.\n * @param frame\n */\nexport function sanitizeErrorStackFrame(frame: ErrorStackFrame): void {\n if (frame.functionName) {\n const leftParenthesisIndex = frame.functionName.indexOf('(');\n if (leftParenthesisIndex !== -1) {\n // case 1: method === 'methodName (rootOfThePath'\n frame.functionName = frame.functionName\n .substr(0, leftParenthesisIndex)\n .trim();\n } else {\n // case 2: method === <no_method> or something without '(', fileName is full path\n }\n }\n\n // anonymize the filePath\n frame.filePath = sanitizeUtils.getAnonymizedPath(frame.filePath);\n}\n"]}
@@ -9,4 +9,4 @@
9
9
  * @param projectRoot Optional root path for the project. Defaults to process.cwd().
10
10
  * @returns The anonymized path.
11
11
  */
12
- export declare function getAnonymizedPath(filepath: string, projectRoot?: string): string;
12
+ export declare function getAnonymizedPath(filepath: string | undefined, projectRoot?: string): string;
@@ -25,6 +25,9 @@ const knownEnvironmentVariablePaths = [
25
25
  * @returns The anonymized path.
26
26
  */
27
27
  function getAnonymizedPath(filepath, projectRoot) {
28
+ if (filepath === undefined) {
29
+ return '[path]';
30
+ }
28
31
  projectRoot = (projectRoot !== null && projectRoot !== void 0 ? projectRoot : process.cwd())
29
32
  .replace(/\//g, '\\')
30
33
  .toLowerCase();
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeUtils.js","sourceRoot":"","sources":["../../src/utils/sanitizeUtils.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;AAEH,gDAAwB;AAExB,4CAAgD;AAEhD,MAAM,WAAW,GAAG,kBAAkB,CAAC;AACvC,MAAM,OAAO,GAAG,aAAa,CAAC;AAE9B,MAAM,6BAA6B,GAAG;IACpC,SAAS;IACT,cAAc;IACd,aAAa;CACd,CAAC;AAEF;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,QAAgB,EAChB,WAAoB;IAEpB,WAAW,GAAG,CAAC,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,OAAO,CAAC,GAAG,EAAE,CAAC;SACzC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC;SACpB,WAAW,EAAE,CAAC;IACjB,WAA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C1C,0DAA0D;YAC1D,OAAO,iBAAiB,GAAG,IAAI,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC;SAChE;aAAM;YACL,mEAAmE;YACnE,IAAI,IAAI,KAAK,EAAE,IAAI,IAAI,KAAK,IAAI,EAAE;gBAChC,OAAO,eAAe,CAAC;aACxB;iBAAM;gBACL,OAAO,qBAAqB,GAAG,IAC7B,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAC9C,GAAG,CAAC;aACL;SACF;KACF;IAED,2DAA2D;IAC3D,KAAK,MAAM,SAAS,IAAI,6BAA6B,EAAE;QACrD,IACE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;YACtB,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,WAAW,EAAE,CAAC,EACxE;YACA,OAAO,IAAI,SAAS,UAClB,QAAQ,CAAC,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC,MAC5C,GAAG,CAAC;SACL;KACF;IAED,+CAA+C;IAC/C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAzED,8CAyEC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\n\nimport {NpmPackagesWeTrack} from '../telemetry';\n\nconst nodeModules = '\\\\node_modules\\\\';\nconst windows = '\\\\windows\\\\';\n\nconst knownEnvironmentVariablePaths = [\n 'AppData',\n 'LocalAppData',\n 'UserProfile',\n];\n\n/**\n * Gets an anonymized version of the given path, suitable for Telemetry.\n * @param filepath The path to anonymize.\n * @param projectRoot Optional root path for the project. Defaults to process.cwd().\n * @returns The anonymized path.\n */\nexport function getAnonymizedPath(\n filepath: string,\n projectRoot?: string,\n): string {\n projectRoot = (projectRoot ?? process.cwd())\n .replace(/\\//g, '\\\\')\n .toLowerCase();\n projectRoot = projectRoot.endsWith('\\\\')\n ? projectRoot.slice(0, -1)\n : projectRoot;\n filepath = filepath.replace(/\\//g, '\\\\');\n\n const ext = path.extname(filepath);\n\n // Check if we're under node_modules\n const nodeModulesIndex = filepath.toLowerCase().lastIndexOf(nodeModules);\n if (nodeModulesIndex >= 0) {\n // We are under node_modules\n\n // Check if it's an npm package we're tracking\n for (const trackedNpmPackage of NpmPackagesWeTrack) {\n const startIndex = filepath\n .toLowerCase()\n .lastIndexOf(\n nodeModules + trackedNpmPackage.replace(/\\//g, '\\\\') + '\\\\',\n );\n if (startIndex >= 0) {\n // We are under node_modules within an npm package we're tracking, anonymize by removing root\n return (\n '[node_modules]\\\\' + filepath.slice(startIndex + nodeModules.length)\n );\n }\n }\n\n // It's an npm package we're not tracking, anonymize with [node_modules]\n return `[node_modules]\\\\???${ext}(${\n filepath.slice(nodeModulesIndex).length - nodeModules.length\n })`;\n }\n\n // Check if we're under the projectRoot\n if (filepath.toLowerCase().startsWith(projectRoot)) {\n // We are under the projectRoot\n const rest = filepath.slice(projectRoot.length);\n if (rest.toLowerCase().startsWith(windows)) {\n // We are under the windows path, anonymize with [windows]\n return `[windows]\\\\???${ext}(${rest.length - windows.length})`;\n } else {\n // We are just within the projectRoot, anonymize with [project_dir]\n if (rest === '' || rest === '\\\\') {\n return '[project_dir]';\n } else {\n return `[project_dir]\\\\???${ext}(${\n rest.length - (rest.startsWith('\\\\') ? 1 : 0)\n })`;\n }\n }\n }\n\n // Check if we're under a known environmental variable path\n for (const knownPath of knownEnvironmentVariablePaths) {\n if (\n process.env[knownPath] &&\n filepath.toLowerCase().startsWith(process.env[knownPath]!.toLowerCase())\n ) {\n return `[${knownPath}]\\\\???(${\n filepath.length - process.env[knownPath]!.length\n })`;\n }\n }\n\n // We are somewhere else, anonymize with [path]\n return '[path]';\n}\n"]}
1
+ {"version":3,"file":"sanitizeUtils.js","sourceRoot":"","sources":["../../src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G,CAAC,SAAS,CAAE,CAAC,MAC5C,GAAG,CAAC;SACL;KACF;IAED,+CAA+C;IAC/C,OAAO,QAAQ,CAAC;AAClB,CAAC;AA7ED,8CA6EC","sourcesContent":["/**\n * Copyright (c) Microsoft Corporation.\n * Licensed under the MIT License.\n * @format\n */\n\nimport path from 'path';\n\nimport {NpmPackagesWeTrack} from '../telemetry';\n\nconst nodeModules = '\\\\node_modules\\\\';\nconst windows = '\\\\windows\\\\';\n\nconst knownEnvironmentVariablePaths = [\n 'AppData',\n 'LocalAppData',\n 'UserProfile',\n];\n\n/**\n * Gets an anonymized version of the given path, suitable for Telemetry.\n * @param filepath The path to anonymize.\n * @param projectRoot Optional root path for the project. Defaults to process.cwd().\n * @returns The anonymized path.\n */\nexport function getAnonymizedPath(\n filepath: string | undefined,\n projectRoot?: string,\n): string {\n if (filepath === undefined) {\n return '[path]';\n }\n\n projectRoot = (projectRoot ?? process.cwd())\n .replace(/\\//g, '\\\\')\n .toLowerCase();\n projectRoot = projectRoot.endsWith('\\\\')\n ? projectRoot.slice(0, -1)\n : projectRoot;\n filepath = filepath.replace(/\\//g, '\\\\');\n\n const ext = path.extname(filepath);\n\n // Check if we're under node_modules\n const nodeModulesIndex = filepath.toLowerCase().lastIndexOf(nodeModules);\n if (nodeModulesIndex >= 0) {\n // We are under node_modules\n\n // Check if it's an npm package we're tracking\n for (const trackedNpmPackage of NpmPackagesWeTrack) {\n const startIndex = filepath\n .toLowerCase()\n .lastIndexOf(\n nodeModules + trackedNpmPackage.replace(/\\//g, '\\\\') + '\\\\',\n );\n if (startIndex >= 0) {\n // We are under node_modules within an npm package we're tracking, anonymize by removing root\n return (\n '[node_modules]\\\\' + filepath.slice(startIndex + nodeModules.length)\n );\n }\n }\n\n // It's an npm package we're not tracking, anonymize with [node_modules]\n return `[node_modules]\\\\???${ext}(${\n filepath.slice(nodeModulesIndex).length - nodeModules.length\n })`;\n }\n\n // Check if we're under the projectRoot\n if (filepath.toLowerCase().startsWith(projectRoot)) {\n // We are under the projectRoot\n const rest = filepath.slice(projectRoot.length);\n if (rest.toLowerCase().startsWith(windows)) {\n // We are under the windows path, anonymize with [windows]\n return `[windows]\\\\???${ext}(${rest.length - windows.length})`;\n } else {\n // We are just within the projectRoot, anonymize with [project_dir]\n if (rest === '' || rest === '\\\\') {\n return '[project_dir]';\n } else {\n return `[project_dir]\\\\???${ext}(${\n rest.length - (rest.startsWith('\\\\') ? 1 : 0)\n })`;\n }\n }\n }\n\n // Check if we're under a known environmental variable path\n for (const knownPath of knownEnvironmentVariablePaths) {\n if (\n process.env[knownPath] &&\n filepath.toLowerCase().startsWith(process.env[knownPath]!.toLowerCase())\n ) {\n return `[${knownPath}]\\\\???(${\n filepath.length - process.env[knownPath]!.length\n })`;\n }\n }\n\n // We are somewhere else, anonymize with [path]\n return '[path]';\n}\n"]}