@sentry/replay 0.5.15 → 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 +133 -74
- package/dist/index.js +137 -74
- package/dist/index.js.map +1 -1
- package/dist/types/src/api/captureReplayEvent.d.ts +22 -0
- package/dist/types/src/createPerformanceEntry.d.ts +2 -1
- package/dist/types/src/index.d.ts +26 -8
- package/dist/types/src/types.d.ts +1 -0
- package/package.json +3 -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/captureReplay.d.ts +0 -10
- package/dist/config/types/src/api/captureReplayEvent.d.ts +0 -15
- package/dist/config/types/src/api/captureReplayUpdate.d.ts +0 -12
- 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 -42
- 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 -235
- 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/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/types.d.ts +0 -97
- 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.js
CHANGED
|
@@ -4,8 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@sentry/core');
|
|
6
6
|
var utils = require('@sentry/utils');
|
|
7
|
+
var throttle = require('lodash.throttle');
|
|
7
8
|
var rrweb = require('rrweb');
|
|
8
9
|
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
13
|
+
|
|
9
14
|
/******************************************************************************
|
|
10
15
|
Copyright (c) Microsoft Corporation.
|
|
11
16
|
|
|
@@ -101,11 +106,11 @@ var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
|
101
106
|
|
|
102
107
|
function captureReplayEvent(_a) {
|
|
103
108
|
var initialState = _a.initialState, includeReplayStartTimestamp = _a.includeReplayStartTimestamp, errorIds = _a.errorIds, replay_id = _a.replayId, segment_id = _a.segmentId, timestamp = _a.timestamp, traceIds = _a.traceIds, urls = _a.urls;
|
|
104
|
-
core.captureEvent(__assign(__assign(
|
|
109
|
+
core.captureEvent(__assign(__assign({
|
|
105
110
|
// @ts-expect-error replay_event is a new event type
|
|
106
111
|
type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
|
|
107
112
|
? { replay_start_timestamp: initialState.timestamp / 1000 }
|
|
108
|
-
: {})),
|
|
113
|
+
: {})), { timestamp: timestamp / 1000, error_ids: errorIds, trace_ids: traceIds, urls: urls, replay_id: replay_id, segment_id: segment_id }), { event_id: replay_id });
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
function createBreadcrumb(breadcrumb) {
|
|
@@ -167,6 +172,11 @@ function getBreadcrumbHandler(type) {
|
|
|
167
172
|
function isIngestHost(targetHost) {
|
|
168
173
|
var _a;
|
|
169
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
|
+
}
|
|
170
180
|
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
171
181
|
}
|
|
172
182
|
|
|
@@ -790,7 +800,7 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
790
800
|
|
|
791
801
|
var BASE_RETRY_INTERVAL = 5000;
|
|
792
802
|
var MAX_RETRY_COUNT = 3;
|
|
793
|
-
var UNABLE_TO_SEND_REPLAY = 'Unable to send
|
|
803
|
+
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
794
804
|
var SentryReplay = /** @class */ (function () {
|
|
795
805
|
function SentryReplay(_a) {
|
|
796
806
|
if (_a === void 0) { _a = {}; }
|
|
@@ -818,6 +828,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
818
828
|
* slightly differently in this case: `replay_start_timestamp` is included.
|
|
819
829
|
*/
|
|
820
830
|
this.newSessionCreated = false;
|
|
831
|
+
this.flushLock = null;
|
|
821
832
|
/**
|
|
822
833
|
* Is the integration currently active?
|
|
823
834
|
*/
|
|
@@ -868,7 +879,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
868
879
|
) {
|
|
869
880
|
// TODO: Do we continue to record after?
|
|
870
881
|
// TODO: What happens if another error happens? Do we record in the same session?
|
|
871
|
-
setTimeout(function () { return _this.
|
|
882
|
+
setTimeout(function () { return _this.flush(); });
|
|
872
883
|
}
|
|
873
884
|
return event;
|
|
874
885
|
};
|
|
@@ -931,6 +942,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
931
942
|
var breadcrumb = createBreadcrumb({
|
|
932
943
|
category: 'ui.blur',
|
|
933
944
|
});
|
|
945
|
+
// Do not count blur as a user action -- it's part of the process of them
|
|
946
|
+
// leaving the page
|
|
934
947
|
_this.doChangeToBackgroundTasks(breadcrumb);
|
|
935
948
|
};
|
|
936
949
|
/**
|
|
@@ -940,6 +953,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
940
953
|
var breadcrumb = createBreadcrumb({
|
|
941
954
|
category: 'ui.focus',
|
|
942
955
|
});
|
|
956
|
+
// Do not count focus as a user action -- instead wait until they focus and
|
|
957
|
+
// interactive with page
|
|
943
958
|
_this.doChangeToForegroundTasks(breadcrumb);
|
|
944
959
|
};
|
|
945
960
|
/**
|
|
@@ -960,6 +975,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
960
975
|
if (type === 'history') {
|
|
961
976
|
// Need to collect visited URLs
|
|
962
977
|
_this.context.urls.push(result.name);
|
|
978
|
+
_this.updateLastActivity();
|
|
963
979
|
}
|
|
964
980
|
_this.addUpdate(function () {
|
|
965
981
|
_this.createPerformanceSpans([result]);
|
|
@@ -986,6 +1002,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
986
1002
|
if (result.category === 'sentry.transaction') {
|
|
987
1003
|
return;
|
|
988
1004
|
}
|
|
1005
|
+
if (result.category === 'ui.click') {
|
|
1006
|
+
_this.updateLastActivity();
|
|
1007
|
+
}
|
|
989
1008
|
_this.addUpdate(function () {
|
|
990
1009
|
_this.addEvent({
|
|
991
1010
|
type: rrweb.EventType.Custom,
|
|
@@ -1008,6 +1027,67 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1008
1027
|
var newEntries = new Set(list.getEntries());
|
|
1009
1028
|
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), Array.from(newEntries), true);
|
|
1010
1029
|
};
|
|
1030
|
+
/**
|
|
1031
|
+
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
1032
|
+
* can be active at a time.
|
|
1033
|
+
*/
|
|
1034
|
+
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1035
|
+
var err_1;
|
|
1036
|
+
var _a;
|
|
1037
|
+
return __generator(this, function (_b) {
|
|
1038
|
+
switch (_b.label) {
|
|
1039
|
+
case 0:
|
|
1040
|
+
if (!this.isEnabled) {
|
|
1041
|
+
// This is just a precaution, there should be no listeners that would
|
|
1042
|
+
// cause a flush.
|
|
1043
|
+
return [2 /*return*/];
|
|
1044
|
+
}
|
|
1045
|
+
if (!this.checkAndHandleExpiredSession()) {
|
|
1046
|
+
logger.error(new Error('Attempting to finish replay event after session expired.'));
|
|
1047
|
+
return [2 /*return*/];
|
|
1048
|
+
}
|
|
1049
|
+
if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1050
|
+
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1051
|
+
return [2 /*return*/];
|
|
1052
|
+
}
|
|
1053
|
+
// Since flushing, ensure other queued flushes are cancelled
|
|
1054
|
+
// We do this regardless of having a queued flush since the event updates
|
|
1055
|
+
// will be handled by queued flush
|
|
1056
|
+
clearTimeout(this.timeout);
|
|
1057
|
+
if (!!this.flushLock) return [3 /*break*/, 2];
|
|
1058
|
+
this.flushLock = this.runFlush();
|
|
1059
|
+
return [4 /*yield*/, this.flushLock];
|
|
1060
|
+
case 1:
|
|
1061
|
+
_b.sent();
|
|
1062
|
+
this.flushLock = null;
|
|
1063
|
+
return [2 /*return*/];
|
|
1064
|
+
case 2:
|
|
1065
|
+
_b.trys.push([2, 4, 5, 6]);
|
|
1066
|
+
return [4 /*yield*/, this.flushLock];
|
|
1067
|
+
case 3:
|
|
1068
|
+
_b.sent();
|
|
1069
|
+
return [3 /*break*/, 6];
|
|
1070
|
+
case 4:
|
|
1071
|
+
err_1 = _b.sent();
|
|
1072
|
+
console.error(err_1);
|
|
1073
|
+
return [3 /*break*/, 6];
|
|
1074
|
+
case 5:
|
|
1075
|
+
this.throttledFlush();
|
|
1076
|
+
return [7 /*endfinally*/];
|
|
1077
|
+
case 6: return [2 /*return*/];
|
|
1078
|
+
}
|
|
1079
|
+
});
|
|
1080
|
+
}); };
|
|
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, {
|
|
1088
|
+
leading: false,
|
|
1089
|
+
trailing: true,
|
|
1090
|
+
});
|
|
1011
1091
|
this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
|
|
1012
1092
|
this.options = {
|
|
1013
1093
|
flushMinDelay: flushMinDelay,
|
|
@@ -1053,6 +1133,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1053
1133
|
// If session was not sampled, then we do not initialize the integration at all.
|
|
1054
1134
|
return;
|
|
1055
1135
|
}
|
|
1136
|
+
// setup() is generally called on page load or manually - in both cases we
|
|
1137
|
+
// should treat it as an activity
|
|
1138
|
+
this.updateLastActivity();
|
|
1056
1139
|
this.eventBuffer = createEventBuffer({
|
|
1057
1140
|
useCompression: Boolean(this.options.useCompression),
|
|
1058
1141
|
});
|
|
@@ -1086,7 +1169,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1086
1169
|
}
|
|
1087
1170
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1088
1171
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1089
|
-
// 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`
|
|
1090
1173
|
// explicitly
|
|
1091
1174
|
if (this.options.captureOnlyOnError) {
|
|
1092
1175
|
return;
|
|
@@ -1101,7 +1184,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1101
1184
|
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1102
1185
|
if (flushMaxDelayExceeded) {
|
|
1103
1186
|
logger.log('replay max delay exceeded, finishing replay event');
|
|
1104
|
-
this.
|
|
1187
|
+
this.flush();
|
|
1105
1188
|
return;
|
|
1106
1189
|
}
|
|
1107
1190
|
// Set timer to finish replay event and send replay attachment to
|
|
@@ -1109,7 +1192,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1109
1192
|
// elapses.
|
|
1110
1193
|
this.timeout = window.setTimeout(function () {
|
|
1111
1194
|
logger.log('replay timeout exceeded, finishing replay event');
|
|
1112
|
-
_this.
|
|
1195
|
+
_this.flush();
|
|
1113
1196
|
}, this.options.flushMinDelay);
|
|
1114
1197
|
};
|
|
1115
1198
|
/**
|
|
@@ -1117,7 +1200,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1117
1200
|
*/
|
|
1118
1201
|
SentryReplay.prototype.destroy = function () {
|
|
1119
1202
|
var _a, _b;
|
|
1120
|
-
logger.log('
|
|
1203
|
+
logger.log('Stopping Replays');
|
|
1121
1204
|
this.isEnabled = false;
|
|
1122
1205
|
this.removeListeners();
|
|
1123
1206
|
(_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -1163,7 +1246,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1163
1246
|
this.performanceEvents = [];
|
|
1164
1247
|
this.initialEventTimestampSinceFlush = null;
|
|
1165
1248
|
// Reset context as well
|
|
1166
|
-
this.
|
|
1249
|
+
this.clearContext();
|
|
1167
1250
|
this.initialState = {
|
|
1168
1251
|
timestamp: new Date().getTime(),
|
|
1169
1252
|
url: url,
|
|
@@ -1406,13 +1489,22 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1406
1489
|
if (this.options.captureOnlyOnError) {
|
|
1407
1490
|
return;
|
|
1408
1491
|
}
|
|
1409
|
-
return this.
|
|
1492
|
+
return this.flush();
|
|
1493
|
+
};
|
|
1494
|
+
/**
|
|
1495
|
+
* Clear context
|
|
1496
|
+
*/
|
|
1497
|
+
SentryReplay.prototype.clearContext = function () {
|
|
1498
|
+
this.context.errorIds.clear();
|
|
1499
|
+
this.context.traceIds.clear();
|
|
1500
|
+
this.context.urls = [];
|
|
1501
|
+
this.context.earliestEvent = null;
|
|
1410
1502
|
};
|
|
1411
1503
|
/**
|
|
1412
1504
|
* Return and clear context
|
|
1413
1505
|
*/
|
|
1414
1506
|
SentryReplay.prototype.popEventContext = function (_a) {
|
|
1415
|
-
var
|
|
1507
|
+
var timestamp = _a.timestamp;
|
|
1416
1508
|
var initialState = this.initialState;
|
|
1417
1509
|
if (this.initialState &&
|
|
1418
1510
|
this.context.earliestEvent &&
|
|
@@ -1426,52 +1518,37 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1426
1518
|
traceIds: Array.from(this.context.traceIds).filter(Boolean),
|
|
1427
1519
|
urls: this.context.urls,
|
|
1428
1520
|
};
|
|
1429
|
-
this.
|
|
1430
|
-
this.context.traceIds.clear();
|
|
1431
|
-
this.context.urls = [];
|
|
1432
|
-
this.context.earliestEvent = null;
|
|
1433
|
-
// @ts-expect-error: Type 'undefined' is not assignable to type 'Session'.ts(2322)
|
|
1521
|
+
this.clearContext();
|
|
1434
1522
|
return context;
|
|
1435
1523
|
};
|
|
1436
1524
|
/**
|
|
1437
1525
|
* Flushes replay event buffer to Sentry.
|
|
1438
1526
|
*
|
|
1439
|
-
* Performance events are only added right before flushing - this is
|
|
1527
|
+
* Performance events are only added right before flushing - this is
|
|
1440
1528
|
* due to the buffered performance observer events.
|
|
1441
1529
|
*/
|
|
1442
|
-
SentryReplay.prototype.
|
|
1443
|
-
var _a
|
|
1530
|
+
SentryReplay.prototype.runFlush = function () {
|
|
1531
|
+
var _a;
|
|
1444
1532
|
return __awaiter(this, void 0, void 0, function () {
|
|
1445
|
-
var timestamp, replayId, newSessionCreated, segmentId, recordingData,
|
|
1446
|
-
return __generator(this, function (
|
|
1447
|
-
switch (
|
|
1533
|
+
var timestamp, replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
1534
|
+
return __generator(this, function (_b) {
|
|
1535
|
+
switch (_b.label) {
|
|
1448
1536
|
case 0:
|
|
1449
|
-
if (!this.
|
|
1450
|
-
// This is just a precaution, there should be no listeners that would
|
|
1451
|
-
// cause a flush.
|
|
1452
|
-
return [2 /*return*/];
|
|
1453
|
-
}
|
|
1454
|
-
if (!this.checkAndHandleExpiredSession()) {
|
|
1455
|
-
logger.error(new Error('Attempting to finish replay event after session expired.'));
|
|
1456
|
-
return [2 /*return*/];
|
|
1457
|
-
}
|
|
1458
|
-
if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1537
|
+
if (!this.session) {
|
|
1459
1538
|
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1460
1539
|
return [2 /*return*/];
|
|
1461
1540
|
}
|
|
1462
|
-
// Since already flushing, ensure other queued flushes are cancelled
|
|
1463
|
-
clearTimeout(this.timeout);
|
|
1464
1541
|
return [4 /*yield*/, this.addPerformanceEntries()];
|
|
1465
1542
|
case 1:
|
|
1466
|
-
|
|
1467
|
-
if (!((
|
|
1543
|
+
_b.sent();
|
|
1544
|
+
if (!((_a = this.eventBuffer) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1468
1545
|
return [2 /*return*/];
|
|
1469
1546
|
}
|
|
1470
1547
|
// Only attach memory event if eventBuffer is not empty
|
|
1471
1548
|
return [4 /*yield*/, this.addMemoryEntry()];
|
|
1472
1549
|
case 2:
|
|
1473
1550
|
// Only attach memory event if eventBuffer is not empty
|
|
1474
|
-
|
|
1551
|
+
_b.sent();
|
|
1475
1552
|
timestamp = new Date().getTime();
|
|
1476
1553
|
replayId = this.session.id;
|
|
1477
1554
|
newSessionCreated = this.newSessionCreated;
|
|
@@ -1479,28 +1556,23 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1479
1556
|
// Reset this to null regardless of `sendReplay` result so that future
|
|
1480
1557
|
// events will get flushed properly
|
|
1481
1558
|
this.initialEventTimestampSinceFlush = null;
|
|
1482
|
-
|
|
1559
|
+
_b.label = 3;
|
|
1483
1560
|
case 3:
|
|
1484
|
-
|
|
1561
|
+
_b.trys.push([3, 6, , 7]);
|
|
1485
1562
|
return [4 /*yield*/, this.eventBuffer.finish()];
|
|
1486
1563
|
case 4:
|
|
1487
|
-
recordingData =
|
|
1564
|
+
recordingData = _b.sent();
|
|
1488
1565
|
return [4 /*yield*/, this.sendReplay(replayId, recordingData, segmentId)];
|
|
1489
1566
|
case 5:
|
|
1490
|
-
|
|
1567
|
+
_b.sent();
|
|
1491
1568
|
// The below will only happen after successfully sending replay //
|
|
1492
|
-
// TBD: Alternatively we could update this after every rrweb event
|
|
1493
|
-
// `timestamp` should reflect when the event happens. e.g. the timestamp
|
|
1494
|
-
// of the event is passed as an argument in the case where a timeout
|
|
1495
|
-
// occurs.
|
|
1496
|
-
this.updateLastActivity(timestamp);
|
|
1497
1569
|
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp: timestamp })), { replayId: replayId, segmentId: segmentId, includeReplayStartTimestamp: newSessionCreated }));
|
|
1498
1570
|
this.newSessionCreated = false;
|
|
1499
1571
|
return [3 /*break*/, 7];
|
|
1500
1572
|
case 6:
|
|
1501
|
-
|
|
1502
|
-
core.captureException(
|
|
1503
|
-
console.error(
|
|
1573
|
+
err_2 = _b.sent();
|
|
1574
|
+
core.captureException(err_2);
|
|
1575
|
+
console.error(err_2);
|
|
1504
1576
|
return [3 /*break*/, 7];
|
|
1505
1577
|
case 7: return [2 /*return*/];
|
|
1506
1578
|
}
|
|
@@ -1574,8 +1646,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1574
1646
|
return __awaiter(this, void 0, void 0, function () {
|
|
1575
1647
|
var client, endpoint, ex_1;
|
|
1576
1648
|
var _this = this;
|
|
1577
|
-
return __generator(this, function (
|
|
1578
|
-
switch (
|
|
1649
|
+
return __generator(this, function (_a) {
|
|
1650
|
+
switch (_a.label) {
|
|
1579
1651
|
case 0:
|
|
1580
1652
|
// short circuit if there's no events to upload
|
|
1581
1653
|
if (!events.length) {
|
|
@@ -1583,9 +1655,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1583
1655
|
}
|
|
1584
1656
|
client = core.getCurrentHub().getClient();
|
|
1585
1657
|
endpoint = core.getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1586
|
-
|
|
1658
|
+
_a.label = 1;
|
|
1587
1659
|
case 1:
|
|
1588
|
-
|
|
1660
|
+
_a.trys.push([1, 3, , 5]);
|
|
1589
1661
|
return [4 /*yield*/, this.sendReplayRequest({
|
|
1590
1662
|
endpoint: endpoint,
|
|
1591
1663
|
events: events,
|
|
@@ -1593,11 +1665,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1593
1665
|
segmentId: segmentId,
|
|
1594
1666
|
})];
|
|
1595
1667
|
case 2:
|
|
1596
|
-
|
|
1668
|
+
_a.sent();
|
|
1597
1669
|
this.resetRetries();
|
|
1598
1670
|
return [2 /*return*/, true];
|
|
1599
1671
|
case 3:
|
|
1600
|
-
ex_1 =
|
|
1672
|
+
ex_1 = _a.sent();
|
|
1601
1673
|
console.error(ex_1);
|
|
1602
1674
|
// Capture error for every failed replay
|
|
1603
1675
|
// TODO: Remove this before GA as this will create an error on customer's project
|
|
@@ -1608,43 +1680,34 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1608
1680
|
// If an error happened here, it's likely that uploading the attachment
|
|
1609
1681
|
// failed, we'll can retry with the same events payload
|
|
1610
1682
|
if (this.retryCount >= MAX_RETRY_COUNT) {
|
|
1611
|
-
|
|
1612
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1683
|
+
throw new Error("".concat(UNABLE_TO_SEND_REPLAY, " - max retries exceeded"));
|
|
1613
1684
|
}
|
|
1614
1685
|
this.retryCount = this.retryCount + 1;
|
|
1615
1686
|
// will retry in intervals of 5, 10, 30
|
|
1616
1687
|
this.retryInterval = this.retryCount * this.retryInterval;
|
|
1617
|
-
_b.label = 4;
|
|
1618
|
-
case 4:
|
|
1619
|
-
_b.trys.push([4, 6, , 7]);
|
|
1620
1688
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
1621
1689
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1622
|
-
|
|
1623
|
-
|
|
1690
|
+
var err_3;
|
|
1691
|
+
return __generator(this, function (_a) {
|
|
1692
|
+
switch (_a.label) {
|
|
1624
1693
|
case 0:
|
|
1625
|
-
|
|
1694
|
+
_a.trys.push([0, 2, , 3]);
|
|
1626
1695
|
return [4 /*yield*/, this.sendReplay(replayId, events, segmentId)];
|
|
1627
1696
|
case 1:
|
|
1628
|
-
|
|
1697
|
+
_a.sent();
|
|
1629
1698
|
resolve(true);
|
|
1630
1699
|
return [3 /*break*/, 3];
|
|
1631
1700
|
case 2:
|
|
1632
|
-
|
|
1633
|
-
reject(
|
|
1701
|
+
err_3 = _a.sent();
|
|
1702
|
+
reject(err_3);
|
|
1634
1703
|
return [3 /*break*/, 3];
|
|
1635
1704
|
case 3: return [2 /*return*/];
|
|
1636
1705
|
}
|
|
1637
1706
|
});
|
|
1638
1707
|
}); }, _this.retryInterval);
|
|
1639
1708
|
})];
|
|
1640
|
-
case
|
|
1641
|
-
|
|
1642
|
-
return [2 /*return*/, true];
|
|
1643
|
-
case 6:
|
|
1644
|
-
_b.sent();
|
|
1645
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1646
|
-
case 7: return [3 /*break*/, 8];
|
|
1647
|
-
case 8: return [2 /*return*/];
|
|
1709
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
1710
|
+
case 5: return [2 /*return*/];
|
|
1648
1711
|
}
|
|
1649
1712
|
});
|
|
1650
1713
|
});
|