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.es.js
CHANGED
|
@@ -931,6 +931,16 @@ function getRandomBytes(length) {
|
|
|
931
931
|
return bytes;
|
|
932
932
|
}
|
|
933
933
|
|
|
934
|
+
function convertErrorToJson(err) {
|
|
935
|
+
var jsonObj = {};
|
|
936
|
+
if (!err) return jsonObj;
|
|
937
|
+
Object.getOwnPropertyNames(err).forEach(function (key) {
|
|
938
|
+
// @ts-ignore
|
|
939
|
+
jsonObj[key] = err[key];
|
|
940
|
+
});
|
|
941
|
+
return jsonObj;
|
|
942
|
+
}
|
|
943
|
+
|
|
934
944
|
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; } } }; }
|
|
935
945
|
|
|
936
946
|
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); }
|
|
@@ -3442,13 +3452,7 @@ var InsightMetrics = function InsightMetrics() {
|
|
|
3442
3452
|
this.instanceClientId = randomId();
|
|
3443
3453
|
};
|
|
3444
3454
|
function buildWsFatalInsight(connection, event) {
|
|
3445
|
-
return _objectSpread$2({
|
|
3446
|
-
err: {
|
|
3447
|
-
wasClean: event.wasClean,
|
|
3448
|
-
code: event.code,
|
|
3449
|
-
reason: event.reason
|
|
3450
|
-
}
|
|
3451
|
-
}, buildWsBaseInsight(connection));
|
|
3455
|
+
return _objectSpread$2(_objectSpread$2({}, event), buildWsBaseInsight(connection));
|
|
3452
3456
|
}
|
|
3453
3457
|
|
|
3454
3458
|
function buildWsBaseInsight(connection) {
|
|
@@ -3686,13 +3690,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3686
3690
|
});
|
|
3687
3691
|
|
|
3688
3692
|
_defineProperty(this, "onclose", function (wsID, event) {
|
|
3689
|
-
if (
|
|
3690
|
-
var _this$postInsights;
|
|
3691
|
-
|
|
3692
|
-
_this.insightMetrics.wsConsecutiveFailures++;
|
|
3693
|
-
_this.insightMetrics.wsTotalFailures++;
|
|
3694
|
-
(_this$postInsights = _this.postInsights) === null || _this$postInsights === void 0 ? void 0 : _this$postInsights.call(_this, 'ws_fatal', buildWsFatalInsight(_this, event));
|
|
3695
|
-
}
|
|
3693
|
+
if (_this.wsID !== wsID) return;
|
|
3696
3694
|
|
|
3697
3695
|
_this.logger('info', 'connection:onclose() - onclose callback - ' + event.code, {
|
|
3698
3696
|
tags: ['connection'],
|
|
@@ -3700,8 +3698,6 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3700
3698
|
wsID: wsID
|
|
3701
3699
|
});
|
|
3702
3700
|
|
|
3703
|
-
if (_this.wsID !== wsID) return;
|
|
3704
|
-
|
|
3705
3701
|
if (event.code === chatCodes.WS_CLOSED_SUCCESS) {
|
|
3706
3702
|
var _this$rejectPromise2;
|
|
3707
3703
|
|
|
@@ -3709,6 +3705,9 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
3709
3705
|
// usually caused by invalid auth details
|
|
3710
3706
|
var error = new Error("WS connection reject with error ".concat(event.reason));
|
|
3711
3707
|
error.reason = event.reason;
|
|
3708
|
+
error.code = event.code;
|
|
3709
|
+
error.wasClean = event.wasClean;
|
|
3710
|
+
error.target = event.target;
|
|
3712
3711
|
(_this$rejectPromise2 = _this.rejectPromise) === null || _this$rejectPromise2 === void 0 ? void 0 : _this$rejectPromise2.call(_this, error);
|
|
3713
3712
|
|
|
3714
3713
|
_this.logger('info', "connection:onclose() - WS connection reject with error ".concat(event.reason), {
|
|
@@ -4239,7 +4238,7 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4239
4238
|
key: "_connect",
|
|
4240
4239
|
value: function () {
|
|
4241
4240
|
var _connect3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
4242
|
-
var wsURL, response, _this$
|
|
4241
|
+
var wsURL, response, _this$postInsights, insights;
|
|
4243
4242
|
|
|
4244
4243
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
4245
4244
|
while (1) {
|
|
@@ -4284,24 +4283,33 @@ var StableWSConnection = /*#__PURE__*/function () {
|
|
|
4284
4283
|
|
|
4285
4284
|
this.connectionID = response.connection_id;
|
|
4286
4285
|
|
|
4287
|
-
if (this.insightMetrics.wsConsecutiveFailures > 0) {
|
|
4288
|
-
|
|
4286
|
+
if (this.insightMetrics.wsConsecutiveFailures > 0 && this.postInsights) {
|
|
4287
|
+
this.postInsights('ws_success_after_failure', buildWsSuccessAfterFailureInsight(this));
|
|
4289
4288
|
this.insightMetrics.wsConsecutiveFailures = 0;
|
|
4290
4289
|
}
|
|
4291
4290
|
|
|
4292
4291
|
return _context5.abrupt("return", response);
|
|
4293
4292
|
|
|
4294
4293
|
case 23:
|
|
4295
|
-
_context5.next =
|
|
4294
|
+
_context5.next = 30;
|
|
4296
4295
|
break;
|
|
4297
4296
|
|
|
4298
4297
|
case 25:
|
|
4299
4298
|
_context5.prev = 25;
|
|
4300
4299
|
_context5.t0 = _context5["catch"](5);
|
|
4301
4300
|
this.isConnecting = false;
|
|
4301
|
+
|
|
4302
|
+
if (this.postInsights) {
|
|
4303
|
+
this.insightMetrics.wsConsecutiveFailures++;
|
|
4304
|
+
this.insightMetrics.wsTotalFailures++; // @ts-ignore
|
|
4305
|
+
|
|
4306
|
+
insights = buildWsFatalInsight(this, convertErrorToJson(_context5.t0));
|
|
4307
|
+
(_this$postInsights = this.postInsights) === null || _this$postInsights === void 0 ? void 0 : _this$postInsights.call(this, 'ws_fatal', insights);
|
|
4308
|
+
}
|
|
4309
|
+
|
|
4302
4310
|
throw _context5.t0;
|
|
4303
4311
|
|
|
4304
|
-
case
|
|
4312
|
+
case 30:
|
|
4305
4313
|
case "end":
|
|
4306
4314
|
return _context5.stop();
|
|
4307
4315
|
}
|
|
@@ -8352,7 +8360,7 @@ var StreamChat = /*#__PURE__*/function () {
|
|
|
8352
8360
|
}, {
|
|
8353
8361
|
key: "getUserAgent",
|
|
8354
8362
|
value: function getUserAgent() {
|
|
8355
|
-
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.4.
|
|
8363
|
+
return this.userAgent || "stream-chat-javascript-client-".concat(this.node ? 'node' : 'browser', "-", "4.4.3-dev.0");
|
|
8356
8364
|
}
|
|
8357
8365
|
}, {
|
|
8358
8366
|
key: "setUserAgent",
|