@webex/internal-plugin-mercury 3.0.0-bnr.5 → 3.0.0-next.10

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,"names":["Socket","getWebSocketConstructor","WS"],"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;AAEA;AANA;AACA;AACA;;AAMAA,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuB,GAAG;EAClE,OAAOC,WAAE;AACX,CAAC;AAAC,eAEaF,mBAAM;AAAA"}
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"}
@@ -32,6 +32,5 @@ _socketBase.default.getWebSocketConstructor = function getWebSocketConstructor()
32
32
  }
33
33
  return ws;
34
34
  };
35
- var _default = _socketBase.default;
36
- exports.default = _default;
35
+ var _default = exports.default = _socketBase.default;
37
36
  //# sourceMappingURL=socket.shim.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Socket","getWebSocketConstructor","ws","WebSocket","MozWebSocket","global","window","self"],"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;AARA;;AAEA;AACA;AACA;;AAEA;;AAIAA,mBAAM,CAACC,uBAAuB,GAAG,SAASA,uBAAuB,GAAG;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,eAEaF,mBAAM;AAAA"}
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"}
package/jest.config.js ADDED
@@ -0,0 +1,3 @@
1
+ const config = require('@webex/jest-config-legacy');
2
+
3
+ module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@webex/internal-plugin-mercury",
3
- "version": "3.0.0-bnr.5",
4
3
  "description": "",
5
4
  "license": "MIT",
6
5
  "main": "dist/index.js",
@@ -24,26 +23,46 @@
24
23
  ]
25
24
  },
26
25
  "devDependencies": {
26
+ "@babel/core": "^7.17.10",
27
27
  "@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": "3.0.0-next.8",
33
+ "@webex/test-helper-mocha": "3.0.0-next.8",
34
+ "@webex/test-helper-mock-webex": "3.0.0-next.8",
35
+ "@webex/test-helper-test-users": "3.0.0-next.8",
36
+ "eslint": "^8.24.0",
37
+ "prettier": "^2.7.1",
28
38
  "sinon": "^9.2.4"
29
39
  },
30
40
  "dependencies": {
31
- "@webex/common": "3.0.0-bnr.5",
32
- "@webex/common-timers": "3.0.0-bnr.5",
33
- "@webex/internal-plugin-device": "3.0.0-bnr.5",
34
- "@webex/internal-plugin-feature": "3.0.0-bnr.5",
35
- "@webex/internal-plugin-mercury": "3.0.0-bnr.5",
36
- "@webex/internal-plugin-metrics": "3.0.0-bnr.5",
37
- "@webex/test-helper-chai": "3.0.0-bnr.5",
38
- "@webex/test-helper-mocha": "3.0.0-bnr.5",
39
- "@webex/test-helper-mock-web-socket": "3.0.0-bnr.5",
40
- "@webex/test-helper-mock-webex": "3.0.0-bnr.5",
41
- "@webex/test-helper-refresh-callback": "3.0.0-bnr.5",
42
- "@webex/test-helper-test-users": "3.0.0-bnr.5",
43
- "@webex/webex-core": "3.0.0-bnr.5",
41
+ "@webex/common": "3.0.0-next.8",
42
+ "@webex/common-timers": "3.0.0-next.8",
43
+ "@webex/internal-plugin-device": "3.0.0-next.8",
44
+ "@webex/internal-plugin-feature": "3.0.0-next.10",
45
+ "@webex/internal-plugin-metrics": "3.0.0-next.8",
46
+ "@webex/test-helper-chai": "3.0.0-next.8",
47
+ "@webex/test-helper-mocha": "3.0.0-next.8",
48
+ "@webex/test-helper-mock-web-socket": "3.0.0-next.8",
49
+ "@webex/test-helper-mock-webex": "3.0.0-next.8",
50
+ "@webex/test-helper-refresh-callback": "3.0.0-next.8",
51
+ "@webex/test-helper-test-users": "3.0.0-next.8",
52
+ "@webex/webex-core": "3.0.0-next.8",
44
53
  "backoff": "^2.5.0",
45
54
  "lodash": "^4.17.21",
46
55
  "uuid": "^3.3.2",
47
56
  "ws": "^8.2.2"
48
- }
49
- }
57
+ },
58
+ "scripts": {
59
+ "build": "yarn build:src",
60
+ "build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
61
+ "deploy:npm": "yarn npm publish",
62
+ "test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
63
+ "test:browser": "webex-legacy-tools test --integration --unit --runner karma",
64
+ "test:style": "eslint ./src/**/*.*",
65
+ "test:unit": "webex-legacy-tools test --unit --runner mocha"
66
+ },
67
+ "version": "3.0.0-next.10"
68
+ }
package/process ADDED
@@ -0,0 +1 @@
1
+ module.exports = {browser: true};
package/src/mercury.js CHANGED
@@ -1,3 +1,4 @@
1
+ /* eslint-disable require-jsdoc */
1
2
  /*!
2
3
  * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
4
  */
@@ -23,6 +24,7 @@ const normalReconnectReasons = ['idle', 'done (forced)', 'pong not received', 'p
23
24
 
24
25
  const Mercury = WebexPlugin.extend({
25
26
  namespace: 'Mercury',
27
+ lastError: undefined,
26
28
 
27
29
  session: {
28
30
  connected: {
@@ -33,6 +35,10 @@ const Mercury = WebexPlugin.extend({
33
35
  default: false,
34
36
  type: 'boolean',
35
37
  },
38
+ hasEverConnected: {
39
+ default: false,
40
+ type: 'boolean',
41
+ },
36
42
  socket: 'object',
37
43
  localClusterServiceUrls: 'object',
38
44
  },
@@ -46,10 +52,18 @@ const Mercury = WebexPlugin.extend({
46
52
  },
47
53
  },
48
54
 
55
+ /**
56
+ * Get the last error.
57
+ * @returns {any} The last error.
58
+ */
59
+ getLastError() {
60
+ return this.lastError;
61
+ },
62
+
49
63
  @oneFlight
50
64
  connect(webSocketUrl) {
51
65
  if (this.connected) {
52
- this.logger.info('mercury: already connected, will not connect again');
66
+ this.logger.info(`${this.namespace}: already connected, will not connect again`);
53
67
 
54
68
  return Promise.resolve();
55
69
  }
@@ -59,7 +73,7 @@ const Mercury = WebexPlugin.extend({
59
73
  return Promise.resolve(
60
74
  this.webex.internal.device.registered || this.webex.internal.device.register()
61
75
  ).then(() => {
62
- this.logger.info('mercury: connecting');
76
+ this.logger.info(`${this.namespace}: connecting`);
63
77
 
64
78
  return this._connectWithBackoff(webSocketUrl);
65
79
  });
@@ -69,16 +83,14 @@ const Mercury = WebexPlugin.extend({
69
83
  disconnect() {
70
84
  return new Promise((resolve) => {
71
85
  if (this.backoffCall) {
72
- this.logger.info('mercury: aborting connection');
86
+ this.logger.info(`${this.namespace}: aborting connection`);
73
87
  this.backoffCall.abort();
74
88
  }
75
89
 
76
90
  if (this.socket) {
77
91
  this.socket.removeAllListeners('message');
78
92
  this.once('offline', resolve);
79
- this.socket.close();
80
-
81
- return;
93
+ resolve(this.socket.close());
82
94
  }
83
95
 
84
96
  resolve();
@@ -161,11 +173,12 @@ const Mercury = WebexPlugin.extend({
161
173
  socket.on('close', (...args) => this._onclose(...args));
162
174
  socket.on('message', (...args) => this._onmessage(...args));
163
175
  socket.on('sequence-mismatch', (...args) => this._emit('sequence-mismatch', ...args));
176
+ socket.on('ping-pong-latency', (...args) => this._emit('ping-pong-latency', ...args));
164
177
 
165
178
  Promise.all([this._prepareUrl(socketUrl), this.webex.credentials.getUserToken()])
166
179
  .then(([webSocketUrl, token]) => {
167
180
  if (!this.backoffCall) {
168
- const msg = 'mercury: prevent socket open when backoffCall no longer defined';
181
+ const msg = `${this.namespace}: prevent socket open when backoffCall no longer defined`;
169
182
 
170
183
  this.logger.info(msg);
171
184
 
@@ -185,7 +198,7 @@ const Mercury = WebexPlugin.extend({
185
198
 
186
199
  // if the consumer has supplied request options use them
187
200
  if (this.webex.config.defaultMercuryOptions) {
188
- this.logger.info('mercury: setting custom options');
201
+ this.logger.info(`${this.namespace}: setting custom options`);
189
202
  options = {...options, ...this.webex.config.defaultMercuryOptions};
190
203
  }
191
204
 
@@ -193,18 +206,14 @@ const Mercury = WebexPlugin.extend({
193
206
  // the socket if it is in the process of being opened.
194
207
  this.socket = socket;
195
208
 
209
+ this.logger.info(`${this.namespace} connection url: ${webSocketUrl}`);
210
+
196
211
  return socket.open(webSocketUrl, options);
197
212
  })
198
213
  .then(() => {
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
- });
214
+ this.logger.info(
215
+ `${this.namespace}: connected to mercury, success, action: connected, url: ${attemptWSUrl}`
216
+ );
208
217
  callback();
209
218
 
210
219
  return this.webex.internal.feature
@@ -218,6 +227,8 @@ const Mercury = WebexPlugin.extend({
218
227
  });
219
228
  })
220
229
  .catch((reason) => {
230
+ this.lastError = reason; // remember the last error
231
+
221
232
  // Suppress connection errors that appear to be network related. This
222
233
  // may end up suppressing metrics during outages, but we might not care
223
234
  // (especially since many of our outages happen in a way that client
@@ -225,19 +236,19 @@ const Mercury = WebexPlugin.extend({
225
236
  if (reason.code !== 1006 && this.backoffCall && this.backoffCall.getNumRetries() > 0) {
226
237
  this._emit('connection_failed', reason, {retries: this.backoffCall.getNumRetries()});
227
238
  }
228
- this.logger.info('mercury: connection attempt failed', reason);
239
+ this.logger.info(`${this.namespace}: connection attempt failed`, reason);
229
240
  // UnknownResponse is produced by IE for any 4XXX; treated it like a bad
230
241
  // web socket url and let WDM handle the token checking
231
242
  if (reason instanceof UnknownResponse) {
232
243
  this.logger.info(
233
- 'mercury: received unknown response code, refreshing device registration'
244
+ `${this.namespace}: received unknown response code, refreshing device registration`
234
245
  );
235
246
 
236
247
  return this.webex.internal.device.refresh().then(() => callback(reason));
237
248
  }
238
249
  // NotAuthorized implies expired token
239
250
  if (reason instanceof NotAuthorized) {
240
- this.logger.info('mercury: received authorization error, reauthorizing');
251
+ this.logger.info(`${this.namespace}: received authorization error, reauthorizing`);
241
252
 
242
253
  return this.webex.credentials.refresh({force: true}).then(() => callback(reason));
243
254
  }
@@ -250,7 +261,7 @@ const Mercury = WebexPlugin.extend({
250
261
  // BadRequest implies current credentials are for a Service Account
251
262
  // Forbidden implies current user is not entitle for Webex
252
263
  if (reason instanceof BadRequest || reason instanceof Forbidden) {
253
- this.logger.warn('mercury: received unrecoverable response from mercury');
264
+ this.logger.warn(`${this.namespace}: received unrecoverable response from mercury`);
254
265
  this.backoffCall.abort();
255
266
 
256
267
  return callback(reason);
@@ -261,18 +272,8 @@ const Mercury = WebexPlugin.extend({
261
272
  .then((haMessagingEnabled) => {
262
273
  if (haMessagingEnabled) {
263
274
  this.logger.info(
264
- 'mercury: received a generic connection error, will try to connect to another datacenter'
275
+ `${this.namespace}: received a generic connection error, will try to connect to another datacenter. failed, action: 'failed', url: ${attemptWSUrl} error: ${reason.message}`
265
276
  );
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
- });
276
277
 
277
278
  return this.webex.internal.services.markFailedUrl(attemptWSUrl);
278
279
  }
@@ -285,7 +286,7 @@ const Mercury = WebexPlugin.extend({
285
286
  return callback(reason);
286
287
  })
287
288
  .catch((reason) => {
288
- this.logger.error('mercury: failed to handle connection failure', reason);
289
+ this.logger.error(`${this.namespace}: failed to handle connection failure`, reason);
289
290
  callback(reason);
290
291
  });
291
292
  },
@@ -301,12 +302,15 @@ const Mercury = WebexPlugin.extend({
301
302
  this.backoffCall = undefined;
302
303
  if (err) {
303
304
  this.logger.info(
304
- `mercury: failed to connect after ${call.getNumRetries()} retries; log statement about next retry was inaccurate; ${err}`
305
+ `${
306
+ this.namespace
307
+ }: failed to connect after ${call.getNumRetries()} retries; log statement about next retry was inaccurate; ${err}`
305
308
  );
306
309
 
307
310
  return reject(err);
308
311
  }
309
312
  this.connected = true;
313
+ this.hasEverConnected = true;
310
314
  this._emit('online');
311
315
 
312
316
  return resolve();
@@ -314,7 +318,7 @@ const Mercury = WebexPlugin.extend({
314
318
 
315
319
  // eslint-disable-next-line prefer-reflect
316
320
  call = backoff.call((callback) => {
317
- this.logger.info(`mercury: executing connection attempt ${call.getNumRetries()}`);
321
+ this.logger.info(`${this.namespace}: executing connection attempt ${call.getNumRetries()}`);
318
322
  this._attemptConnection(webSocketUrl, callback);
319
323
  }, onComplete);
320
324
 
@@ -325,12 +329,14 @@ const Mercury = WebexPlugin.extend({
325
329
  })
326
330
  );
327
331
 
328
- if (this.config.maxRetries) {
332
+ if (this.config.initialConnectionMaxRetries && !this.hasEverConnected) {
333
+ call.failAfter(this.config.initialConnectionMaxRetries);
334
+ } else if (this.config.maxRetries) {
329
335
  call.failAfter(this.config.maxRetries);
330
336
  }
331
337
 
332
338
  call.on('abort', () => {
333
- this.logger.info('mercury: connection aborted');
339
+ this.logger.info(`${this.namespace}: connection aborted`);
334
340
  reject(new Error('Mercury Connection Aborted'));
335
341
  });
336
342
 
@@ -340,16 +346,16 @@ const Mercury = WebexPlugin.extend({
340
346
  const delay = Math.min(call.strategy_.nextBackoffDelay_, this.config.backoffTimeMax);
341
347
 
342
348
  this.logger.info(
343
- `mercury: failed to connect; attempting retry ${number + 1} in ${delay} ms`
349
+ `${this.namespace}: failed to connect; attempting retry ${number + 1} in ${delay} ms`
344
350
  );
345
351
  /* istanbul ignore if */
346
352
  if (process.env.NODE_ENV === 'development') {
347
- this.logger.debug('mercury: ', err, err.stack);
353
+ this.logger.debug(`${this.namespace}: `, err, err.stack);
348
354
  }
349
355
 
350
356
  return;
351
357
  }
352
- this.logger.info('mercury: connected');
358
+ this.logger.info(`${this.namespace}: connected`);
353
359
  });
354
360
 
355
361
  call.start();
@@ -362,7 +368,10 @@ const Mercury = WebexPlugin.extend({
362
368
  try {
363
369
  this.trigger(...args);
364
370
  } catch (error) {
365
- this.logger.error('mercury: error occurred in event handler', error);
371
+ this.logger.error(`${this.namespace}: error occurred in event handler`, {
372
+ error,
373
+ arguments: args,
374
+ });
366
375
  }
367
376
  },
368
377
 
@@ -403,20 +412,20 @@ const Mercury = WebexPlugin.extend({
403
412
  case 1003:
404
413
  // metric: disconnect
405
414
  this.logger.info(
406
- `mercury: Mercury service rejected last message; will not reconnect: ${event.reason}`
415
+ `${this.namespace}: Mercury service rejected last message; will not reconnect: ${event.reason}`
407
416
  );
408
417
  this._emit('offline.permanent', event);
409
418
  break;
410
419
  case 4000:
411
420
  // metric: disconnect
412
- this.logger.info('mercury: socket replaced; will not reconnect');
421
+ this.logger.info(`${this.namespace}: socket replaced; will not reconnect`);
413
422
  this._emit('offline.replaced', event);
414
423
  break;
415
424
  case 1001:
416
425
  case 1005:
417
426
  case 1006:
418
427
  case 1011:
419
- this.logger.info('mercury: socket disconnected; reconnecting');
428
+ this.logger.info(`${this.namespace}: socket disconnected; reconnecting`);
420
429
  this._emit('offline.transient', event);
421
430
  this._reconnect(socketUrl);
422
431
  // metric: disconnect
@@ -424,23 +433,25 @@ const Mercury = WebexPlugin.extend({
424
433
  break;
425
434
  case 1000:
426
435
  if (normalReconnectReasons.includes(reason)) {
427
- this.logger.info('mercury: socket disconnected; reconnecting');
436
+ this.logger.info(`${this.namespace}: socket disconnected; reconnecting`);
428
437
  this._emit('offline.transient', event);
429
438
  this._reconnect(socketUrl);
430
439
  // metric: disconnect
431
440
  // if (reason === done forced) metric: force closure
432
441
  } else {
433
- this.logger.info('mercury: socket disconnected; will not reconnect');
442
+ this.logger.info(`${this.namespace}: socket disconnected; will not reconnect`);
434
443
  this._emit('offline.permanent', event);
435
444
  }
436
445
  break;
437
446
  default:
438
- this.logger.info('mercury: socket disconnected unexpectedly; will not reconnect');
447
+ this.logger.info(
448
+ `${this.namespace}: socket disconnected unexpectedly; will not reconnect`
449
+ );
439
450
  // unexpected disconnect
440
451
  this._emit('offline.permanent', event);
441
452
  }
442
453
  } catch (error) {
443
- this.logger.error('mercury: error occurred in close handler', error);
454
+ this.logger.error(`${this.namespace}: error occurred in close handler`, error);
444
455
  }
445
456
  },
446
457
 
@@ -448,7 +459,7 @@ const Mercury = WebexPlugin.extend({
448
459
  const envelope = event.data;
449
460
 
450
461
  if (process.env.ENABLE_MERCURY_LOGGING) {
451
- this.logger.debug('mercury: message envelope: ', envelope);
462
+ this.logger.debug(`${this.namespace}: message envelope: `, envelope);
452
463
  }
453
464
 
454
465
  const {data} = envelope;
@@ -465,7 +476,7 @@ const Mercury = WebexPlugin.extend({
465
476
  resolve((this.webex[namespace] || this.webex.internal[namespace])[name](data))
466
477
  ).catch((reason) =>
467
478
  this.logger.error(
468
- `mercury: error occurred in autowired event handler for ${data.eventType}`,
479
+ `${this.namespace}: error occurred in autowired event handler for ${data.eventType}`,
469
480
  reason
470
481
  )
471
482
  );
@@ -484,12 +495,12 @@ const Mercury = WebexPlugin.extend({
484
495
  }
485
496
  })
486
497
  .catch((reason) => {
487
- this.logger.error('mercury: error occurred processing socket message', reason);
498
+ this.logger.error(`${this.namespace}: error occurred processing socket message`, reason);
488
499
  });
489
500
  },
490
501
 
491
502
  _reconnect(webSocketUrl) {
492
- this.logger.info('mercury: reconnecting');
503
+ this.logger.info(`${this.namespace}: reconnecting`);
493
504
 
494
505
  return this.connect(webSocketUrl);
495
506
  },