@sentry/replay 0.5.18 → 0.5.20
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 +9 -8
- package/dist/config/types/src/coreHandlers/handleConsole.d.ts +1 -0
- package/dist/config/types/src/index.d.ts +3 -6
- package/dist/config/types/src/util/dedupeNavigationEntries.d.ts +10 -0
- package/dist/index.es.js +19 -35
- package/dist/index.js +20 -35
- package/dist/index.js.map +1 -1
- package/dist/types/src/coreHandlers/handleConsole.d.ts +1 -0
- package/dist/types/src/index.d.ts +3 -6
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -46,17 +46,18 @@ Sentry.init({
|
|
|
46
46
|
});
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
###
|
|
49
|
+
### Stop Recording
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
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
52
|
|
|
53
53
|
```javascript
|
|
54
54
|
|
|
55
|
-
const replay = new SentryReplay(); // This will begin recording replays
|
|
55
|
+
const replay = new SentryReplay(); // This will *NOT* begin recording replays
|
|
56
56
|
|
|
57
|
-
replay.
|
|
57
|
+
replay.start(); // Start recording
|
|
58
|
+
|
|
59
|
+
replay.stop(); // Stop recording
|
|
58
60
|
|
|
59
|
-
replay.setup(); // Start recording again
|
|
60
61
|
```
|
|
61
62
|
|
|
62
63
|
## Configuration
|
|
@@ -72,6 +73,6 @@ replay.setup(); // Start recording again
|
|
|
72
73
|
| `useCompression` | `boolean` | `true` | Uses `WebWorkers` (if available) to compress the recording payload before uploading to Sentry. |
|
|
73
74
|
| `captureOnlyOnError` | `boolean` | `false` | Only capture the recording when an error happens. |
|
|
74
75
|
| `recordingConfig.maskAllInputs` | `boolean` | `true` | Mask all `<input>` elements |
|
|
75
|
-
| `recordingConfig.blockClass` | `string` | `'
|
|
76
|
-
| `recordingConfig.ignoreClass` | `string` | `'
|
|
77
|
-
| `recordingConfig.maskTextClass` | `string` | `'
|
|
76
|
+
| `recordingConfig.blockClass` | `string` | `'sentry-block'` | Redact all elements with the class name `sentry-block` |
|
|
77
|
+
| `recordingConfig.ignoreClass` | `string` | `'sentry-ignore'` | Ignores all elements with the class name `sentry-ignore` |
|
|
78
|
+
| `recordingConfig.maskTextClass` | `string` | `'sentry-mask'` | Mask all elements with the class name `sentry-ignore` |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function handleConsole(handlerData: any): void;
|
|
@@ -28,10 +28,6 @@ export declare class SentryReplay implements Integration {
|
|
|
28
28
|
*/
|
|
29
29
|
readonly recordingOptions: RecordingConfig;
|
|
30
30
|
readonly options: SentryReplayPluginOptions;
|
|
31
|
-
/**
|
|
32
|
-
* setTimeout id used for debouncing sending rrweb attachments
|
|
33
|
-
*/
|
|
34
|
-
private timeout;
|
|
35
31
|
/**
|
|
36
32
|
* The timestamp of the first event since the last flush. This is used to
|
|
37
33
|
* determine if the maximum allowed time has passed before events should be
|
|
@@ -41,6 +37,7 @@ export declare class SentryReplay implements Integration {
|
|
|
41
37
|
private performanceObserver;
|
|
42
38
|
private retryCount;
|
|
43
39
|
private retryInterval;
|
|
40
|
+
private debouncedFlush;
|
|
44
41
|
/**
|
|
45
42
|
* Flag when a new session has been created. Captured replay events behave
|
|
46
43
|
* slightly differently in this case: `replay_start_timestamp` is included.
|
|
@@ -82,7 +79,7 @@ export declare class SentryReplay implements Integration {
|
|
|
82
79
|
*
|
|
83
80
|
* Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
|
|
84
81
|
*/
|
|
85
|
-
|
|
82
|
+
start(): void;
|
|
86
83
|
/**
|
|
87
84
|
* We want to batch uploads of replay events. Save events only if
|
|
88
85
|
* `<flushMinDelay>` milliseconds have elapsed since the last event
|
|
@@ -95,7 +92,7 @@ export declare class SentryReplay implements Integration {
|
|
|
95
92
|
/**
|
|
96
93
|
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
|
|
97
94
|
*/
|
|
98
|
-
|
|
95
|
+
stop(): void;
|
|
99
96
|
clearSession(): void;
|
|
100
97
|
/**
|
|
101
98
|
* Loads a session from storage, or creates a new one if it does not exist or
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* There are some difficulties diagnosing why there are duplicate navigation
|
|
3
|
+
* entries. We've witnessed several intermittent results:
|
|
4
|
+
* - duplicate entries have duration = 0
|
|
5
|
+
* - duplicate entries are the same object reference
|
|
6
|
+
* - none of the above
|
|
7
|
+
*
|
|
8
|
+
* Compare the values of several keys to determine if the entries are duplicates or not.
|
|
9
|
+
*/
|
|
10
|
+
export declare function dedupeNavigationEntries(currentList: PerformanceEntryList, newList: PerformanceNavigationTiming[]): PerformanceNavigationTiming[];
|
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 debounce from 'lodash.debounce';
|
|
3
4
|
import throttle from 'lodash.throttle';
|
|
4
5
|
import { record, EventType } from 'rrweb';
|
|
5
6
|
|
|
@@ -797,7 +798,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
797
798
|
function SentryReplay(_a) {
|
|
798
799
|
if (_a === void 0) { _a = {}; }
|
|
799
800
|
var _this = this;
|
|
800
|
-
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 ? '
|
|
801
|
+
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"]);
|
|
801
802
|
/**
|
|
802
803
|
* @inheritDoc
|
|
803
804
|
*/
|
|
@@ -1025,9 +1026,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1025
1026
|
*/
|
|
1026
1027
|
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1027
1028
|
var err_1;
|
|
1028
|
-
var _a;
|
|
1029
|
-
return __generator(this, function (
|
|
1030
|
-
switch (
|
|
1029
|
+
var _a, _b;
|
|
1030
|
+
return __generator(this, function (_c) {
|
|
1031
|
+
switch (_c.label) {
|
|
1031
1032
|
case 0:
|
|
1032
1033
|
if (!this.isEnabled) {
|
|
1033
1034
|
// This is just a precaution, there should be no listeners that would
|
|
@@ -1045,22 +1046,22 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1045
1046
|
// Since flushing, ensure other queued flushes are cancelled
|
|
1046
1047
|
// We do this regardless of having a queued flush since the event updates
|
|
1047
1048
|
// will be handled by queued flush
|
|
1048
|
-
|
|
1049
|
+
(_b = this.debouncedFlush) === null || _b === void 0 ? void 0 : _b.cancel();
|
|
1049
1050
|
if (!!this.flushLock) return [3 /*break*/, 2];
|
|
1050
1051
|
this.flushLock = this.runFlush();
|
|
1051
1052
|
return [4 /*yield*/, this.flushLock];
|
|
1052
1053
|
case 1:
|
|
1053
|
-
|
|
1054
|
+
_c.sent();
|
|
1054
1055
|
this.flushLock = null;
|
|
1055
1056
|
return [2 /*return*/];
|
|
1056
1057
|
case 2:
|
|
1057
|
-
|
|
1058
|
+
_c.trys.push([2, 4, 5, 6]);
|
|
1058
1059
|
return [4 /*yield*/, this.flushLock];
|
|
1059
1060
|
case 3:
|
|
1060
|
-
|
|
1061
|
+
_c.sent();
|
|
1061
1062
|
return [3 /*break*/, 6];
|
|
1062
1063
|
case 4:
|
|
1063
|
-
err_1 =
|
|
1064
|
+
err_1 = _c.sent();
|
|
1064
1065
|
console.error(err_1);
|
|
1065
1066
|
return [3 /*break*/, 6];
|
|
1066
1067
|
case 5:
|
|
@@ -1102,6 +1103,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1102
1103
|
// content masked.
|
|
1103
1104
|
this.recordingOptions.maskTextSelector = '*';
|
|
1104
1105
|
}
|
|
1106
|
+
this.debouncedFlush = debounce(function () { return _this.flush(); }, this.options.flushMinDelay, {
|
|
1107
|
+
maxWait: this.options.flushMaxDelay,
|
|
1108
|
+
});
|
|
1105
1109
|
}
|
|
1106
1110
|
/**
|
|
1107
1111
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
@@ -1115,14 +1119,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1115
1119
|
SentryReplay.prototype.setupOnce = function () {
|
|
1116
1120
|
var _this = this;
|
|
1117
1121
|
// XXX: See method comments above
|
|
1118
|
-
window.setTimeout(function () { return _this.
|
|
1122
|
+
window.setTimeout(function () { return _this.start(); });
|
|
1119
1123
|
};
|
|
1120
1124
|
/**
|
|
1121
1125
|
* Initializes the plugin.
|
|
1122
1126
|
*
|
|
1123
1127
|
* Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
|
|
1124
1128
|
*/
|
|
1125
|
-
SentryReplay.prototype.
|
|
1129
|
+
SentryReplay.prototype.start = function () {
|
|
1126
1130
|
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
1127
1131
|
// If there is no session, then something bad has happened - can't continue
|
|
1128
1132
|
if (!this.session) {
|
|
@@ -1154,7 +1158,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1154
1158
|
* processing and hand back control to caller.
|
|
1155
1159
|
*/
|
|
1156
1160
|
SentryReplay.prototype.addUpdate = function (cb) {
|
|
1157
|
-
var _this = this;
|
|
1158
1161
|
var now = new Date().getTime();
|
|
1159
1162
|
// Timestamp of the first replay event since the last flush, this gets
|
|
1160
1163
|
// reset when we finish the replay event
|
|
@@ -1162,10 +1165,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1162
1165
|
!this.options.captureOnlyOnError) {
|
|
1163
1166
|
this.initialEventTimestampSinceFlush = now;
|
|
1164
1167
|
}
|
|
1165
|
-
// Do not finish the replay event if we receive a new replay event
|
|
1166
|
-
if (this.timeout) {
|
|
1167
|
-
window.clearTimeout(this.timeout);
|
|
1168
|
-
}
|
|
1169
1168
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1170
1169
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1171
1170
|
// If this option is turned on then we will only want to call `flush`
|
|
@@ -1178,26 +1177,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1178
1177
|
if (cbResult === true) {
|
|
1179
1178
|
return;
|
|
1180
1179
|
}
|
|
1181
|
-
|
|
1182
|
-
// If `flushMaxDelayExceeded` is true, then we should finish the replay event immediately,
|
|
1183
|
-
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1184
|
-
if (flushMaxDelayExceeded) {
|
|
1185
|
-
logger.log('replay max delay exceeded, finishing replay event');
|
|
1186
|
-
this.flush();
|
|
1187
|
-
return;
|
|
1188
|
-
}
|
|
1189
|
-
// Set timer to finish replay event and send replay attachment to
|
|
1190
|
-
// Sentry. Will be cancelled if an event happens before `flushMinDelay`
|
|
1191
|
-
// elapses.
|
|
1192
|
-
this.timeout = window.setTimeout(function () {
|
|
1193
|
-
logger.log('replay timeout exceeded, finishing replay event');
|
|
1194
|
-
_this.flush();
|
|
1195
|
-
}, this.options.flushMinDelay);
|
|
1180
|
+
this.debouncedFlush();
|
|
1196
1181
|
};
|
|
1197
1182
|
/**
|
|
1198
1183
|
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
|
|
1199
1184
|
*/
|
|
1200
|
-
SentryReplay.prototype.
|
|
1185
|
+
SentryReplay.prototype.stop = function () {
|
|
1201
1186
|
var _a, _b;
|
|
1202
1187
|
logger.log('Stopping Replays');
|
|
1203
1188
|
this.isEnabled = false;
|
|
@@ -1529,7 +1514,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1529
1514
|
SentryReplay.prototype.runFlush = function () {
|
|
1530
1515
|
var _a;
|
|
1531
1516
|
return __awaiter(this, void 0, void 0, function () {
|
|
1532
|
-
var
|
|
1517
|
+
var replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
1533
1518
|
return __generator(this, function (_b) {
|
|
1534
1519
|
switch (_b.label) {
|
|
1535
1520
|
case 0:
|
|
@@ -1548,7 +1533,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1548
1533
|
case 2:
|
|
1549
1534
|
// Only attach memory event if eventBuffer is not empty
|
|
1550
1535
|
_b.sent();
|
|
1551
|
-
timestamp = new Date().getTime();
|
|
1552
1536
|
replayId = this.session.id;
|
|
1553
1537
|
newSessionCreated = this.newSessionCreated;
|
|
1554
1538
|
segmentId = this.session.segmentId++;
|
|
@@ -1565,7 +1549,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1565
1549
|
case 5:
|
|
1566
1550
|
_b.sent();
|
|
1567
1551
|
// The below will only happen after successfully sending replay //
|
|
1568
|
-
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp:
|
|
1552
|
+
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp: new Date().getTime() })), { replayId: replayId, segmentId: segmentId, includeReplayStartTimestamp: newSessionCreated }));
|
|
1569
1553
|
this.newSessionCreated = false;
|
|
1570
1554
|
return [3 /*break*/, 7];
|
|
1571
1555
|
case 6:
|
package/dist/index.js
CHANGED
|
@@ -4,11 +4,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var core = require('@sentry/core');
|
|
6
6
|
var utils = require('@sentry/utils');
|
|
7
|
+
var debounce = require('lodash.debounce');
|
|
7
8
|
var throttle = require('lodash.throttle');
|
|
8
9
|
var rrweb = require('rrweb');
|
|
9
10
|
|
|
10
11
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
12
|
|
|
13
|
+
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
12
14
|
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle);
|
|
13
15
|
|
|
14
16
|
/******************************************************************************
|
|
@@ -805,7 +807,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
805
807
|
function SentryReplay(_a) {
|
|
806
808
|
if (_a === void 0) { _a = {}; }
|
|
807
809
|
var _this = this;
|
|
808
|
-
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 ? '
|
|
810
|
+
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"]);
|
|
809
811
|
/**
|
|
810
812
|
* @inheritDoc
|
|
811
813
|
*/
|
|
@@ -1033,9 +1035,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1033
1035
|
*/
|
|
1034
1036
|
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1035
1037
|
var err_1;
|
|
1036
|
-
var _a;
|
|
1037
|
-
return __generator(this, function (
|
|
1038
|
-
switch (
|
|
1038
|
+
var _a, _b;
|
|
1039
|
+
return __generator(this, function (_c) {
|
|
1040
|
+
switch (_c.label) {
|
|
1039
1041
|
case 0:
|
|
1040
1042
|
if (!this.isEnabled) {
|
|
1041
1043
|
// This is just a precaution, there should be no listeners that would
|
|
@@ -1053,22 +1055,22 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1053
1055
|
// Since flushing, ensure other queued flushes are cancelled
|
|
1054
1056
|
// We do this regardless of having a queued flush since the event updates
|
|
1055
1057
|
// will be handled by queued flush
|
|
1056
|
-
|
|
1058
|
+
(_b = this.debouncedFlush) === null || _b === void 0 ? void 0 : _b.cancel();
|
|
1057
1059
|
if (!!this.flushLock) return [3 /*break*/, 2];
|
|
1058
1060
|
this.flushLock = this.runFlush();
|
|
1059
1061
|
return [4 /*yield*/, this.flushLock];
|
|
1060
1062
|
case 1:
|
|
1061
|
-
|
|
1063
|
+
_c.sent();
|
|
1062
1064
|
this.flushLock = null;
|
|
1063
1065
|
return [2 /*return*/];
|
|
1064
1066
|
case 2:
|
|
1065
|
-
|
|
1067
|
+
_c.trys.push([2, 4, 5, 6]);
|
|
1066
1068
|
return [4 /*yield*/, this.flushLock];
|
|
1067
1069
|
case 3:
|
|
1068
|
-
|
|
1070
|
+
_c.sent();
|
|
1069
1071
|
return [3 /*break*/, 6];
|
|
1070
1072
|
case 4:
|
|
1071
|
-
err_1 =
|
|
1073
|
+
err_1 = _c.sent();
|
|
1072
1074
|
console.error(err_1);
|
|
1073
1075
|
return [3 /*break*/, 6];
|
|
1074
1076
|
case 5:
|
|
@@ -1110,6 +1112,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1110
1112
|
// content masked.
|
|
1111
1113
|
this.recordingOptions.maskTextSelector = '*';
|
|
1112
1114
|
}
|
|
1115
|
+
this.debouncedFlush = debounce__default["default"](function () { return _this.flush(); }, this.options.flushMinDelay, {
|
|
1116
|
+
maxWait: this.options.flushMaxDelay,
|
|
1117
|
+
});
|
|
1113
1118
|
}
|
|
1114
1119
|
/**
|
|
1115
1120
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
@@ -1123,14 +1128,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1123
1128
|
SentryReplay.prototype.setupOnce = function () {
|
|
1124
1129
|
var _this = this;
|
|
1125
1130
|
// XXX: See method comments above
|
|
1126
|
-
window.setTimeout(function () { return _this.
|
|
1131
|
+
window.setTimeout(function () { return _this.start(); });
|
|
1127
1132
|
};
|
|
1128
1133
|
/**
|
|
1129
1134
|
* Initializes the plugin.
|
|
1130
1135
|
*
|
|
1131
1136
|
* Creates or loads a session, attaches listeners to varying events (DOM, PerformanceObserver, Recording, Sentry SDK, etc)
|
|
1132
1137
|
*/
|
|
1133
|
-
SentryReplay.prototype.
|
|
1138
|
+
SentryReplay.prototype.start = function () {
|
|
1134
1139
|
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
1135
1140
|
// If there is no session, then something bad has happened - can't continue
|
|
1136
1141
|
if (!this.session) {
|
|
@@ -1162,7 +1167,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1162
1167
|
* processing and hand back control to caller.
|
|
1163
1168
|
*/
|
|
1164
1169
|
SentryReplay.prototype.addUpdate = function (cb) {
|
|
1165
|
-
var _this = this;
|
|
1166
1170
|
var now = new Date().getTime();
|
|
1167
1171
|
// Timestamp of the first replay event since the last flush, this gets
|
|
1168
1172
|
// reset when we finish the replay event
|
|
@@ -1170,10 +1174,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1170
1174
|
!this.options.captureOnlyOnError) {
|
|
1171
1175
|
this.initialEventTimestampSinceFlush = now;
|
|
1172
1176
|
}
|
|
1173
|
-
// Do not finish the replay event if we receive a new replay event
|
|
1174
|
-
if (this.timeout) {
|
|
1175
|
-
window.clearTimeout(this.timeout);
|
|
1176
|
-
}
|
|
1177
1177
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1178
1178
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1179
1179
|
// If this option is turned on then we will only want to call `flush`
|
|
@@ -1186,26 +1186,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1186
1186
|
if (cbResult === true) {
|
|
1187
1187
|
return;
|
|
1188
1188
|
}
|
|
1189
|
-
|
|
1190
|
-
// If `flushMaxDelayExceeded` is true, then we should finish the replay event immediately,
|
|
1191
|
-
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1192
|
-
if (flushMaxDelayExceeded) {
|
|
1193
|
-
logger.log('replay max delay exceeded, finishing replay event');
|
|
1194
|
-
this.flush();
|
|
1195
|
-
return;
|
|
1196
|
-
}
|
|
1197
|
-
// Set timer to finish replay event and send replay attachment to
|
|
1198
|
-
// Sentry. Will be cancelled if an event happens before `flushMinDelay`
|
|
1199
|
-
// elapses.
|
|
1200
|
-
this.timeout = window.setTimeout(function () {
|
|
1201
|
-
logger.log('replay timeout exceeded, finishing replay event');
|
|
1202
|
-
_this.flush();
|
|
1203
|
-
}, this.options.flushMinDelay);
|
|
1189
|
+
this.debouncedFlush();
|
|
1204
1190
|
};
|
|
1205
1191
|
/**
|
|
1206
1192
|
* Currently, this needs to be manually called (e.g. for tests). Sentry SDK does not support a teardown
|
|
1207
1193
|
*/
|
|
1208
|
-
SentryReplay.prototype.
|
|
1194
|
+
SentryReplay.prototype.stop = function () {
|
|
1209
1195
|
var _a, _b;
|
|
1210
1196
|
logger.log('Stopping Replays');
|
|
1211
1197
|
this.isEnabled = false;
|
|
@@ -1537,7 +1523,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1537
1523
|
SentryReplay.prototype.runFlush = function () {
|
|
1538
1524
|
var _a;
|
|
1539
1525
|
return __awaiter(this, void 0, void 0, function () {
|
|
1540
|
-
var
|
|
1526
|
+
var replayId, newSessionCreated, segmentId, recordingData, err_2;
|
|
1541
1527
|
return __generator(this, function (_b) {
|
|
1542
1528
|
switch (_b.label) {
|
|
1543
1529
|
case 0:
|
|
@@ -1556,7 +1542,6 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1556
1542
|
case 2:
|
|
1557
1543
|
// Only attach memory event if eventBuffer is not empty
|
|
1558
1544
|
_b.sent();
|
|
1559
|
-
timestamp = new Date().getTime();
|
|
1560
1545
|
replayId = this.session.id;
|
|
1561
1546
|
newSessionCreated = this.newSessionCreated;
|
|
1562
1547
|
segmentId = this.session.segmentId++;
|
|
@@ -1573,7 +1558,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1573
1558
|
case 5:
|
|
1574
1559
|
_b.sent();
|
|
1575
1560
|
// The below will only happen after successfully sending replay //
|
|
1576
|
-
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp:
|
|
1561
|
+
captureReplayEvent(__assign(__assign({}, this.popEventContext({ timestamp: new Date().getTime() })), { replayId: replayId, segmentId: segmentId, includeReplayStartTimestamp: newSessionCreated }));
|
|
1577
1562
|
this.newSessionCreated = false;
|
|
1578
1563
|
return [3 /*break*/, 7];
|
|
1579
1564
|
case 6:
|