@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.es.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor, setContext, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
|
|
2
2
|
import { htmlTreeAsString, logger as logger$1, uuid4, addInstrumentationHandler, createEnvelope, serializeEnvelope } from '@sentry/utils';
|
|
3
|
+
import throttle from 'lodash.throttle';
|
|
3
4
|
import { record, EventType } from 'rrweb';
|
|
4
5
|
|
|
5
6
|
/******************************************************************************
|
|
@@ -97,11 +98,11 @@ var VISIBILITY_CHANGE_TIMEOUT = SESSION_IDLE_DURATION;
|
|
|
97
98
|
|
|
98
99
|
function captureReplayEvent(_a) {
|
|
99
100
|
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;
|
|
100
|
-
captureEvent(__assign(__assign(
|
|
101
|
+
captureEvent(__assign(__assign({
|
|
101
102
|
// @ts-expect-error replay_event is a new event type
|
|
102
103
|
type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
|
|
103
104
|
? { replay_start_timestamp: initialState.timestamp / 1000 }
|
|
104
|
-
: {})),
|
|
105
|
+
: {})), { timestamp: timestamp / 1000, error_ids: errorIds, trace_ids: traceIds, urls: urls, replay_id: replay_id, segment_id: segment_id }), { event_id: replay_id });
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
function createBreadcrumb(breadcrumb) {
|
|
@@ -163,6 +164,11 @@ function getBreadcrumbHandler(type) {
|
|
|
163
164
|
function isIngestHost(targetHost) {
|
|
164
165
|
var _a;
|
|
165
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
|
+
}
|
|
166
172
|
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
167
173
|
}
|
|
168
174
|
|
|
@@ -786,7 +792,7 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
786
792
|
|
|
787
793
|
var BASE_RETRY_INTERVAL = 5000;
|
|
788
794
|
var MAX_RETRY_COUNT = 3;
|
|
789
|
-
var UNABLE_TO_SEND_REPLAY = 'Unable to send
|
|
795
|
+
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
790
796
|
var SentryReplay = /** @class */ (function () {
|
|
791
797
|
function SentryReplay(_a) {
|
|
792
798
|
if (_a === void 0) { _a = {}; }
|
|
@@ -814,6 +820,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
814
820
|
* slightly differently in this case: `replay_start_timestamp` is included.
|
|
815
821
|
*/
|
|
816
822
|
this.newSessionCreated = false;
|
|
823
|
+
this.flushLock = null;
|
|
817
824
|
/**
|
|
818
825
|
* Is the integration currently active?
|
|
819
826
|
*/
|
|
@@ -864,7 +871,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
864
871
|
) {
|
|
865
872
|
// TODO: Do we continue to record after?
|
|
866
873
|
// TODO: What happens if another error happens? Do we record in the same session?
|
|
867
|
-
setTimeout(function () { return _this.
|
|
874
|
+
setTimeout(function () { return _this.flush(); });
|
|
868
875
|
}
|
|
869
876
|
return event;
|
|
870
877
|
};
|
|
@@ -927,6 +934,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
927
934
|
var breadcrumb = createBreadcrumb({
|
|
928
935
|
category: 'ui.blur',
|
|
929
936
|
});
|
|
937
|
+
// Do not count blur as a user action -- it's part of the process of them
|
|
938
|
+
// leaving the page
|
|
930
939
|
_this.doChangeToBackgroundTasks(breadcrumb);
|
|
931
940
|
};
|
|
932
941
|
/**
|
|
@@ -936,6 +945,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
936
945
|
var breadcrumb = createBreadcrumb({
|
|
937
946
|
category: 'ui.focus',
|
|
938
947
|
});
|
|
948
|
+
// Do not count focus as a user action -- instead wait until they focus and
|
|
949
|
+
// interactive with page
|
|
939
950
|
_this.doChangeToForegroundTasks(breadcrumb);
|
|
940
951
|
};
|
|
941
952
|
/**
|
|
@@ -956,6 +967,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
956
967
|
if (type === 'history') {
|
|
957
968
|
// Need to collect visited URLs
|
|
958
969
|
_this.context.urls.push(result.name);
|
|
970
|
+
_this.updateLastActivity();
|
|
959
971
|
}
|
|
960
972
|
_this.addUpdate(function () {
|
|
961
973
|
_this.createPerformanceSpans([result]);
|
|
@@ -982,6 +994,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
982
994
|
if (result.category === 'sentry.transaction') {
|
|
983
995
|
return;
|
|
984
996
|
}
|
|
997
|
+
if (result.category === 'ui.click') {
|
|
998
|
+
_this.updateLastActivity();
|
|
999
|
+
}
|
|
985
1000
|
_this.addUpdate(function () {
|
|
986
1001
|
_this.addEvent({
|
|
987
1002
|
type: EventType.Custom,
|
|
@@ -1004,6 +1019,67 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1004
1019
|
var newEntries = new Set(list.getEntries());
|
|
1005
1020
|
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), Array.from(newEntries), true);
|
|
1006
1021
|
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
1024
|
+
* can be active at a time.
|
|
1025
|
+
*/
|
|
1026
|
+
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1027
|
+
var err_1;
|
|
1028
|
+
var _a;
|
|
1029
|
+
return __generator(this, function (_b) {
|
|
1030
|
+
switch (_b.label) {
|
|
1031
|
+
case 0:
|
|
1032
|
+
if (!this.isEnabled) {
|
|
1033
|
+
// This is just a precaution, there should be no listeners that would
|
|
1034
|
+
// cause a flush.
|
|
1035
|
+
return [2 /*return*/];
|
|
1036
|
+
}
|
|
1037
|
+
if (!this.checkAndHandleExpiredSession()) {
|
|
1038
|
+
logger.error(new Error('Attempting to finish replay event after session expired.'));
|
|
1039
|
+
return [2 /*return*/];
|
|
1040
|
+
}
|
|
1041
|
+
if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1042
|
+
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1043
|
+
return [2 /*return*/];
|
|
1044
|
+
}
|
|
1045
|
+
// Since flushing, ensure other queued flushes are cancelled
|
|
1046
|
+
// We do this regardless of having a queued flush since the event updates
|
|
1047
|
+
// will be handled by queued flush
|
|
1048
|
+
clearTimeout(this.timeout);
|
|
1049
|
+
if (!!this.flushLock) return [3 /*break*/, 2];
|
|
1050
|
+
this.flushLock = this.runFlush();
|
|
1051
|
+
return [4 /*yield*/, this.flushLock];
|
|
1052
|
+
case 1:
|
|
1053
|
+
_b.sent();
|
|
1054
|
+
this.flushLock = null;
|
|
1055
|
+
return [2 /*return*/];
|
|
1056
|
+
case 2:
|
|
1057
|
+
_b.trys.push([2, 4, 5, 6]);
|
|
1058
|
+
return [4 /*yield*/, this.flushLock];
|
|
1059
|
+
case 3:
|
|
1060
|
+
_b.sent();
|
|
1061
|
+
return [3 /*break*/, 6];
|
|
1062
|
+
case 4:
|
|
1063
|
+
err_1 = _b.sent();
|
|
1064
|
+
console.error(err_1);
|
|
1065
|
+
return [3 /*break*/, 6];
|
|
1066
|
+
case 5:
|
|
1067
|
+
this.throttledFlush();
|
|
1068
|
+
return [7 /*endfinally*/];
|
|
1069
|
+
case 6: return [2 /*return*/];
|
|
1070
|
+
}
|
|
1071
|
+
});
|
|
1072
|
+
}); };
|
|
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, {
|
|
1080
|
+
leading: false,
|
|
1081
|
+
trailing: true,
|
|
1082
|
+
});
|
|
1007
1083
|
this.recordingOptions = __assign({ maskAllInputs: maskAllInputs, blockClass: blockClass, ignoreClass: ignoreClass, maskTextClass: maskTextClass }, recordingOptions);
|
|
1008
1084
|
this.options = {
|
|
1009
1085
|
flushMinDelay: flushMinDelay,
|
|
@@ -1049,6 +1125,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1049
1125
|
// If session was not sampled, then we do not initialize the integration at all.
|
|
1050
1126
|
return;
|
|
1051
1127
|
}
|
|
1128
|
+
// setup() is generally called on page load or manually - in both cases we
|
|
1129
|
+
// should treat it as an activity
|
|
1130
|
+
this.updateLastActivity();
|
|
1052
1131
|
this.eventBuffer = createEventBuffer({
|
|
1053
1132
|
useCompression: Boolean(this.options.useCompression),
|
|
1054
1133
|
});
|
|
@@ -1082,7 +1161,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1082
1161
|
}
|
|
1083
1162
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1084
1163
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1085
|
-
// 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`
|
|
1086
1165
|
// explicitly
|
|
1087
1166
|
if (this.options.captureOnlyOnError) {
|
|
1088
1167
|
return;
|
|
@@ -1097,7 +1176,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1097
1176
|
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1098
1177
|
if (flushMaxDelayExceeded) {
|
|
1099
1178
|
logger.log('replay max delay exceeded, finishing replay event');
|
|
1100
|
-
this.
|
|
1179
|
+
this.flush();
|
|
1101
1180
|
return;
|
|
1102
1181
|
}
|
|
1103
1182
|
// Set timer to finish replay event and send replay attachment to
|
|
@@ -1105,7 +1184,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1105
1184
|
// elapses.
|
|
1106
1185
|
this.timeout = window.setTimeout(function () {
|
|
1107
1186
|
logger.log('replay timeout exceeded, finishing replay event');
|
|
1108
|
-
_this.
|
|
1187
|
+
_this.flush();
|
|
1109
1188
|
}, this.options.flushMinDelay);
|
|
1110
1189
|
};
|
|
1111
1190
|
/**
|
|
@@ -1113,7 +1192,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1113
1192
|
*/
|
|
1114
1193
|
SentryReplay.prototype.destroy = function () {
|
|
1115
1194
|
var _a, _b;
|
|
1116
|
-
logger.log('
|
|
1195
|
+
logger.log('Stopping Replays');
|
|
1117
1196
|
this.isEnabled = false;
|
|
1118
1197
|
this.removeListeners();
|
|
1119
1198
|
(_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -1159,7 +1238,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1159
1238
|
this.performanceEvents = [];
|
|
1160
1239
|
this.initialEventTimestampSinceFlush = null;
|
|
1161
1240
|
// Reset context as well
|
|
1162
|
-
this.
|
|
1241
|
+
this.clearContext();
|
|
1163
1242
|
this.initialState = {
|
|
1164
1243
|
timestamp: new Date().getTime(),
|
|
1165
1244
|
url: url,
|
|
@@ -1402,13 +1481,22 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1402
1481
|
if (this.options.captureOnlyOnError) {
|
|
1403
1482
|
return;
|
|
1404
1483
|
}
|
|
1405
|
-
return this.
|
|
1484
|
+
return this.flush();
|
|
1485
|
+
};
|
|
1486
|
+
/**
|
|
1487
|
+
* Clear context
|
|
1488
|
+
*/
|
|
1489
|
+
SentryReplay.prototype.clearContext = function () {
|
|
1490
|
+
this.context.errorIds.clear();
|
|
1491
|
+
this.context.traceIds.clear();
|
|
1492
|
+
this.context.urls = [];
|
|
1493
|
+
this.context.earliestEvent = null;
|
|
1406
1494
|
};
|
|
1407
1495
|
/**
|
|
1408
1496
|
* Return and clear context
|
|
1409
1497
|
*/
|
|
1410
1498
|
SentryReplay.prototype.popEventContext = function (_a) {
|
|
1411
|
-
var
|
|
1499
|
+
var timestamp = _a.timestamp;
|
|
1412
1500
|
var initialState = this.initialState;
|
|
1413
1501
|
if (this.initialState &&
|
|
1414
1502
|
this.context.earliestEvent &&
|
|
@@ -1422,52 +1510,37 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1422
1510
|
traceIds: Array.from(this.context.traceIds).filter(Boolean),
|
|
1423
1511
|
urls: this.context.urls,
|
|
1424
1512
|
};
|
|
1425
|
-
this.
|
|
1426
|
-
this.context.traceIds.clear();
|
|
1427
|
-
this.context.urls = [];
|
|
1428
|
-
this.context.earliestEvent = null;
|
|
1429
|
-
// @ts-expect-error: Type 'undefined' is not assignable to type 'Session'.ts(2322)
|
|
1513
|
+
this.clearContext();
|
|
1430
1514
|
return context;
|
|
1431
1515
|
};
|
|
1432
1516
|
/**
|
|
1433
1517
|
* Flushes replay event buffer to Sentry.
|
|
1434
1518
|
*
|
|
1435
|
-
* Performance events are only added right before flushing - this is
|
|
1519
|
+
* Performance events are only added right before flushing - this is
|
|
1436
1520
|
* due to the buffered performance observer events.
|
|
1437
1521
|
*/
|
|
1438
|
-
SentryReplay.prototype.
|
|
1439
|
-
var _a
|
|
1522
|
+
SentryReplay.prototype.runFlush = function () {
|
|
1523
|
+
var _a;
|
|
1440
1524
|
return __awaiter(this, void 0, void 0, function () {
|
|
1441
|
-
var timestamp, replayId, newSessionCreated, segmentId, recordingData,
|
|
1442
|
-
return __generator(this, function (
|
|
1443
|
-
switch (
|
|
1525
|
+
var timestamp, replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
1526
|
+
return __generator(this, function (_b) {
|
|
1527
|
+
switch (_b.label) {
|
|
1444
1528
|
case 0:
|
|
1445
|
-
if (!this.
|
|
1446
|
-
// This is just a precaution, there should be no listeners that would
|
|
1447
|
-
// cause a flush.
|
|
1448
|
-
return [2 /*return*/];
|
|
1449
|
-
}
|
|
1450
|
-
if (!this.checkAndHandleExpiredSession()) {
|
|
1451
|
-
logger.error(new Error('Attempting to finish replay event after session expired.'));
|
|
1452
|
-
return [2 /*return*/];
|
|
1453
|
-
}
|
|
1454
|
-
if (!((_a = this.session) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
1529
|
+
if (!this.session) {
|
|
1455
1530
|
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
1456
1531
|
return [2 /*return*/];
|
|
1457
1532
|
}
|
|
1458
|
-
// Since already flushing, ensure other queued flushes are cancelled
|
|
1459
|
-
clearTimeout(this.timeout);
|
|
1460
1533
|
return [4 /*yield*/, this.addPerformanceEntries()];
|
|
1461
1534
|
case 1:
|
|
1462
|
-
|
|
1463
|
-
if (!((
|
|
1535
|
+
_b.sent();
|
|
1536
|
+
if (!((_a = this.eventBuffer) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1464
1537
|
return [2 /*return*/];
|
|
1465
1538
|
}
|
|
1466
1539
|
// Only attach memory event if eventBuffer is not empty
|
|
1467
1540
|
return [4 /*yield*/, this.addMemoryEntry()];
|
|
1468
1541
|
case 2:
|
|
1469
1542
|
// Only attach memory event if eventBuffer is not empty
|
|
1470
|
-
|
|
1543
|
+
_b.sent();
|
|
1471
1544
|
timestamp = new Date().getTime();
|
|
1472
1545
|
replayId = this.session.id;
|
|
1473
1546
|
newSessionCreated = this.newSessionCreated;
|
|
@@ -1475,28 +1548,23 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1475
1548
|
// Reset this to null regardless of `sendReplay` result so that future
|
|
1476
1549
|
// events will get flushed properly
|
|
1477
1550
|
this.initialEventTimestampSinceFlush = null;
|
|
1478
|
-
|
|
1551
|
+
_b.label = 3;
|
|
1479
1552
|
case 3:
|
|
1480
|
-
|
|
1553
|
+
_b.trys.push([3, 6, , 7]);
|
|
1481
1554
|
return [4 /*yield*/, this.eventBuffer.finish()];
|
|
1482
1555
|
case 4:
|
|
1483
|
-
recordingData =
|
|
1556
|
+
recordingData = _b.sent();
|
|
1484
1557
|
return [4 /*yield*/, this.sendReplay(replayId, recordingData, segmentId)];
|
|
1485
1558
|
case 5:
|
|
1486
|
-
|
|
1559
|
+
_b.sent();
|
|
1487
1560
|
// The below will only happen after successfully sending replay //
|
|
1488
|
-
// TBD: Alternatively we could update this after every rrweb event
|
|
1489
|
-
// `timestamp` should reflect when the event happens. e.g. the timestamp
|
|
1490
|
-
// of the event is passed as an argument in the case where a timeout
|
|
1491
|
-
// occurs.
|
|
1492
|
-
this.updateLastActivity(timestamp);
|
|
1493
1561
|
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp: timestamp })), { replayId: replayId, segmentId: segmentId, includeReplayStartTimestamp: newSessionCreated }));
|
|
1494
1562
|
this.newSessionCreated = false;
|
|
1495
1563
|
return [3 /*break*/, 7];
|
|
1496
1564
|
case 6:
|
|
1497
|
-
|
|
1498
|
-
captureException(
|
|
1499
|
-
console.error(
|
|
1565
|
+
err_2 = _b.sent();
|
|
1566
|
+
captureException(err_2);
|
|
1567
|
+
console.error(err_2);
|
|
1500
1568
|
return [3 /*break*/, 7];
|
|
1501
1569
|
case 7: return [2 /*return*/];
|
|
1502
1570
|
}
|
|
@@ -1570,8 +1638,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1570
1638
|
return __awaiter(this, void 0, void 0, function () {
|
|
1571
1639
|
var client, endpoint, ex_1;
|
|
1572
1640
|
var _this = this;
|
|
1573
|
-
return __generator(this, function (
|
|
1574
|
-
switch (
|
|
1641
|
+
return __generator(this, function (_a) {
|
|
1642
|
+
switch (_a.label) {
|
|
1575
1643
|
case 0:
|
|
1576
1644
|
// short circuit if there's no events to upload
|
|
1577
1645
|
if (!events.length) {
|
|
@@ -1579,9 +1647,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1579
1647
|
}
|
|
1580
1648
|
client = getCurrentHub().getClient();
|
|
1581
1649
|
endpoint = getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1582
|
-
|
|
1650
|
+
_a.label = 1;
|
|
1583
1651
|
case 1:
|
|
1584
|
-
|
|
1652
|
+
_a.trys.push([1, 3, , 5]);
|
|
1585
1653
|
return [4 /*yield*/, this.sendReplayRequest({
|
|
1586
1654
|
endpoint: endpoint,
|
|
1587
1655
|
events: events,
|
|
@@ -1589,11 +1657,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1589
1657
|
segmentId: segmentId,
|
|
1590
1658
|
})];
|
|
1591
1659
|
case 2:
|
|
1592
|
-
|
|
1660
|
+
_a.sent();
|
|
1593
1661
|
this.resetRetries();
|
|
1594
1662
|
return [2 /*return*/, true];
|
|
1595
1663
|
case 3:
|
|
1596
|
-
ex_1 =
|
|
1664
|
+
ex_1 = _a.sent();
|
|
1597
1665
|
console.error(ex_1);
|
|
1598
1666
|
// Capture error for every failed replay
|
|
1599
1667
|
// TODO: Remove this before GA as this will create an error on customer's project
|
|
@@ -1604,43 +1672,34 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1604
1672
|
// If an error happened here, it's likely that uploading the attachment
|
|
1605
1673
|
// failed, we'll can retry with the same events payload
|
|
1606
1674
|
if (this.retryCount >= MAX_RETRY_COUNT) {
|
|
1607
|
-
|
|
1608
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1675
|
+
throw new Error("".concat(UNABLE_TO_SEND_REPLAY, " - max retries exceeded"));
|
|
1609
1676
|
}
|
|
1610
1677
|
this.retryCount = this.retryCount + 1;
|
|
1611
1678
|
// will retry in intervals of 5, 10, 30
|
|
1612
1679
|
this.retryInterval = this.retryCount * this.retryInterval;
|
|
1613
|
-
_b.label = 4;
|
|
1614
|
-
case 4:
|
|
1615
|
-
_b.trys.push([4, 6, , 7]);
|
|
1616
1680
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
1617
1681
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1618
|
-
|
|
1619
|
-
|
|
1682
|
+
var err_3;
|
|
1683
|
+
return __generator(this, function (_a) {
|
|
1684
|
+
switch (_a.label) {
|
|
1620
1685
|
case 0:
|
|
1621
|
-
|
|
1686
|
+
_a.trys.push([0, 2, , 3]);
|
|
1622
1687
|
return [4 /*yield*/, this.sendReplay(replayId, events, segmentId)];
|
|
1623
1688
|
case 1:
|
|
1624
|
-
|
|
1689
|
+
_a.sent();
|
|
1625
1690
|
resolve(true);
|
|
1626
1691
|
return [3 /*break*/, 3];
|
|
1627
1692
|
case 2:
|
|
1628
|
-
|
|
1629
|
-
reject(
|
|
1693
|
+
err_3 = _a.sent();
|
|
1694
|
+
reject(err_3);
|
|
1630
1695
|
return [3 /*break*/, 3];
|
|
1631
1696
|
case 3: return [2 /*return*/];
|
|
1632
1697
|
}
|
|
1633
1698
|
});
|
|
1634
1699
|
}); }, _this.retryInterval);
|
|
1635
1700
|
})];
|
|
1636
|
-
case
|
|
1637
|
-
|
|
1638
|
-
return [2 /*return*/, true];
|
|
1639
|
-
case 6:
|
|
1640
|
-
_b.sent();
|
|
1641
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1642
|
-
case 7: return [3 /*break*/, 8];
|
|
1643
|
-
case 8: return [2 /*return*/];
|
|
1701
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
1702
|
+
case 5: return [2 /*return*/];
|
|
1644
1703
|
}
|
|
1645
1704
|
});
|
|
1646
1705
|
});
|