@webex/internal-plugin-mercury 2.60.1-next.9 → 2.60.2

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.
@@ -15,5 +15,6 @@ var _socketBase = _interopRequireDefault(require("./socket-base"));
15
15
  _socketBase.default.getWebSocketConstructor = function getWebSocketConstructor() {
16
16
  return _ws.default;
17
17
  };
18
- var _default = exports.default = _socketBase.default;
18
+ var _default = _socketBase.default;
19
+ exports.default = _default;
19
20
  //# sourceMappingURL=socket.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_ws","_interopRequireDefault","require","_socketBase","Socket","getWebSocketConstructor","WS","_default","exports","default"],"sources":["socket.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport WS from 'ws';\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n return WS;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAIA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AANA;AACA;AACA;;AAMAE,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE,OAAOC,WAAE;AACX,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaL,mBAAM"}
1
+ {"version":3,"names":["_ws","_interopRequireDefault","require","_socketBase","Socket","getWebSocketConstructor","WS","_default","exports","default"],"sources":["socket.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport WS from 'ws';\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n return WS;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAIA,IAAAA,GAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AANA;AACA;AACA;;AAMAE,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE,OAAOC,WAAE;AACX,CAAC;AAAC,IAAAC,QAAA,GAEaH,mBAAM;AAAAI,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
@@ -32,5 +32,6 @@ _socketBase.default.getWebSocketConstructor = function getWebSocketConstructor()
32
32
  }
33
33
  return ws;
34
34
  };
35
- var _default = exports.default = _socketBase.default;
35
+ var _default = _socketBase.default;
36
+ exports.default = _default;
36
37
  //# sourceMappingURL=socket.shim.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_socketBase","_interopRequireDefault","require","Socket","getWebSocketConstructor","ws","WebSocket","MozWebSocket","global","window","self","_default","exports","default"],"sources":["socket.shim.js"],"sourcesContent":["/* eslint-disable no-restricted-globals */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n // Grabed from https://github.com/heineiuo/isomorphic-ws/blob/9b977394ac875638c045fd9cf774ed418484b394/browser.js\n let ws;\n\n if (typeof WebSocket !== 'undefined') {\n ws = WebSocket;\n } else if (typeof MozWebSocket !== 'undefined') {\n // eslint-disable-next-line no-undef\n ws = MozWebSocket;\n } else if (typeof global !== 'undefined') {\n ws = global.WebSocket || global.MozWebSocket;\n } else if (typeof window !== 'undefined') {\n ws = window.WebSocket || window.MozWebSocket;\n } else if (typeof self !== 'undefined') {\n ws = self.WebSocket || self.MozWebSocket;\n }\n\n return ws;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAQA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AARA;;AAEA;AACA;AACA;;AAEA;;AAIAC,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE;EACA,IAAIC,EAAE;EAEN,IAAI,OAAOC,SAAS,KAAK,WAAW,EAAE;IACpCD,EAAE,GAAGC,SAAS;EAChB,CAAC,MAAM,IAAI,OAAOC,YAAY,KAAK,WAAW,EAAE;IAC9C;IACAF,EAAE,GAAGE,YAAY;EACnB,CAAC,MAAM,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACxCH,EAAE,GAAGG,MAAM,CAACF,SAAS,IAAIE,MAAM,CAACD,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOE,MAAM,KAAK,WAAW,EAAE;IACxCJ,EAAE,GAAGI,MAAM,CAACH,SAAS,IAAIG,MAAM,CAACF,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOG,IAAI,KAAK,WAAW,EAAE;IACtCL,EAAE,GAAGK,IAAI,CAACJ,SAAS,IAAII,IAAI,CAACH,YAAY;EAC1C;EAEA,OAAOF,EAAE;AACX,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,mBAAM"}
1
+ {"version":3,"names":["_socketBase","_interopRequireDefault","require","Socket","getWebSocketConstructor","ws","WebSocket","MozWebSocket","global","window","self","_default","exports","default"],"sources":["socket.shim.js"],"sourcesContent":["/* eslint-disable no-restricted-globals */\n\n/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint-env browser */\n\nimport Socket from './socket-base';\n\nSocket.getWebSocketConstructor = function getWebSocketConstructor() {\n // Grabed from https://github.com/heineiuo/isomorphic-ws/blob/9b977394ac875638c045fd9cf774ed418484b394/browser.js\n let ws;\n\n if (typeof WebSocket !== 'undefined') {\n ws = WebSocket;\n } else if (typeof MozWebSocket !== 'undefined') {\n // eslint-disable-next-line no-undef\n ws = MozWebSocket;\n } else if (typeof global !== 'undefined') {\n ws = global.WebSocket || global.MozWebSocket;\n } else if (typeof window !== 'undefined') {\n ws = window.WebSocket || window.MozWebSocket;\n } else if (typeof self !== 'undefined') {\n ws = self.WebSocket || self.MozWebSocket;\n }\n\n return ws;\n};\n\nexport default Socket;\n"],"mappings":";;;;;;;;AAQA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AARA;;AAEA;AACA;AACA;;AAEA;;AAIAC,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuBA,CAAA,EAAG;EAClE;EACA,IAAIC,EAAE;EAEN,IAAI,OAAOC,SAAS,KAAK,WAAW,EAAE;IACpCD,EAAE,GAAGC,SAAS;EAChB,CAAC,MAAM,IAAI,OAAOC,YAAY,KAAK,WAAW,EAAE;IAC9C;IACAF,EAAE,GAAGE,YAAY;EACnB,CAAC,MAAM,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IACxCH,EAAE,GAAGG,MAAM,CAACF,SAAS,IAAIE,MAAM,CAACD,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOE,MAAM,KAAK,WAAW,EAAE;IACxCJ,EAAE,GAAGI,MAAM,CAACH,SAAS,IAAIG,MAAM,CAACF,YAAY;EAC9C,CAAC,MAAM,IAAI,OAAOG,IAAI,KAAK,WAAW,EAAE;IACtCL,EAAE,GAAGK,IAAI,CAACJ,SAAS,IAAII,IAAI,CAACH,YAAY;EAC1C;EAEA,OAAOF,EAAE;AACX,CAAC;AAAC,IAAAM,QAAA,GAEaR,mBAAM;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "@webex/internal-plugin-mercury",
3
+ "version": "2.60.2",
3
4
  "description": "",
4
5
  "license": "MIT",
5
6
  "main": "dist/index.js",
@@ -10,7 +11,7 @@
10
11
  "directory": "packages/@webex/internal-plugin-mercury"
11
12
  },
12
13
  "engines": {
13
- "node": ">=16"
14
+ "node": ">=14"
14
15
  },
15
16
  "browser": {
16
17
  "./dist/socket/socket.js": "./dist/socket/socket.shim.js",
@@ -25,31 +26,31 @@
25
26
  "devDependencies": {
26
27
  "@babel/core": "^7.17.10",
27
28
  "@sinonjs/fake-timers": "^6.0.1",
28
- "@webex/babel-config-legacy": "0.0.0",
29
- "@webex/eslint-config-legacy": "0.0.0",
30
- "@webex/jest-config-legacy": "0.0.0",
31
- "@webex/legacy-tools": "0.0.0",
32
- "@webex/test-helper-chai": "2.60.1-next.9",
33
- "@webex/test-helper-mocha": "2.60.1-next.9",
34
- "@webex/test-helper-mock-webex": "2.60.1-next.9",
35
- "@webex/test-helper-test-users": "2.60.1-next.9",
29
+ "@webex/babel-config-legacy": "2.60.2",
30
+ "@webex/eslint-config-legacy": "2.60.2",
31
+ "@webex/jest-config-legacy": "2.60.2",
32
+ "@webex/legacy-tools": "2.60.2",
33
+ "@webex/test-helper-chai": "2.60.2",
34
+ "@webex/test-helper-mocha": "2.60.2",
35
+ "@webex/test-helper-mock-webex": "2.60.2",
36
+ "@webex/test-helper-test-users": "2.60.2",
36
37
  "eslint": "^8.24.0",
37
38
  "prettier": "^2.7.1",
38
39
  "sinon": "^9.2.4"
39
40
  },
40
41
  "dependencies": {
41
- "@webex/common": "2.60.1-next.9",
42
- "@webex/common-timers": "2.60.1-next.9",
43
- "@webex/internal-plugin-device": "2.60.1-next.9",
44
- "@webex/internal-plugin-feature": "2.60.1-next.9",
45
- "@webex/internal-plugin-metrics": "2.60.1-next.9",
46
- "@webex/test-helper-chai": "2.60.1-next.9",
47
- "@webex/test-helper-mocha": "2.60.1-next.9",
48
- "@webex/test-helper-mock-web-socket": "2.60.1-next.9",
49
- "@webex/test-helper-mock-webex": "2.60.1-next.9",
50
- "@webex/test-helper-refresh-callback": "2.60.1-next.9",
51
- "@webex/test-helper-test-users": "2.60.1-next.9",
52
- "@webex/webex-core": "2.60.1-next.9",
42
+ "@webex/common": "2.60.2",
43
+ "@webex/common-timers": "2.60.2",
44
+ "@webex/internal-plugin-device": "2.60.2",
45
+ "@webex/internal-plugin-feature": "2.60.2",
46
+ "@webex/internal-plugin-metrics": "2.60.2",
47
+ "@webex/test-helper-chai": "2.60.2",
48
+ "@webex/test-helper-mocha": "2.60.2",
49
+ "@webex/test-helper-mock-web-socket": "2.60.2",
50
+ "@webex/test-helper-mock-webex": "2.60.2",
51
+ "@webex/test-helper-refresh-callback": "2.60.2",
52
+ "@webex/test-helper-test-users": "2.60.2",
53
+ "@webex/webex-core": "2.60.2",
53
54
  "backoff": "^2.5.0",
54
55
  "lodash": "^4.17.21",
55
56
  "uuid": "^3.3.2",
@@ -58,12 +59,10 @@
58
59
  "scripts": {
59
60
  "build": "yarn build:src",
60
61
  "build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
61
- "deploy:npm": "yarn npm publish",
62
62
  "test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
63
63
  "test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
64
64
  "test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
65
65
  "test:style": "eslint ./src/**/*.*",
66
66
  "test:unit": "webex-legacy-tools test --unit --runner jest"
67
- },
68
- "version": "2.60.1-next.9"
69
- }
67
+ }
68
+ }
package/src/mercury.js CHANGED
@@ -49,7 +49,7 @@ const Mercury = WebexPlugin.extend({
49
49
  @oneFlight
50
50
  connect(webSocketUrl) {
51
51
  if (this.connected) {
52
- this.logger.info(`${this.namespace}: already connected, will not connect again`);
52
+ this.logger.info('mercury: already connected, will not connect again');
53
53
 
54
54
  return Promise.resolve();
55
55
  }
@@ -59,7 +59,7 @@ const Mercury = WebexPlugin.extend({
59
59
  return Promise.resolve(
60
60
  this.webex.internal.device.registered || this.webex.internal.device.register()
61
61
  ).then(() => {
62
- this.logger.info(`${this.namespace}: connecting`);
62
+ this.logger.info('mercury: connecting');
63
63
 
64
64
  return this._connectWithBackoff(webSocketUrl);
65
65
  });
@@ -69,14 +69,16 @@ const Mercury = WebexPlugin.extend({
69
69
  disconnect() {
70
70
  return new Promise((resolve) => {
71
71
  if (this.backoffCall) {
72
- this.logger.info(`${this.namespace}: aborting connection`);
72
+ this.logger.info('mercury: aborting connection');
73
73
  this.backoffCall.abort();
74
74
  }
75
75
 
76
76
  if (this.socket) {
77
77
  this.socket.removeAllListeners('message');
78
78
  this.once('offline', resolve);
79
- resolve(this.socket.close());
79
+ this.socket.close();
80
+
81
+ return;
80
82
  }
81
83
 
82
84
  resolve();
@@ -159,12 +161,11 @@ const Mercury = WebexPlugin.extend({
159
161
  socket.on('close', (...args) => this._onclose(...args));
160
162
  socket.on('message', (...args) => this._onmessage(...args));
161
163
  socket.on('sequence-mismatch', (...args) => this._emit('sequence-mismatch', ...args));
162
- socket.on('ping-pong-latency', (...args) => this._emit('ping-pong-latency', ...args));
163
164
 
164
165
  Promise.all([this._prepareUrl(socketUrl), this.webex.credentials.getUserToken()])
165
166
  .then(([webSocketUrl, token]) => {
166
167
  if (!this.backoffCall) {
167
- const msg = `${this.namespace}: prevent socket open when backoffCall no longer defined`;
168
+ const msg = 'mercury: prevent socket open when backoffCall no longer defined';
168
169
 
169
170
  this.logger.info(msg);
170
171
 
@@ -184,7 +185,7 @@ const Mercury = WebexPlugin.extend({
184
185
 
185
186
  // if the consumer has supplied request options use them
186
187
  if (this.webex.config.defaultMercuryOptions) {
187
- this.logger.info(`${this.namespace}: setting custom options`);
188
+ this.logger.info('mercury: setting custom options');
188
189
  options = {...options, ...this.webex.config.defaultMercuryOptions};
189
190
  }
190
191
 
@@ -192,14 +193,18 @@ const Mercury = WebexPlugin.extend({
192
193
  // the socket if it is in the process of being opened.
193
194
  this.socket = socket;
194
195
 
195
- this.logger.info(`${this.namespace} connection url: ${webSocketUrl}`);
196
-
197
196
  return socket.open(webSocketUrl, options);
198
197
  })
199
198
  .then(() => {
200
- this.logger.info(
201
- `${this.namespace}: connected to mercury, success, action: connected, url: ${attemptWSUrl}`
202
- );
199
+ this.webex.internal.metrics.submitClientMetrics('web-ha-mercury', {
200
+ fields: {
201
+ success: true,
202
+ },
203
+ tags: {
204
+ action: 'connected',
205
+ url: attemptWSUrl,
206
+ },
207
+ });
203
208
  callback();
204
209
 
205
210
  return this.webex.internal.feature
@@ -220,19 +225,19 @@ const Mercury = WebexPlugin.extend({
220
225
  if (reason.code !== 1006 && this.backoffCall && this.backoffCall.getNumRetries() > 0) {
221
226
  this._emit('connection_failed', reason, {retries: this.backoffCall.getNumRetries()});
222
227
  }
223
- this.logger.info(`${this.namespace}: connection attempt failed`, reason);
228
+ this.logger.info('mercury: connection attempt failed', reason);
224
229
  // UnknownResponse is produced by IE for any 4XXX; treated it like a bad
225
230
  // web socket url and let WDM handle the token checking
226
231
  if (reason instanceof UnknownResponse) {
227
232
  this.logger.info(
228
- `${this.namespace}: received unknown response code, refreshing device registration`
233
+ 'mercury: received unknown response code, refreshing device registration'
229
234
  );
230
235
 
231
236
  return this.webex.internal.device.refresh().then(() => callback(reason));
232
237
  }
233
238
  // NotAuthorized implies expired token
234
239
  if (reason instanceof NotAuthorized) {
235
- this.logger.info(`${this.namespace}: received authorization error, reauthorizing`);
240
+ this.logger.info('mercury: received authorization error, reauthorizing');
236
241
 
237
242
  return this.webex.credentials.refresh({force: true}).then(() => callback(reason));
238
243
  }
@@ -245,7 +250,7 @@ const Mercury = WebexPlugin.extend({
245
250
  // BadRequest implies current credentials are for a Service Account
246
251
  // Forbidden implies current user is not entitle for Webex
247
252
  if (reason instanceof BadRequest || reason instanceof Forbidden) {
248
- this.logger.warn(`${this.namespace}: received unrecoverable response from mercury`);
253
+ this.logger.warn('mercury: received unrecoverable response from mercury');
249
254
  this.backoffCall.abort();
250
255
 
251
256
  return callback(reason);
@@ -256,8 +261,18 @@ const Mercury = WebexPlugin.extend({
256
261
  .then((haMessagingEnabled) => {
257
262
  if (haMessagingEnabled) {
258
263
  this.logger.info(
259
- `${this.namespace}: received a generic connection error, will try to connect to another datacenter. failed, action: 'failed', url: ${attemptWSUrl} error: ${reason.message}`
264
+ 'mercury: received a generic connection error, will try to connect to another datacenter'
260
265
  );
266
+ this.webex.internal.metrics.submitClientMetrics('web-ha-mercury', {
267
+ fields: {
268
+ success: false,
269
+ },
270
+ tags: {
271
+ action: 'failed',
272
+ error: reason.message,
273
+ url: attemptWSUrl,
274
+ },
275
+ });
261
276
 
262
277
  return this.webex.internal.services.markFailedUrl(attemptWSUrl);
263
278
  }
@@ -270,7 +285,7 @@ const Mercury = WebexPlugin.extend({
270
285
  return callback(reason);
271
286
  })
272
287
  .catch((reason) => {
273
- this.logger.error(`${this.namespace}: failed to handle connection failure`, reason);
288
+ this.logger.error('mercury: failed to handle connection failure', reason);
274
289
  callback(reason);
275
290
  });
276
291
  },
@@ -286,9 +301,7 @@ const Mercury = WebexPlugin.extend({
286
301
  this.backoffCall = undefined;
287
302
  if (err) {
288
303
  this.logger.info(
289
- `${
290
- this.namespace
291
- }: failed to connect after ${call.getNumRetries()} retries; log statement about next retry was inaccurate; ${err}`
304
+ `mercury: failed to connect after ${call.getNumRetries()} retries; log statement about next retry was inaccurate; ${err}`
292
305
  );
293
306
 
294
307
  return reject(err);
@@ -301,7 +314,7 @@ const Mercury = WebexPlugin.extend({
301
314
 
302
315
  // eslint-disable-next-line prefer-reflect
303
316
  call = backoff.call((callback) => {
304
- this.logger.info(`${this.namespace}: executing connection attempt ${call.getNumRetries()}`);
317
+ this.logger.info(`mercury: executing connection attempt ${call.getNumRetries()}`);
305
318
  this._attemptConnection(webSocketUrl, callback);
306
319
  }, onComplete);
307
320
 
@@ -317,7 +330,7 @@ const Mercury = WebexPlugin.extend({
317
330
  }
318
331
 
319
332
  call.on('abort', () => {
320
- this.logger.info(`${this.namespace}: connection aborted`);
333
+ this.logger.info('mercury: connection aborted');
321
334
  reject(new Error('Mercury Connection Aborted'));
322
335
  });
323
336
 
@@ -327,16 +340,16 @@ const Mercury = WebexPlugin.extend({
327
340
  const delay = Math.min(call.strategy_.nextBackoffDelay_, this.config.backoffTimeMax);
328
341
 
329
342
  this.logger.info(
330
- `${this.namespace}: failed to connect; attempting retry ${number + 1} in ${delay} ms`
343
+ `mercury: failed to connect; attempting retry ${number + 1} in ${delay} ms`
331
344
  );
332
345
  /* istanbul ignore if */
333
346
  if (process.env.NODE_ENV === 'development') {
334
- this.logger.debug(`${this.namespace}: `, err, err.stack);
347
+ this.logger.debug('mercury: ', err, err.stack);
335
348
  }
336
349
 
337
350
  return;
338
351
  }
339
- this.logger.info(`${this.namespace}: connected`);
352
+ this.logger.info('mercury: connected');
340
353
  });
341
354
 
342
355
  call.start();
@@ -349,10 +362,7 @@ const Mercury = WebexPlugin.extend({
349
362
  try {
350
363
  this.trigger(...args);
351
364
  } catch (error) {
352
- this.logger.error(`${this.namespace}: error occurred in event handler`, {
353
- error,
354
- arguments: args,
355
- });
365
+ this.logger.error('mercury: error occurred in event handler', error);
356
366
  }
357
367
  },
358
368
 
@@ -393,20 +403,20 @@ const Mercury = WebexPlugin.extend({
393
403
  case 1003:
394
404
  // metric: disconnect
395
405
  this.logger.info(
396
- `${this.namespace}: Mercury service rejected last message; will not reconnect: ${event.reason}`
406
+ `mercury: Mercury service rejected last message; will not reconnect: ${event.reason}`
397
407
  );
398
408
  this._emit('offline.permanent', event);
399
409
  break;
400
410
  case 4000:
401
411
  // metric: disconnect
402
- this.logger.info(`${this.namespace}: socket replaced; will not reconnect`);
412
+ this.logger.info('mercury: socket replaced; will not reconnect');
403
413
  this._emit('offline.replaced', event);
404
414
  break;
405
415
  case 1001:
406
416
  case 1005:
407
417
  case 1006:
408
418
  case 1011:
409
- this.logger.info(`${this.namespace}: socket disconnected; reconnecting`);
419
+ this.logger.info('mercury: socket disconnected; reconnecting');
410
420
  this._emit('offline.transient', event);
411
421
  this._reconnect(socketUrl);
412
422
  // metric: disconnect
@@ -414,25 +424,23 @@ const Mercury = WebexPlugin.extend({
414
424
  break;
415
425
  case 1000:
416
426
  if (normalReconnectReasons.includes(reason)) {
417
- this.logger.info(`${this.namespace}: socket disconnected; reconnecting`);
427
+ this.logger.info('mercury: socket disconnected; reconnecting');
418
428
  this._emit('offline.transient', event);
419
429
  this._reconnect(socketUrl);
420
430
  // metric: disconnect
421
431
  // if (reason === done forced) metric: force closure
422
432
  } else {
423
- this.logger.info(`${this.namespace}: socket disconnected; will not reconnect`);
433
+ this.logger.info('mercury: socket disconnected; will not reconnect');
424
434
  this._emit('offline.permanent', event);
425
435
  }
426
436
  break;
427
437
  default:
428
- this.logger.info(
429
- `${this.namespace}: socket disconnected unexpectedly; will not reconnect`
430
- );
438
+ this.logger.info('mercury: socket disconnected unexpectedly; will not reconnect');
431
439
  // unexpected disconnect
432
440
  this._emit('offline.permanent', event);
433
441
  }
434
442
  } catch (error) {
435
- this.logger.error(`${this.namespace}: error occurred in close handler`, error);
443
+ this.logger.error('mercury: error occurred in close handler', error);
436
444
  }
437
445
  },
438
446
 
@@ -440,7 +448,7 @@ const Mercury = WebexPlugin.extend({
440
448
  const envelope = event.data;
441
449
 
442
450
  if (process.env.ENABLE_MERCURY_LOGGING) {
443
- this.logger.debug(`${this.namespace}: message envelope: `, envelope);
451
+ this.logger.debug('mercury: message envelope: ', envelope);
444
452
  }
445
453
 
446
454
  const {data} = envelope;
@@ -457,7 +465,7 @@ const Mercury = WebexPlugin.extend({
457
465
  resolve((this.webex[namespace] || this.webex.internal[namespace])[name](data))
458
466
  ).catch((reason) =>
459
467
  this.logger.error(
460
- `${this.namespace}: error occurred in autowired event handler for ${data.eventType}`,
468
+ `mercury: error occurred in autowired event handler for ${data.eventType}`,
461
469
  reason
462
470
  )
463
471
  );
@@ -476,12 +484,12 @@ const Mercury = WebexPlugin.extend({
476
484
  }
477
485
  })
478
486
  .catch((reason) => {
479
- this.logger.error(`${this.namespace}: error occurred processing socket message`, reason);
487
+ this.logger.error('mercury: error occurred processing socket message', reason);
480
488
  });
481
489
  },
482
490
 
483
491
  _reconnect(webSocketUrl) {
484
- this.logger.info(`${this.namespace}: reconnecting`);
492
+ this.logger.info('mercury: reconnecting');
485
493
 
486
494
  return this.connect(webSocketUrl);
487
495
  },
@@ -30,7 +30,6 @@ export default class Socket extends EventEmitter {
30
30
  */
31
31
  constructor() {
32
32
  super();
33
- this._domain = 'unknown-domain';
34
33
  this.onmessage = this.onmessage.bind(this);
35
34
  this.onclose = this.onclose.bind(this);
36
35
  }
@@ -112,10 +111,10 @@ export default class Socket extends EventEmitter {
112
111
  return;
113
112
  }
114
113
  // logger is defined once open is called
115
- this.logger.info(`socket,${this._domain}: closing`);
114
+ this.logger.info('socket: closing');
116
115
 
117
116
  if (socket.readyState === 2 || socket.readyState === 3) {
118
- this.logger.info(`socket,${this._domain}: already closed`);
117
+ this.logger.info('socket: already closed');
119
118
  resolve();
120
119
 
121
120
  return;
@@ -135,7 +134,7 @@ export default class Socket extends EventEmitter {
135
134
 
136
135
  const closeTimer = safeSetTimeout(() => {
137
136
  try {
138
- this.logger.info(`socket,${this._domain}: no close event received, forcing closure`);
137
+ this.logger.info('socket: no close event received, forcing closure');
139
138
  resolve(
140
139
  this.onclose({
141
140
  code: 1000,
@@ -143,12 +142,12 @@ export default class Socket extends EventEmitter {
143
142
  })
144
143
  );
145
144
  } catch (error) {
146
- this.logger.warn(`socket,${this._domain}: force-close failed`, error);
145
+ this.logger.warn('socket: force-close failed', error);
147
146
  }
148
147
  }, this.forceCloseDelay);
149
148
 
150
149
  socket.onclose = (event) => {
151
- this.logger.info(`socket,${this._domain}: close event fired`, event.code, event.reason);
150
+ this.logger.info('socket: close event fired', event.code, event.reason);
152
151
  clearTimeout(closeTimer);
153
152
  this.onclose(event);
154
153
  resolve(event);
@@ -172,12 +171,6 @@ export default class Socket extends EventEmitter {
172
171
  * @returns {Promise}
173
172
  */
174
173
  open(url, options) {
175
- try {
176
- this._domain = new URL(url).hostname;
177
- } catch {
178
- this._domain = url;
179
- }
180
-
181
174
  return new Promise((resolve, reject) => {
182
175
  /* eslint complexity: [0] */
183
176
  if (!url) {
@@ -208,7 +201,7 @@ export default class Socket extends EventEmitter {
208
201
 
209
202
  const WebSocket = Socket.getWebSocketConstructor();
210
203
 
211
- this.logger.info(`socket,${this._domain}: creating WebSocket`);
204
+ this.logger.info('socket: creating WebSocket');
212
205
  const socket = new WebSocket(url, [], options);
213
206
 
214
207
  socket.binaryType = 'arraybuffer';
@@ -216,7 +209,7 @@ export default class Socket extends EventEmitter {
216
209
 
217
210
  socket.onclose = (event) => {
218
211
  event = this._fixCloseCode(event);
219
- this.logger.info(`socket,${this._domain}: closed before open`, event.code, event.reason);
212
+ this.logger.info('socket: closed before open', event.code, event.reason);
220
213
  switch (event.code) {
221
214
  case 1005:
222
215
  // IE 11 doesn't seem to allow 4XXX codes, so if we get a 1005, assume
@@ -238,10 +231,10 @@ export default class Socket extends EventEmitter {
238
231
  };
239
232
 
240
233
  socket.onopen = () => {
241
- this.logger.info(`socket,${this._domain}: connected`);
234
+ this.logger.info('socket: connected');
242
235
  this._authorize()
243
236
  .then(() => {
244
- this.logger.info(`socket,${this._domain}: authorized`);
237
+ this.logger.info('socket: authorized');
245
238
  socket.onclose = this.onclose;
246
239
  resolve();
247
240
  })
@@ -249,11 +242,11 @@ export default class Socket extends EventEmitter {
249
242
  };
250
243
 
251
244
  socket.onerror = (event) => {
252
- this.logger.warn(`socket,${this._domain}: error event fired`, event);
245
+ this.logger.warn('socket: error event fired', event);
253
246
  };
254
247
 
255
248
  sockets.set(this, socket);
256
- this.logger.info(`socket,${this._domain}: waiting for server`);
249
+ this.logger.info('socket: waiting for server');
257
250
  });
258
251
  }
259
252
 
@@ -263,7 +256,7 @@ export default class Socket extends EventEmitter {
263
256
  * @returns {undefined}
264
257
  */
265
258
  onclose(event) {
266
- this.logger.info(`socket,${this._domain}: closed`, event.code, event.reason);
259
+ this.logger.info('socket: closed', event.code, event.reason);
267
260
  clearTimeout(this.pongTimer);
268
261
  clearTimeout(this.pingTimer);
269
262
 
@@ -285,10 +278,10 @@ export default class Socket extends EventEmitter {
285
278
  const data = JSON.parse(event.data);
286
279
  const sequenceNumber = parseInt(data.sequenceNumber, 10);
287
280
 
288
- this.logger.debug(`socket,${this._domain}: sequence number: `, sequenceNumber);
281
+ this.logger.debug('socket: sequence number: ', sequenceNumber);
289
282
  if (this.expectedSequenceNumber && sequenceNumber !== this.expectedSequenceNumber) {
290
283
  this.logger.debug(
291
- `socket,${this._domain}: sequence number mismatch indicates lost mercury message. expected: ${this.expectedSequenceNumber}, actual: ${sequenceNumber}`
284
+ `socket: sequence number mismatch indicates lost mercury message. expected: ${this.expectedSequenceNumber}, actual: ${sequenceNumber}`
292
285
  );
293
286
  this.emit('sequence-mismatch', sequenceNumber, this.expectedSequenceNumber);
294
287
  }
@@ -310,7 +303,7 @@ export default class Socket extends EventEmitter {
310
303
  // message from Mercury. At this time, the only action we have is to
311
304
  // ignore it and move on.
312
305
  /* istanbul ignore next */
313
- this.logger.warn(`socket,${this._domain}: error while receiving WebSocket message`, error);
306
+ this.logger.warn('socket: error while receiving WebSocket message', error);
314
307
  }
315
308
  }
316
309
 
@@ -364,7 +357,7 @@ export default class Socket extends EventEmitter {
364
357
  */
365
358
  _authorize() {
366
359
  return new Promise((resolve) => {
367
- this.logger.info(`socket,${this._domain}: authorizing`);
360
+ this.logger.info('socket: authorizing');
368
361
  this.send({
369
362
  id: uuid.v4(),
370
363
  type: 'authorization',
@@ -402,18 +395,12 @@ export default class Socket extends EventEmitter {
402
395
  if (event.code === 1005 && event.reason) {
403
396
  switch (event.reason.toLowerCase()) {
404
397
  case 'replaced':
405
- this.logger.info(
406
- `socket,${this._domain}: fixing CloseEvent code for reason: `,
407
- event.reason
408
- );
398
+ this.logger.info('socket: fixing CloseEvent code for reason: ', event.reason);
409
399
  event.code = 4000;
410
400
  break;
411
401
  case 'authentication failed':
412
402
  case 'authentication did not happen within the timeout window of 30000 seconds.':
413
- this.logger.info(
414
- `socket,${this._domain}: fixing CloseEvent code for reason: `,
415
- event.reason
416
- );
403
+ this.logger.info('socket: fixing CloseEvent code for reason: ', event.reason);
417
404
  event.code = 1008;
418
405
  break;
419
406
  default:
@@ -433,12 +420,10 @@ export default class Socket extends EventEmitter {
433
420
  _ping(id) {
434
421
  const confirmPongId = (event) => {
435
422
  try {
436
- this.logger.debug(`socket,${this._domain}: pong`, event.data.id);
423
+ this.logger.debug('socket: pong', event.data.id);
437
424
  if (event.data && event.data.id !== id) {
438
- this.logger.info(
439
- `socket,${this._domain}: received pong for wrong ping id, closing socket`
440
- );
441
- this.logger.debug(`socket,${this._domain}: expected`, id, 'received', event.data.id);
425
+ this.logger.info('socket: received pong for wrong ping id, closing socket');
426
+ this.logger.debug('socket: expected', id, 'received', event.data.id);
442
427
  this.close({
443
428
  code: 1000,
444
429
  reason: 'Pong mismatch',
@@ -448,29 +433,24 @@ export default class Socket extends EventEmitter {
448
433
  // This try/catch block was added as a debugging step; to the best of my
449
434
  // knowledge, the above can never throw.
450
435
  /* istanbul ignore next */
451
- this.logger.error(`socket,${this._domain}: error occurred in confirmPongId`, error);
436
+ this.logger.error('socket: error occurred in confirmPongId', error);
452
437
  }
453
438
  };
454
439
 
455
440
  const onPongNotReceived = () => {
456
441
  try {
457
- this.logger.info(
458
- `socket,${this._domain}: pong not receive in expected period, closing socket`
459
- );
442
+ this.logger.info('socket: pong not receive in expected period, closing socket');
460
443
  this.close({
461
444
  code: 1000,
462
445
  reason: 'Pong not received',
463
446
  }).catch((reason) => {
464
- this.logger.warn(
465
- `socket,${this._domain}: failed to close socket after missed pong`,
466
- reason
467
- );
447
+ this.logger.warn('socket: failed to close socket after missed pong', reason);
468
448
  });
469
449
  } catch (error) {
470
450
  // This try/catch block was added as a debugging step; to the best of my
471
451
  // knowledge, the above can never throw.
472
452
  /* istanbul ignore next */
473
- this.logger.error(`socket,${this._domain}: error occurred in onPongNotReceived`, error);
453
+ this.logger.error('socket: error occurred in onPongNotReceived', error);
474
454
  }
475
455
  };
476
456
 
@@ -482,29 +462,16 @@ export default class Socket extends EventEmitter {
482
462
  // This try/catch block was added as a debugging step; to the best of my
483
463
  // knowledge, the above can never throw.
484
464
  /* istanbul ignore next */
485
- this.logger.error(
486
- `socket,${this._domain}: error occurred in scheduleNextPingAndCancelPongTimer`,
487
- error
488
- );
465
+ this.logger.error('socket: error occurred in scheduleNextPingAndCancelPongTimer', error);
489
466
  }
490
467
  };
491
468
 
492
- const calculateLatency = (pingTimestamp) => {
493
- const now = performance.now();
494
- const latency = now - pingTimestamp;
495
-
496
- this.logger.debug(`socket,${this._domain}: latency: `, latency);
497
- this.emit('ping-pong-latency', latency);
498
- };
499
-
500
469
  id = id || uuid.v4();
501
- const pingTimestamp = performance.now();
502
-
503
470
  this.pongTimer = safeSetTimeout(onPongNotReceived, this.pongTimeout);
504
471
  this.once('pong', scheduleNextPingAndCancelPongTimer);
505
472
  this.once('pong', confirmPongId);
506
- this.once('pong', () => calculateLatency(pingTimestamp));
507
- this.logger.debug(`socket,${this._domain}: ping ${id}`);
473
+
474
+ this.logger.debug(`socket: ping ${id}`);
508
475
 
509
476
  return this.send({
510
477
  id,