@sentry/replay 0.5.22 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -22
- package/dist/index.es.js +44 -52
- package/dist/index.js +44 -52
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.ts +4 -10
- package/dist/src/types.d.ts +2 -2
- package/dist/src/util/logger.d.ts +1 -1
- package/dist/test/mocks/mockSdk.d.ts +4 -4
- package/dist/types/src/index.d.ts +4 -10
- package/dist/types/src/types.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -131,7 +131,7 @@ function captureReplayEvent(_a) {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
core.withScope(function (scope) {
|
|
134
|
-
scope.setTag('replay_sdk_version', "0.
|
|
134
|
+
scope.setTag('replay_sdk_version', "0.6.0");
|
|
135
135
|
core.captureEvent(__assign(__assign({
|
|
136
136
|
// @ts-expect-error replay_event is a new event type
|
|
137
137
|
type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
|
|
@@ -897,25 +897,19 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
897
897
|
var BASE_RETRY_INTERVAL = 5000;
|
|
898
898
|
var MAX_RETRY_COUNT = 3;
|
|
899
899
|
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
900
|
-
var
|
|
901
|
-
function
|
|
900
|
+
var Replay = /** @class */ (function () {
|
|
901
|
+
function Replay(_a) {
|
|
902
902
|
if (_a === void 0) { _a = {}; }
|
|
903
903
|
var _this = this;
|
|
904
904
|
var _b = _a.flushMinDelay, flushMinDelay = _b === void 0 ? 5000 : _b, _c = _a.flushMaxDelay, flushMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.initialFlushDelay, initialFlushDelay = _d === void 0 ? 5000 : _d, _e = _a.stickySession, stickySession = _e === void 0 ? true : _e, _f = _a.useCompression, useCompression = _f === void 0 ? true : _f, _g = _a.captureOnlyOnError, captureOnlyOnError = _g === void 0 ? false : _g, _h = _a.replaysSamplingRate, replaysSamplingRate = _h === void 0 ? 1.0 : _h, _j = _a.maskAllText, maskAllText = _j === void 0 ? false : _j, _k = _a.recordingConfig, _l = _k === void 0 ? {} : _k, _m = _l.maskAllInputs, maskAllInputs = _m === void 0 ? true : _m, _o = _l.blockClass, blockClass = _o === void 0 ? 'sentry-block' : _o, _p = _l.ignoreClass, ignoreClass = _p === void 0 ? 'sentry-ignore' : _p, _q = _l.maskTextClass, maskTextClass = _q === void 0 ? 'sentry-mask' : _q, recordingOptions = __rest(_l, ["maskAllInputs", "blockClass", "ignoreClass", "maskTextClass"]);
|
|
905
905
|
/**
|
|
906
906
|
* @inheritDoc
|
|
907
907
|
*/
|
|
908
|
-
this.name =
|
|
908
|
+
this.name = Replay.id;
|
|
909
909
|
/**
|
|
910
910
|
* List of PerformanceEntry from PerformanceObserver
|
|
911
911
|
*/
|
|
912
912
|
this.performanceEvents = [];
|
|
913
|
-
/**
|
|
914
|
-
* The timestamp of the first event since the last flush. This is used to
|
|
915
|
-
* determine if the maximum allowed time has passed before events should be
|
|
916
|
-
* flushed again.
|
|
917
|
-
*/
|
|
918
|
-
this.initialEventTimestampSinceFlush = null;
|
|
919
913
|
this.performanceObserver = null;
|
|
920
914
|
this.retryCount = 0;
|
|
921
915
|
this.retryInterval = BASE_RETRY_INTERVAL;
|
|
@@ -997,7 +991,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
997
991
|
return;
|
|
998
992
|
}
|
|
999
993
|
_this.addUpdate(function () {
|
|
1000
|
-
var _a;
|
|
994
|
+
var _a, _b;
|
|
1001
995
|
// We need to clear existing events on a checkout, otherwise they are
|
|
1002
996
|
// incremental event updates and should be appended
|
|
1003
997
|
_this.addEvent(event, isCheckout);
|
|
@@ -1020,6 +1014,15 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1020
1014
|
// for a set amount of time before flushing. This can help avoid
|
|
1021
1015
|
// capturing replays of users that immediately close the window.
|
|
1022
1016
|
setTimeout(function () { return _this.conditionalFlush(); }, _this.options.initialFlushDelay);
|
|
1017
|
+
// Cancel any previously debounced flushes to ensure there are no [near]
|
|
1018
|
+
// simultaneous flushes happening. The latter request should be
|
|
1019
|
+
// insignificant in this case, so wait for additional user interaction to
|
|
1020
|
+
// trigger a new flush.
|
|
1021
|
+
//
|
|
1022
|
+
// This can happen because there's no guarantee that a recording event
|
|
1023
|
+
// happens first. e.g. a mouse click can happen and trigger a debounced
|
|
1024
|
+
// flush before the checkout.
|
|
1025
|
+
(_b = _this.debouncedFlush) === null || _b === void 0 ? void 0 : _b.cancel();
|
|
1023
1026
|
return true;
|
|
1024
1027
|
});
|
|
1025
1028
|
};
|
|
@@ -1215,7 +1218,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1215
1218
|
* So we call `this.setup` in next event loop as a workaround to wait for
|
|
1216
1219
|
* other global event processors to finish
|
|
1217
1220
|
*/
|
|
1218
|
-
|
|
1221
|
+
Replay.prototype.setupOnce = function () {
|
|
1219
1222
|
var _this = this;
|
|
1220
1223
|
// XXX: See method comments above
|
|
1221
1224
|
window.setTimeout(function () { return _this.start(); });
|
|
@@ -1225,7 +1228,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1225
1228
|
*
|
|
1226
1229
|
* Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
|
|
1227
1230
|
*/
|
|
1228
|
-
|
|
1231
|
+
Replay.prototype.start = function () {
|
|
1229
1232
|
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
1230
1233
|
// If there is no session, then something bad has happened - can't continue
|
|
1231
1234
|
if (!this.session) {
|
|
@@ -1256,14 +1259,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1256
1259
|
* Accepts a callback to perform side-effects and returns true to stop batch
|
|
1257
1260
|
* processing and hand back control to caller.
|
|
1258
1261
|
*/
|
|
1259
|
-
|
|
1260
|
-
var now = new Date().getTime();
|
|
1261
|
-
// Timestamp of the first replay event since the last flush, this gets
|
|
1262
|
-
// reset when we finish the replay event
|
|
1263
|
-
if (!this.initialEventTimestampSinceFlush &&
|
|
1264
|
-
!this.options.captureOnlyOnError) {
|
|
1265
|
-
this.initialEventTimestampSinceFlush = now;
|
|
1266
|
-
}
|
|
1262
|
+
Replay.prototype.addUpdate = function (cb) {
|
|
1267
1263
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1268
1264
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1269
1265
|
// If this option is turned on then we will only want to call `flush`
|
|
@@ -1283,7 +1279,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1283
1279
|
/**
|
|
1284
1280
|
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
|
|
1285
1281
|
*/
|
|
1286
|
-
|
|
1282
|
+
Replay.prototype.stop = function () {
|
|
1287
1283
|
var _a, _b;
|
|
1288
1284
|
logger.log('Stopping Replays');
|
|
1289
1285
|
this.isEnabled = false;
|
|
@@ -1292,7 +1288,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1292
1288
|
(_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
1293
1289
|
this.eventBuffer = null;
|
|
1294
1290
|
};
|
|
1295
|
-
|
|
1291
|
+
Replay.prototype.clearSession = function () {
|
|
1296
1292
|
deleteSession();
|
|
1297
1293
|
this.session = undefined;
|
|
1298
1294
|
};
|
|
@@ -1300,7 +1296,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1300
1296
|
* Loads a session from storage, or creates a new one if it does not exist or
|
|
1301
1297
|
* is expired.
|
|
1302
1298
|
*/
|
|
1303
|
-
|
|
1299
|
+
Replay.prototype.loadSession = function (_a) {
|
|
1304
1300
|
var _b, _c;
|
|
1305
1301
|
var expiry = _a.expiry;
|
|
1306
1302
|
var _d = getSession({
|
|
@@ -1325,11 +1321,10 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1325
1321
|
* replay. This is required because otherwise they would be captured at the
|
|
1326
1322
|
* first flush.
|
|
1327
1323
|
*/
|
|
1328
|
-
|
|
1324
|
+
Replay.prototype.setInitialState = function () {
|
|
1329
1325
|
var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
|
|
1330
1326
|
var url = "".concat(window.location.origin).concat(urlPath);
|
|
1331
1327
|
this.performanceEvents = [];
|
|
1332
|
-
this.initialEventTimestampSinceFlush = null;
|
|
1333
1328
|
// Reset context as well
|
|
1334
1329
|
this.clearContext();
|
|
1335
1330
|
this.initialState = {
|
|
@@ -1341,7 +1336,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1341
1336
|
/**
|
|
1342
1337
|
* Adds listeners to record events for the replay
|
|
1343
1338
|
*/
|
|
1344
|
-
|
|
1339
|
+
Replay.prototype.addListeners = function () {
|
|
1345
1340
|
var _this = this;
|
|
1346
1341
|
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
1347
1342
|
window.addEventListener('blur', this.handleWindowBlur);
|
|
@@ -1390,7 +1385,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1390
1385
|
/**
|
|
1391
1386
|
* Cleans up listeners that were created in `addListeners`
|
|
1392
1387
|
*/
|
|
1393
|
-
|
|
1388
|
+
Replay.prototype.removeListeners = function () {
|
|
1394
1389
|
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
|
1395
1390
|
window.removeEventListener('blur', this.handleWindowBlur);
|
|
1396
1391
|
window.removeEventListener('focus', this.handleWindowFocus);
|
|
@@ -1402,7 +1397,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1402
1397
|
/**
|
|
1403
1398
|
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
|
|
1404
1399
|
*/
|
|
1405
|
-
|
|
1400
|
+
Replay.prototype.doChangeToBackgroundTasks = function (breadcrumb) {
|
|
1406
1401
|
if (!this.session) {
|
|
1407
1402
|
return;
|
|
1408
1403
|
}
|
|
@@ -1418,7 +1413,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1418
1413
|
/**
|
|
1419
1414
|
* Tasks to run when we consider a page to be visible (via focus and/or visibility)
|
|
1420
1415
|
*/
|
|
1421
|
-
|
|
1416
|
+
Replay.prototype.doChangeToForegroundTasks = function (breadcrumb) {
|
|
1422
1417
|
if (!this.session) {
|
|
1423
1418
|
return;
|
|
1424
1419
|
}
|
|
@@ -1445,14 +1440,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1445
1440
|
* Trigger rrweb to take a full snapshot which will cause this plugin to
|
|
1446
1441
|
* create a new Replay event.
|
|
1447
1442
|
*/
|
|
1448
|
-
|
|
1443
|
+
Replay.prototype.triggerFullSnapshot = function () {
|
|
1449
1444
|
logger.log('Taking full rrweb snapshot');
|
|
1450
1445
|
rrweb.record.takeFullSnapshot(true);
|
|
1451
1446
|
};
|
|
1452
1447
|
/**
|
|
1453
1448
|
* Add an event to the event buffer
|
|
1454
1449
|
*/
|
|
1455
|
-
|
|
1450
|
+
Replay.prototype.addEvent = function (event, isCheckout) {
|
|
1456
1451
|
if (!this.eventBuffer) {
|
|
1457
1452
|
// This implies that `isEnabled` is false
|
|
1458
1453
|
return;
|
|
@@ -1473,7 +1468,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1473
1468
|
/**
|
|
1474
1469
|
* Updates the session's last activity timestamp
|
|
1475
1470
|
*/
|
|
1476
|
-
|
|
1471
|
+
Replay.prototype.updateLastActivity = function (lastActivity) {
|
|
1477
1472
|
if (lastActivity === void 0) { lastActivity = new Date().getTime(); }
|
|
1478
1473
|
if (this.session) {
|
|
1479
1474
|
this.session.lastActivity = lastActivity;
|
|
@@ -1482,7 +1477,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1482
1477
|
/**
|
|
1483
1478
|
* Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
|
|
1484
1479
|
*/
|
|
1485
|
-
|
|
1480
|
+
Replay.prototype.createCustomBreadcrumb = function (breadcrumb) {
|
|
1486
1481
|
var _this = this;
|
|
1487
1482
|
this.addUpdate(function () {
|
|
1488
1483
|
_this.addEvent({
|
|
@@ -1498,7 +1493,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1498
1493
|
/**
|
|
1499
1494
|
* Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
|
|
1500
1495
|
*/
|
|
1501
|
-
|
|
1496
|
+
Replay.prototype.createPerformanceSpans = function (entries) {
|
|
1502
1497
|
var _this = this;
|
|
1503
1498
|
return Promise.all(entries.map(function (_a) {
|
|
1504
1499
|
var type = _a.type, start = _a.start, end = _a.end, name = _a.name, data = _a.data;
|
|
@@ -1522,7 +1517,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1522
1517
|
* Observed performance events are added to `this.performanceEvents`. These
|
|
1523
1518
|
* are included in the replay event before it is finished and sent to Sentry.
|
|
1524
1519
|
*/
|
|
1525
|
-
|
|
1520
|
+
Replay.prototype.addPerformanceEntries = function () {
|
|
1526
1521
|
// Copy and reset entries before processing
|
|
1527
1522
|
var entries = __spreadArray([], this.performanceEvents, true);
|
|
1528
1523
|
this.performanceEvents = [];
|
|
@@ -1532,7 +1527,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1532
1527
|
* Create a "span" for the total amount of memory being used by JS objects
|
|
1533
1528
|
* (including v8 internal objects).
|
|
1534
1529
|
*/
|
|
1535
|
-
|
|
1530
|
+
Replay.prototype.addMemoryEntry = function () {
|
|
1536
1531
|
// window.performance.memory is a non-standard API and doesn't work on all browsers
|
|
1537
1532
|
// so we check before creating the event.
|
|
1538
1533
|
if (!('memory' in window.performance)) {
|
|
@@ -1548,7 +1543,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1548
1543
|
*
|
|
1549
1544
|
* Returns true if session is not expired, false otherwise.
|
|
1550
1545
|
*/
|
|
1551
|
-
|
|
1546
|
+
Replay.prototype.checkAndHandleExpiredSession = function (expiry) {
|
|
1552
1547
|
var _a, _b;
|
|
1553
1548
|
if (expiry === void 0) { expiry = SESSION_IDLE_DURATION; }
|
|
1554
1549
|
var oldSessionId = (_a = this.session) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -1570,7 +1565,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1570
1565
|
/**
|
|
1571
1566
|
* Only flush if `captureOnlyOnError` is false.
|
|
1572
1567
|
*/
|
|
1573
|
-
|
|
1568
|
+
Replay.prototype.conditionalFlush = function () {
|
|
1574
1569
|
if (this.options.captureOnlyOnError) {
|
|
1575
1570
|
return;
|
|
1576
1571
|
}
|
|
@@ -1579,7 +1574,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1579
1574
|
/**
|
|
1580
1575
|
* Clear context
|
|
1581
1576
|
*/
|
|
1582
|
-
|
|
1577
|
+
Replay.prototype.clearContext = function () {
|
|
1583
1578
|
this.context.errorIds.clear();
|
|
1584
1579
|
this.context.traceIds.clear();
|
|
1585
1580
|
this.context.urls = [];
|
|
@@ -1588,7 +1583,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1588
1583
|
/**
|
|
1589
1584
|
* Return and clear context
|
|
1590
1585
|
*/
|
|
1591
|
-
|
|
1586
|
+
Replay.prototype.popEventContext = function (_a) {
|
|
1592
1587
|
var timestamp = _a.timestamp;
|
|
1593
1588
|
var initialState = this.initialState;
|
|
1594
1589
|
if (this.initialState &&
|
|
@@ -1614,7 +1609,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1614
1609
|
*
|
|
1615
1610
|
* Should never be called directly, only by `flush`
|
|
1616
1611
|
*/
|
|
1617
|
-
|
|
1612
|
+
Replay.prototype.runFlush = function () {
|
|
1618
1613
|
var _a, _b, _c;
|
|
1619
1614
|
return __awaiter(this, void 0, void 0, function () {
|
|
1620
1615
|
var stack, replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
@@ -1643,9 +1638,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1643
1638
|
replayId = this.session.id;
|
|
1644
1639
|
newSessionCreated = this.newSessionCreated;
|
|
1645
1640
|
segmentId = this.session.segmentId++;
|
|
1646
|
-
// Reset this to null regardless of `sendReplay` result so that future
|
|
1647
|
-
// events will get flushed properly
|
|
1648
|
-
this.initialEventTimestampSinceFlush = null;
|
|
1649
1641
|
_d.label = 3;
|
|
1650
1642
|
case 3:
|
|
1651
1643
|
_d.trys.push([3, 6, , 7]);
|
|
@@ -1672,7 +1664,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1672
1664
|
/**
|
|
1673
1665
|
* Send replay attachment using `fetch()`
|
|
1674
1666
|
*/
|
|
1675
|
-
|
|
1667
|
+
Replay.prototype.sendReplayRequest = function (_a) {
|
|
1676
1668
|
var endpoint = _a.endpoint, events = _a.events, event_id = _a.replayId, segment_id = _a.segmentId;
|
|
1677
1669
|
return __awaiter(this, void 0, void 0, function () {
|
|
1678
1670
|
var payloadWithSequence, envelope, response, _b, _c;
|
|
@@ -1691,7 +1683,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1691
1683
|
sent_at: new Date().toISOString(),
|
|
1692
1684
|
sdk: {
|
|
1693
1685
|
name: 'sentry.javascript.integration.replay',
|
|
1694
|
-
version: "0.
|
|
1686
|
+
version: "0.6.0",
|
|
1695
1687
|
},
|
|
1696
1688
|
}, [
|
|
1697
1689
|
[
|
|
@@ -1728,14 +1720,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1728
1720
|
});
|
|
1729
1721
|
});
|
|
1730
1722
|
};
|
|
1731
|
-
|
|
1723
|
+
Replay.prototype.resetRetries = function () {
|
|
1732
1724
|
this.retryCount = 0;
|
|
1733
1725
|
this.retryInterval = BASE_RETRY_INTERVAL;
|
|
1734
1726
|
};
|
|
1735
1727
|
/**
|
|
1736
1728
|
* Finalize and send the current replay event to Sentry
|
|
1737
1729
|
*/
|
|
1738
|
-
|
|
1730
|
+
Replay.prototype.sendReplay = function (replayId, events, segmentId) {
|
|
1739
1731
|
return __awaiter(this, void 0, void 0, function () {
|
|
1740
1732
|
var client, endpoint, ex_1;
|
|
1741
1733
|
var _this = this;
|
|
@@ -1808,9 +1800,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1808
1800
|
/**
|
|
1809
1801
|
* @inheritDoc
|
|
1810
1802
|
*/
|
|
1811
|
-
|
|
1812
|
-
return
|
|
1803
|
+
Replay.id = 'Replay';
|
|
1804
|
+
return Replay;
|
|
1813
1805
|
}());
|
|
1814
1806
|
|
|
1815
|
-
exports.
|
|
1807
|
+
exports.Replay = Replay;
|
|
1816
1808
|
//# sourceMappingURL=index.js.map
|