@sentry/replay 0.5.2 → 0.5.5

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { captureEvent, getCurrentHub, captureException, addGlobalEventProcessor, getEnvelopeEndpointWithUrlEncodedAuth } from '@sentry/core';
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
3
  import { record, EventType } from 'rrweb';
4
4
 
@@ -114,7 +114,7 @@ function captureReplayUpdate(_a) {
114
114
  captureEvent({
115
115
  // @ts-expect-error replay_event is a new event type
116
116
  type: REPLAY_EVENT_NAME,
117
- replay_start_timestamp: timestamp / 1000,
117
+ timestamp: timestamp / 1000,
118
118
  error_ids: errorIds,
119
119
  trace_ids: traceIds,
120
120
  urls: urls,
@@ -483,13 +483,6 @@ function createPayload(_a) {
483
483
  return payloadWithSequence;
484
484
  }
485
485
 
486
- /**
487
- * Determine if there is browser support for `navigator.sendBeacon`
488
- */
489
- function supportsSendBeacon() {
490
- return 'navigator' in window && 'sendBeacon' in window.navigator;
491
- }
492
-
493
486
  var _a;
494
487
  // Map entryType -> function to normalize data for event
495
488
  var ENTRY_TYPES = (_a = {
@@ -771,6 +764,7 @@ var EventBufferCompressionWorker = /** @class */ (function () {
771
764
 
772
765
  var BASE_RETRY_INTERVAL = 5000;
773
766
  var MAX_RETRY_COUNT = 5;
767
+ var UNABLE_TO_SEND_REPLAY = 'Unable to send replay';
774
768
  var SentryReplay = /** @class */ (function () {
775
769
  function SentryReplay(_a) {
776
770
  if (_a === void 0) { _a = {}; }
@@ -810,6 +804,7 @@ var SentryReplay = /** @class */ (function () {
810
804
  errorIds: new Set(),
811
805
  traceIds: new Set(),
812
806
  urls: [],
807
+ earliestEvent: null,
813
808
  };
814
809
  /**
815
810
  * Core Sentry SDK global event handler. Attaches `replayId` to all [non-replay]
@@ -835,7 +830,10 @@ var SentryReplay = /** @class */ (function () {
835
830
  // XXX: Is it safe to assume that all other events are error events?
836
831
  _this.context.errorIds.add(event.event_id);
837
832
  // Need to be very careful that this does not cause an infinite loop
838
- if (_this.options.captureOnlyOnError && event.exception) {
833
+ if (_this.options.captureOnlyOnError &&
834
+ event.exception &&
835
+ event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because other we could loop indefinitely with trying to capture replay and failing
836
+ ) {
839
837
  // TODO: Do we continue to record after?
840
838
  // TODO: What happens if another error happens? Do we record in the same session?
841
839
  setTimeout(function () { return _this.flushUpdate(); });
@@ -856,7 +854,7 @@ var SentryReplay = /** @class */ (function () {
856
854
  _this.addUpdate(function () {
857
855
  // We need to clear existing events on a checkout, otherwise they are
858
856
  // incremental event updates and should be appended
859
- _this.eventBuffer.addEvent(event, isCheckout);
857
+ _this.addEvent(event, isCheckout);
860
858
  // Different behavior for full snapshots (type=2), ignore other event types
861
859
  // See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16
862
860
  if (event.type !== 2) {
@@ -956,7 +954,7 @@ var SentryReplay = /** @class */ (function () {
956
954
  return;
957
955
  }
958
956
  _this.addUpdate(function () {
959
- _this.eventBuffer.addEvent({
957
+ _this.addEvent({
960
958
  type: EventType.Custom,
961
959
  // TODO: We were converting from ms to seconds for breadcrumbs, spans,
962
960
  // but maybe we should just keep them as milliseconds
@@ -1030,15 +1028,6 @@ var SentryReplay = /** @class */ (function () {
1030
1028
  // replay ID so that we can reference them later in the UI
1031
1029
  addGlobalEventProcessor(this.handleGlobalEvent);
1032
1030
  record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1033
- var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
1034
- var url = "".concat(window.location.origin).concat(urlPath);
1035
- // Otherwise, these will be captured after the first flush, which means the
1036
- // URL and timestamps could be incorrect
1037
- this.initialState = {
1038
- timestamp: new Date().getTime(),
1039
- url: url,
1040
- };
1041
- this.context.urls.push(url);
1042
1031
  };
1043
1032
  /**
1044
1033
  * We want to batch uploads of replay events. Save events only if
@@ -1116,12 +1105,29 @@ var SentryReplay = /** @class */ (function () {
1116
1105
  // enable flag to create the root replay
1117
1106
  if (type === 'new') {
1118
1107
  this.needsCaptureReplay = true;
1108
+ this.setInitialState();
1119
1109
  }
1120
1110
  if (session.id !== ((_b = this.session) === null || _b === void 0 ? void 0 : _b.id)) {
1121
1111
  session.previousSessionId = (_c = this.session) === null || _c === void 0 ? void 0 : _c.id;
1122
1112
  }
1123
1113
  this.session = session;
1124
1114
  };
1115
+ /**
1116
+ * Capture some initial state that can change throughout the lifespan of the
1117
+ * replay. This is required because otherwise they would be captured at the
1118
+ * first flush.
1119
+ */
1120
+ SentryReplay.prototype.setInitialState = function () {
1121
+ var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
1122
+ var url = "".concat(window.location.origin).concat(urlPath);
1123
+ // Reset context as well
1124
+ this.popEventContext();
1125
+ this.initialState = {
1126
+ timestamp: new Date().getTime(),
1127
+ url: url,
1128
+ };
1129
+ this.context.urls.push(url);
1130
+ };
1125
1131
  /**
1126
1132
  * Adds listeners to record events for the replay
1127
1133
  */
@@ -1224,6 +1230,17 @@ var SentryReplay = /** @class */ (function () {
1224
1230
  logger.log('Taking full rrweb snapshot');
1225
1231
  record.takeFullSnapshot(true);
1226
1232
  };
1233
+ /**
1234
+ * Add an event to the event buffer
1235
+ */
1236
+ SentryReplay.prototype.addEvent = function (event, isCheckout) {
1237
+ var timestampInMs = event.timestamp * 1000;
1238
+ if (!this.context.earliestEvent ||
1239
+ timestampInMs < this.context.earliestEvent) {
1240
+ this.context.earliestEvent = timestampInMs;
1241
+ }
1242
+ this.eventBuffer.addEvent(event, isCheckout);
1243
+ };
1227
1244
  /**
1228
1245
  * Updates the session's last activity timestamp
1229
1246
  */
@@ -1237,7 +1254,7 @@ var SentryReplay = /** @class */ (function () {
1237
1254
  SentryReplay.prototype.createCustomBreadcrumb = function (breadcrumb) {
1238
1255
  var _this = this;
1239
1256
  this.addUpdate(function () {
1240
- _this.eventBuffer.addEvent({
1257
+ _this.addEvent({
1241
1258
  type: EventType.Custom,
1242
1259
  timestamp: breadcrumb.timestamp,
1243
1260
  data: {
@@ -1254,7 +1271,7 @@ var SentryReplay = /** @class */ (function () {
1254
1271
  var _this = this;
1255
1272
  return Promise.all(entries.map(function (_a) {
1256
1273
  var type = _a.type, start = _a.start, end = _a.end, name = _a.name, data = _a.data;
1257
- return _this.eventBuffer.addEvent({
1274
+ return _this.addEvent({
1258
1275
  type: EventType.Custom,
1259
1276
  timestamp: start,
1260
1277
  data: {
@@ -1331,10 +1348,16 @@ var SentryReplay = /** @class */ (function () {
1331
1348
  * Return and clear context
1332
1349
  */
1333
1350
  SentryReplay.prototype.popEventContext = function (_a) {
1334
- var timestamp = _a.timestamp;
1351
+ var _b = _a === void 0 ? {} : _a, timestamp = _b.timestamp;
1352
+ var initialState = this.initialState;
1353
+ if (this.initialState &&
1354
+ this.context.earliestEvent &&
1355
+ this.context.earliestEvent < this.initialState.timestamp) {
1356
+ initialState.timestamp = this.context.earliestEvent;
1357
+ }
1335
1358
  var context = {
1336
1359
  session: this.session,
1337
- initialState: this.initialState,
1360
+ initialState: initialState,
1338
1361
  timestamp: timestamp,
1339
1362
  errorIds: Array.from(this.context.errorIds).filter(Boolean),
1340
1363
  traceIds: Array.from(this.context.traceIds).filter(Boolean),
@@ -1343,6 +1366,7 @@ var SentryReplay = /** @class */ (function () {
1343
1366
  this.context.errorIds.clear();
1344
1367
  this.context.traceIds.clear();
1345
1368
  this.context.urls = [];
1369
+ this.context.earliestEvent = null;
1346
1370
  return context;
1347
1371
  };
1348
1372
  /**
@@ -1416,14 +1440,15 @@ var SentryReplay = /** @class */ (function () {
1416
1440
  });
1417
1441
  };
1418
1442
  /**
1419
- * Send replay attachment using either `sendBeacon()` or `fetch()`
1443
+ * Send replay attachment using `fetch()`
1420
1444
  */
1421
1445
  SentryReplay.prototype.sendReplayRequest = function (_a) {
1422
1446
  var endpoint = _a.endpoint, events = _a.events;
1423
1447
  return __awaiter(this, void 0, void 0, function () {
1424
- var payloadWithSequence, envelope;
1425
- return __generator(this, function (_b) {
1426
- switch (_b.label) {
1448
+ var payloadWithSequence, envelope, response, _b, _c;
1449
+ var _d;
1450
+ return __generator(this, function (_e) {
1451
+ switch (_e.label) {
1427
1452
  case 0:
1428
1453
  payloadWithSequence = createPayload({
1429
1454
  events: events,
@@ -1445,12 +1470,6 @@ var SentryReplay = /** @class */ (function () {
1445
1470
  payloadWithSequence,
1446
1471
  ],
1447
1472
  ]);
1448
- // If sendBeacon is supported and payload is smol enough...
1449
- if (supportsSendBeacon() && events.length <= 65536) {
1450
- logger.log("uploading attachment via sendBeacon()");
1451
- window.navigator.sendBeacon(endpoint, serializeEnvelope(envelope));
1452
- return [2 /*return*/];
1453
- }
1454
1473
  // Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
1455
1474
  logger.log("uploading attachment via fetch()");
1456
1475
  return [4 /*yield*/, fetch(endpoint, {
@@ -1458,8 +1477,19 @@ var SentryReplay = /** @class */ (function () {
1458
1477
  body: serializeEnvelope(envelope),
1459
1478
  })];
1460
1479
  case 1:
1461
- _b.sent();
1462
- return [2 /*return*/];
1480
+ response = _e.sent();
1481
+ if (!(response.status !== 200)) return [3 /*break*/, 3];
1482
+ _b = setContext;
1483
+ _c = ['Send Replay Response'];
1484
+ _d = {
1485
+ status: response.status
1486
+ };
1487
+ return [4 /*yield*/, response.text()];
1488
+ case 2:
1489
+ _b.apply(void 0, _c.concat([(_d.body = _e.sent(),
1490
+ _d)]));
1491
+ throw new Error(UNABLE_TO_SEND_REPLAY);
1492
+ case 3: return [2 /*return*/];
1463
1493
  }
1464
1494
  });
1465
1495
  });
@@ -1497,8 +1527,13 @@ var SentryReplay = /** @class */ (function () {
1497
1527
  return [2 /*return*/, true];
1498
1528
  case 3:
1499
1529
  ex_1 = _b.sent();
1500
- // we have to catch this otherwise it throws an infinite loop in Sentry
1501
1530
  console.error(ex_1);
1531
+ // Capture error for every failed replay
1532
+ // TODO: Remove this before GA as this will create an error on customer's project
1533
+ setContext('Replays', {
1534
+ retryCount: this.retryCount,
1535
+ });
1536
+ captureException(new Error(UNABLE_TO_SEND_REPLAY));
1502
1537
  // If an error happened here, it's likely that uploading the attachment
1503
1538
  // failed, we'll can retry with the same events payload
1504
1539
  if (this.retryCount >= MAX_RETRY_COUNT) {
package/dist/index.js CHANGED
@@ -118,7 +118,7 @@ function captureReplayUpdate(_a) {
118
118
  core.captureEvent({
119
119
  // @ts-expect-error replay_event is a new event type
120
120
  type: REPLAY_EVENT_NAME,
121
- replay_start_timestamp: timestamp / 1000,
121
+ timestamp: timestamp / 1000,
122
122
  error_ids: errorIds,
123
123
  trace_ids: traceIds,
124
124
  urls: urls,
@@ -487,13 +487,6 @@ function createPayload(_a) {
487
487
  return payloadWithSequence;
488
488
  }
489
489
 
490
- /**
491
- * Determine if there is browser support for `navigator.sendBeacon`
492
- */
493
- function supportsSendBeacon() {
494
- return 'navigator' in window && 'sendBeacon' in window.navigator;
495
- }
496
-
497
490
  var _a;
498
491
  // Map entryType -> function to normalize data for event
499
492
  var ENTRY_TYPES = (_a = {
@@ -775,6 +768,7 @@ var EventBufferCompressionWorker = /** @class */ (function () {
775
768
 
776
769
  var BASE_RETRY_INTERVAL = 5000;
777
770
  var MAX_RETRY_COUNT = 5;
771
+ var UNABLE_TO_SEND_REPLAY = 'Unable to send replay';
778
772
  var SentryReplay = /** @class */ (function () {
779
773
  function SentryReplay(_a) {
780
774
  if (_a === void 0) { _a = {}; }
@@ -814,6 +808,7 @@ var SentryReplay = /** @class */ (function () {
814
808
  errorIds: new Set(),
815
809
  traceIds: new Set(),
816
810
  urls: [],
811
+ earliestEvent: null,
817
812
  };
818
813
  /**
819
814
  * Core Sentry SDK global event handler. Attaches `replayId` to all [non-replay]
@@ -839,7 +834,10 @@ var SentryReplay = /** @class */ (function () {
839
834
  // XXX: Is it safe to assume that all other events are error events?
840
835
  _this.context.errorIds.add(event.event_id);
841
836
  // Need to be very careful that this does not cause an infinite loop
842
- if (_this.options.captureOnlyOnError && event.exception) {
837
+ if (_this.options.captureOnlyOnError &&
838
+ event.exception &&
839
+ event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because other we could loop indefinitely with trying to capture replay and failing
840
+ ) {
843
841
  // TODO: Do we continue to record after?
844
842
  // TODO: What happens if another error happens? Do we record in the same session?
845
843
  setTimeout(function () { return _this.flushUpdate(); });
@@ -860,7 +858,7 @@ var SentryReplay = /** @class */ (function () {
860
858
  _this.addUpdate(function () {
861
859
  // We need to clear existing events on a checkout, otherwise they are
862
860
  // incremental event updates and should be appended
863
- _this.eventBuffer.addEvent(event, isCheckout);
861
+ _this.addEvent(event, isCheckout);
864
862
  // Different behavior for full snapshots (type=2), ignore other event types
865
863
  // See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16
866
864
  if (event.type !== 2) {
@@ -960,7 +958,7 @@ var SentryReplay = /** @class */ (function () {
960
958
  return;
961
959
  }
962
960
  _this.addUpdate(function () {
963
- _this.eventBuffer.addEvent({
961
+ _this.addEvent({
964
962
  type: rrweb.EventType.Custom,
965
963
  // TODO: We were converting from ms to seconds for breadcrumbs, spans,
966
964
  // but maybe we should just keep them as milliseconds
@@ -1034,15 +1032,6 @@ var SentryReplay = /** @class */ (function () {
1034
1032
  // replay ID so that we can reference them later in the UI
1035
1033
  core.addGlobalEventProcessor(this.handleGlobalEvent);
1036
1034
  rrweb.record(__assign(__assign({}, this.recordingOptions), { emit: this.handleRecordingEmit }));
1037
- var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
1038
- var url = "".concat(window.location.origin).concat(urlPath);
1039
- // Otherwise, these will be captured after the first flush, which means the
1040
- // URL and timestamps could be incorrect
1041
- this.initialState = {
1042
- timestamp: new Date().getTime(),
1043
- url: url,
1044
- };
1045
- this.context.urls.push(url);
1046
1035
  };
1047
1036
  /**
1048
1037
  * We want to batch uploads of replay events. Save events only if
@@ -1120,12 +1109,29 @@ var SentryReplay = /** @class */ (function () {
1120
1109
  // enable flag to create the root replay
1121
1110
  if (type === 'new') {
1122
1111
  this.needsCaptureReplay = true;
1112
+ this.setInitialState();
1123
1113
  }
1124
1114
  if (session.id !== ((_b = this.session) === null || _b === void 0 ? void 0 : _b.id)) {
1125
1115
  session.previousSessionId = (_c = this.session) === null || _c === void 0 ? void 0 : _c.id;
1126
1116
  }
1127
1117
  this.session = session;
1128
1118
  };
1119
+ /**
1120
+ * Capture some initial state that can change throughout the lifespan of the
1121
+ * replay. This is required because otherwise they would be captured at the
1122
+ * first flush.
1123
+ */
1124
+ SentryReplay.prototype.setInitialState = function () {
1125
+ var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
1126
+ var url = "".concat(window.location.origin).concat(urlPath);
1127
+ // Reset context as well
1128
+ this.popEventContext();
1129
+ this.initialState = {
1130
+ timestamp: new Date().getTime(),
1131
+ url: url,
1132
+ };
1133
+ this.context.urls.push(url);
1134
+ };
1129
1135
  /**
1130
1136
  * Adds listeners to record events for the replay
1131
1137
  */
@@ -1228,6 +1234,17 @@ var SentryReplay = /** @class */ (function () {
1228
1234
  logger.log('Taking full rrweb snapshot');
1229
1235
  rrweb.record.takeFullSnapshot(true);
1230
1236
  };
1237
+ /**
1238
+ * Add an event to the event buffer
1239
+ */
1240
+ SentryReplay.prototype.addEvent = function (event, isCheckout) {
1241
+ var timestampInMs = event.timestamp * 1000;
1242
+ if (!this.context.earliestEvent ||
1243
+ timestampInMs < this.context.earliestEvent) {
1244
+ this.context.earliestEvent = timestampInMs;
1245
+ }
1246
+ this.eventBuffer.addEvent(event, isCheckout);
1247
+ };
1231
1248
  /**
1232
1249
  * Updates the session's last activity timestamp
1233
1250
  */
@@ -1241,7 +1258,7 @@ var SentryReplay = /** @class */ (function () {
1241
1258
  SentryReplay.prototype.createCustomBreadcrumb = function (breadcrumb) {
1242
1259
  var _this = this;
1243
1260
  this.addUpdate(function () {
1244
- _this.eventBuffer.addEvent({
1261
+ _this.addEvent({
1245
1262
  type: rrweb.EventType.Custom,
1246
1263
  timestamp: breadcrumb.timestamp,
1247
1264
  data: {
@@ -1258,7 +1275,7 @@ var SentryReplay = /** @class */ (function () {
1258
1275
  var _this = this;
1259
1276
  return Promise.all(entries.map(function (_a) {
1260
1277
  var type = _a.type, start = _a.start, end = _a.end, name = _a.name, data = _a.data;
1261
- return _this.eventBuffer.addEvent({
1278
+ return _this.addEvent({
1262
1279
  type: rrweb.EventType.Custom,
1263
1280
  timestamp: start,
1264
1281
  data: {
@@ -1335,10 +1352,16 @@ var SentryReplay = /** @class */ (function () {
1335
1352
  * Return and clear context
1336
1353
  */
1337
1354
  SentryReplay.prototype.popEventContext = function (_a) {
1338
- var timestamp = _a.timestamp;
1355
+ var _b = _a === void 0 ? {} : _a, timestamp = _b.timestamp;
1356
+ var initialState = this.initialState;
1357
+ if (this.initialState &&
1358
+ this.context.earliestEvent &&
1359
+ this.context.earliestEvent < this.initialState.timestamp) {
1360
+ initialState.timestamp = this.context.earliestEvent;
1361
+ }
1339
1362
  var context = {
1340
1363
  session: this.session,
1341
- initialState: this.initialState,
1364
+ initialState: initialState,
1342
1365
  timestamp: timestamp,
1343
1366
  errorIds: Array.from(this.context.errorIds).filter(Boolean),
1344
1367
  traceIds: Array.from(this.context.traceIds).filter(Boolean),
@@ -1347,6 +1370,7 @@ var SentryReplay = /** @class */ (function () {
1347
1370
  this.context.errorIds.clear();
1348
1371
  this.context.traceIds.clear();
1349
1372
  this.context.urls = [];
1373
+ this.context.earliestEvent = null;
1350
1374
  return context;
1351
1375
  };
1352
1376
  /**
@@ -1420,14 +1444,15 @@ var SentryReplay = /** @class */ (function () {
1420
1444
  });
1421
1445
  };
1422
1446
  /**
1423
- * Send replay attachment using either `sendBeacon()` or `fetch()`
1447
+ * Send replay attachment using `fetch()`
1424
1448
  */
1425
1449
  SentryReplay.prototype.sendReplayRequest = function (_a) {
1426
1450
  var endpoint = _a.endpoint, events = _a.events;
1427
1451
  return __awaiter(this, void 0, void 0, function () {
1428
- var payloadWithSequence, envelope;
1429
- return __generator(this, function (_b) {
1430
- switch (_b.label) {
1452
+ var payloadWithSequence, envelope, response, _b, _c;
1453
+ var _d;
1454
+ return __generator(this, function (_e) {
1455
+ switch (_e.label) {
1431
1456
  case 0:
1432
1457
  payloadWithSequence = createPayload({
1433
1458
  events: events,
@@ -1449,12 +1474,6 @@ var SentryReplay = /** @class */ (function () {
1449
1474
  payloadWithSequence,
1450
1475
  ],
1451
1476
  ]);
1452
- // If sendBeacon is supported and payload is smol enough...
1453
- if (supportsSendBeacon() && events.length <= 65536) {
1454
- logger.log("uploading attachment via sendBeacon()");
1455
- window.navigator.sendBeacon(endpoint, utils.serializeEnvelope(envelope));
1456
- return [2 /*return*/];
1457
- }
1458
1477
  // Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
1459
1478
  logger.log("uploading attachment via fetch()");
1460
1479
  return [4 /*yield*/, fetch(endpoint, {
@@ -1462,8 +1481,19 @@ var SentryReplay = /** @class */ (function () {
1462
1481
  body: utils.serializeEnvelope(envelope),
1463
1482
  })];
1464
1483
  case 1:
1465
- _b.sent();
1466
- return [2 /*return*/];
1484
+ response = _e.sent();
1485
+ if (!(response.status !== 200)) return [3 /*break*/, 3];
1486
+ _b = core.setContext;
1487
+ _c = ['Send Replay Response'];
1488
+ _d = {
1489
+ status: response.status
1490
+ };
1491
+ return [4 /*yield*/, response.text()];
1492
+ case 2:
1493
+ _b.apply(void 0, _c.concat([(_d.body = _e.sent(),
1494
+ _d)]));
1495
+ throw new Error(UNABLE_TO_SEND_REPLAY);
1496
+ case 3: return [2 /*return*/];
1467
1497
  }
1468
1498
  });
1469
1499
  });
@@ -1501,8 +1531,13 @@ var SentryReplay = /** @class */ (function () {
1501
1531
  return [2 /*return*/, true];
1502
1532
  case 3:
1503
1533
  ex_1 = _b.sent();
1504
- // we have to catch this otherwise it throws an infinite loop in Sentry
1505
1534
  console.error(ex_1);
1535
+ // Capture error for every failed replay
1536
+ // TODO: Remove this before GA as this will create an error on customer's project
1537
+ core.setContext('Replays', {
1538
+ retryCount: this.retryCount,
1539
+ });
1540
+ core.captureException(new Error(UNABLE_TO_SEND_REPLAY));
1506
1541
  // If an error happened here, it's likely that uploading the attachment
1507
1542
  // failed, we'll can retry with the same events payload
1508
1543
  if (this.retryCount >= MAX_RETRY_COUNT) {