@salesforce/telemetry 2.0.5 → 3.0.1

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.md CHANGED
@@ -1,7 +1,31 @@
1
- # Change Log
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### [3.0.1](https://github.com/forcedotcom/telemetry/compare/v3.0.0...v3.0.1) (2021-11-17)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * release 3.0.1 ([050953a](https://github.com/forcedotcom/telemetry/commit/050953a117a4f3c6c5a2100d2a47e80719e64976))
11
+ * replace homedir ([2bcb2ed](https://github.com/forcedotcom/telemetry/commit/2bcb2ede66dc7ef3c14cb40d530fb34530b84147))
12
+ * sanitizing exception strings ([b12c52c](https://github.com/forcedotcom/telemetry/commit/b12c52cad97b736bcb0e5968c8427ae89f0d8397))
13
+ * sinon types match sinon ([4cbefbf](https://github.com/forcedotcom/telemetry/commit/4cbefbf4ded50b4fdd1f451e27aba449c886b481))
14
+
15
+ ## 3.0.0 (2021-07-08)
16
+
17
+
18
+ ### Features
19
+
20
+ * publish ([9336302](https://github.com/forcedotcom/telemetry/commit/9336302f15b43bd824ec70fe604e05a6bb2f5ba2))
21
+
22
+ ## [2.0.6](https://github.com/forcedotcom/cli-packages/compare/@salesforce/telemetry@2.0.5...@salesforce/telemetry@2.0.6) (2021-05-11)
23
+
24
+ **Note:** Version bump only for package @salesforce/telemetry
25
+
26
+
27
+
2
28
 
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
29
 
6
30
  ## [2.0.5](https://github.com/forcedotcom/cli-packages/compare/@salesforce/telemetry@2.0.4...@salesforce/telemetry@2.0.5) (2021-01-22)
7
31
 
@@ -83,7 +83,7 @@ export declare class AppInsights extends AsyncCreatable<TelemetryOptions> {
83
83
  /**
84
84
  * Builds the properties to send with every event
85
85
  *
86
- * @return {Properties} map of base properites and properties provided when class was created
86
+ * @return {Properties} map of base properties and properties provided when class was created
87
87
  */
88
88
  private buildCommonProperties;
89
89
  /**
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AppInsights = exports.buildPropertiesAndMeasurements = exports.getCpus = exports.getPlatformVersion = void 0;
4
4
  /*
5
- * Copyright (c) 2020, salesforce.com, inc.
5
+ * Copyright (c) 2021, salesforce.com, inc.
6
6
  * All rights reserved.
7
7
  * Licensed under the BSD 3-Clause license.
8
8
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
@@ -29,6 +29,20 @@ function getCpus() {
29
29
  }
30
30
  }
31
31
  exports.getCpus = getCpus;
32
+ const homeDir = os.homedir();
33
+ const sanitizeError = (err) => {
34
+ if (err.name) {
35
+ err.name = err.name.replace(homeDir, '~');
36
+ }
37
+ if (err.message) {
38
+ err.message = err.message.replace(homeDir, '~');
39
+ }
40
+ if (err.stack) {
41
+ // there might be lots of this one
42
+ err.stack = err.stack.replace(new RegExp(`\\b${homeDir}\\b`, 'gi'), '~');
43
+ }
44
+ return err;
45
+ };
32
46
  function getSystemMemory() {
33
47
  return `${(os.totalmem() / (1024 * 1024 * 1024)).toFixed(2)} GB`;
34
48
  }
@@ -41,7 +55,7 @@ function buildPropertiesAndMeasurements(attributes) {
41
55
  Object.keys(attributes).forEach((key) => {
42
56
  const value = attributes[key];
43
57
  if (ts_types_1.isString(value)) {
44
- properties[key] = value;
58
+ properties[key] = value.replace(homeDir, '~');
45
59
  }
46
60
  else if (ts_types_1.isNumber(value)) {
47
61
  measurements[key] = value;
@@ -97,9 +111,10 @@ class AppInsights extends kit_1.AsyncCreatable {
97
111
  * @param attributes {Attributes} - map of measurements to publish alongside the exception.
98
112
  */
99
113
  sendTelemetryException(exception, attributes = {}) {
100
- this.logger.debug(`Sending telemetry exception: ${exception.message}`);
114
+ const cleanException = sanitizeError(exception);
115
+ this.logger.debug(`Sending telemetry exception: ${cleanException.message}`);
101
116
  const { properties, measurements } = buildPropertiesAndMeasurements(attributes);
102
- this.appInsightsClient.trackException({ exception, properties, measurements });
117
+ this.appInsightsClient.trackException({ exception: cleanException, properties, measurements });
103
118
  }
104
119
  /**
105
120
  * Publishes diagnostic information to app insights dashboard
@@ -152,7 +167,7 @@ class AppInsights extends kit_1.AsyncCreatable {
152
167
  /**
153
168
  * Builds the properties to send with every event
154
169
  *
155
- * @return {Properties} map of base properites and properties provided when class was created
170
+ * @return {Properties} map of base properties and properties provided when class was created
156
171
  */
157
172
  buildCommonProperties() {
158
173
  const baseProperties = {
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@salesforce/telemetry",
3
- "version": "2.0.5",
3
+ "version": "3.0.1",
4
4
  "description": "Library for application insights",
5
5
  "main": "lib/exported",
6
- "repository": "https://github.com/forcedotcom/cli-packages",
6
+ "repository": "forcedotcom/telemetry",
7
7
  "author": "Salesforce",
8
8
  "license": "BSD-3-Clause",
9
9
  "scripts": {
@@ -65,6 +65,5 @@
65
65
  "types": "lib/exported.d.ts",
66
66
  "publishConfig": {
67
67
  "access": "public"
68
- },
69
- "gitHead": "b089ff3508131aa35774ee088376b7a98dcb3167"
68
+ }
70
69
  }