@salesforce/telemetry 2.0.3 → 3.1.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.
- package/CHANGELOG.md +49 -3
- package/lib/appInsights.d.ts +1 -1
- package/lib/appInsights.js +24 -9
- package/lib/exported.js +1 -1
- package/lib/telemetryReporter.js +1 -1
- package/package.json +6 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,53 @@
|
|
|
1
|
-
#
|
|
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.1.0](https://github.com/forcedotcom/telemetry/compare/v3.0.0...v3.1.0) (2021-11-30)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* bump version of core and axios ([376ae9c](https://github.com/forcedotcom/telemetry/commit/376ae9c2c2c26517f2ede7e1ac7b065caeca9390))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* release 3.0.1 ([050953a](https://github.com/forcedotcom/telemetry/commit/050953a117a4f3c6c5a2100d2a47e80719e64976))
|
|
16
|
+
* replace homedir ([2bcb2ed](https://github.com/forcedotcom/telemetry/commit/2bcb2ede66dc7ef3c14cb40d530fb34530b84147))
|
|
17
|
+
* sanitizing exception strings ([b12c52c](https://github.com/forcedotcom/telemetry/commit/b12c52cad97b736bcb0e5968c8427ae89f0d8397))
|
|
18
|
+
* sinon types match sinon ([4cbefbf](https://github.com/forcedotcom/telemetry/commit/4cbefbf4ded50b4fdd1f451e27aba449c886b481))
|
|
19
|
+
* typescript bump and fixes ([012bcff](https://github.com/forcedotcom/telemetry/commit/012bcffee2655705b0e97684eec20b81d3f9e6f2))
|
|
20
|
+
|
|
21
|
+
## 3.0.0 (2021-07-08)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* publish ([9336302](https://github.com/forcedotcom/telemetry/commit/9336302f15b43bd824ec70fe604e05a6bb2f5ba2))
|
|
27
|
+
|
|
28
|
+
## [2.0.6](https://github.com/forcedotcom/cli-packages/compare/@salesforce/telemetry@2.0.5...@salesforce/telemetry@2.0.6) (2021-05-11)
|
|
29
|
+
|
|
30
|
+
**Note:** Version bump only for package @salesforce/telemetry
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## [2.0.5](https://github.com/forcedotcom/cli-packages/compare/@salesforce/telemetry@2.0.4...@salesforce/telemetry@2.0.5) (2021-01-22)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package @salesforce/telemetry
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
## [2.0.4](https://github.com/forcedotcom/cli-packages/compare/@salesforce/telemetry@2.0.3...@salesforce/telemetry@2.0.4) (2020-11-13)
|
|
45
|
+
|
|
46
|
+
**Note:** Version bump only for package @salesforce/telemetry
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
2
50
|
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
51
|
|
|
6
52
|
## [2.0.3](https://github.com/forcedotcom/cli-packages/compare/@salesforce/telemetry@2.0.2...@salesforce/telemetry@2.0.3) (2020-11-11)
|
|
7
53
|
|
package/lib/appInsights.d.ts
CHANGED
|
@@ -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
|
|
86
|
+
* @return {Properties} map of base properties and properties provided when class was created
|
|
87
87
|
*/
|
|
88
88
|
private buildCommonProperties;
|
|
89
89
|
/**
|
package/lib/appInsights.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppInsights = exports.buildPropertiesAndMeasurements = exports.getCpus = exports.getPlatformVersion = void 0;
|
|
3
|
+
exports.AppInsights = exports.buildPropertiesAndMeasurements = exports.getCpus = exports.getPlatformVersion = exports.TelemetryClient = void 0;
|
|
4
4
|
/*
|
|
5
|
-
* Copyright (c)
|
|
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
|
}
|
|
@@ -40,13 +54,13 @@ function buildPropertiesAndMeasurements(attributes) {
|
|
|
40
54
|
const measurements = {};
|
|
41
55
|
Object.keys(attributes).forEach((key) => {
|
|
42
56
|
const value = attributes[key];
|
|
43
|
-
if (ts_types_1.isString(value)) {
|
|
44
|
-
properties[key] = value;
|
|
57
|
+
if ((0, ts_types_1.isString)(value)) {
|
|
58
|
+
properties[key] = value.replace(homeDir, '~');
|
|
45
59
|
}
|
|
46
|
-
else if (ts_types_1.isNumber(value)) {
|
|
60
|
+
else if ((0, ts_types_1.isNumber)(value)) {
|
|
47
61
|
measurements[key] = value;
|
|
48
62
|
}
|
|
49
|
-
else if (ts_types_1.isBoolean(value)) {
|
|
63
|
+
else if ((0, ts_types_1.isBoolean)(value)) {
|
|
50
64
|
properties[key] = value.toString();
|
|
51
65
|
}
|
|
52
66
|
});
|
|
@@ -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
|
-
|
|
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
|
|
170
|
+
* @return {Properties} map of base properties and properties provided when class was created
|
|
156
171
|
*/
|
|
157
172
|
buildCommonProperties() {
|
|
158
173
|
const baseProperties = {
|
package/lib/exported.js
CHANGED
|
@@ -13,7 +13,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
o[k2] = m[k];
|
|
14
14
|
}));
|
|
15
15
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
-
for (var p in m) if (p !== "default" && !
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
const telemetryReporter_1 = require("./telemetryReporter");
|
package/lib/telemetryReporter.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/telemetry",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Library for application insights",
|
|
5
5
|
"main": "lib/exported",
|
|
6
|
-
"repository": "
|
|
6
|
+
"repository": "forcedotcom/telemetry",
|
|
7
7
|
"author": "Salesforce",
|
|
8
8
|
"license": "BSD-3-Clause",
|
|
9
9
|
"scripts": {
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"!lib/**/*.map"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@salesforce/core": "^2.
|
|
36
|
+
"@salesforce/core": "^2.31.0",
|
|
37
37
|
"@salesforce/ts-types": "^1.2.1",
|
|
38
38
|
"applicationinsights": "^1.4.0",
|
|
39
|
-
"axios": "^0.
|
|
39
|
+
"axios": "^0.21.2"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@salesforce/dev-config": "^2.0.0",
|
|
@@ -60,11 +60,10 @@
|
|
|
60
60
|
"prettier": "^2.0.5",
|
|
61
61
|
"sinon": "^9.0.2",
|
|
62
62
|
"ts-node": "^8.10.2",
|
|
63
|
-
"typescript": "^
|
|
63
|
+
"typescript": "^4.1.3"
|
|
64
64
|
},
|
|
65
65
|
"types": "lib/exported.d.ts",
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
68
|
-
}
|
|
69
|
-
"gitHead": "3a461dd65c8dde45f70aef69c028c57b51bbb9ff"
|
|
68
|
+
}
|
|
70
69
|
}
|