@sentry/replay 0.5.16 → 0.5.17
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/index.es.js +45 -39
- package/dist/index.js +45 -39
- package/dist/index.js.map +1 -1
- package/dist/types/src/index.d.ts +15 -5
- package/package.json +1 -1
- package/dist/config/types/jest.config.d.ts +0 -3
- package/dist/config/types/jest.setup.d.ts +0 -10
- package/dist/config/types/src/api/captureReplayEvent.d.ts +0 -37
- package/dist/config/types/src/coreHandlers/getBreadcrumbHandler.d.ts +0 -3
- package/dist/config/types/src/coreHandlers/getSpanHandler.d.ts +0 -5
- package/dist/config/types/src/coreHandlers/handleDom.d.ts +0 -1
- package/dist/config/types/src/coreHandlers/handleFetch.d.ts +0 -19
- package/dist/config/types/src/coreHandlers/handleFetch.test.d.ts +0 -1
- package/dist/config/types/src/coreHandlers/handleHistory.d.ts +0 -7
- package/dist/config/types/src/coreHandlers/handleScope-unit.test.d.ts +0 -1
- package/dist/config/types/src/coreHandlers/handleScope.d.ts +0 -2
- package/dist/config/types/src/coreHandlers/handleScope.test.d.ts +0 -1
- package/dist/config/types/src/coreHandlers/handleXhr.d.ts +0 -21
- package/dist/config/types/src/createPerformanceEntry.d.ts +0 -43
- package/dist/config/types/src/createPerformanceEntry.test.d.ts +0 -1
- package/dist/config/types/src/eventBuffer.d.ts +0 -45
- package/dist/config/types/src/eventBuffer.test.d.ts +0 -1
- package/dist/config/types/src/flags.d.ts +0 -2
- package/dist/config/types/src/index-captureOnlyOnError.test.d.ts +0 -1
- package/dist/config/types/src/index-noSticky.test.d.ts +0 -1
- package/dist/config/types/src/index-sampling.test.d.ts +0 -1
- package/dist/config/types/src/index.d.ts +0 -243
- package/dist/config/types/src/index.test.d.ts +0 -1
- package/dist/config/types/src/session/Session.d.ts +0 -63
- package/dist/config/types/src/session/Session.test.d.ts +0 -1
- package/dist/config/types/src/session/constants.d.ts +0 -5
- package/dist/config/types/src/session/createSession.d.ts +0 -19
- package/dist/config/types/src/session/createSession.test.d.ts +0 -1
- package/dist/config/types/src/session/deleteSession.d.ts +0 -4
- package/dist/config/types/src/session/deleteSession.test.d.ts +0 -1
- package/dist/config/types/src/session/fetchSession.d.ts +0 -5
- package/dist/config/types/src/session/fetchSession.test.d.ts +0 -1
- package/dist/config/types/src/session/getSession.d.ts +0 -28
- package/dist/config/types/src/session/getSession.test.d.ts +0 -1
- package/dist/config/types/src/session/index.d.ts +0 -1
- package/dist/config/types/src/session/saveSession.d.ts +0 -2
- package/dist/config/types/src/session/saveSession.test.d.ts +0 -1
- package/dist/config/types/src/stop.test.d.ts +0 -1
- package/dist/config/types/src/types.d.ts +0 -98
- package/dist/config/types/src/util/createBreadcrumb.d.ts +0 -4
- package/dist/config/types/src/util/createPayload.d.ts +0 -5
- package/dist/config/types/src/util/isExpired.d.ts +0 -5
- package/dist/config/types/src/util/isExpired.test.d.ts +0 -1
- package/dist/config/types/src/util/isIngestHost.d.ts +0 -4
- package/dist/config/types/src/util/isSampled.d.ts +0 -7
- package/dist/config/types/src/util/isSampled.test.d.ts +0 -1
- package/dist/config/types/src/util/isSessionExpired.d.ts +0 -5
- package/dist/config/types/src/util/isSessionExpired.test.d.ts +0 -1
- package/dist/config/types/src/util/logger.d.ts +0 -12
- package/dist/config/types/test/index.d.ts +0 -3
- package/dist/config/types/test/mocks/mockRrweb.d.ts +0 -15
- package/dist/config/types/test/mocks/mockSdk.d.ts +0 -11
package/dist/index.es.js
CHANGED
|
@@ -164,6 +164,11 @@ function getBreadcrumbHandler(type) {
|
|
|
164
164
|
function isIngestHost(targetHost) {
|
|
165
165
|
var _a;
|
|
166
166
|
var _b = ((_a = getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getDsn()) || {}, protocol = _b.protocol, host = _b.host;
|
|
167
|
+
// XXX: Special case when this integration is used by Sentry on `sentry.io`
|
|
168
|
+
// We would like to capture network requests made to our ingest endpoints for debugging
|
|
169
|
+
if (window.location.host === 'sentry.io') {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
167
172
|
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
168
173
|
}
|
|
169
174
|
|
|
@@ -787,7 +792,7 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
787
792
|
|
|
788
793
|
var BASE_RETRY_INTERVAL = 5000;
|
|
789
794
|
var MAX_RETRY_COUNT = 3;
|
|
790
|
-
var UNABLE_TO_SEND_REPLAY = 'Unable to send
|
|
795
|
+
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
791
796
|
var SentryReplay = /** @class */ (function () {
|
|
792
797
|
function SentryReplay(_a) {
|
|
793
798
|
if (_a === void 0) { _a = {}; }
|
|
@@ -866,7 +871,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
866
871
|
) {
|
|
867
872
|
// TODO: Do we continue to record after?
|
|
868
873
|
// TODO: What happens if another error happens? Do we record in the same session?
|
|
869
|
-
setTimeout(function () { return _this.
|
|
874
|
+
setTimeout(function () { return _this.flush(); });
|
|
870
875
|
}
|
|
871
876
|
return event;
|
|
872
877
|
};
|
|
@@ -1015,12 +1020,10 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1015
1020
|
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), Array.from(newEntries), true);
|
|
1016
1021
|
};
|
|
1017
1022
|
/**
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1020
|
-
* Performance events are only added right before flushing - this is probably
|
|
1021
|
-
* due to the buffered performance observer events.
|
|
1023
|
+
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
1024
|
+
* can be active at a time.
|
|
1022
1025
|
*/
|
|
1023
|
-
this.
|
|
1026
|
+
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1024
1027
|
var err_1;
|
|
1025
1028
|
var _a;
|
|
1026
1029
|
return __generator(this, function (_b) {
|
|
@@ -1061,13 +1064,19 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1061
1064
|
console.error(err_1);
|
|
1062
1065
|
return [3 /*break*/, 6];
|
|
1063
1066
|
case 5:
|
|
1064
|
-
this.
|
|
1067
|
+
this.throttledFlush();
|
|
1065
1068
|
return [7 /*endfinally*/];
|
|
1066
1069
|
case 6: return [2 /*return*/];
|
|
1067
1070
|
}
|
|
1068
1071
|
});
|
|
1069
1072
|
}); };
|
|
1070
|
-
|
|
1073
|
+
/**
|
|
1074
|
+
* A throttled `flush()` that is called after a flush is completed and there
|
|
1075
|
+
* are other queued flushes.
|
|
1076
|
+
*
|
|
1077
|
+
* Instead of calling a flush for every <n> queued flush, condense it to a single call
|
|
1078
|
+
*/
|
|
1079
|
+
this.throttledFlush = throttle(this.flush, 1000, {
|
|
1071
1080
|
leading: false,
|
|
1072
1081
|
trailing: true,
|
|
1073
1082
|
});
|
|
@@ -1152,7 +1161,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1152
1161
|
}
|
|
1153
1162
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1154
1163
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1155
|
-
// If this option is turned on then we will only want to call `
|
|
1164
|
+
// If this option is turned on then we will only want to call `flush`
|
|
1156
1165
|
// explicitly
|
|
1157
1166
|
if (this.options.captureOnlyOnError) {
|
|
1158
1167
|
return;
|
|
@@ -1167,7 +1176,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1167
1176
|
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1168
1177
|
if (flushMaxDelayExceeded) {
|
|
1169
1178
|
logger.log('replay max delay exceeded, finishing replay event');
|
|
1170
|
-
this.
|
|
1179
|
+
this.flush();
|
|
1171
1180
|
return;
|
|
1172
1181
|
}
|
|
1173
1182
|
// Set timer to finish replay event and send replay attachment to
|
|
@@ -1175,7 +1184,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1175
1184
|
// elapses.
|
|
1176
1185
|
this.timeout = window.setTimeout(function () {
|
|
1177
1186
|
logger.log('replay timeout exceeded, finishing replay event');
|
|
1178
|
-
_this.
|
|
1187
|
+
_this.flush();
|
|
1179
1188
|
}, this.options.flushMinDelay);
|
|
1180
1189
|
};
|
|
1181
1190
|
/**
|
|
@@ -1183,7 +1192,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1183
1192
|
*/
|
|
1184
1193
|
SentryReplay.prototype.destroy = function () {
|
|
1185
1194
|
var _a, _b;
|
|
1186
|
-
logger.log('
|
|
1195
|
+
logger.log('Stopping Replays');
|
|
1187
1196
|
this.isEnabled = false;
|
|
1188
1197
|
this.removeListeners();
|
|
1189
1198
|
(_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -1472,7 +1481,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1472
1481
|
if (this.options.captureOnlyOnError) {
|
|
1473
1482
|
return;
|
|
1474
1483
|
}
|
|
1475
|
-
return this.
|
|
1484
|
+
return this.flush();
|
|
1476
1485
|
};
|
|
1477
1486
|
/**
|
|
1478
1487
|
* Clear context
|
|
@@ -1504,6 +1513,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1504
1513
|
this.clearContext();
|
|
1505
1514
|
return context;
|
|
1506
1515
|
};
|
|
1516
|
+
/**
|
|
1517
|
+
* Flushes replay event buffer to Sentry.
|
|
1518
|
+
*
|
|
1519
|
+
* Performance events are only added right before flushing - this is
|
|
1520
|
+
* due to the buffered performance observer events.
|
|
1521
|
+
*/
|
|
1507
1522
|
SentryReplay.prototype.runFlush = function () {
|
|
1508
1523
|
var _a;
|
|
1509
1524
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1623,8 +1638,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1623
1638
|
return __awaiter(this, void 0, void 0, function () {
|
|
1624
1639
|
var client, endpoint, ex_1;
|
|
1625
1640
|
var _this = this;
|
|
1626
|
-
return __generator(this, function (
|
|
1627
|
-
switch (
|
|
1641
|
+
return __generator(this, function (_a) {
|
|
1642
|
+
switch (_a.label) {
|
|
1628
1643
|
case 0:
|
|
1629
1644
|
// short circuit if there's no events to upload
|
|
1630
1645
|
if (!events.length) {
|
|
@@ -1632,9 +1647,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1632
1647
|
}
|
|
1633
1648
|
client = getCurrentHub().getClient();
|
|
1634
1649
|
endpoint = getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1635
|
-
|
|
1650
|
+
_a.label = 1;
|
|
1636
1651
|
case 1:
|
|
1637
|
-
|
|
1652
|
+
_a.trys.push([1, 3, , 5]);
|
|
1638
1653
|
return [4 /*yield*/, this.sendReplayRequest({
|
|
1639
1654
|
endpoint: endpoint,
|
|
1640
1655
|
events: events,
|
|
@@ -1642,11 +1657,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1642
1657
|
segmentId: segmentId,
|
|
1643
1658
|
})];
|
|
1644
1659
|
case 2:
|
|
1645
|
-
|
|
1660
|
+
_a.sent();
|
|
1646
1661
|
this.resetRetries();
|
|
1647
1662
|
return [2 /*return*/, true];
|
|
1648
1663
|
case 3:
|
|
1649
|
-
ex_1 =
|
|
1664
|
+
ex_1 = _a.sent();
|
|
1650
1665
|
console.error(ex_1);
|
|
1651
1666
|
// Capture error for every failed replay
|
|
1652
1667
|
// TODO: Remove this before GA as this will create an error on customer's project
|
|
@@ -1657,43 +1672,34 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1657
1672
|
// If an error happened here, it's likely that uploading the attachment
|
|
1658
1673
|
// failed, we'll can retry with the same events payload
|
|
1659
1674
|
if (this.retryCount >= MAX_RETRY_COUNT) {
|
|
1660
|
-
|
|
1661
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1675
|
+
throw new Error("".concat(UNABLE_TO_SEND_REPLAY, " - max retries exceeded"));
|
|
1662
1676
|
}
|
|
1663
1677
|
this.retryCount = this.retryCount + 1;
|
|
1664
1678
|
// will retry in intervals of 5, 10, 30
|
|
1665
1679
|
this.retryInterval = this.retryCount * this.retryInterval;
|
|
1666
|
-
_b.label = 4;
|
|
1667
|
-
case 4:
|
|
1668
|
-
_b.trys.push([4, 6, , 7]);
|
|
1669
1680
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
1670
1681
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1671
|
-
|
|
1672
|
-
|
|
1682
|
+
var err_3;
|
|
1683
|
+
return __generator(this, function (_a) {
|
|
1684
|
+
switch (_a.label) {
|
|
1673
1685
|
case 0:
|
|
1674
|
-
|
|
1686
|
+
_a.trys.push([0, 2, , 3]);
|
|
1675
1687
|
return [4 /*yield*/, this.sendReplay(replayId, events, segmentId)];
|
|
1676
1688
|
case 1:
|
|
1677
|
-
|
|
1689
|
+
_a.sent();
|
|
1678
1690
|
resolve(true);
|
|
1679
1691
|
return [3 /*break*/, 3];
|
|
1680
1692
|
case 2:
|
|
1681
|
-
|
|
1682
|
-
reject(
|
|
1693
|
+
err_3 = _a.sent();
|
|
1694
|
+
reject(err_3);
|
|
1683
1695
|
return [3 /*break*/, 3];
|
|
1684
1696
|
case 3: return [2 /*return*/];
|
|
1685
1697
|
}
|
|
1686
1698
|
});
|
|
1687
1699
|
}); }, _this.retryInterval);
|
|
1688
1700
|
})];
|
|
1689
|
-
case
|
|
1690
|
-
|
|
1691
|
-
return [2 /*return*/, true];
|
|
1692
|
-
case 6:
|
|
1693
|
-
_b.sent();
|
|
1694
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1695
|
-
case 7: return [3 /*break*/, 8];
|
|
1696
|
-
case 8: return [2 /*return*/];
|
|
1701
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
1702
|
+
case 5: return [2 /*return*/];
|
|
1697
1703
|
}
|
|
1698
1704
|
});
|
|
1699
1705
|
});
|
package/dist/index.js
CHANGED
|
@@ -172,6 +172,11 @@ function getBreadcrumbHandler(type) {
|
|
|
172
172
|
function isIngestHost(targetHost) {
|
|
173
173
|
var _a;
|
|
174
174
|
var _b = ((_a = core.getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getDsn()) || {}, protocol = _b.protocol, host = _b.host;
|
|
175
|
+
// XXX: Special case when this integration is used by Sentry on `sentry.io`
|
|
176
|
+
// We would like to capture network requests made to our ingest endpoints for debugging
|
|
177
|
+
if (window.location.host === 'sentry.io') {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
175
180
|
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
176
181
|
}
|
|
177
182
|
|
|
@@ -795,7 +800,7 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
795
800
|
|
|
796
801
|
var BASE_RETRY_INTERVAL = 5000;
|
|
797
802
|
var MAX_RETRY_COUNT = 3;
|
|
798
|
-
var UNABLE_TO_SEND_REPLAY = 'Unable to send
|
|
803
|
+
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
799
804
|
var SentryReplay = /** @class */ (function () {
|
|
800
805
|
function SentryReplay(_a) {
|
|
801
806
|
if (_a === void 0) { _a = {}; }
|
|
@@ -874,7 +879,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
874
879
|
) {
|
|
875
880
|
// TODO: Do we continue to record after?
|
|
876
881
|
// TODO: What happens if another error happens? Do we record in the same session?
|
|
877
|
-
setTimeout(function () { return _this.
|
|
882
|
+
setTimeout(function () { return _this.flush(); });
|
|
878
883
|
}
|
|
879
884
|
return event;
|
|
880
885
|
};
|
|
@@ -1023,12 +1028,10 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1023
1028
|
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), Array.from(newEntries), true);
|
|
1024
1029
|
};
|
|
1025
1030
|
/**
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
* Performance events are only added right before flushing - this is probably
|
|
1029
|
-
* due to the buffered performance observer events.
|
|
1031
|
+
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
1032
|
+
* can be active at a time.
|
|
1030
1033
|
*/
|
|
1031
|
-
this.
|
|
1034
|
+
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1032
1035
|
var err_1;
|
|
1033
1036
|
var _a;
|
|
1034
1037
|
return __generator(this, function (_b) {
|
|
@@ -1069,13 +1072,19 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1069
1072
|
console.error(err_1);
|
|
1070
1073
|
return [3 /*break*/, 6];
|
|
1071
1074
|
case 5:
|
|
1072
|
-
this.
|
|
1075
|
+
this.throttledFlush();
|
|
1073
1076
|
return [7 /*endfinally*/];
|
|
1074
1077
|
case 6: return [2 /*return*/];
|
|
1075
1078
|
}
|
|
1076
1079
|
});
|
|
1077
1080
|
}); };
|
|
1078
|
-
|
|
1081
|
+
/**
|
|
1082
|
+
* A throttled `flush()` that is called after a flush is completed and there
|
|
1083
|
+
* are other queued flushes.
|
|
1084
|
+
*
|
|
1085
|
+
* Instead of calling a flush for every <n> queued flush, condense it to a single call
|
|
1086
|
+
*/
|
|
1087
|
+
this.throttledFlush = throttle__default["default"](this.flush, 1000, {
|
|
1079
1088
|
leading: false,
|
|
1080
1089
|
trailing: true,
|
|
1081
1090
|
});
|
|
@@ -1160,7 +1169,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1160
1169
|
}
|
|
1161
1170
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1162
1171
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1163
|
-
// If this option is turned on then we will only want to call `
|
|
1172
|
+
// If this option is turned on then we will only want to call `flush`
|
|
1164
1173
|
// explicitly
|
|
1165
1174
|
if (this.options.captureOnlyOnError) {
|
|
1166
1175
|
return;
|
|
@@ -1175,7 +1184,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1175
1184
|
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1176
1185
|
if (flushMaxDelayExceeded) {
|
|
1177
1186
|
logger.log('replay max delay exceeded, finishing replay event');
|
|
1178
|
-
this.
|
|
1187
|
+
this.flush();
|
|
1179
1188
|
return;
|
|
1180
1189
|
}
|
|
1181
1190
|
// Set timer to finish replay event and send replay attachment to
|
|
@@ -1183,7 +1192,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1183
1192
|
// elapses.
|
|
1184
1193
|
this.timeout = window.setTimeout(function () {
|
|
1185
1194
|
logger.log('replay timeout exceeded, finishing replay event');
|
|
1186
|
-
_this.
|
|
1195
|
+
_this.flush();
|
|
1187
1196
|
}, this.options.flushMinDelay);
|
|
1188
1197
|
};
|
|
1189
1198
|
/**
|
|
@@ -1191,7 +1200,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1191
1200
|
*/
|
|
1192
1201
|
SentryReplay.prototype.destroy = function () {
|
|
1193
1202
|
var _a, _b;
|
|
1194
|
-
logger.log('
|
|
1203
|
+
logger.log('Stopping Replays');
|
|
1195
1204
|
this.isEnabled = false;
|
|
1196
1205
|
this.removeListeners();
|
|
1197
1206
|
(_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -1480,7 +1489,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1480
1489
|
if (this.options.captureOnlyOnError) {
|
|
1481
1490
|
return;
|
|
1482
1491
|
}
|
|
1483
|
-
return this.
|
|
1492
|
+
return this.flush();
|
|
1484
1493
|
};
|
|
1485
1494
|
/**
|
|
1486
1495
|
* Clear context
|
|
@@ -1512,6 +1521,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1512
1521
|
this.clearContext();
|
|
1513
1522
|
return context;
|
|
1514
1523
|
};
|
|
1524
|
+
/**
|
|
1525
|
+
* Flushes replay event buffer to Sentry.
|
|
1526
|
+
*
|
|
1527
|
+
* Performance events are only added right before flushing - this is
|
|
1528
|
+
* due to the buffered performance observer events.
|
|
1529
|
+
*/
|
|
1515
1530
|
SentryReplay.prototype.runFlush = function () {
|
|
1516
1531
|
var _a;
|
|
1517
1532
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1631,8 +1646,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1631
1646
|
return __awaiter(this, void 0, void 0, function () {
|
|
1632
1647
|
var client, endpoint, ex_1;
|
|
1633
1648
|
var _this = this;
|
|
1634
|
-
return __generator(this, function (
|
|
1635
|
-
switch (
|
|
1649
|
+
return __generator(this, function (_a) {
|
|
1650
|
+
switch (_a.label) {
|
|
1636
1651
|
case 0:
|
|
1637
1652
|
// short circuit if there's no events to upload
|
|
1638
1653
|
if (!events.length) {
|
|
@@ -1640,9 +1655,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1640
1655
|
}
|
|
1641
1656
|
client = core.getCurrentHub().getClient();
|
|
1642
1657
|
endpoint = core.getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1643
|
-
|
|
1658
|
+
_a.label = 1;
|
|
1644
1659
|
case 1:
|
|
1645
|
-
|
|
1660
|
+
_a.trys.push([1, 3, , 5]);
|
|
1646
1661
|
return [4 /*yield*/, this.sendReplayRequest({
|
|
1647
1662
|
endpoint: endpoint,
|
|
1648
1663
|
events: events,
|
|
@@ -1650,11 +1665,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1650
1665
|
segmentId: segmentId,
|
|
1651
1666
|
})];
|
|
1652
1667
|
case 2:
|
|
1653
|
-
|
|
1668
|
+
_a.sent();
|
|
1654
1669
|
this.resetRetries();
|
|
1655
1670
|
return [2 /*return*/, true];
|
|
1656
1671
|
case 3:
|
|
1657
|
-
ex_1 =
|
|
1672
|
+
ex_1 = _a.sent();
|
|
1658
1673
|
console.error(ex_1);
|
|
1659
1674
|
// Capture error for every failed replay
|
|
1660
1675
|
// TODO: Remove this before GA as this will create an error on customer's project
|
|
@@ -1665,43 +1680,34 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1665
1680
|
// If an error happened here, it's likely that uploading the attachment
|
|
1666
1681
|
// failed, we'll can retry with the same events payload
|
|
1667
1682
|
if (this.retryCount >= MAX_RETRY_COUNT) {
|
|
1668
|
-
|
|
1669
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1683
|
+
throw new Error("".concat(UNABLE_TO_SEND_REPLAY, " - max retries exceeded"));
|
|
1670
1684
|
}
|
|
1671
1685
|
this.retryCount = this.retryCount + 1;
|
|
1672
1686
|
// will retry in intervals of 5, 10, 30
|
|
1673
1687
|
this.retryInterval = this.retryCount * this.retryInterval;
|
|
1674
|
-
_b.label = 4;
|
|
1675
|
-
case 4:
|
|
1676
|
-
_b.trys.push([4, 6, , 7]);
|
|
1677
1688
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
1678
1689
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1679
|
-
|
|
1680
|
-
|
|
1690
|
+
var err_3;
|
|
1691
|
+
return __generator(this, function (_a) {
|
|
1692
|
+
switch (_a.label) {
|
|
1681
1693
|
case 0:
|
|
1682
|
-
|
|
1694
|
+
_a.trys.push([0, 2, , 3]);
|
|
1683
1695
|
return [4 /*yield*/, this.sendReplay(replayId, events, segmentId)];
|
|
1684
1696
|
case 1:
|
|
1685
|
-
|
|
1697
|
+
_a.sent();
|
|
1686
1698
|
resolve(true);
|
|
1687
1699
|
return [3 /*break*/, 3];
|
|
1688
1700
|
case 2:
|
|
1689
|
-
|
|
1690
|
-
reject(
|
|
1701
|
+
err_3 = _a.sent();
|
|
1702
|
+
reject(err_3);
|
|
1691
1703
|
return [3 /*break*/, 3];
|
|
1692
1704
|
case 3: return [2 /*return*/];
|
|
1693
1705
|
}
|
|
1694
1706
|
});
|
|
1695
1707
|
}); }, _this.retryInterval);
|
|
1696
1708
|
})];
|
|
1697
|
-
case
|
|
1698
|
-
|
|
1699
|
-
return [2 /*return*/, true];
|
|
1700
|
-
case 6:
|
|
1701
|
-
_b.sent();
|
|
1702
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1703
|
-
case 7: return [3 /*break*/, 8];
|
|
1704
|
-
case 8: return [2 /*return*/];
|
|
1709
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
1710
|
+
case 5: return [2 /*return*/];
|
|
1705
1711
|
}
|
|
1706
1712
|
});
|
|
1707
1713
|
});
|