@salesforce/telemetry 4.0.12 → 4.0.14

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,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.AppInsights = exports.buildPropertiesAndMeasurements = exports.getCpus = exports.getPlatformVersion = exports.TelemetryClient = void 0;
4
27
  /*
@@ -7,11 +30,11 @@ exports.AppInsights = exports.buildPropertiesAndMeasurements = exports.getCpus =
7
30
  * Licensed under the BSD 3-Clause license.
8
31
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
32
  */
10
- const os = require("os");
33
+ const os = __importStar(require("os"));
11
34
  const core_1 = require("@salesforce/core");
12
35
  const kit_1 = require("@salesforce/kit");
13
36
  const ts_types_1 = require("@salesforce/ts-types");
14
- const appInsights = require("applicationinsights");
37
+ const appInsights = __importStar(require("applicationinsights"));
15
38
  var applicationinsights_1 = require("applicationinsights");
16
39
  Object.defineProperty(exports, "TelemetryClient", { enumerable: true, get: function () { return applicationinsights_1.TelemetryClient; } });
17
40
  function getPlatformVersion() {
@@ -1,4 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
2
28
  Object.defineProperty(exports, "__esModule", { value: true });
3
29
  exports.TelemetryReporter = exports.TelemetryClient = void 0;
4
30
  /*
@@ -7,10 +33,11 @@ exports.TelemetryReporter = exports.TelemetryClient = void 0;
7
33
  * Licensed under the BSD 3-Clause license.
8
34
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
9
35
  */
10
- const os = require("os");
36
+ const os = __importStar(require("os"));
11
37
  const core_1 = require("@salesforce/core");
12
38
  const kit_1 = require("@salesforce/kit");
13
- const axios_1 = require("axios");
39
+ const got_1 = __importDefault(require("got"));
40
+ const proxy_agent_1 = require("proxy-agent");
14
41
  const appInsights_1 = require("./appInsights");
15
42
  var appInsights_2 = require("./appInsights");
16
43
  Object.defineProperty(exports, "TelemetryClient", { enumerable: true, get: function () { return appInsights_2.TelemetryClient; } });
@@ -68,32 +95,31 @@ class TelemetryReporter extends kit_1.AsyncCreatable {
68
95
  async testConnection() {
69
96
  const timeout = parseInt(kit_1.env.getString('SFDX_TELEMETRY_TIMEOUT', '1000'), 10);
70
97
  this.logger.debug(`Testing connection to ${appInsights_1.AppInsights.APP_INSIGHTS_SERVER} with timeout of ${timeout} ms`);
71
- // set up a CancelToken to handle connection timeouts because
72
- // the built in timeout functionality only handles response timeouts
73
- // see here: https://github.com/axios/axios/issues/647#issuecomment-322209906
74
- const cancelRequest = axios_1.default.CancelToken.source();
75
- setTimeout(() => cancelRequest.cancel('connection timeout'), timeout);
76
- let canConnect;
77
98
  try {
78
- const options = {
79
- timeout,
80
- cancelToken: cancelRequest.token,
81
- // We want any status less than 500 to be resolved (not rejected)
82
- validateStatus: (status) => status < 500,
83
- };
84
- await axios_1.default.get(appInsights_1.AppInsights.APP_INSIGHTS_SERVER, options);
85
- canConnect = true;
99
+ const resp = await got_1.default.get(appInsights_1.AppInsights.APP_INSIGHTS_SERVER, {
100
+ throwHttpErrors: false,
101
+ agent: { https: new proxy_agent_1.ProxyAgent() },
102
+ retry: {
103
+ methods: ['GET'],
104
+ errorCodes: ['ECONNRESET', 'EADDRINUSE', 'ECONNREFUSED', 'EPIPE'],
105
+ },
106
+ timeout: {
107
+ lookup: 100,
108
+ send: 10000,
109
+ response: 1000,
110
+ },
111
+ });
112
+ if (resp.statusCode < 500) {
113
+ this.logger.debug(`Successfully made a connection to ${appInsights_1.AppInsights.APP_INSIGHTS_SERVER}`);
114
+ return true;
115
+ }
116
+ this.logger.error(`${appInsights_1.AppInsights.APP_INSIGHTS_SERVER} responded with ${resp.statusCode}`);
117
+ throw new Error(resp.statusCode.toString());
86
118
  }
87
119
  catch (err) {
88
- canConnect = false;
89
- }
90
- if (canConnect) {
91
- this.logger.debug(`Successfully made a connection to ${appInsights_1.AppInsights.APP_INSIGHTS_SERVER}`);
92
- }
93
- else {
94
120
  this.logger.warn(`Connection to ${appInsights_1.AppInsights.APP_INSIGHTS_SERVER} timed out after ${timeout} ms`);
121
+ return false;
95
122
  }
96
- return canConnect;
97
123
  }
98
124
  /**
99
125
  * Sends message to child process.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/telemetry",
3
- "version": "4.0.12",
3
+ "version": "4.0.14",
4
4
  "description": "Library for application insights",
5
5
  "main": "lib/exported",
6
6
  "repository": "forcedotcom/telemetry",
@@ -35,36 +35,37 @@
35
35
  "!lib/**/*.map"
36
36
  ],
37
37
  "dependencies": {
38
- "@salesforce/core": "^4.3.6",
38
+ "@salesforce/core": "^5.1.4",
39
39
  "@salesforce/ts-types": "^2.0.5",
40
40
  "applicationinsights": "^2.7.0",
41
- "axios": "^1.4.0"
41
+ "got": "^11",
42
+ "proxy-agent": "^6.3.0"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@salesforce/dev-config": "^4.0.1",
45
- "@salesforce/dev-scripts": "^5.4.2",
46
+ "@salesforce/dev-scripts": "^5.4.3",
46
47
  "@salesforce/prettier-config": "^0.0.3",
47
- "@salesforce/ts-sinon": "^1.4.9",
48
+ "@salesforce/ts-sinon": "^1.4.12",
48
49
  "@typescript-eslint/eslint-plugin": "^5.62.0",
49
- "@typescript-eslint/parser": "^5.61.0",
50
+ "@typescript-eslint/parser": "^5.62.0",
50
51
  "chai": "^4.3.7",
51
- "eslint": "^8.44.0",
52
- "eslint-config-prettier": "^8.8.0",
53
- "eslint-config-salesforce": "^2.0.1",
52
+ "eslint": "^8.46.0",
53
+ "eslint-config-prettier": "^8.9.0",
54
+ "eslint-config-salesforce": "^2.0.2",
54
55
  "eslint-config-salesforce-license": "^0.2.0",
55
- "eslint-config-salesforce-typescript": "^1.1.1",
56
+ "eslint-config-salesforce-typescript": "^1.1.2",
56
57
  "eslint-plugin-header": "^3.1.1",
57
- "eslint-plugin-import": "2.27.5",
58
+ "eslint-plugin-import": "2.28.0",
58
59
  "eslint-plugin-jsdoc": "^44.2.7",
59
60
  "husky": "^8.0.3",
60
61
  "mocha": "^10.2.0",
61
62
  "nyc": "^15.1.0",
62
63
  "prettier": "^2.8.8",
63
64
  "pretty-quick": "^3.1.0",
64
- "sinon": "10.0.0",
65
+ "sinon": "^15.2.0",
65
66
  "ts-node": "^10.0.0",
66
67
  "typescript": "^4.9.5",
67
- "wireit": "^0.9.5"
68
+ "wireit": "^0.10.0"
68
69
  },
69
70
  "types": "lib/exported.d.ts",
70
71
  "publishConfig": {
@@ -142,4 +143,4 @@
142
143
  "output": []
143
144
  }
144
145
  }
145
- }
146
+ }