@sentry/replay 0.5.16 → 0.5.18
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 +3 -2
- package/dist/config/types/src/flush.test.d.ts +1 -0
- package/dist/config/types/src/index.d.ts +16 -6
- package/dist/config/types/src/types.d.ts +4 -0
- package/dist/index.es.js +53 -40
- package/dist/index.js +53 -40
- package/dist/index.js.map +1 -1
- package/dist/types/src/index.d.ts +16 -6
- package/dist/types/src/types.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ Sentry.init({
|
|
|
36
36
|
dsn: '__DSN__',
|
|
37
37
|
integrations: [
|
|
38
38
|
new SentryReplay({
|
|
39
|
-
|
|
39
|
+
maskAllText: true, // Will mask all text strings
|
|
40
40
|
recordingConfig: {
|
|
41
41
|
maskAllInputs: false, // Default is true
|
|
42
42
|
},
|
|
@@ -66,10 +66,11 @@ replay.setup(); // Start recording again
|
|
|
66
66
|
| `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. |
|
|
67
67
|
| `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. |
|
|
68
68
|
| `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. |
|
|
69
|
+
| `maskAllText` | `boolean` | `false` | Mask *all* text strings with `*`. |
|
|
70
|
+
| `replaysSamplingRate` | `number` | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
|
|
69
71
|
| `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
72
|
| `useCompression` | `boolean` | `true` | Uses `WebWorkers` (if available) to compress the recording payload before uploading to Sentry. |
|
|
71
73
|
| `captureOnlyOnError` | `boolean` | `false` | Only capture the recording when an error happens. |
|
|
72
|
-
| `replaysSamplingRate` | `number` | `1.0` | The rate at which to sample replays. (1.0 will collect all replays, 0 will collect no replays). |
|
|
73
74
|
| `recordingConfig.maskAllInputs` | `boolean` | `true` | Mask all `<input>` elements |
|
|
74
75
|
| `recordingConfig.blockClass` | `string` | `'sr-block'` | Redact all elements with the class name `sr-block` |
|
|
75
76
|
| `recordingConfig.ignoreClass` | `string` | `'sr-ignore'` | Ignores all elements with the class name `sr-ignore` |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -66,7 +66,7 @@ export declare class SentryReplay implements Integration {
|
|
|
66
66
|
private initialState;
|
|
67
67
|
private context;
|
|
68
68
|
session: Session | undefined;
|
|
69
|
-
constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
|
|
69
|
+
constructor({ flushMinDelay, flushMaxDelay, initialFlushDelay, stickySession, useCompression, captureOnlyOnError, replaysSamplingRate, maskAllText, recordingConfig: { maskAllInputs, blockClass, ignoreClass, maskTextClass, ...recordingOptions }, }?: SentryReplayConfiguration);
|
|
70
70
|
/**
|
|
71
71
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
72
72
|
* transaction before some native SDK integrations have run and applied their
|
|
@@ -221,15 +221,25 @@ export declare class SentryReplay implements Integration {
|
|
|
221
221
|
popEventContext({ timestamp, }: {
|
|
222
222
|
timestamp: number;
|
|
223
223
|
}): Omit<CaptureReplayEventParams, 'includeReplayStartTimestamp' | 'segmentId' | 'replayId'>;
|
|
224
|
-
runFlush(): Promise<void>;
|
|
225
224
|
/**
|
|
226
225
|
* Flushes replay event buffer to Sentry.
|
|
227
226
|
*
|
|
228
|
-
* Performance events are only added right before flushing - this is
|
|
227
|
+
* Performance events are only added right before flushing - this is
|
|
229
228
|
* due to the buffered performance observer events.
|
|
230
229
|
*/
|
|
231
|
-
|
|
232
|
-
|
|
230
|
+
runFlush(): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
233
|
+
* can be active at a time.
|
|
234
|
+
*/
|
|
235
|
+
flush: () => Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* A throttled `flush()` that is called after a flush is completed and there
|
|
238
|
+
* are other queued flushes.
|
|
239
|
+
*
|
|
240
|
+
* Instead of calling a flush for every <n> queued flush, condense it to a single call
|
|
241
|
+
*/
|
|
242
|
+
throttledFlush: import("lodash").DebouncedFunc<() => Promise<void>>;
|
|
233
243
|
/**
|
|
234
244
|
* Send replay attachment using `fetch()`
|
|
235
245
|
*/
|
|
@@ -238,6 +248,6 @@ export declare class SentryReplay implements Integration {
|
|
|
238
248
|
/**
|
|
239
249
|
* Finalize and send the current replay event to Sentry
|
|
240
250
|
*/
|
|
241
|
-
sendReplay(replayId: string, events: RecordedEvents, segmentId: number): Promise<
|
|
251
|
+
sendReplay(replayId: string, events: RecordedEvents, segmentId: number): Promise<unknown>;
|
|
242
252
|
}
|
|
243
253
|
export {};
|
|
@@ -61,6 +61,10 @@ export interface SentryReplayPluginOptions {
|
|
|
61
61
|
* The sampling rate for replays. 1.0 will record all replays, 0 will record none.
|
|
62
62
|
*/
|
|
63
63
|
replaysSamplingRate?: number;
|
|
64
|
+
/**
|
|
65
|
+
* Mask all text in recordings. All text will be replaced with asterisks by default.
|
|
66
|
+
*/
|
|
67
|
+
maskAllText?: boolean;
|
|
64
68
|
}
|
|
65
69
|
export interface SentryReplayConfiguration extends SentryReplayPluginOptions {
|
|
66
70
|
/**
|
package/dist/index.es.js
CHANGED
|
@@ -164,6 +164,11 @@ function getBreadcrumbHandler(type) {
|
|
|
164
164
|
function isIngestHost(targetHost) {
|
|
165
165
|
var _a;
|
|
166
166
|
var _b = ((_a = getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getDsn()) || {}, protocol = _b.protocol, host = _b.host;
|
|
167
|
+
// XXX: Special case when this integration is used by Sentry on `sentry.io`
|
|
168
|
+
// We would like to capture network requests made to our ingest endpoints for debugging
|
|
169
|
+
if (window.location.host === 'sentry.io') {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
167
172
|
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
168
173
|
}
|
|
169
174
|
|
|
@@ -787,12 +792,12 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
787
792
|
|
|
788
793
|
var BASE_RETRY_INTERVAL = 5000;
|
|
789
794
|
var MAX_RETRY_COUNT = 3;
|
|
790
|
-
var UNABLE_TO_SEND_REPLAY = 'Unable to send
|
|
795
|
+
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
791
796
|
var SentryReplay = /** @class */ (function () {
|
|
792
797
|
function SentryReplay(_a) {
|
|
793
798
|
if (_a === void 0) { _a = {}; }
|
|
794
799
|
var _this = this;
|
|
795
|
-
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.
|
|
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 ? 'sr-block' : _o, _p = _l.ignoreClass, ignoreClass = _p === void 0 ? 'sr-ignore' : _p, _q = _l.maskTextClass, maskTextClass = _q === void 0 ? 'sr-mask' : _q, recordingOptions = __rest(_l, ["maskAllInputs", "blockClass", "ignoreClass", "maskTextClass"]);
|
|
796
801
|
/**
|
|
797
802
|
* @inheritDoc
|
|
798
803
|
*/
|
|
@@ -866,7 +871,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
866
871
|
) {
|
|
867
872
|
// TODO: Do we continue to record after?
|
|
868
873
|
// TODO: What happens if another error happens? Do we record in the same session?
|
|
869
|
-
setTimeout(function () { return _this.
|
|
874
|
+
setTimeout(function () { return _this.flush(); });
|
|
870
875
|
}
|
|
871
876
|
return event;
|
|
872
877
|
};
|
|
@@ -1015,12 +1020,10 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1015
1020
|
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), Array.from(newEntries), true);
|
|
1016
1021
|
};
|
|
1017
1022
|
/**
|
|
1018
|
-
*
|
|
1019
|
-
*
|
|
1020
|
-
* Performance events are only added right before flushing - this is probably
|
|
1021
|
-
* due to the buffered performance observer events.
|
|
1023
|
+
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
1024
|
+
* can be active at a time.
|
|
1022
1025
|
*/
|
|
1023
|
-
this.
|
|
1026
|
+
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1024
1027
|
var err_1;
|
|
1025
1028
|
var _a;
|
|
1026
1029
|
return __generator(this, function (_b) {
|
|
@@ -1061,13 +1064,19 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1061
1064
|
console.error(err_1);
|
|
1062
1065
|
return [3 /*break*/, 6];
|
|
1063
1066
|
case 5:
|
|
1064
|
-
this.
|
|
1067
|
+
this.throttledFlush();
|
|
1065
1068
|
return [7 /*endfinally*/];
|
|
1066
1069
|
case 6: return [2 /*return*/];
|
|
1067
1070
|
}
|
|
1068
1071
|
});
|
|
1069
1072
|
}); };
|
|
1070
|
-
|
|
1073
|
+
/**
|
|
1074
|
+
* A throttled `flush()` that is called after a flush is completed and there
|
|
1075
|
+
* are other queued flushes.
|
|
1076
|
+
*
|
|
1077
|
+
* Instead of calling a flush for every <n> queued flush, condense it to a single call
|
|
1078
|
+
*/
|
|
1079
|
+
this.throttledFlush = throttle(this.flush, 1000, {
|
|
1071
1080
|
leading: false,
|
|
1072
1081
|
trailing: true,
|
|
1073
1082
|
});
|
|
@@ -1080,12 +1089,19 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1080
1089
|
captureOnlyOnError: captureOnlyOnError,
|
|
1081
1090
|
replaysSamplingRate: replaysSamplingRate,
|
|
1082
1091
|
useCompression: useCompression,
|
|
1092
|
+
maskAllText: maskAllText,
|
|
1083
1093
|
};
|
|
1084
1094
|
// Modify rrweb options to checkoutEveryNthSecond if this is defined, as we don't know when an error occurs, so we want to try to minimize the number of events captured.
|
|
1085
1095
|
if (this.options.captureOnlyOnError) {
|
|
1086
1096
|
// Checkout every minute, meaning we only get up-to one minute of events before the error happens
|
|
1087
1097
|
this.recordingOptions.checkoutEveryNms = 60000;
|
|
1088
1098
|
}
|
|
1099
|
+
if (this.options.maskAllText) {
|
|
1100
|
+
// `maskAllText` is a more user friendly option to configure
|
|
1101
|
+
// `maskTextSelector`. This means that all nodes will have their text
|
|
1102
|
+
// content masked.
|
|
1103
|
+
this.recordingOptions.maskTextSelector = '*';
|
|
1104
|
+
}
|
|
1089
1105
|
}
|
|
1090
1106
|
/**
|
|
1091
1107
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
@@ -1152,7 +1168,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1152
1168
|
}
|
|
1153
1169
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1154
1170
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1155
|
-
// If this option is turned on then we will only want to call `
|
|
1171
|
+
// If this option is turned on then we will only want to call `flush`
|
|
1156
1172
|
// explicitly
|
|
1157
1173
|
if (this.options.captureOnlyOnError) {
|
|
1158
1174
|
return;
|
|
@@ -1167,7 +1183,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1167
1183
|
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1168
1184
|
if (flushMaxDelayExceeded) {
|
|
1169
1185
|
logger.log('replay max delay exceeded, finishing replay event');
|
|
1170
|
-
this.
|
|
1186
|
+
this.flush();
|
|
1171
1187
|
return;
|
|
1172
1188
|
}
|
|
1173
1189
|
// Set timer to finish replay event and send replay attachment to
|
|
@@ -1175,7 +1191,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1175
1191
|
// elapses.
|
|
1176
1192
|
this.timeout = window.setTimeout(function () {
|
|
1177
1193
|
logger.log('replay timeout exceeded, finishing replay event');
|
|
1178
|
-
_this.
|
|
1194
|
+
_this.flush();
|
|
1179
1195
|
}, this.options.flushMinDelay);
|
|
1180
1196
|
};
|
|
1181
1197
|
/**
|
|
@@ -1183,7 +1199,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1183
1199
|
*/
|
|
1184
1200
|
SentryReplay.prototype.destroy = function () {
|
|
1185
1201
|
var _a, _b;
|
|
1186
|
-
logger.log('
|
|
1202
|
+
logger.log('Stopping Replays');
|
|
1187
1203
|
this.isEnabled = false;
|
|
1188
1204
|
this.removeListeners();
|
|
1189
1205
|
(_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -1472,7 +1488,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1472
1488
|
if (this.options.captureOnlyOnError) {
|
|
1473
1489
|
return;
|
|
1474
1490
|
}
|
|
1475
|
-
return this.
|
|
1491
|
+
return this.flush();
|
|
1476
1492
|
};
|
|
1477
1493
|
/**
|
|
1478
1494
|
* Clear context
|
|
@@ -1504,6 +1520,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1504
1520
|
this.clearContext();
|
|
1505
1521
|
return context;
|
|
1506
1522
|
};
|
|
1523
|
+
/**
|
|
1524
|
+
* Flushes replay event buffer to Sentry.
|
|
1525
|
+
*
|
|
1526
|
+
* Performance events are only added right before flushing - this is
|
|
1527
|
+
* due to the buffered performance observer events.
|
|
1528
|
+
*/
|
|
1507
1529
|
SentryReplay.prototype.runFlush = function () {
|
|
1508
1530
|
var _a;
|
|
1509
1531
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1623,8 +1645,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1623
1645
|
return __awaiter(this, void 0, void 0, function () {
|
|
1624
1646
|
var client, endpoint, ex_1;
|
|
1625
1647
|
var _this = this;
|
|
1626
|
-
return __generator(this, function (
|
|
1627
|
-
switch (
|
|
1648
|
+
return __generator(this, function (_a) {
|
|
1649
|
+
switch (_a.label) {
|
|
1628
1650
|
case 0:
|
|
1629
1651
|
// short circuit if there's no events to upload
|
|
1630
1652
|
if (!events.length) {
|
|
@@ -1632,9 +1654,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1632
1654
|
}
|
|
1633
1655
|
client = getCurrentHub().getClient();
|
|
1634
1656
|
endpoint = getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1635
|
-
|
|
1657
|
+
_a.label = 1;
|
|
1636
1658
|
case 1:
|
|
1637
|
-
|
|
1659
|
+
_a.trys.push([1, 3, , 5]);
|
|
1638
1660
|
return [4 /*yield*/, this.sendReplayRequest({
|
|
1639
1661
|
endpoint: endpoint,
|
|
1640
1662
|
events: events,
|
|
@@ -1642,11 +1664,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1642
1664
|
segmentId: segmentId,
|
|
1643
1665
|
})];
|
|
1644
1666
|
case 2:
|
|
1645
|
-
|
|
1667
|
+
_a.sent();
|
|
1646
1668
|
this.resetRetries();
|
|
1647
1669
|
return [2 /*return*/, true];
|
|
1648
1670
|
case 3:
|
|
1649
|
-
ex_1 =
|
|
1671
|
+
ex_1 = _a.sent();
|
|
1650
1672
|
console.error(ex_1);
|
|
1651
1673
|
// Capture error for every failed replay
|
|
1652
1674
|
// TODO: Remove this before GA as this will create an error on customer's project
|
|
@@ -1657,43 +1679,34 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1657
1679
|
// If an error happened here, it's likely that uploading the attachment
|
|
1658
1680
|
// failed, we'll can retry with the same events payload
|
|
1659
1681
|
if (this.retryCount >= MAX_RETRY_COUNT) {
|
|
1660
|
-
|
|
1661
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1682
|
+
throw new Error("".concat(UNABLE_TO_SEND_REPLAY, " - max retries exceeded"));
|
|
1662
1683
|
}
|
|
1663
1684
|
this.retryCount = this.retryCount + 1;
|
|
1664
1685
|
// will retry in intervals of 5, 10, 30
|
|
1665
1686
|
this.retryInterval = this.retryCount * this.retryInterval;
|
|
1666
|
-
_b.label = 4;
|
|
1667
|
-
case 4:
|
|
1668
|
-
_b.trys.push([4, 6, , 7]);
|
|
1669
1687
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
1670
1688
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1671
|
-
|
|
1672
|
-
|
|
1689
|
+
var err_3;
|
|
1690
|
+
return __generator(this, function (_a) {
|
|
1691
|
+
switch (_a.label) {
|
|
1673
1692
|
case 0:
|
|
1674
|
-
|
|
1693
|
+
_a.trys.push([0, 2, , 3]);
|
|
1675
1694
|
return [4 /*yield*/, this.sendReplay(replayId, events, segmentId)];
|
|
1676
1695
|
case 1:
|
|
1677
|
-
|
|
1696
|
+
_a.sent();
|
|
1678
1697
|
resolve(true);
|
|
1679
1698
|
return [3 /*break*/, 3];
|
|
1680
1699
|
case 2:
|
|
1681
|
-
|
|
1682
|
-
reject(
|
|
1700
|
+
err_3 = _a.sent();
|
|
1701
|
+
reject(err_3);
|
|
1683
1702
|
return [3 /*break*/, 3];
|
|
1684
1703
|
case 3: return [2 /*return*/];
|
|
1685
1704
|
}
|
|
1686
1705
|
});
|
|
1687
1706
|
}); }, _this.retryInterval);
|
|
1688
1707
|
})];
|
|
1689
|
-
case
|
|
1690
|
-
|
|
1691
|
-
return [2 /*return*/, true];
|
|
1692
|
-
case 6:
|
|
1693
|
-
_b.sent();
|
|
1694
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1695
|
-
case 7: return [3 /*break*/, 8];
|
|
1696
|
-
case 8: return [2 /*return*/];
|
|
1708
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
1709
|
+
case 5: return [2 /*return*/];
|
|
1697
1710
|
}
|
|
1698
1711
|
});
|
|
1699
1712
|
});
|
package/dist/index.js
CHANGED
|
@@ -172,6 +172,11 @@ function getBreadcrumbHandler(type) {
|
|
|
172
172
|
function isIngestHost(targetHost) {
|
|
173
173
|
var _a;
|
|
174
174
|
var _b = ((_a = core.getCurrentHub().getClient()) === null || _a === void 0 ? void 0 : _a.getDsn()) || {}, protocol = _b.protocol, host = _b.host;
|
|
175
|
+
// XXX: Special case when this integration is used by Sentry on `sentry.io`
|
|
176
|
+
// We would like to capture network requests made to our ingest endpoints for debugging
|
|
177
|
+
if (window.location.host === 'sentry.io') {
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
175
180
|
return targetHost.startsWith("".concat(protocol, "://").concat(host));
|
|
176
181
|
}
|
|
177
182
|
|
|
@@ -795,12 +800,12 @@ var EventBufferCompressionWorker = /** @class */ (function () {
|
|
|
795
800
|
|
|
796
801
|
var BASE_RETRY_INTERVAL = 5000;
|
|
797
802
|
var MAX_RETRY_COUNT = 3;
|
|
798
|
-
var UNABLE_TO_SEND_REPLAY = 'Unable to send
|
|
803
|
+
var UNABLE_TO_SEND_REPLAY = 'Unable to send Replay';
|
|
799
804
|
var SentryReplay = /** @class */ (function () {
|
|
800
805
|
function SentryReplay(_a) {
|
|
801
806
|
if (_a === void 0) { _a = {}; }
|
|
802
807
|
var _this = this;
|
|
803
|
-
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.
|
|
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 ? 'sr-block' : _o, _p = _l.ignoreClass, ignoreClass = _p === void 0 ? 'sr-ignore' : _p, _q = _l.maskTextClass, maskTextClass = _q === void 0 ? 'sr-mask' : _q, recordingOptions = __rest(_l, ["maskAllInputs", "blockClass", "ignoreClass", "maskTextClass"]);
|
|
804
809
|
/**
|
|
805
810
|
* @inheritDoc
|
|
806
811
|
*/
|
|
@@ -874,7 +879,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
874
879
|
) {
|
|
875
880
|
// TODO: Do we continue to record after?
|
|
876
881
|
// TODO: What happens if another error happens? Do we record in the same session?
|
|
877
|
-
setTimeout(function () { return _this.
|
|
882
|
+
setTimeout(function () { return _this.flush(); });
|
|
878
883
|
}
|
|
879
884
|
return event;
|
|
880
885
|
};
|
|
@@ -1023,12 +1028,10 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1023
1028
|
_this.performanceEvents = __spreadArray(__spreadArray([], _this.performanceEvents, true), Array.from(newEntries), true);
|
|
1024
1029
|
};
|
|
1025
1030
|
/**
|
|
1026
|
-
*
|
|
1027
|
-
*
|
|
1028
|
-
* Performance events are only added right before flushing - this is probably
|
|
1029
|
-
* due to the buffered performance observer events.
|
|
1031
|
+
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
1032
|
+
* can be active at a time.
|
|
1030
1033
|
*/
|
|
1031
|
-
this.
|
|
1034
|
+
this.flush = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1032
1035
|
var err_1;
|
|
1033
1036
|
var _a;
|
|
1034
1037
|
return __generator(this, function (_b) {
|
|
@@ -1069,13 +1072,19 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1069
1072
|
console.error(err_1);
|
|
1070
1073
|
return [3 /*break*/, 6];
|
|
1071
1074
|
case 5:
|
|
1072
|
-
this.
|
|
1075
|
+
this.throttledFlush();
|
|
1073
1076
|
return [7 /*endfinally*/];
|
|
1074
1077
|
case 6: return [2 /*return*/];
|
|
1075
1078
|
}
|
|
1076
1079
|
});
|
|
1077
1080
|
}); };
|
|
1078
|
-
|
|
1081
|
+
/**
|
|
1082
|
+
* A throttled `flush()` that is called after a flush is completed and there
|
|
1083
|
+
* are other queued flushes.
|
|
1084
|
+
*
|
|
1085
|
+
* Instead of calling a flush for every <n> queued flush, condense it to a single call
|
|
1086
|
+
*/
|
|
1087
|
+
this.throttledFlush = throttle__default["default"](this.flush, 1000, {
|
|
1079
1088
|
leading: false,
|
|
1080
1089
|
trailing: true,
|
|
1081
1090
|
});
|
|
@@ -1088,12 +1097,19 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1088
1097
|
captureOnlyOnError: captureOnlyOnError,
|
|
1089
1098
|
replaysSamplingRate: replaysSamplingRate,
|
|
1090
1099
|
useCompression: useCompression,
|
|
1100
|
+
maskAllText: maskAllText,
|
|
1091
1101
|
};
|
|
1092
1102
|
// Modify rrweb options to checkoutEveryNthSecond if this is defined, as we don't know when an error occurs, so we want to try to minimize the number of events captured.
|
|
1093
1103
|
if (this.options.captureOnlyOnError) {
|
|
1094
1104
|
// Checkout every minute, meaning we only get up-to one minute of events before the error happens
|
|
1095
1105
|
this.recordingOptions.checkoutEveryNms = 60000;
|
|
1096
1106
|
}
|
|
1107
|
+
if (this.options.maskAllText) {
|
|
1108
|
+
// `maskAllText` is a more user friendly option to configure
|
|
1109
|
+
// `maskTextSelector`. This means that all nodes will have their text
|
|
1110
|
+
// content masked.
|
|
1111
|
+
this.recordingOptions.maskTextSelector = '*';
|
|
1112
|
+
}
|
|
1097
1113
|
}
|
|
1098
1114
|
/**
|
|
1099
1115
|
* Because we create a transaction in `setupOnce`, we can potentially create a
|
|
@@ -1160,7 +1176,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1160
1176
|
}
|
|
1161
1177
|
// We need to always run `cb` (e.g. in the case of captureOnlyOnError == true)
|
|
1162
1178
|
var cbResult = cb === null || cb === void 0 ? void 0 : cb();
|
|
1163
|
-
// If this option is turned on then we will only want to call `
|
|
1179
|
+
// If this option is turned on then we will only want to call `flush`
|
|
1164
1180
|
// explicitly
|
|
1165
1181
|
if (this.options.captureOnlyOnError) {
|
|
1166
1182
|
return;
|
|
@@ -1175,7 +1191,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1175
1191
|
// Otherwise schedule it to be finished in `this.options.flushMinDelay`
|
|
1176
1192
|
if (flushMaxDelayExceeded) {
|
|
1177
1193
|
logger.log('replay max delay exceeded, finishing replay event');
|
|
1178
|
-
this.
|
|
1194
|
+
this.flush();
|
|
1179
1195
|
return;
|
|
1180
1196
|
}
|
|
1181
1197
|
// Set timer to finish replay event and send replay attachment to
|
|
@@ -1183,7 +1199,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1183
1199
|
// elapses.
|
|
1184
1200
|
this.timeout = window.setTimeout(function () {
|
|
1185
1201
|
logger.log('replay timeout exceeded, finishing replay event');
|
|
1186
|
-
_this.
|
|
1202
|
+
_this.flush();
|
|
1187
1203
|
}, this.options.flushMinDelay);
|
|
1188
1204
|
};
|
|
1189
1205
|
/**
|
|
@@ -1191,7 +1207,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1191
1207
|
*/
|
|
1192
1208
|
SentryReplay.prototype.destroy = function () {
|
|
1193
1209
|
var _a, _b;
|
|
1194
|
-
logger.log('
|
|
1210
|
+
logger.log('Stopping Replays');
|
|
1195
1211
|
this.isEnabled = false;
|
|
1196
1212
|
this.removeListeners();
|
|
1197
1213
|
(_a = this.stopRecording) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
@@ -1480,7 +1496,7 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1480
1496
|
if (this.options.captureOnlyOnError) {
|
|
1481
1497
|
return;
|
|
1482
1498
|
}
|
|
1483
|
-
return this.
|
|
1499
|
+
return this.flush();
|
|
1484
1500
|
};
|
|
1485
1501
|
/**
|
|
1486
1502
|
* Clear context
|
|
@@ -1512,6 +1528,12 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1512
1528
|
this.clearContext();
|
|
1513
1529
|
return context;
|
|
1514
1530
|
};
|
|
1531
|
+
/**
|
|
1532
|
+
* Flushes replay event buffer to Sentry.
|
|
1533
|
+
*
|
|
1534
|
+
* Performance events are only added right before flushing - this is
|
|
1535
|
+
* due to the buffered performance observer events.
|
|
1536
|
+
*/
|
|
1515
1537
|
SentryReplay.prototype.runFlush = function () {
|
|
1516
1538
|
var _a;
|
|
1517
1539
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1631,8 +1653,8 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1631
1653
|
return __awaiter(this, void 0, void 0, function () {
|
|
1632
1654
|
var client, endpoint, ex_1;
|
|
1633
1655
|
var _this = this;
|
|
1634
|
-
return __generator(this, function (
|
|
1635
|
-
switch (
|
|
1656
|
+
return __generator(this, function (_a) {
|
|
1657
|
+
switch (_a.label) {
|
|
1636
1658
|
case 0:
|
|
1637
1659
|
// short circuit if there's no events to upload
|
|
1638
1660
|
if (!events.length) {
|
|
@@ -1640,9 +1662,9 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1640
1662
|
}
|
|
1641
1663
|
client = core.getCurrentHub().getClient();
|
|
1642
1664
|
endpoint = core.getEnvelopeEndpointWithUrlEncodedAuth(client.getDsn());
|
|
1643
|
-
|
|
1665
|
+
_a.label = 1;
|
|
1644
1666
|
case 1:
|
|
1645
|
-
|
|
1667
|
+
_a.trys.push([1, 3, , 5]);
|
|
1646
1668
|
return [4 /*yield*/, this.sendReplayRequest({
|
|
1647
1669
|
endpoint: endpoint,
|
|
1648
1670
|
events: events,
|
|
@@ -1650,11 +1672,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1650
1672
|
segmentId: segmentId,
|
|
1651
1673
|
})];
|
|
1652
1674
|
case 2:
|
|
1653
|
-
|
|
1675
|
+
_a.sent();
|
|
1654
1676
|
this.resetRetries();
|
|
1655
1677
|
return [2 /*return*/, true];
|
|
1656
1678
|
case 3:
|
|
1657
|
-
ex_1 =
|
|
1679
|
+
ex_1 = _a.sent();
|
|
1658
1680
|
console.error(ex_1);
|
|
1659
1681
|
// Capture error for every failed replay
|
|
1660
1682
|
// TODO: Remove this before GA as this will create an error on customer's project
|
|
@@ -1665,43 +1687,34 @@ var SentryReplay = /** @class */ (function () {
|
|
|
1665
1687
|
// If an error happened here, it's likely that uploading the attachment
|
|
1666
1688
|
// failed, we'll can retry with the same events payload
|
|
1667
1689
|
if (this.retryCount >= MAX_RETRY_COUNT) {
|
|
1668
|
-
|
|
1669
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1690
|
+
throw new Error("".concat(UNABLE_TO_SEND_REPLAY, " - max retries exceeded"));
|
|
1670
1691
|
}
|
|
1671
1692
|
this.retryCount = this.retryCount + 1;
|
|
1672
1693
|
// will retry in intervals of 5, 10, 30
|
|
1673
1694
|
this.retryInterval = this.retryCount * this.retryInterval;
|
|
1674
|
-
_b.label = 4;
|
|
1675
|
-
case 4:
|
|
1676
|
-
_b.trys.push([4, 6, , 7]);
|
|
1677
1695
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
1678
1696
|
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1679
|
-
|
|
1680
|
-
|
|
1697
|
+
var err_3;
|
|
1698
|
+
return __generator(this, function (_a) {
|
|
1699
|
+
switch (_a.label) {
|
|
1681
1700
|
case 0:
|
|
1682
|
-
|
|
1701
|
+
_a.trys.push([0, 2, , 3]);
|
|
1683
1702
|
return [4 /*yield*/, this.sendReplay(replayId, events, segmentId)];
|
|
1684
1703
|
case 1:
|
|
1685
|
-
|
|
1704
|
+
_a.sent();
|
|
1686
1705
|
resolve(true);
|
|
1687
1706
|
return [3 /*break*/, 3];
|
|
1688
1707
|
case 2:
|
|
1689
|
-
|
|
1690
|
-
reject(
|
|
1708
|
+
err_3 = _a.sent();
|
|
1709
|
+
reject(err_3);
|
|
1691
1710
|
return [3 /*break*/, 3];
|
|
1692
1711
|
case 3: return [2 /*return*/];
|
|
1693
1712
|
}
|
|
1694
1713
|
});
|
|
1695
1714
|
}); }, _this.retryInterval);
|
|
1696
1715
|
})];
|
|
1697
|
-
case
|
|
1698
|
-
|
|
1699
|
-
return [2 /*return*/, true];
|
|
1700
|
-
case 6:
|
|
1701
|
-
_b.sent();
|
|
1702
|
-
throw new Error(UNABLE_TO_SEND_REPLAY);
|
|
1703
|
-
case 7: return [3 /*break*/, 8];
|
|
1704
|
-
case 8: return [2 /*return*/];
|
|
1716
|
+
case 4: return [2 /*return*/, _a.sent()];
|
|
1717
|
+
case 5: return [2 /*return*/];
|
|
1705
1718
|
}
|
|
1706
1719
|
});
|
|
1707
1720
|
});
|