stream-chat 4.4.2 → 4.4.3-dev.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/dist/browser.es.js +30 -22
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.full-bundle.min.js +1 -1
- package/dist/browser.full-bundle.min.js.map +1 -1
- package/dist/browser.js +30 -22
- package/dist/browser.js.map +1 -1
- package/dist/index.es.js +30 -22
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +30 -22
- package/dist/index.js.map +1 -1
- package/dist/types/connection.d.ts.map +1 -1
- package/dist/types/insights.d.ts +3 -9
- package/dist/types/insights.d.ts.map +1 -1
- package/dist/types/utils.d.ts +1 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/connection.ts +19 -11
- package/src/insights.ts +2 -7
- package/src/utils.ts +13 -0
package/dist/index.js
CHANGED
|
@@ -954,6 +954,16 @@ function getRandomBytes(length) {
|
|
|
954
954
|
return bytes;
|
|
955
955
|
}
|
|
956
956
|
|
|
957
|
+
function convertErrorToJson(err) {
|
|
958
|
+
var jsonObj = {};
|
|
959
|
+
if (!err) return jsonObj;
|
|
960
|
+
Object.getOwnPropertyNames(err).forEach(function (key) {
|
|
961
|
+
// @ts-ignore
|
|
962
|
+
jsonObj[key] = err[key];
|
|
963
|
+
});
|
|
964
|
+
return jsonObj;
|
|
965
|
+
}
|
|
966
|
+
|
|
957
967
|
function _createForOfIteratorHelper$2(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray$2(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
958
968
|
|
|
959
969
|
function _unsupportedIterableToArray$2(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$2(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$2(o, minLen); }
|
|
@@ -3465,13 +3475,7 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3465
3475
|
this.instanceClientId = randomId();
|
|
3466
3476
|
};
|
|
3467
3477
|
function buildWsFatalInsight(connection, event) {
|
|
3468
|
-
return _objectSpread$2({
|
|
3469
|
-
err: {
|
|
3470
|
-
wasClean: event.wasClean,
|
|
3471
|
-
code: event.code,
|
|
3472
|
-
reason: event.reason
|
|
3473
|
-
}
|
|
3474
|
-
}, buildWsBaseInsight(connection));
|
|
3478
|
+
return _objectSpread$2(_objectSpread$2({}, event), buildWsBaseInsight(connection));
|
|
3475
3479
|
}
|
|
3476
3480
|
|
|
3477
3481
|
function buildWsBaseInsight(connection) {
|
|
@@ -3709,13 +3713,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3709
3713
|
});
|
|
3710
3714
|
|
|
3711
3715
|
_defineProperty__default['default'](this, "onclose", function (wsID, event) {
|
|
3712
|
-
if (
|
|
3713
|
-
var _this$postInsights;
|
|
3714
|
-
|
|
3715
|
-
_this.insightMetrics.wsConsecutiveFailures++;
|
|
3716
|
-
_this.insightMetrics.wsTotalFailures++;
|
|
3717
|
-
(_this$postInsights = _this.postInsights) === null || _this$postInsights === void 0 ? void 0 : _this$postInsights.call(_this, 'ws_fatal', buildWsFatalInsight(_this, event));
|
|
3718
|
-
}
|
|
3716
|
+
if (_this.wsID !== wsID) return;
|
|
3719
3717
|
|
|
3720
3718
|
_this.logger('info', 'connection:onclose() - onclose callback - ' + event.code, {
|
|
3721
3719
|
tags: ['connection'],
|
|
@@ -3723,8 +3721,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3723
3721
|
wsID: wsID
|
|
3724
3722
|
});
|
|
3725
3723
|
|
|
3726
|
-
if (_this.wsID !== wsID) return;
|
|
3727
|
-
|
|
3728
3724
|
if (event.code === chatCodes.WS_CLOSED_SUCCESS) {
|
|
3729
3725
|
var _this$rejectPromise2;
|
|
3730
3726
|
|
|
@@ -3732,6 +3728,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3732
3728
|
// usually caused by invalid auth details
|
|
3733
3729
|
var error = new Error("WS connection reject with error ".concat(event.reason));
|
|
3734
3730
|
error.reason = event.reason;
|
|
3731
|
+
error.code = event.code;
|
|
3732
|
+
error.wasClean = event.wasClean;
|
|
3733
|
+
error.target = event.target;
|
|
3735
3734
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3736
3735
|
|
|
3737
3736
|
_this.logger('info', "connection:onclose() - WS connection reject with error ".concat(event.reason), {
|
|
@@ -4262,7 +4261,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4262
4261
|
key: "_connect",
|
|
4263
4262
|
value: function () {
|
|
4264
4263
|
var _connect3 = _asyncToGenerator__default['default']( /*#__PURE__*/_regeneratorRuntime__default['default'].mark(function _callee5() {
|
|
4265
|
-
var wsURL, response, _this$
|
|
4264
|
+
var wsURL, response, _this$postInsights, insights;
|
|
4266
4265
|
|
|
4267
4266
|
return _regeneratorRuntime__default['default'].wrap(function _callee5$(_context5) {
|
|
4268
4267
|
while (1) {
|
|
@@ -4307,24 +4306,33 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4307
4306
|
|
|
4308
4307
|
this.connectionID = response.connection_id;
|
|
4309
4308
|
|
|
4310
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0) {
|
|
4311
|
-
|
|
4309
|
+
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.postInsights) {
|
|
4310
|
+
this.postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4312
4311
|
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4313
4312
|
}
|
|
4314
4313
|
|
|
4315
4314
|
return _context5.abrupt("return", response);
|
|
4316
4315
|
|
|
4317
4316
|
case 23:
|
|
4318
|
-
_context5.next =
|
|
4317
|
+
_context5.next = 30;
|
|
4319
4318
|
break;
|
|
4320
4319
|
|
|
4321
4320
|
case 25:
|
|
4322
4321
|
_context5.prev = 25;
|
|
4323
4322
|
_context5.t0 = _context5["catch"](5);
|
|
4324
4323
|
this.isConnecting = false;
|
|
4324
|
+
|
|
4325
|
+
if (this.postInsights) {
|
|
4326
|
+
this.insightMetrics.wsConsecutiveFailures++;
|
|
4327
|
+
this.insightMetrics.wsTotalFailures++; // @ts-ignore
|
|
4328
|
+
|
|
4329
|
+
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4330
|
+
(_this$postInsights = this.postInsights) === null || _this$postInsights === void 0 ? void 0 : _this$postInsights.call(this, 'ws_fatal', insights);
|
|
4331
|
+
}
|
|
4332
|
+
|
|
4325
4333
|
throw _context5.t0;
|
|
4326
4334
|
|
|
4327
|
-
case
|
|
4335
|
+
case 30:
|
|
4328
4336
|
case "end":
|
|
4329
4337
|
return _context5.stop();
|
|
4330
4338
|
}
|
|
@@ -8375,7 +8383,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8375
8383
|
}, {
|
|
8376
8384
|
key: "getUserAgent",
|
|
8377
8385
|
value: function getUserAgent() {
|
|
8378
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.4.
|
|
8386
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.4.3-dev.0");
|
|
8379
8387
|
}
|
|
8380
8388
|
}, {
|
|
8381
8389
|
key: "setUserAgent",
|