@sentry/replay 0.5.23 → 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 +34 -34
- package/dist/index.js +34 -34
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.ts +4 -4
- 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 -4
- package/dist/types/src/types.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,16 +27,15 @@ yarn add @sentry/browser @sentry/replay
|
|
|
27
27
|
To set up the integration add the following to your Sentry initialization. Several options are supported and passable via the integration constructor.
|
|
28
28
|
See the rrweb documentation for advice on configuring these values.
|
|
29
29
|
|
|
30
|
-
|
|
31
30
|
```javascript
|
|
32
31
|
import * as Sentry from '@sentry/browser';
|
|
33
|
-
import {
|
|
32
|
+
import { Replay } from '@sentry/replay';
|
|
34
33
|
|
|
35
34
|
Sentry.init({
|
|
36
35
|
dsn: '__DSN__',
|
|
37
36
|
integrations: [
|
|
38
|
-
new
|
|
39
|
-
maskAllText:
|
|
37
|
+
new Replay({
|
|
38
|
+
maskAllText: true, // Will mask all text strings
|
|
40
39
|
recordingConfig: {
|
|
41
40
|
maskAllInputs: false, // Default is true
|
|
42
41
|
},
|
|
@@ -46,33 +45,31 @@ Sentry.init({
|
|
|
46
45
|
});
|
|
47
46
|
```
|
|
48
47
|
|
|
49
|
-
### Stop Recording
|
|
48
|
+
### Stop Recording
|
|
50
49
|
|
|
51
50
|
Replay recording only starts automatically when it is included in the `integrations` key when calling `Sentry.init`. Otherwise you can initialize the plugin and manually call the `start()` method on the integration instance. To stop recording you can call the `stop()`.
|
|
52
51
|
|
|
53
52
|
```javascript
|
|
54
|
-
|
|
55
|
-
const replay = new SentryReplay(); // This will *NOT* begin recording replays
|
|
53
|
+
const replay = new Replay(); // This will *NOT* begin recording replays
|
|
56
54
|
|
|
57
55
|
replay.start(); // Start recording
|
|
58
56
|
|
|
59
57
|
replay.stop(); // Stop recording
|
|
60
|
-
|
|
61
58
|
```
|
|
62
59
|
|
|
63
60
|
## Configuration
|
|
64
61
|
|
|
65
|
-
| key
|
|
66
|
-
|
|
|
67
|
-
| `flushMinDelay`
|
|
68
|
-
| `flushMaxDelay`
|
|
69
|
-
| `initialFlushDelay`
|
|
70
|
-
| `maskAllText`
|
|
71
|
-
| `replaysSamplingRate`
|
|
72
|
-
| `stickySession`
|
|
73
|
-
| `useCompression`
|
|
74
|
-
| `captureOnlyOnError`
|
|
75
|
-
| `recordingConfig.maskAllInputs` | `boolean` | `true`
|
|
76
|
-
| `recordingConfig.blockClass`
|
|
77
|
-
| `recordingConfig.ignoreClass`
|
|
78
|
-
| `recordingConfig.maskTextClass` | `string`
|
|
62
|
+
| key | type | default | description |
|
|
63
|
+
| ------------------------------- | --------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
64
|
+
| `flushMinDelay` | `number` | `5000` | The minimum time to wait (in ms) before sending the recording payload. The payload is sent if `flushMinDelay` ms have elapsed between two events. |
|
|
65
|
+
| `flushMaxDelay` | `number` | `15000` | The maximum time to wait (in ms) when sending the recording payload. The payload is sent if events occur at an interval less than `flushMinDelay` and `flushMaxDelay` ms have elapsed since the last time a payload was sent. |
|
|
66
|
+
| `initialFlushDelay` | `number` | `5000` | The amount of time to wait (in ms) before sending the initial recording payload. This helps drop recordings where users visit and close the page quickly. |
|
|
67
|
+
| `maskAllText` | `boolean` | `false` | Mask _all_ text strings with `*`. |
|
|
68
|
+
| `replaysSamplingRate` | `number` | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
|
|
69
|
+
| `stickySession` | `boolean` | `true` | Keep track of the user across page loads. Note a single user using multiple tabs will result in multiple sessions. Closing a tab will result in the session being closed as well. |
|
|
70
|
+
| `useCompression` | `boolean` | `true` | Uses `WebWorkers` (if available) to compress the recording payload before uploading to Sentry. |
|
|
71
|
+
| `captureOnlyOnError` | `boolean` | `false` | Only capture the recording when an error happens. |
|
|
72
|
+
| `recordingConfig.maskAllInputs` | `boolean` | `true` | Mask all `<input>` elements |
|
|
73
|
+
| `recordingConfig.blockClass` | `string` | `'sentry-block'` | Redact all elements with the class name `sentry-block` |
|
|
74
|
+
| `recordingConfig.ignoreClass` | `string` | `'sentry-ignore'` | Ignores all elements with the class name `sentry-ignore` |
|
|
75
|
+
| `recordingConfig.maskTextClass` | `string` | `'sentry-mask'` | Mask all elements with the class name `sentry-ignore` |
|
package/dist/index.es.js
CHANGED
|
@@ -123,7 +123,7 @@ function captureReplayEvent(_a) {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
withScope(function (scope) {
|
|
126
|
-
scope.setTag('replay_sdk_version', "0.
|
|
126
|
+
scope.setTag('replay_sdk_version', "0.6.0");
|
|
127
127
|
captureEvent(__assign(__assign({
|
|
128
128
|
// @ts-expect-error replay_event is a new event type
|
|
129
129
|
type: REPLAY_EVENT_NAME }, (includeReplayStartTimestamp
|
|
@@ -889,15 +889,15 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
889
889
|
var BASE_RETRY_INTERVAL = 5000;
|
|
890
890
|
var MAX_RETRY_COUNT = 3;
|
|
891
891
|
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
892
|
-
var
|
|
893
|
-
function
|
|
892
|
+
var Replay = /** @class */ (function () {
|
|
893
|
+
function Replay(_a) {
|
|
894
894
|
if (_a === void 0) { _a = {}; }
|
|
895
895
|
var _this = this;
|
|
896
896
|
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"]);
|
|
897
897
|
/**
|
|
898
898
|
* @inheritDoc
|
|
899
899
|
*/
|
|
900
|
-
this.name =
|
|
900
|
+
this.name = Replay.id;
|
|
901
901
|
/**
|
|
902
902
|
* List of PerformanceEntry from PerformanceObserver
|
|
903
903
|
*/
|
|
@@ -1210,7 +1210,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1210
1210
|
* So we call `this.setup` in next event loop as a workaround to wait for
|
|
1211
1211
|
* other global event processors to finish
|
|
1212
1212
|
*/
|
|
1213
|
-
|
|
1213
|
+
Replay.prototype.setupOnce = function () {
|
|
1214
1214
|
var _this = this;
|
|
1215
1215
|
// XXX: See method comments above
|
|
1216
1216
|
window.setTimeout(function () { return _this.start(); });
|
|
@@ -1220,7 +1220,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1220
1220
|
*
|
|
1221
1221
|
* Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
|
|
1222
1222
|
*/
|
|
1223
|
-
|
|
1223
|
+
Replay.prototype.start = function () {
|
|
1224
1224
|
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
1225
1225
|
// If there is no session, then something bad has happened - can't continue
|
|
1226
1226
|
if (!this.session) {
|
|
@@ -1251,7 +1251,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1251
1251
|
* Accepts a callback to perform side-effects and returns true to stop batch
|
|
1252
1252
|
* processing and hand back control to caller.
|
|
1253
1253
|
*/
|
|
1254
|
-
|
|
1254
|
+
Replay.prototype.addUpdate = function (cb) {
|
|
1255
1255
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1256
1256
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1257
1257
|
// If this option is turned on then we will only want to call `flush`
|
|
@@ -1271,7 +1271,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1271
1271
|
/**
|
|
1272
1272
|
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
|
|
1273
1273
|
*/
|
|
1274
|
-
|
|
1274
|
+
Replay.prototype.stop = function () {
|
|
1275
1275
|
var _a, _b;
|
|
1276
1276
|
logger.log('Stopping Replays');
|
|
1277
1277
|
this.isEnabled = false;
|
|
@@ -1280,7 +1280,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1280
1280
|
(_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
1281
1281
|
this.eventBuffer = null;
|
|
1282
1282
|
};
|
|
1283
|
-
|
|
1283
|
+
Replay.prototype.clearSession = function () {
|
|
1284
1284
|
deleteSession();
|
|
1285
1285
|
this.session = undefined;
|
|
1286
1286
|
};
|
|
@@ -1288,7 +1288,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1288
1288
|
* Loads a session from storage, or creates a new one if it does not exist or
|
|
1289
1289
|
* is expired.
|
|
1290
1290
|
*/
|
|
1291
|
-
|
|
1291
|
+
Replay.prototype.loadSession = function (_a) {
|
|
1292
1292
|
var _b, _c;
|
|
1293
1293
|
var expiry = _a.expiry;
|
|
1294
1294
|
var _d = getSession({
|
|
@@ -1313,7 +1313,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1313
1313
|
* replay. This is required because otherwise they would be captured at the
|
|
1314
1314
|
* first flush.
|
|
1315
1315
|
*/
|
|
1316
|
-
|
|
1316
|
+
Replay.prototype.setInitialState = function () {
|
|
1317
1317
|
var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
|
|
1318
1318
|
var url = "".concat(window.location.origin).concat(urlPath);
|
|
1319
1319
|
this.performanceEvents = [];
|
|
@@ -1328,7 +1328,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1328
1328
|
/**
|
|
1329
1329
|
* Adds listeners to record events for the replay
|
|
1330
1330
|
*/
|
|
1331
|
-
|
|
1331
|
+
Replay.prototype.addListeners = function () {
|
|
1332
1332
|
var _this = this;
|
|
1333
1333
|
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
1334
1334
|
window.addEventListener('blur', this.handleWindowBlur);
|
|
@@ -1377,7 +1377,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1377
1377
|
/**
|
|
1378
1378
|
* Cleans up listeners that were created in `addListeners`
|
|
1379
1379
|
*/
|
|
1380
|
-
|
|
1380
|
+
Replay.prototype.removeListeners = function () {
|
|
1381
1381
|
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
|
1382
1382
|
window.removeEventListener('blur', this.handleWindowBlur);
|
|
1383
1383
|
window.removeEventListener('focus', this.handleWindowFocus);
|
|
@@ -1389,7 +1389,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1389
1389
|
/**
|
|
1390
1390
|
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
|
|
1391
1391
|
*/
|
|
1392
|
-
|
|
1392
|
+
Replay.prototype.doChangeToBackgroundTasks = function (breadcrumb) {
|
|
1393
1393
|
if (!this.session) {
|
|
1394
1394
|
return;
|
|
1395
1395
|
}
|
|
@@ -1405,7 +1405,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1405
1405
|
/**
|
|
1406
1406
|
* Tasks to run when we consider a page to be visible (via focus and/or visibility)
|
|
1407
1407
|
*/
|
|
1408
|
-
|
|
1408
|
+
Replay.prototype.doChangeToForegroundTasks = function (breadcrumb) {
|
|
1409
1409
|
if (!this.session) {
|
|
1410
1410
|
return;
|
|
1411
1411
|
}
|
|
@@ -1432,14 +1432,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1432
1432
|
* Trigger rrweb to take a full snapshot which will cause this plugin to
|
|
1433
1433
|
* create a new Replay event.
|
|
1434
1434
|
*/
|
|
1435
|
-
|
|
1435
|
+
Replay.prototype.triggerFullSnapshot = function () {
|
|
1436
1436
|
logger.log('Taking full rrweb snapshot');
|
|
1437
1437
|
record.takeFullSnapshot(true);
|
|
1438
1438
|
};
|
|
1439
1439
|
/**
|
|
1440
1440
|
* Add an event to the event buffer
|
|
1441
1441
|
*/
|
|
1442
|
-
|
|
1442
|
+
Replay.prototype.addEvent = function (event, isCheckout) {
|
|
1443
1443
|
if (!this.eventBuffer) {
|
|
1444
1444
|
// This implies that `isEnabled` is false
|
|
1445
1445
|
return;
|
|
@@ -1460,7 +1460,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1460
1460
|
/**
|
|
1461
1461
|
* Updates the session's last activity timestamp
|
|
1462
1462
|
*/
|
|
1463
|
-
|
|
1463
|
+
Replay.prototype.updateLastActivity = function (lastActivity) {
|
|
1464
1464
|
if (lastActivity === void 0) { lastActivity = new Date().getTime(); }
|
|
1465
1465
|
if (this.session) {
|
|
1466
1466
|
this.session.lastActivity = lastActivity;
|
|
@@ -1469,7 +1469,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1469
1469
|
/**
|
|
1470
1470
|
* Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
|
|
1471
1471
|
*/
|
|
1472
|
-
|
|
1472
|
+
Replay.prototype.createCustomBreadcrumb = function (breadcrumb) {
|
|
1473
1473
|
var _this = this;
|
|
1474
1474
|
this.addUpdate(function () {
|
|
1475
1475
|
_this.addEvent({
|
|
@@ -1485,7 +1485,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1485
1485
|
/**
|
|
1486
1486
|
* Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
|
|
1487
1487
|
*/
|
|
1488
|
-
|
|
1488
|
+
Replay.prototype.createPerformanceSpans = function (entries) {
|
|
1489
1489
|
var _this = this;
|
|
1490
1490
|
return Promise.all(entries.map(function (_a) {
|
|
1491
1491
|
var type = _a.type, start = _a.start, end = _a.end, name = _a.name, data = _a.data;
|
|
@@ -1509,7 +1509,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1509
1509
|
* Observed performance events are added to `this.performanceEvents`. These
|
|
1510
1510
|
* are included in the replay event before it is finished and sent to Sentry.
|
|
1511
1511
|
*/
|
|
1512
|
-
|
|
1512
|
+
Replay.prototype.addPerformanceEntries = function () {
|
|
1513
1513
|
// Copy and reset entries before processing
|
|
1514
1514
|
var entries = __spreadArray([], this.performanceEvents, true);
|
|
1515
1515
|
this.performanceEvents = [];
|
|
@@ -1519,7 +1519,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1519
1519
|
* Create a "span" for the total amount of memory being used by JS objects
|
|
1520
1520
|
* (including v8 internal objects).
|
|
1521
1521
|
*/
|
|
1522
|
-
|
|
1522
|
+
Replay.prototype.addMemoryEntry = function () {
|
|
1523
1523
|
// window.performance.memory is a non-standard API and doesn't work on all browsers
|
|
1524
1524
|
// so we check before creating the event.
|
|
1525
1525
|
if (!('memory' in window.performance)) {
|
|
@@ -1535,7 +1535,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1535
1535
|
*
|
|
1536
1536
|
* Returns true if session is not expired, false otherwise.
|
|
1537
1537
|
*/
|
|
1538
|
-
|
|
1538
|
+
Replay.prototype.checkAndHandleExpiredSession = function (expiry) {
|
|
1539
1539
|
var _a, _b;
|
|
1540
1540
|
if (expiry === void 0) { expiry = SESSION_IDLE_DURATION; }
|
|
1541
1541
|
var oldSessionId = (_a = this.session) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -1557,7 +1557,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1557
1557
|
/**
|
|
1558
1558
|
* Only flush if `captureOnlyOnError` is false.
|
|
1559
1559
|
*/
|
|
1560
|
-
|
|
1560
|
+
Replay.prototype.conditionalFlush = function () {
|
|
1561
1561
|
if (this.options.captureOnlyOnError) {
|
|
1562
1562
|
return;
|
|
1563
1563
|
}
|
|
@@ -1566,7 +1566,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1566
1566
|
/**
|
|
1567
1567
|
* Clear context
|
|
1568
1568
|
*/
|
|
1569
|
-
|
|
1569
|
+
Replay.prototype.clearContext = function () {
|
|
1570
1570
|
this.context.errorIds.clear();
|
|
1571
1571
|
this.context.traceIds.clear();
|
|
1572
1572
|
this.context.urls = [];
|
|
@@ -1575,7 +1575,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1575
1575
|
/**
|
|
1576
1576
|
* Return and clear context
|
|
1577
1577
|
*/
|
|
1578
|
-
|
|
1578
|
+
Replay.prototype.popEventContext = function (_a) {
|
|
1579
1579
|
var timestamp = _a.timestamp;
|
|
1580
1580
|
var initialState = this.initialState;
|
|
1581
1581
|
if (this.initialState &&
|
|
@@ -1601,7 +1601,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1601
1601
|
*
|
|
1602
1602
|
* Should never be called directly, only by `flush`
|
|
1603
1603
|
*/
|
|
1604
|
-
|
|
1604
|
+
Replay.prototype.runFlush = function () {
|
|
1605
1605
|
var _a, _b, _c;
|
|
1606
1606
|
return __awaiter(this, void 0, void 0, function () {
|
|
1607
1607
|
var stack, replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
@@ -1656,7 +1656,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1656
1656
|
/**
|
|
1657
1657
|
* Send replay attachment using `fetch()`
|
|
1658
1658
|
*/
|
|
1659
|
-
|
|
1659
|
+
Replay.prototype.sendReplayRequest = function (_a) {
|
|
1660
1660
|
var endpoint = _a.endpoint, events = _a.events, event_id = _a.replayId, segment_id = _a.segmentId;
|
|
1661
1661
|
return __awaiter(this, void 0, void 0, function () {
|
|
1662
1662
|
var payloadWithSequence, envelope, response, _b, _c;
|
|
@@ -1675,7 +1675,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1675
1675
|
sent_at: new Date().toISOString(),
|
|
1676
1676
|
sdk: {
|
|
1677
1677
|
name: 'sentry.javascript.integration.replay',
|
|
1678
|
-
version: "0.
|
|
1678
|
+
version: "0.6.0",
|
|
1679
1679
|
},
|
|
1680
1680
|
}, [
|
|
1681
1681
|
[
|
|
@@ -1712,14 +1712,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1712
1712
|
});
|
|
1713
1713
|
});
|
|
1714
1714
|
};
|
|
1715
|
-
|
|
1715
|
+
Replay.prototype.resetRetries = function () {
|
|
1716
1716
|
this.retryCount = 0;
|
|
1717
1717
|
this.retryInterval = BASE_RETRY_INTERVAL;
|
|
1718
1718
|
};
|
|
1719
1719
|
/**
|
|
1720
1720
|
* Finalize and send the current replay event to Sentry
|
|
1721
1721
|
*/
|
|
1722
|
-
|
|
1722
|
+
Replay.prototype.sendReplay = function (replayId, events, segmentId) {
|
|
1723
1723
|
return __awaiter(this, void 0, void 0, function () {
|
|
1724
1724
|
var client, endpoint, ex_1;
|
|
1725
1725
|
var _this = this;
|
|
@@ -1792,8 +1792,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1792
1792
|
/**
|
|
1793
1793
|
* @inheritDoc
|
|
1794
1794
|
*/
|
|
1795
|
-
|
|
1796
|
-
return
|
|
1795
|
+
Replay.id = 'Replay';
|
|
1796
|
+
return Replay;
|
|
1797
1797
|
}());
|
|
1798
1798
|
|
|
1799
|
-
export {
|
|
1799
|
+
export { Replay };
|
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,15 +897,15 @@ 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
|
*/
|
|
@@ -1218,7 +1218,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1218
1218
|
* So we call `this.setup` in next event loop as a workaround to wait for
|
|
1219
1219
|
* other global event processors to finish
|
|
1220
1220
|
*/
|
|
1221
|
-
|
|
1221
|
+
Replay.prototype.setupOnce = function () {
|
|
1222
1222
|
var _this = this;
|
|
1223
1223
|
// XXX: See method comments above
|
|
1224
1224
|
window.setTimeout(function () { return _this.start(); });
|
|
@@ -1228,7 +1228,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1228
1228
|
*
|
|
1229
1229
|
* Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
|
|
1230
1230
|
*/
|
|
1231
|
-
|
|
1231
|
+
Replay.prototype.start = function () {
|
|
1232
1232
|
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
1233
1233
|
// If there is no session, then something bad has happened - can't continue
|
|
1234
1234
|
if (!this.session) {
|
|
@@ -1259,7 +1259,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1259
1259
|
* Accepts a callback to perform side-effects and returns true to stop batch
|
|
1260
1260
|
* processing and hand back control to caller.
|
|
1261
1261
|
*/
|
|
1262
|
-
|
|
1262
|
+
Replay.prototype.addUpdate = function (cb) {
|
|
1263
1263
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1264
1264
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1265
1265
|
// If this option is turned on then we will only want to call `flush`
|
|
@@ -1279,7 +1279,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1279
1279
|
/**
|
|
1280
1280
|
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
|
|
1281
1281
|
*/
|
|
1282
|
-
|
|
1282
|
+
Replay.prototype.stop = function () {
|
|
1283
1283
|
var _a, _b;
|
|
1284
1284
|
logger.log('Stopping Replays');
|
|
1285
1285
|
this.isEnabled = false;
|
|
@@ -1288,7 +1288,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1288
1288
|
(_b = this.eventBuffer) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
1289
1289
|
this.eventBuffer = null;
|
|
1290
1290
|
};
|
|
1291
|
-
|
|
1291
|
+
Replay.prototype.clearSession = function () {
|
|
1292
1292
|
deleteSession();
|
|
1293
1293
|
this.session = undefined;
|
|
1294
1294
|
};
|
|
@@ -1296,7 +1296,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1296
1296
|
* Loads a session from storage, or creates a new one if it does not exist or
|
|
1297
1297
|
* is expired.
|
|
1298
1298
|
*/
|
|
1299
|
-
|
|
1299
|
+
Replay.prototype.loadSession = function (_a) {
|
|
1300
1300
|
var _b, _c;
|
|
1301
1301
|
var expiry = _a.expiry;
|
|
1302
1302
|
var _d = getSession({
|
|
@@ -1321,7 +1321,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1321
1321
|
* replay. This is required because otherwise they would be captured at the
|
|
1322
1322
|
* first flush.
|
|
1323
1323
|
*/
|
|
1324
|
-
|
|
1324
|
+
Replay.prototype.setInitialState = function () {
|
|
1325
1325
|
var urlPath = "".concat(window.location.pathname).concat(window.location.hash).concat(window.location.search);
|
|
1326
1326
|
var url = "".concat(window.location.origin).concat(urlPath);
|
|
1327
1327
|
this.performanceEvents = [];
|
|
@@ -1336,7 +1336,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1336
1336
|
/**
|
|
1337
1337
|
* Adds listeners to record events for the replay
|
|
1338
1338
|
*/
|
|
1339
|
-
|
|
1339
|
+
Replay.prototype.addListeners = function () {
|
|
1340
1340
|
var _this = this;
|
|
1341
1341
|
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
1342
1342
|
window.addEventListener('blur', this.handleWindowBlur);
|
|
@@ -1385,7 +1385,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1385
1385
|
/**
|
|
1386
1386
|
* Cleans up listeners that were created in `addListeners`
|
|
1387
1387
|
*/
|
|
1388
|
-
|
|
1388
|
+
Replay.prototype.removeListeners = function () {
|
|
1389
1389
|
document.removeEventListener('visibilitychange', this.handleVisibilityChange);
|
|
1390
1390
|
window.removeEventListener('blur', this.handleWindowBlur);
|
|
1391
1391
|
window.removeEventListener('focus', this.handleWindowFocus);
|
|
@@ -1397,7 +1397,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1397
1397
|
/**
|
|
1398
1398
|
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
|
|
1399
1399
|
*/
|
|
1400
|
-
|
|
1400
|
+
Replay.prototype.doChangeToBackgroundTasks = function (breadcrumb) {
|
|
1401
1401
|
if (!this.session) {
|
|
1402
1402
|
return;
|
|
1403
1403
|
}
|
|
@@ -1413,7 +1413,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1413
1413
|
/**
|
|
1414
1414
|
* Tasks to run when we consider a page to be visible (via focus and/or visibility)
|
|
1415
1415
|
*/
|
|
1416
|
-
|
|
1416
|
+
Replay.prototype.doChangeToForegroundTasks = function (breadcrumb) {
|
|
1417
1417
|
if (!this.session) {
|
|
1418
1418
|
return;
|
|
1419
1419
|
}
|
|
@@ -1440,14 +1440,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1440
1440
|
* Trigger rrweb to take a full snapshot which will cause this plugin to
|
|
1441
1441
|
* create a new Replay event.
|
|
1442
1442
|
*/
|
|
1443
|
-
|
|
1443
|
+
Replay.prototype.triggerFullSnapshot = function () {
|
|
1444
1444
|
logger.log('Taking full rrweb snapshot');
|
|
1445
1445
|
rrweb.record.takeFullSnapshot(true);
|
|
1446
1446
|
};
|
|
1447
1447
|
/**
|
|
1448
1448
|
* Add an event to the event buffer
|
|
1449
1449
|
*/
|
|
1450
|
-
|
|
1450
|
+
Replay.prototype.addEvent = function (event, isCheckout) {
|
|
1451
1451
|
if (!this.eventBuffer) {
|
|
1452
1452
|
// This implies that `isEnabled` is false
|
|
1453
1453
|
return;
|
|
@@ -1468,7 +1468,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1468
1468
|
/**
|
|
1469
1469
|
* Updates the session's last activity timestamp
|
|
1470
1470
|
*/
|
|
1471
|
-
|
|
1471
|
+
Replay.prototype.updateLastActivity = function (lastActivity) {
|
|
1472
1472
|
if (lastActivity === void 0) { lastActivity = new Date().getTime(); }
|
|
1473
1473
|
if (this.session) {
|
|
1474
1474
|
this.session.lastActivity = lastActivity;
|
|
@@ -1477,7 +1477,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1477
1477
|
/**
|
|
1478
1478
|
* Helper to create (and buffer) a replay breadcrumb from a core SDK breadcrumb
|
|
1479
1479
|
*/
|
|
1480
|
-
|
|
1480
|
+
Replay.prototype.createCustomBreadcrumb = function (breadcrumb) {
|
|
1481
1481
|
var _this = this;
|
|
1482
1482
|
this.addUpdate(function () {
|
|
1483
1483
|
_this.addEvent({
|
|
@@ -1493,7 +1493,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1493
1493
|
/**
|
|
1494
1494
|
* Create a "span" for each performance entry. The parent transaction is `this.replayEvent`.
|
|
1495
1495
|
*/
|
|
1496
|
-
|
|
1496
|
+
Replay.prototype.createPerformanceSpans = function (entries) {
|
|
1497
1497
|
var _this = this;
|
|
1498
1498
|
return Promise.all(entries.map(function (_a) {
|
|
1499
1499
|
var type = _a.type, start = _a.start, end = _a.end, name = _a.name, data = _a.data;
|
|
@@ -1517,7 +1517,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1517
1517
|
* Observed performance events are added to `this.performanceEvents`. These
|
|
1518
1518
|
* are included in the replay event before it is finished and sent to Sentry.
|
|
1519
1519
|
*/
|
|
1520
|
-
|
|
1520
|
+
Replay.prototype.addPerformanceEntries = function () {
|
|
1521
1521
|
// Copy and reset entries before processing
|
|
1522
1522
|
var entries = __spreadArray([], this.performanceEvents, true);
|
|
1523
1523
|
this.performanceEvents = [];
|
|
@@ -1527,7 +1527,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1527
1527
|
* Create a "span" for the total amount of memory being used by JS objects
|
|
1528
1528
|
* (including v8 internal objects).
|
|
1529
1529
|
*/
|
|
1530
|
-
|
|
1530
|
+
Replay.prototype.addMemoryEntry = function () {
|
|
1531
1531
|
// window.performance.memory is a non-standard API and doesn't work on all browsers
|
|
1532
1532
|
// so we check before creating the event.
|
|
1533
1533
|
if (!('memory' in window.performance)) {
|
|
@@ -1543,7 +1543,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1543
1543
|
*
|
|
1544
1544
|
* Returns true if session is not expired, false otherwise.
|
|
1545
1545
|
*/
|
|
1546
|
-
|
|
1546
|
+
Replay.prototype.checkAndHandleExpiredSession = function (expiry) {
|
|
1547
1547
|
var _a, _b;
|
|
1548
1548
|
if (expiry === void 0) { expiry = SESSION_IDLE_DURATION; }
|
|
1549
1549
|
var oldSessionId = (_a = this.session) === null || _a === void 0 ? void 0 : _a.id;
|
|
@@ -1565,7 +1565,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1565
1565
|
/**
|
|
1566
1566
|
* Only flush if `captureOnlyOnError` is false.
|
|
1567
1567
|
*/
|
|
1568
|
-
|
|
1568
|
+
Replay.prototype.conditionalFlush = function () {
|
|
1569
1569
|
if (this.options.captureOnlyOnError) {
|
|
1570
1570
|
return;
|
|
1571
1571
|
}
|
|
@@ -1574,7 +1574,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1574
1574
|
/**
|
|
1575
1575
|
* Clear context
|
|
1576
1576
|
*/
|
|
1577
|
-
|
|
1577
|
+
Replay.prototype.clearContext = function () {
|
|
1578
1578
|
this.context.errorIds.clear();
|
|
1579
1579
|
this.context.traceIds.clear();
|
|
1580
1580
|
this.context.urls = [];
|
|
@@ -1583,7 +1583,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1583
1583
|
/**
|
|
1584
1584
|
* Return and clear context
|
|
1585
1585
|
*/
|
|
1586
|
-
|
|
1586
|
+
Replay.prototype.popEventContext = function (_a) {
|
|
1587
1587
|
var timestamp = _a.timestamp;
|
|
1588
1588
|
var initialState = this.initialState;
|
|
1589
1589
|
if (this.initialState &&
|
|
@@ -1609,7 +1609,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1609
1609
|
*
|
|
1610
1610
|
* Should never be called directly, only by `flush`
|
|
1611
1611
|
*/
|
|
1612
|
-
|
|
1612
|
+
Replay.prototype.runFlush = function () {
|
|
1613
1613
|
var _a, _b, _c;
|
|
1614
1614
|
return __awaiter(this, void 0, void 0, function () {
|
|
1615
1615
|
var stack, replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
@@ -1664,7 +1664,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1664
1664
|
/**
|
|
1665
1665
|
* Send replay attachment using `fetch()`
|
|
1666
1666
|
*/
|
|
1667
|
-
|
|
1667
|
+
Replay.prototype.sendReplayRequest = function (_a) {
|
|
1668
1668
|
var endpoint = _a.endpoint, events = _a.events, event_id = _a.replayId, segment_id = _a.segmentId;
|
|
1669
1669
|
return __awaiter(this, void 0, void 0, function () {
|
|
1670
1670
|
var payloadWithSequence, envelope, response, _b, _c;
|
|
@@ -1683,7 +1683,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1683
1683
|
sent_at: new Date().toISOString(),
|
|
1684
1684
|
sdk: {
|
|
1685
1685
|
name: 'sentry.javascript.integration.replay',
|
|
1686
|
-
version: "0.
|
|
1686
|
+
version: "0.6.0",
|
|
1687
1687
|
},
|
|
1688
1688
|
}, [
|
|
1689
1689
|
[
|
|
@@ -1720,14 +1720,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1720
1720
|
});
|
|
1721
1721
|
});
|
|
1722
1722
|
};
|
|
1723
|
-
|
|
1723
|
+
Replay.prototype.resetRetries = function () {
|
|
1724
1724
|
this.retryCount = 0;
|
|
1725
1725
|
this.retryInterval = BASE_RETRY_INTERVAL;
|
|
1726
1726
|
};
|
|
1727
1727
|
/**
|
|
1728
1728
|
* Finalize and send the current replay event to Sentry
|
|
1729
1729
|
*/
|
|
1730
|
-
|
|
1730
|
+
Replay.prototype.sendReplay = function (replayId, events, segmentId) {
|
|
1731
1731
|
return __awaiter(this, void 0, void 0, function () {
|
|
1732
1732
|
var client, endpoint, ex_1;
|
|
1733
1733
|
var _this = this;
|
|
@@ -1800,9 +1800,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1800
1800
|
/**
|
|
1801
1801
|
* @inheritDoc
|
|
1802
1802
|
*/
|
|
1803
|
-
|
|
1804
|
-
return
|
|
1803
|
+
Replay.id = 'Replay';
|
|
1804
|
+
return Replay;
|
|
1805
1805
|
}());
|
|
1806
1806
|
|
|
1807
|
-
exports.
|
|
1807
|
+
exports.Replay = Replay;
|
|
1808
1808
|
//# sourceMappingURL=index.js.map
|