@sentry/replay 0.2.0-0 → 0.2.0-1
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 -26
- package/dist/index.es.js +265 -96
- package/dist/index.js +265 -96
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,54 +13,37 @@ To install the stable version:
|
|
|
13
13
|
with npm:
|
|
14
14
|
|
|
15
15
|
```shell
|
|
16
|
-
npm install --save @sentry/replay rrweb
|
|
16
|
+
npm install --save @sentry/browser @sentry/replay @sentry/tracing rrweb
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
with yarn:
|
|
20
20
|
|
|
21
21
|
```shell
|
|
22
|
-
yarn add @sentry/replay rrweb
|
|
22
|
+
yarn add @sentry/replay @sentry/browser @sentry/replay @sentry/tracing rrweb
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Setup
|
|
26
26
|
|
|
27
|
-
To set up the integration add the following to your Sentry initialization
|
|
27
|
+
To set up the integration add the following to your Sentry initialization. Several options are supported and passable via the integration constructor.
|
|
28
|
+
See the rrweb documentation for advice on configuring these values.
|
|
28
29
|
|
|
29
|
-
```javascript
|
|
30
|
-
import * as Sentry from '@sentry/browser';
|
|
31
|
-
import { SentryReplay } from '@sentry/replay';
|
|
32
|
-
|
|
33
|
-
Sentry.init({
|
|
34
|
-
dsn: '__DSN__',
|
|
35
|
-
integrations: [
|
|
36
|
-
new SentryReplay({
|
|
37
|
-
// ...options
|
|
38
|
-
}),
|
|
39
|
-
],
|
|
40
|
-
// ...
|
|
41
|
-
});
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Several options are supported and passable via the integration constructor:
|
|
45
30
|
|
|
46
31
|
```javascript
|
|
47
32
|
import * as Sentry from '@sentry/browser';
|
|
48
33
|
import { SentryReplay } from '@sentry/replay';
|
|
34
|
+
import '@sentry/tracing';
|
|
49
35
|
|
|
50
36
|
Sentry.init({
|
|
51
37
|
dsn: '__DSN__',
|
|
52
38
|
integrations: [
|
|
53
39
|
new SentryReplay({
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
// on by default
|
|
59
|
-
maskAllInputs: false,
|
|
40
|
+
stickySession: true, // Default is false
|
|
41
|
+
rrwebOptions: {
|
|
42
|
+
maskAllInputs: false, // Default is true
|
|
43
|
+
},
|
|
60
44
|
}),
|
|
61
45
|
],
|
|
62
46
|
// ...
|
|
63
47
|
});
|
|
64
48
|
```
|
|
65
49
|
|
|
66
|
-
See the rrweb documentation for advice on configuring these values.
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/browser';
|
|
2
|
-
import { isDebugBuild, logger, uuid4 } from '@sentry/utils';
|
|
3
2
|
import { record } from 'rrweb';
|
|
3
|
+
import { logger as logger$1, isDebugBuild } from '@sentry/utils';
|
|
4
4
|
|
|
5
5
|
/*! *****************************************************************************
|
|
6
6
|
Copyright (c) Microsoft Corporation.
|
|
@@ -158,12 +158,156 @@ function createLargestContentfulPaint(entry) {
|
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Given an initial timestamp and an expiry duration, checks to see if current
|
|
163
|
+
* time should be considered as expired.
|
|
164
|
+
*/
|
|
165
|
+
function isExpired(initialTime, expiry, targetTime) {
|
|
166
|
+
if (targetTime === void 0) { targetTime = +new Date(); }
|
|
167
|
+
// Always expired if < 0
|
|
168
|
+
if (expiry < 0) {
|
|
169
|
+
return true;
|
|
170
|
+
}
|
|
171
|
+
// Never expires if == 0
|
|
172
|
+
if (expiry === 0) {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
return initialTime + expiry <= targetTime;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Checks to see if session is expired
|
|
180
|
+
*/
|
|
181
|
+
function isSessionExpired(session, expiry, targetTime) {
|
|
182
|
+
if (targetTime === void 0) { targetTime = +new Date(); }
|
|
183
|
+
return isExpired(session.lastActivity, expiry, targetTime);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function wrapLogger(logFn) {
|
|
187
|
+
return function wrappedLog() {
|
|
188
|
+
var args = [];
|
|
189
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
190
|
+
args[_i] = arguments[_i];
|
|
191
|
+
}
|
|
192
|
+
if (!isDebugBuild()) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
return logFn.call.apply(logFn, __spreadArray([logger$1, '[Replay]'], args, false));
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
var logger = __assign(__assign({}, logger$1), { error: wrapLogger(logger$1.error), warn: wrapLogger(logger$1.warn), log: wrapLogger(logger$1.log) });
|
|
199
|
+
|
|
200
|
+
var REPLAY_SESSION_KEY = 'sentryReplaySession';
|
|
201
|
+
|
|
202
|
+
function saveSession(session) {
|
|
203
|
+
var hasSessionStorage = 'sessionStorage' in window;
|
|
204
|
+
if (!hasSessionStorage) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
window.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
209
|
+
}
|
|
210
|
+
catch (_a) {
|
|
211
|
+
// this shouldn't happen
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Create a new session, which in its current implementation is a Sentry event
|
|
217
|
+
* that all replays will be saved to as attachments. Currently, we only expect
|
|
218
|
+
* one of these Sentry events per "replay session".
|
|
219
|
+
*/
|
|
220
|
+
function createSession(_a) {
|
|
221
|
+
var _b = _a.stickySession, stickySession = _b === void 0 ? false : _b;
|
|
222
|
+
var currentDate = new Date().getTime();
|
|
223
|
+
// Create root replay event, this is where attachments will be saved
|
|
224
|
+
var transaction = Sentry.getCurrentHub().startTransaction({
|
|
225
|
+
name: 'sentry-replay',
|
|
226
|
+
tags: {
|
|
227
|
+
isReplayRoot: 'yes',
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
// We have to finish the transaction to get an event ID to be able to
|
|
231
|
+
// upload an attachment for that event
|
|
232
|
+
// @ts-expect-error This returns an eventId (string), but is not typed as such
|
|
233
|
+
var id = transaction.finish();
|
|
234
|
+
logger.log("Creating new session: ".concat(id));
|
|
235
|
+
var session = {
|
|
236
|
+
id: id,
|
|
237
|
+
spanId: transaction.spanId,
|
|
238
|
+
traceId: transaction.traceId,
|
|
239
|
+
started: currentDate,
|
|
240
|
+
lastActivity: currentDate,
|
|
241
|
+
};
|
|
242
|
+
if (stickySession) {
|
|
243
|
+
saveSession(session);
|
|
244
|
+
}
|
|
245
|
+
return session;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function fetchSession() {
|
|
249
|
+
var hasSessionStorage = 'sessionStorage' in window;
|
|
250
|
+
if (!hasSessionStorage) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
return JSON.parse(window.sessionStorage.getItem(REPLAY_SESSION_KEY));
|
|
255
|
+
}
|
|
256
|
+
catch (_a) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Get or create a session
|
|
263
|
+
*/
|
|
264
|
+
function getSession(_a) {
|
|
265
|
+
var expiry = _a.expiry, stickySession = _a.stickySession;
|
|
266
|
+
var session = stickySession && fetchSession();
|
|
267
|
+
if (session) {
|
|
268
|
+
// If there is a session, check if it is valid (e.g. "last activity" time should be within the "session idle time")
|
|
269
|
+
// TODO: We should probably set a max age on this as well
|
|
270
|
+
var isExpired = isSessionExpired(session, expiry);
|
|
271
|
+
if (!isExpired) {
|
|
272
|
+
logger.log("Using existing session: ".concat(session.id));
|
|
273
|
+
return session;
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
logger.log("Session has expired");
|
|
277
|
+
}
|
|
278
|
+
// Otherwise continue to create a new session
|
|
279
|
+
}
|
|
280
|
+
var newSession = createSession({ stickySession: stickySession });
|
|
281
|
+
return newSession;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function updateSessionActivity(_a) {
|
|
285
|
+
var stickySession = _a.stickySession;
|
|
286
|
+
// Nothing to do if there are no sticky sessions
|
|
287
|
+
if (!stickySession) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
var existingSession = fetchSession();
|
|
291
|
+
// If user manually deleted from session storage, create a new session
|
|
292
|
+
if (!existingSession) {
|
|
293
|
+
// TBD: There was an issue here where sessions weren't saving and this
|
|
294
|
+
// caused lots of transactions to be created
|
|
295
|
+
return createSession({ stickySession: stickySession });
|
|
296
|
+
}
|
|
297
|
+
var newSession = __assign(__assign({}, existingSession), { lastActivity: new Date().getTime() });
|
|
298
|
+
saveSession(newSession);
|
|
299
|
+
return newSession;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
var VISIBILITY_CHANGE_TIMEOUT = 60000; // 1 minute
|
|
303
|
+
var SESSION_IDLE_DURATION = 900000; // 15 minutes
|
|
162
304
|
var SentryReplay = /** @class */ (function () {
|
|
163
305
|
function SentryReplay(_a) {
|
|
164
306
|
if (_a === void 0) { _a = {}; }
|
|
165
307
|
var _this = this;
|
|
166
|
-
var _b = _a.
|
|
308
|
+
var _b = _a.uploadMinDelay, uploadMinDelay = _b === void 0 ? 5000 : _b, _c = _a.uploadMaxDelay, uploadMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.stickySession, stickySession = _d === void 0 ? false : _d, // TBD: Making this opt-in for now
|
|
309
|
+
_e = _a.rrwebConfig, // TBD: Making this opt-in for now
|
|
310
|
+
_f = _e === void 0 ? {} : _e, _g = _f.maskAllInputs, maskAllInputs = _g === void 0 ? true : _g, rrwebRecordOptions = __rest(_f, ["maskAllInputs"]);
|
|
167
311
|
/**
|
|
168
312
|
* @inheritDoc
|
|
169
313
|
*/
|
|
@@ -173,6 +317,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
173
317
|
*/
|
|
174
318
|
this.events = [];
|
|
175
319
|
this.performanceEvents = [];
|
|
320
|
+
/**
|
|
321
|
+
* The timestamp of the first event since the last flush.
|
|
322
|
+
* This is used to determine if the maximum allowed time has passed before we should flush events again.
|
|
323
|
+
*/
|
|
324
|
+
this.initialEventTimestampSinceFlush = null;
|
|
176
325
|
this.performanceObserver = null;
|
|
177
326
|
/**
|
|
178
327
|
* Keep a list of performance entries that will be sent with a replay
|
|
@@ -186,70 +335,45 @@ var SentryReplay = /** @class */ (function () {
|
|
|
186
335
|
* Handle when visibility of the page changes. (e.g. new tab is opened)
|
|
187
336
|
*/
|
|
188
337
|
this.handleVisibilityChange = function () {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
338
|
+
var isExpired = isSessionExpired(_this.session, VISIBILITY_CHANGE_TIMEOUT);
|
|
339
|
+
if (isExpired) {
|
|
340
|
+
if (document.visibilityState === 'visible') {
|
|
341
|
+
// If the user has come back to the page within VISIBILITY_CHANGE_TIMEOUT
|
|
342
|
+
// ms, we will re-use the existing session, otherwise create a new
|
|
343
|
+
// session
|
|
344
|
+
logger.log('Document has become active, but session has expired');
|
|
345
|
+
_this.triggerFullSnapshot();
|
|
346
|
+
}
|
|
347
|
+
// We definitely want to return if visibilityState is "visible", and I
|
|
348
|
+
// think we also want to do the same when "hidden", as there shouldn't be
|
|
349
|
+
// any action to take if user has gone idle for a long period and then
|
|
350
|
+
// comes back to hide the tab. We don't trigger a full snapshot because
|
|
351
|
+
// we don't want to start a new session as they immediately have hidden
|
|
352
|
+
// the tab.
|
|
198
353
|
return;
|
|
199
354
|
}
|
|
200
|
-
//
|
|
201
|
-
|
|
202
|
-
//
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
_this.
|
|
206
|
-
}
|
|
355
|
+
// Otherwise if session is not expired...
|
|
356
|
+
// Update with current timestamp as the last session activity
|
|
357
|
+
// Only updating session on visibility change to be conservative about
|
|
358
|
+
// writing to session storage. This could be changed in the future.
|
|
359
|
+
updateSessionActivity({
|
|
360
|
+
stickySession: _this.options.stickySession,
|
|
361
|
+
});
|
|
362
|
+
// Send replay when the page/tab becomes hidden. There is no reason to send
|
|
363
|
+
// replay if it becomes visible, since no actions we care about were done
|
|
364
|
+
// while it was hidden
|
|
365
|
+
if (document.visibilityState !== 'visible') {
|
|
366
|
+
_this.finishReplayEvent();
|
|
367
|
+
}
|
|
207
368
|
};
|
|
208
369
|
this.rrwebRecordOptions = __assign({ maskAllInputs: maskAllInputs }, rrwebRecordOptions);
|
|
209
|
-
|
|
210
|
-
// TBD on behavior here (e.g. should this be saved to localStorage/cookies)
|
|
211
|
-
this.replayId = uuid4();
|
|
370
|
+
this.options = { uploadMinDelay: uploadMinDelay, uploadMaxDelay: uploadMaxDelay, stickySession: stickySession };
|
|
212
371
|
this.events = [];
|
|
213
|
-
record(__assign(__assign({}, this.rrwebRecordOptions), { emit: function (event, isCheckout) {
|
|
214
|
-
// "debounce" by `idleTimeout`, how often we save replay events i.e. we
|
|
215
|
-
// will save events only if 15 seconds have elapsed since the last
|
|
216
|
-
// event
|
|
217
|
-
//
|
|
218
|
-
// TODO: We probably want to have a hard timeout where we save
|
|
219
|
-
// so that it does not grow infinitely and we never have a replay
|
|
220
|
-
// saved
|
|
221
|
-
if (_this.timeout) {
|
|
222
|
-
window.clearTimeout(_this.timeout);
|
|
223
|
-
}
|
|
224
|
-
// Always create a new Sentry event on checkouts and clear existing rrweb events
|
|
225
|
-
if (isCheckout) {
|
|
226
|
-
console.log('$$$$$ IS CHECKOUT');
|
|
227
|
-
_this.events = [event];
|
|
228
|
-
}
|
|
229
|
-
else {
|
|
230
|
-
_this.events.push(event);
|
|
231
|
-
}
|
|
232
|
-
// Set timer to send attachment to Sentry, will be cancelled if an
|
|
233
|
-
// event happens before `idleTimeout` elapses
|
|
234
|
-
_this.timeout = window.setTimeout(function () {
|
|
235
|
-
_this.isDebug &&
|
|
236
|
-
logger.log('[Replay] rrweb timeout hit, finishing replay event');
|
|
237
|
-
_this.finishReplayEvent();
|
|
238
|
-
}, idleTimeout);
|
|
239
|
-
} }));
|
|
240
|
-
this.addListeners();
|
|
241
372
|
}
|
|
242
373
|
SentryReplay.attachmentUrlFromDsn = function (dsn, eventId) {
|
|
243
374
|
var host = dsn.host, path = dsn.path, projectId = dsn.projectId, port = dsn.port, protocol = dsn.protocol, user = dsn.user;
|
|
244
375
|
return "".concat(protocol, "://").concat(host).concat(port !== '' ? ":".concat(port) : '').concat(path !== '' ? "/".concat(path) : '', "/api/").concat(projectId, "/events/").concat(eventId, "/attachments/?sentry_key=").concat(user, "&sentry_version=7&sentry_client=replay");
|
|
245
376
|
};
|
|
246
|
-
Object.defineProperty(SentryReplay.prototype, "isDebug", {
|
|
247
|
-
get: function () {
|
|
248
|
-
return isDebugBuild();
|
|
249
|
-
},
|
|
250
|
-
enumerable: false,
|
|
251
|
-
configurable: true
|
|
252
|
-
});
|
|
253
377
|
Object.defineProperty(SentryReplay.prototype, "instance", {
|
|
254
378
|
/**
|
|
255
379
|
* Get integration's instance on the current hub
|
|
@@ -262,17 +386,75 @@ var SentryReplay = /** @class */ (function () {
|
|
|
262
386
|
});
|
|
263
387
|
SentryReplay.prototype.setupOnce = function () {
|
|
264
388
|
var _this = this;
|
|
389
|
+
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
390
|
+
// If there is no session, then something bad has happened - can't continue
|
|
391
|
+
if (!this.session) {
|
|
392
|
+
throw new Error('Invalid session');
|
|
393
|
+
}
|
|
265
394
|
// Tag all (non replay) events that get sent to Sentry with the current
|
|
266
395
|
// replay ID so that we can reference them later in the UI
|
|
267
396
|
Sentry.addGlobalEventProcessor(function (event) {
|
|
268
|
-
event.tags = __assign(__assign({}, event.tags), { replayId: _this.
|
|
397
|
+
event.tags = __assign(__assign({}, event.tags), { replayId: _this.session.id });
|
|
269
398
|
return event;
|
|
270
399
|
});
|
|
400
|
+
record(__assign(__assign({}, this.rrwebRecordOptions), { emit: function (event, isCheckout) {
|
|
401
|
+
// We want to batch uploads of replay events. Save events only if
|
|
402
|
+
// `<uploadMinDelay>` milliseconds have elapsed since the last event
|
|
403
|
+
// *OR* if `<uploadMaxDelay>` milliseconds have elapsed.
|
|
404
|
+
var now = new Date().getTime();
|
|
405
|
+
// Timestamp of the first replay event since the last flush, this gets
|
|
406
|
+
// reset when we finish the replay event
|
|
407
|
+
if (!_this.initialEventTimestampSinceFlush) {
|
|
408
|
+
_this.initialEventTimestampSinceFlush = now;
|
|
409
|
+
}
|
|
410
|
+
var uploadMaxDelayExceeded = isExpired(_this.initialEventTimestampSinceFlush, _this.options.uploadMaxDelay, now);
|
|
411
|
+
// Do not finish the replay event if we receive a new replay event
|
|
412
|
+
// unless `<uploadMaxDelay>` ms have elapsed since the last time we
|
|
413
|
+
// finished the replay
|
|
414
|
+
if (_this.timeout && !uploadMaxDelayExceeded) {
|
|
415
|
+
window.clearTimeout(_this.timeout);
|
|
416
|
+
}
|
|
417
|
+
// We need to clear existing events on a checkout, otherwise they are
|
|
418
|
+
// incremental event updates and should be appended
|
|
419
|
+
if (isCheckout) {
|
|
420
|
+
_this.events = [event];
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
_this.events.push(event);
|
|
424
|
+
}
|
|
425
|
+
// This event type is a fullsnapshot, we should save immediately when this occurs
|
|
426
|
+
// See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16
|
|
427
|
+
if (event.type === 2) {
|
|
428
|
+
// A fullsnapshot happens on initial load and if we need to start a
|
|
429
|
+
// new replay due to idle timeout. In the later case we will need to
|
|
430
|
+
// create a new session before finishing the replay.
|
|
431
|
+
_this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
432
|
+
_this.finishReplayEvent();
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
// Set timer to finish replay event and send replay attachment to
|
|
436
|
+
// Sentry. Will be cancelled if an event happens before `uploadMinDelay`
|
|
437
|
+
// elapses.
|
|
438
|
+
_this.timeout = window.setTimeout(function () {
|
|
439
|
+
logger.log('rrweb timeout hit, finishing replay event');
|
|
440
|
+
_this.finishReplayEvent();
|
|
441
|
+
}, _this.options.uploadMinDelay);
|
|
442
|
+
} }));
|
|
443
|
+
this.addListeners();
|
|
271
444
|
// XXX: this needs to be in `setupOnce` vs `constructor`, otherwise SDK is
|
|
272
445
|
// not fully initialized and the event will not get properly sent to Sentry
|
|
273
|
-
this.createRootEvent();
|
|
274
446
|
this.createReplayEvent();
|
|
275
447
|
};
|
|
448
|
+
/**
|
|
449
|
+
* Loads a session from storage, or creates a new one
|
|
450
|
+
*/
|
|
451
|
+
SentryReplay.prototype.loadSession = function (_a) {
|
|
452
|
+
var expiry = _a.expiry;
|
|
453
|
+
this.session = getSession({
|
|
454
|
+
expiry: expiry,
|
|
455
|
+
stickySession: this.options.stickySession,
|
|
456
|
+
});
|
|
457
|
+
};
|
|
276
458
|
SentryReplay.prototype.addListeners = function () {
|
|
277
459
|
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
278
460
|
if ('PerformanceObserver' in window) {
|
|
@@ -284,36 +466,13 @@ var SentryReplay = /** @class */ (function () {
|
|
|
284
466
|
}
|
|
285
467
|
};
|
|
286
468
|
/**
|
|
287
|
-
*
|
|
288
|
-
*
|
|
469
|
+
* Trigger rrweb to take a full snapshot which will cause this plugin to
|
|
470
|
+
* create a new Replay event.
|
|
289
471
|
*/
|
|
290
|
-
SentryReplay.prototype.
|
|
291
|
-
|
|
472
|
+
SentryReplay.prototype.triggerFullSnapshot = function () {
|
|
473
|
+
logger.log('Taking full rrweb snapshot');
|
|
292
474
|
record.takeFullSnapshot(true);
|
|
293
475
|
};
|
|
294
|
-
/**
|
|
295
|
-
* Creates the Sentry event that all replays will be saved to as attachments.
|
|
296
|
-
* Currently, we only expect one of these per "replay session" (which is not
|
|
297
|
-
* explicitly defined yet).
|
|
298
|
-
*/
|
|
299
|
-
SentryReplay.prototype.createRootEvent = function () {
|
|
300
|
-
// TODO: Figure out if we need to do this, when this gets called from `setupOnce`, `this.instance` is still undefined.
|
|
301
|
-
// if (!this.instance) return;
|
|
302
|
-
this.isDebug && logger.log("[Replay] creating root replay event");
|
|
303
|
-
// Create a transaction to attach event to
|
|
304
|
-
var transaction = Sentry.getCurrentHub().startTransaction({
|
|
305
|
-
name: 'sentry-replay',
|
|
306
|
-
tags: {
|
|
307
|
-
hasReplay: 'yes',
|
|
308
|
-
replayId: this.replayId,
|
|
309
|
-
},
|
|
310
|
-
});
|
|
311
|
-
// We have to finish the transaction to get an event ID to be able to
|
|
312
|
-
// upload an attachment for that event
|
|
313
|
-
// @ts-expect-error This returns an eventId (string), but is not typed as such
|
|
314
|
-
this.eventId = transaction.finish();
|
|
315
|
-
return this.eventId;
|
|
316
|
-
};
|
|
317
476
|
/**
|
|
318
477
|
* This is our pseudo replay event disguised as a transaction. It will be
|
|
319
478
|
* used to store performance entries and breadcrumbs for every incremental
|
|
@@ -321,12 +480,13 @@ var SentryReplay = /** @class */ (function () {
|
|
|
321
480
|
**/
|
|
322
481
|
SentryReplay.prototype.createReplayEvent = function () {
|
|
323
482
|
var _this = this;
|
|
324
|
-
|
|
483
|
+
logger.log('CreateReplayEvent rootReplayId', this.session.id);
|
|
325
484
|
this.replayEvent = Sentry.startTransaction({
|
|
326
485
|
name: 'sentry-replay-event',
|
|
486
|
+
parentSpanId: this.session.spanId,
|
|
487
|
+
traceId: this.session.traceId,
|
|
327
488
|
tags: {
|
|
328
|
-
|
|
329
|
-
replayId: this.replayId,
|
|
489
|
+
replayId: this.session.id,
|
|
330
490
|
},
|
|
331
491
|
});
|
|
332
492
|
Sentry.configureScope(function (scope) { return scope.setSpan(_this.replayEvent); });
|
|
@@ -365,12 +525,22 @@ var SentryReplay = /** @class */ (function () {
|
|
|
365
525
|
SentryReplay.prototype.finishReplayEvent = function () {
|
|
366
526
|
// if (!this.instance) return;
|
|
367
527
|
var _a;
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
528
|
+
// Ensure that our existing session has not expired
|
|
529
|
+
var isExpired = isSessionExpired(this.session, SESSION_IDLE_DURATION);
|
|
530
|
+
if (isExpired) {
|
|
531
|
+
// TBD: If it is expired, we do not send any events...we could send to
|
|
532
|
+
// the expired session, but not sure if that's great
|
|
533
|
+
console.error(new Error('Attempting to finish replay event after session expired.'));
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
if (!this.session.id) {
|
|
537
|
+
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
371
538
|
return;
|
|
372
539
|
}
|
|
373
|
-
this.sendReplay(
|
|
540
|
+
this.sendReplay(this.session.id);
|
|
541
|
+
this.initialEventTimestampSinceFlush = null;
|
|
542
|
+
// TBD: Alternatively we could update this after every rrweb event
|
|
543
|
+
this.session.lastActivity = new Date().getTime();
|
|
374
544
|
// include performance entries
|
|
375
545
|
this.addPerformanceEntries();
|
|
376
546
|
// Close out existing replay event and create a new one
|
|
@@ -399,15 +569,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
399
569
|
}), "rrweb-".concat(new Date().getTime(), ".json"));
|
|
400
570
|
// If sendBeacon is supported and payload is smol enough...
|
|
401
571
|
if (this.hasSendBeacon() && stringifiedPayload.length <= 65536) {
|
|
402
|
-
|
|
403
|
-
logger.log("[Replay] uploading attachment via sendBeacon()");
|
|
572
|
+
logger.log("uploading attachment via sendBeacon()");
|
|
404
573
|
window.navigator.sendBeacon(endpoint, formData);
|
|
405
574
|
return [2 /*return*/];
|
|
406
575
|
}
|
|
407
576
|
_a.label = 1;
|
|
408
577
|
case 1:
|
|
409
578
|
_a.trys.push([1, 3, , 4]);
|
|
410
|
-
|
|
579
|
+
logger.log("uploading attachment via fetch()");
|
|
411
580
|
// Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
|
|
412
581
|
return [4 /*yield*/, fetch(endpoint, {
|
|
413
582
|
method: 'POST',
|
package/dist/index.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var Sentry = require('@sentry/browser');
|
|
6
|
-
var utils = require('@sentry/utils');
|
|
7
6
|
var rrweb = require('rrweb');
|
|
7
|
+
var utils = require('@sentry/utils');
|
|
8
8
|
|
|
9
9
|
function _interopNamespace(e) {
|
|
10
10
|
if (e && e.__esModule) return e;
|
|
@@ -182,12 +182,156 @@ function createLargestContentfulPaint(entry) {
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
/**
|
|
186
|
+
* Given an initial timestamp and an expiry duration, checks to see if current
|
|
187
|
+
* time should be considered as expired.
|
|
188
|
+
*/
|
|
189
|
+
function isExpired(initialTime, expiry, targetTime) {
|
|
190
|
+
if (targetTime === void 0) { targetTime = +new Date(); }
|
|
191
|
+
// Always expired if < 0
|
|
192
|
+
if (expiry < 0) {
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
// Never expires if == 0
|
|
196
|
+
if (expiry === 0) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
return initialTime + expiry <= targetTime;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Checks to see if session is expired
|
|
204
|
+
*/
|
|
205
|
+
function isSessionExpired(session, expiry, targetTime) {
|
|
206
|
+
if (targetTime === void 0) { targetTime = +new Date(); }
|
|
207
|
+
return isExpired(session.lastActivity, expiry, targetTime);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function wrapLogger(logFn) {
|
|
211
|
+
return function wrappedLog() {
|
|
212
|
+
var args = [];
|
|
213
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
214
|
+
args[_i] = arguments[_i];
|
|
215
|
+
}
|
|
216
|
+
if (!utils.isDebugBuild()) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
return logFn.call.apply(logFn, __spreadArray([utils.logger, '[Replay]'], args, false));
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
var logger = __assign(__assign({}, utils.logger), { error: wrapLogger(utils.logger.error), warn: wrapLogger(utils.logger.warn), log: wrapLogger(utils.logger.log) });
|
|
223
|
+
|
|
224
|
+
var REPLAY_SESSION_KEY = 'sentryReplaySession';
|
|
225
|
+
|
|
226
|
+
function saveSession(session) {
|
|
227
|
+
var hasSessionStorage = 'sessionStorage' in window;
|
|
228
|
+
if (!hasSessionStorage) {
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
window.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));
|
|
233
|
+
}
|
|
234
|
+
catch (_a) {
|
|
235
|
+
// this shouldn't happen
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Create a new session, which in its current implementation is a Sentry event
|
|
241
|
+
* that all replays will be saved to as attachments. Currently, we only expect
|
|
242
|
+
* one of these Sentry events per "replay session".
|
|
243
|
+
*/
|
|
244
|
+
function createSession(_a) {
|
|
245
|
+
var _b = _a.stickySession, stickySession = _b === void 0 ? false : _b;
|
|
246
|
+
var currentDate = new Date().getTime();
|
|
247
|
+
// Create root replay event, this is where attachments will be saved
|
|
248
|
+
var transaction = Sentry__namespace.getCurrentHub().startTransaction({
|
|
249
|
+
name: 'sentry-replay',
|
|
250
|
+
tags: {
|
|
251
|
+
isReplayRoot: 'yes',
|
|
252
|
+
},
|
|
253
|
+
});
|
|
254
|
+
// We have to finish the transaction to get an event ID to be able to
|
|
255
|
+
// upload an attachment for that event
|
|
256
|
+
// @ts-expect-error This returns an eventId (string), but is not typed as such
|
|
257
|
+
var id = transaction.finish();
|
|
258
|
+
logger.log("Creating new session: ".concat(id));
|
|
259
|
+
var session = {
|
|
260
|
+
id: id,
|
|
261
|
+
spanId: transaction.spanId,
|
|
262
|
+
traceId: transaction.traceId,
|
|
263
|
+
started: currentDate,
|
|
264
|
+
lastActivity: currentDate,
|
|
265
|
+
};
|
|
266
|
+
if (stickySession) {
|
|
267
|
+
saveSession(session);
|
|
268
|
+
}
|
|
269
|
+
return session;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function fetchSession() {
|
|
273
|
+
var hasSessionStorage = 'sessionStorage' in window;
|
|
274
|
+
if (!hasSessionStorage) {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
try {
|
|
278
|
+
return JSON.parse(window.sessionStorage.getItem(REPLAY_SESSION_KEY));
|
|
279
|
+
}
|
|
280
|
+
catch (_a) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Get or create a session
|
|
287
|
+
*/
|
|
288
|
+
function getSession(_a) {
|
|
289
|
+
var expiry = _a.expiry, stickySession = _a.stickySession;
|
|
290
|
+
var session = stickySession && fetchSession();
|
|
291
|
+
if (session) {
|
|
292
|
+
// If there is a session, check if it is valid (e.g. "last activity" time should be within the "session idle time")
|
|
293
|
+
// TODO: We should probably set a max age on this as well
|
|
294
|
+
var isExpired = isSessionExpired(session, expiry);
|
|
295
|
+
if (!isExpired) {
|
|
296
|
+
logger.log("Using existing session: ".concat(session.id));
|
|
297
|
+
return session;
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
logger.log("Session has expired");
|
|
301
|
+
}
|
|
302
|
+
// Otherwise continue to create a new session
|
|
303
|
+
}
|
|
304
|
+
var newSession = createSession({ stickySession: stickySession });
|
|
305
|
+
return newSession;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function updateSessionActivity(_a) {
|
|
309
|
+
var stickySession = _a.stickySession;
|
|
310
|
+
// Nothing to do if there are no sticky sessions
|
|
311
|
+
if (!stickySession) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
var existingSession = fetchSession();
|
|
315
|
+
// If user manually deleted from session storage, create a new session
|
|
316
|
+
if (!existingSession) {
|
|
317
|
+
// TBD: There was an issue here where sessions weren't saving and this
|
|
318
|
+
// caused lots of transactions to be created
|
|
319
|
+
return createSession({ stickySession: stickySession });
|
|
320
|
+
}
|
|
321
|
+
var newSession = __assign(__assign({}, existingSession), { lastActivity: new Date().getTime() });
|
|
322
|
+
saveSession(newSession);
|
|
323
|
+
return newSession;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
var VISIBILITY_CHANGE_TIMEOUT = 60000; // 1 minute
|
|
327
|
+
var SESSION_IDLE_DURATION = 900000; // 15 minutes
|
|
186
328
|
var SentryReplay = /** @class */ (function () {
|
|
187
329
|
function SentryReplay(_a) {
|
|
188
330
|
if (_a === void 0) { _a = {}; }
|
|
189
331
|
var _this = this;
|
|
190
|
-
var _b = _a.
|
|
332
|
+
var _b = _a.uploadMinDelay, uploadMinDelay = _b === void 0 ? 5000 : _b, _c = _a.uploadMaxDelay, uploadMaxDelay = _c === void 0 ? 15000 : _c, _d = _a.stickySession, stickySession = _d === void 0 ? false : _d, // TBD: Making this opt-in for now
|
|
333
|
+
_e = _a.rrwebConfig, // TBD: Making this opt-in for now
|
|
334
|
+
_f = _e === void 0 ? {} : _e, _g = _f.maskAllInputs, maskAllInputs = _g === void 0 ? true : _g, rrwebRecordOptions = __rest(_f, ["maskAllInputs"]);
|
|
191
335
|
/**
|
|
192
336
|
* @inheritDoc
|
|
193
337
|
*/
|
|
@@ -197,6 +341,11 @@ var SentryReplay = /** @class */ (function () {
|
|
|
197
341
|
*/
|
|
198
342
|
this.events = [];
|
|
199
343
|
this.performanceEvents = [];
|
|
344
|
+
/**
|
|
345
|
+
* The timestamp of the first event since the last flush.
|
|
346
|
+
* This is used to determine if the maximum allowed time has passed before we should flush events again.
|
|
347
|
+
*/
|
|
348
|
+
this.initialEventTimestampSinceFlush = null;
|
|
200
349
|
this.performanceObserver = null;
|
|
201
350
|
/**
|
|
202
351
|
* Keep a list of performance entries that will be sent with a replay
|
|
@@ -210,70 +359,45 @@ var SentryReplay = /** @class */ (function () {
|
|
|
210
359
|
* Handle when visibility of the page changes. (e.g. new tab is opened)
|
|
211
360
|
*/
|
|
212
361
|
this.handleVisibilityChange = function () {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
362
|
+
var isExpired = isSessionExpired(_this.session, VISIBILITY_CHANGE_TIMEOUT);
|
|
363
|
+
if (isExpired) {
|
|
364
|
+
if (document.visibilityState === 'visible') {
|
|
365
|
+
// If the user has come back to the page within VISIBILITY_CHANGE_TIMEOUT
|
|
366
|
+
// ms, we will re-use the existing session, otherwise create a new
|
|
367
|
+
// session
|
|
368
|
+
logger.log('Document has become active, but session has expired');
|
|
369
|
+
_this.triggerFullSnapshot();
|
|
370
|
+
}
|
|
371
|
+
// We definitely want to return if visibilityState is "visible", and I
|
|
372
|
+
// think we also want to do the same when "hidden", as there shouldn't be
|
|
373
|
+
// any action to take if user has gone idle for a long period and then
|
|
374
|
+
// comes back to hide the tab. We don't trigger a full snapshot because
|
|
375
|
+
// we don't want to start a new session as they immediately have hidden
|
|
376
|
+
// the tab.
|
|
222
377
|
return;
|
|
223
378
|
}
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
//
|
|
227
|
-
//
|
|
228
|
-
|
|
229
|
-
_this.
|
|
230
|
-
}
|
|
379
|
+
// Otherwise if session is not expired...
|
|
380
|
+
// Update with current timestamp as the last session activity
|
|
381
|
+
// Only updating session on visibility change to be conservative about
|
|
382
|
+
// writing to session storage. This could be changed in the future.
|
|
383
|
+
updateSessionActivity({
|
|
384
|
+
stickySession: _this.options.stickySession,
|
|
385
|
+
});
|
|
386
|
+
// Send replay when the page/tab becomes hidden. There is no reason to send
|
|
387
|
+
// replay if it becomes visible, since no actions we care about were done
|
|
388
|
+
// while it was hidden
|
|
389
|
+
if (document.visibilityState !== 'visible') {
|
|
390
|
+
_this.finishReplayEvent();
|
|
391
|
+
}
|
|
231
392
|
};
|
|
232
393
|
this.rrwebRecordOptions = __assign({ maskAllInputs: maskAllInputs }, rrwebRecordOptions);
|
|
233
|
-
|
|
234
|
-
// TBD on behavior here (e.g. should this be saved to localStorage/cookies)
|
|
235
|
-
this.replayId = utils.uuid4();
|
|
394
|
+
this.options = { uploadMinDelay: uploadMinDelay, uploadMaxDelay: uploadMaxDelay, stickySession: stickySession };
|
|
236
395
|
this.events = [];
|
|
237
|
-
rrweb.record(__assign(__assign({}, this.rrwebRecordOptions), { emit: function (event, isCheckout) {
|
|
238
|
-
// "debounce" by `idleTimeout`, how often we save replay events i.e. we
|
|
239
|
-
// will save events only if 15 seconds have elapsed since the last
|
|
240
|
-
// event
|
|
241
|
-
//
|
|
242
|
-
// TODO: We probably want to have a hard timeout where we save
|
|
243
|
-
// so that it does not grow infinitely and we never have a replay
|
|
244
|
-
// saved
|
|
245
|
-
if (_this.timeout) {
|
|
246
|
-
window.clearTimeout(_this.timeout);
|
|
247
|
-
}
|
|
248
|
-
// Always create a new Sentry event on checkouts and clear existing rrweb events
|
|
249
|
-
if (isCheckout) {
|
|
250
|
-
console.log('$$$$$ IS CHECKOUT');
|
|
251
|
-
_this.events = [event];
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
_this.events.push(event);
|
|
255
|
-
}
|
|
256
|
-
// Set timer to send attachment to Sentry, will be cancelled if an
|
|
257
|
-
// event happens before `idleTimeout` elapses
|
|
258
|
-
_this.timeout = window.setTimeout(function () {
|
|
259
|
-
_this.isDebug &&
|
|
260
|
-
utils.logger.log('[Replay] rrweb timeout hit, finishing replay event');
|
|
261
|
-
_this.finishReplayEvent();
|
|
262
|
-
}, idleTimeout);
|
|
263
|
-
} }));
|
|
264
|
-
this.addListeners();
|
|
265
396
|
}
|
|
266
397
|
SentryReplay.attachmentUrlFromDsn = function (dsn, eventId) {
|
|
267
398
|
var host = dsn.host, path = dsn.path, projectId = dsn.projectId, port = dsn.port, protocol = dsn.protocol, user = dsn.user;
|
|
268
399
|
return "".concat(protocol, "://").concat(host).concat(port !== '' ? ":".concat(port) : '').concat(path !== '' ? "/".concat(path) : '', "/api/").concat(projectId, "/events/").concat(eventId, "/attachments/?sentry_key=").concat(user, "&sentry_version=7&sentry_client=replay");
|
|
269
400
|
};
|
|
270
|
-
Object.defineProperty(SentryReplay.prototype, "isDebug", {
|
|
271
|
-
get: function () {
|
|
272
|
-
return utils.isDebugBuild();
|
|
273
|
-
},
|
|
274
|
-
enumerable: false,
|
|
275
|
-
configurable: true
|
|
276
|
-
});
|
|
277
401
|
Object.defineProperty(SentryReplay.prototype, "instance", {
|
|
278
402
|
/**
|
|
279
403
|
* Get integration's instance on the current hub
|
|
@@ -286,17 +410,75 @@ var SentryReplay = /** @class */ (function () {
|
|
|
286
410
|
});
|
|
287
411
|
SentryReplay.prototype.setupOnce = function () {
|
|
288
412
|
var _this = this;
|
|
413
|
+
this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
414
|
+
// If there is no session, then something bad has happened - can't continue
|
|
415
|
+
if (!this.session) {
|
|
416
|
+
throw new Error('Invalid session');
|
|
417
|
+
}
|
|
289
418
|
// Tag all (non replay) events that get sent to Sentry with the current
|
|
290
419
|
// replay ID so that we can reference them later in the UI
|
|
291
420
|
Sentry__namespace.addGlobalEventProcessor(function (event) {
|
|
292
|
-
event.tags = __assign(__assign({}, event.tags), { replayId: _this.
|
|
421
|
+
event.tags = __assign(__assign({}, event.tags), { replayId: _this.session.id });
|
|
293
422
|
return event;
|
|
294
423
|
});
|
|
424
|
+
rrweb.record(__assign(__assign({}, this.rrwebRecordOptions), { emit: function (event, isCheckout) {
|
|
425
|
+
// We want to batch uploads of replay events. Save events only if
|
|
426
|
+
// `<uploadMinDelay>` milliseconds have elapsed since the last event
|
|
427
|
+
// *OR* if `<uploadMaxDelay>` milliseconds have elapsed.
|
|
428
|
+
var now = new Date().getTime();
|
|
429
|
+
// Timestamp of the first replay event since the last flush, this gets
|
|
430
|
+
// reset when we finish the replay event
|
|
431
|
+
if (!_this.initialEventTimestampSinceFlush) {
|
|
432
|
+
_this.initialEventTimestampSinceFlush = now;
|
|
433
|
+
}
|
|
434
|
+
var uploadMaxDelayExceeded = isExpired(_this.initialEventTimestampSinceFlush, _this.options.uploadMaxDelay, now);
|
|
435
|
+
// Do not finish the replay event if we receive a new replay event
|
|
436
|
+
// unless `<uploadMaxDelay>` ms have elapsed since the last time we
|
|
437
|
+
// finished the replay
|
|
438
|
+
if (_this.timeout && !uploadMaxDelayExceeded) {
|
|
439
|
+
window.clearTimeout(_this.timeout);
|
|
440
|
+
}
|
|
441
|
+
// We need to clear existing events on a checkout, otherwise they are
|
|
442
|
+
// incremental event updates and should be appended
|
|
443
|
+
if (isCheckout) {
|
|
444
|
+
_this.events = [event];
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
_this.events.push(event);
|
|
448
|
+
}
|
|
449
|
+
// This event type is a fullsnapshot, we should save immediately when this occurs
|
|
450
|
+
// See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16
|
|
451
|
+
if (event.type === 2) {
|
|
452
|
+
// A fullsnapshot happens on initial load and if we need to start a
|
|
453
|
+
// new replay due to idle timeout. In the later case we will need to
|
|
454
|
+
// create a new session before finishing the replay.
|
|
455
|
+
_this.loadSession({ expiry: SESSION_IDLE_DURATION });
|
|
456
|
+
_this.finishReplayEvent();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
// Set timer to finish replay event and send replay attachment to
|
|
460
|
+
// Sentry. Will be cancelled if an event happens before `uploadMinDelay`
|
|
461
|
+
// elapses.
|
|
462
|
+
_this.timeout = window.setTimeout(function () {
|
|
463
|
+
logger.log('rrweb timeout hit, finishing replay event');
|
|
464
|
+
_this.finishReplayEvent();
|
|
465
|
+
}, _this.options.uploadMinDelay);
|
|
466
|
+
} }));
|
|
467
|
+
this.addListeners();
|
|
295
468
|
// XXX: this needs to be in `setupOnce` vs `constructor`, otherwise SDK is
|
|
296
469
|
// not fully initialized and the event will not get properly sent to Sentry
|
|
297
|
-
this.createRootEvent();
|
|
298
470
|
this.createReplayEvent();
|
|
299
471
|
};
|
|
472
|
+
/**
|
|
473
|
+
* Loads a session from storage, or creates a new one
|
|
474
|
+
*/
|
|
475
|
+
SentryReplay.prototype.loadSession = function (_a) {
|
|
476
|
+
var expiry = _a.expiry;
|
|
477
|
+
this.session = getSession({
|
|
478
|
+
expiry: expiry,
|
|
479
|
+
stickySession: this.options.stickySession,
|
|
480
|
+
});
|
|
481
|
+
};
|
|
300
482
|
SentryReplay.prototype.addListeners = function () {
|
|
301
483
|
document.addEventListener('visibilitychange', this.handleVisibilityChange);
|
|
302
484
|
if ('PerformanceObserver' in window) {
|
|
@@ -308,36 +490,13 @@ var SentryReplay = /** @class */ (function () {
|
|
|
308
490
|
}
|
|
309
491
|
};
|
|
310
492
|
/**
|
|
311
|
-
*
|
|
312
|
-
*
|
|
493
|
+
* Trigger rrweb to take a full snapshot which will cause this plugin to
|
|
494
|
+
* create a new Replay event.
|
|
313
495
|
*/
|
|
314
|
-
SentryReplay.prototype.
|
|
315
|
-
|
|
496
|
+
SentryReplay.prototype.triggerFullSnapshot = function () {
|
|
497
|
+
logger.log('Taking full rrweb snapshot');
|
|
316
498
|
rrweb.record.takeFullSnapshot(true);
|
|
317
499
|
};
|
|
318
|
-
/**
|
|
319
|
-
* Creates the Sentry event that all replays will be saved to as attachments.
|
|
320
|
-
* Currently, we only expect one of these per "replay session" (which is not
|
|
321
|
-
* explicitly defined yet).
|
|
322
|
-
*/
|
|
323
|
-
SentryReplay.prototype.createRootEvent = function () {
|
|
324
|
-
// TODO: Figure out if we need to do this, when this gets called from `setupOnce`, `this.instance` is still undefined.
|
|
325
|
-
// if (!this.instance) return;
|
|
326
|
-
this.isDebug && utils.logger.log("[Replay] creating root replay event");
|
|
327
|
-
// Create a transaction to attach event to
|
|
328
|
-
var transaction = Sentry__namespace.getCurrentHub().startTransaction({
|
|
329
|
-
name: 'sentry-replay',
|
|
330
|
-
tags: {
|
|
331
|
-
hasReplay: 'yes',
|
|
332
|
-
replayId: this.replayId,
|
|
333
|
-
},
|
|
334
|
-
});
|
|
335
|
-
// We have to finish the transaction to get an event ID to be able to
|
|
336
|
-
// upload an attachment for that event
|
|
337
|
-
// @ts-expect-error This returns an eventId (string), but is not typed as such
|
|
338
|
-
this.eventId = transaction.finish();
|
|
339
|
-
return this.eventId;
|
|
340
|
-
};
|
|
341
500
|
/**
|
|
342
501
|
* This is our pseudo replay event disguised as a transaction. It will be
|
|
343
502
|
* used to store performance entries and breadcrumbs for every incremental
|
|
@@ -345,12 +504,13 @@ var SentryReplay = /** @class */ (function () {
|
|
|
345
504
|
**/
|
|
346
505
|
SentryReplay.prototype.createReplayEvent = function () {
|
|
347
506
|
var _this = this;
|
|
348
|
-
|
|
507
|
+
logger.log('CreateReplayEvent rootReplayId', this.session.id);
|
|
349
508
|
this.replayEvent = Sentry__namespace.startTransaction({
|
|
350
509
|
name: 'sentry-replay-event',
|
|
510
|
+
parentSpanId: this.session.spanId,
|
|
511
|
+
traceId: this.session.traceId,
|
|
351
512
|
tags: {
|
|
352
|
-
|
|
353
|
-
replayId: this.replayId,
|
|
513
|
+
replayId: this.session.id,
|
|
354
514
|
},
|
|
355
515
|
});
|
|
356
516
|
Sentry__namespace.configureScope(function (scope) { return scope.setSpan(_this.replayEvent); });
|
|
@@ -389,12 +549,22 @@ var SentryReplay = /** @class */ (function () {
|
|
|
389
549
|
SentryReplay.prototype.finishReplayEvent = function () {
|
|
390
550
|
// if (!this.instance) return;
|
|
391
551
|
var _a;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
552
|
+
// Ensure that our existing session has not expired
|
|
553
|
+
var isExpired = isSessionExpired(this.session, SESSION_IDLE_DURATION);
|
|
554
|
+
if (isExpired) {
|
|
555
|
+
// TBD: If it is expired, we do not send any events...we could send to
|
|
556
|
+
// the expired session, but not sure if that's great
|
|
557
|
+
console.error(new Error('Attempting to finish replay event after session expired.'));
|
|
558
|
+
return;
|
|
559
|
+
}
|
|
560
|
+
if (!this.session.id) {
|
|
561
|
+
console.error(new Error('[Sentry]: No transaction, no replay'));
|
|
395
562
|
return;
|
|
396
563
|
}
|
|
397
|
-
this.sendReplay(
|
|
564
|
+
this.sendReplay(this.session.id);
|
|
565
|
+
this.initialEventTimestampSinceFlush = null;
|
|
566
|
+
// TBD: Alternatively we could update this after every rrweb event
|
|
567
|
+
this.session.lastActivity = new Date().getTime();
|
|
398
568
|
// include performance entries
|
|
399
569
|
this.addPerformanceEntries();
|
|
400
570
|
// Close out existing replay event and create a new one
|
|
@@ -423,15 +593,14 @@ var SentryReplay = /** @class */ (function () {
|
|
|
423
593
|
}), "rrweb-".concat(new Date().getTime(), ".json"));
|
|
424
594
|
// If sendBeacon is supported and payload is smol enough...
|
|
425
595
|
if (this.hasSendBeacon() && stringifiedPayload.length <= 65536) {
|
|
426
|
-
|
|
427
|
-
utils.logger.log("[Replay] uploading attachment via sendBeacon()");
|
|
596
|
+
logger.log("uploading attachment via sendBeacon()");
|
|
428
597
|
window.navigator.sendBeacon(endpoint, formData);
|
|
429
598
|
return [2 /*return*/];
|
|
430
599
|
}
|
|
431
600
|
_a.label = 1;
|
|
432
601
|
case 1:
|
|
433
602
|
_a.trys.push([1, 3, , 4]);
|
|
434
|
-
|
|
603
|
+
logger.log("uploading attachment via fetch()");
|
|
435
604
|
// Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads
|
|
436
605
|
return [4 /*yield*/, fetch(endpoint, {
|
|
437
606
|
method: 'POST',
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../node_modules/.pnpm/@rollup+plugin-typescript@8.3.1_859e05ab655ea3c900a5f26a0311c0b5/node_modules/tslib/tslib.es6.js","../../src/createPerformanceEntry.ts","../../src/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","type EntryType =\n | 'element'\n | 'navigation'\n | 'resource'\n | 'mark'\n | 'measure'\n | 'paint'\n | 'longtask';\n\nexport interface ReplayPerformanceEntry {\n /**\n * One of these types https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType\n */\n type: string;\n\n /**\n * A more specific description of the performance entry\n */\n name: string;\n\n /**\n * The start timestamp in seconds\n */\n start: number;\n\n /**\n * The end timestamp in seconds\n */\n end: number;\n\n /**\n * Additional unstructured data to be included\n */\n data?: Record<string, any>;\n}\n\n// Map entryType -> function to normalize data for event\nconst ENTRY_TYPES: Record<\n string,\n (entry: PerformanceEntry) => ReplayPerformanceEntry\n> = {\n resource: createResourceEntry,\n paint: createPaintEntry,\n navigation: createNavigationEntry,\n ['largest-contentful-paint']: createLargestContentfulPaint,\n};\n\nexport function createPerformanceEntries(entries: PerformanceEntry[]) {\n return entries.map(createPerformanceEntry).filter(Boolean);\n}\n\nfunction createPerformanceEntry(entry: PerformanceEntry) {\n if (ENTRY_TYPES[entry.entryType] === undefined) {\n return null;\n }\n\n return ENTRY_TYPES[entry.entryType](entry);\n}\n\nfunction getAbsoluteTime(time: number) {\n return (window.performance.timeOrigin + time) / 1000;\n}\n\nfunction createPaintEntry(entry: PerformancePaintTiming) {\n const { duration, entryType, name, startTime } = entry;\n\n const start = getAbsoluteTime(startTime);\n return {\n type: entryType,\n name,\n start,\n end: start + duration,\n };\n}\n\nfunction createNavigationEntry(entry: PerformanceNavigationTiming) {\n // TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)\n\n const { entryType, name, domComplete, startTime, transferSize, type } = entry;\n\n return {\n type: `${entryType}.${type}`,\n start: getAbsoluteTime(startTime),\n end: getAbsoluteTime(domComplete),\n name,\n data: {\n size: transferSize,\n },\n };\n}\nfunction createResourceEntry(entry: PerformanceResourceTiming) {\n const {\n entryType,\n initiatorType,\n name,\n responseEnd,\n startTime,\n transferSize,\n } = entry;\n\n return {\n type: `${entryType}.${initiatorType}`,\n start: getAbsoluteTime(startTime),\n end: getAbsoluteTime(responseEnd),\n name,\n data: {\n size: transferSize,\n },\n };\n}\n\nfunction createLargestContentfulPaint(\n entry: PerformanceEntry & { size: number }\n) {\n const { duration, entryType, startTime, size } = entry;\n\n const start = getAbsoluteTime(startTime);\n return {\n type: entryType,\n name: entryType,\n start,\n end: start + duration,\n data: {\n size,\n },\n };\n}\n","import * as Sentry from '@sentry/browser';\nimport { DsnComponents, Hub, Transaction } from '@sentry/types';\nimport { isDebugBuild, logger, uuid4 } from '@sentry/utils';\n\nimport { record } from 'rrweb';\nimport type { eventWithTime } from 'rrweb/typings/types';\nimport {\n createPerformanceEntries,\n ReplayPerformanceEntry,\n} from './createPerformanceEntry';\n\ntype RRWebEvent = eventWithTime;\ntype RRWebOptions = Parameters<typeof record>[0];\n\ninterface SentryReplayConfiguration {\n idleTimeout?: number;\n rrwebConfig?: RRWebOptions;\n}\n\nconst VISIBILITY_CHANGE_TIMEOUT = 5000;\n\nexport class SentryReplay {\n /**\n * @inheritDoc\n */\n public static id = 'Replay';\n\n /**\n * @inheritDoc\n */\n public name: string = SentryReplay.id;\n\n /**\n * Buffer of rrweb events that will be serialized as JSON and saved as an attachment to a Sentry event\n */\n public events: RRWebEvent[] = [];\n\n public performanceEvents: PerformanceEntry[] = [];\n\n /**\n * The id of the root Sentry event that all attachments will be saved to\n */\n private eventId: string | undefined;\n\n /**\n * A unique id per \"replay session\" (the term is currently not defined yet)\n */\n private replayId: string | undefined;\n\n /**\n * A Sentry Transaction that should capture every incremental rrweb update,\n * but *not* the attachments themselves. This is currently used to capture\n * breadcrumbs and maybe other spans (e.g. network requests)\n */\n private replayEvent: Transaction | undefined;\n\n /**\n * Options to pass to rrweb.record\n */\n private readonly rrwebRecordOptions: RRWebOptions;\n\n /**\n * setTimeout id used for debouncing sending rrweb attachments\n */\n private timeout: number;\n\n /**\n * timer id used to consider when the page has become inactive (e.g. from switching tags)\n */\n private visibilityChangeTimer: number | null;\n\n private performanceObserver: PerformanceObserver | null = null;\n\n private static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string) {\n const { host, path, projectId, port, protocol, user } = dsn;\n return `${protocol}://${host}${port !== '' ? `:${port}` : ''}${\n path !== '' ? `/${path}` : ''\n }/api/${projectId}/events/${eventId}/attachments/?sentry_key=${user}&sentry_version=7&sentry_client=replay`;\n }\n\n private get isDebug(): boolean {\n return isDebugBuild();\n }\n\n /**\n * Get integration's instance on the current hub\n */\n private get instance() {\n return Sentry.getCurrentHub().getIntegration(SentryReplay);\n }\n\n public constructor({\n idleTimeout = 15000,\n rrwebConfig: { maskAllInputs = true, ...rrwebRecordOptions } = {},\n }: SentryReplayConfiguration = {}) {\n this.rrwebRecordOptions = {\n maskAllInputs,\n ...rrwebRecordOptions,\n };\n\n // Creates a new replay ID everytime we initialize the plugin (e.g. on every pageload).\n // TBD on behavior here (e.g. should this be saved to localStorage/cookies)\n this.replayId = uuid4();\n this.events = [];\n\n record({\n ...this.rrwebRecordOptions,\n emit: (event: RRWebEvent, isCheckout?: boolean) => {\n // \"debounce\" by `idleTimeout`, how often we save replay events i.e. we\n // will save events only if 15 seconds have elapsed since the last\n // event\n //\n // TODO: We probably want to have a hard timeout where we save\n // so that it does not grow infinitely and we never have a replay\n // saved\n if (this.timeout) {\n window.clearTimeout(this.timeout);\n }\n\n // Always create a new Sentry event on checkouts and clear existing rrweb events\n if (isCheckout) {\n console.log('$$$$$ IS CHECKOUT');\n this.events = [event];\n } else {\n this.events.push(event);\n }\n\n // Set timer to send attachment to Sentry, will be cancelled if an\n // event happens before `idleTimeout` elapses\n this.timeout = window.setTimeout(() => {\n this.isDebug &&\n logger.log('[Replay] rrweb timeout hit, finishing replay event');\n this.finishReplayEvent();\n }, idleTimeout);\n },\n });\n\n this.addListeners();\n }\n\n setupOnce() {\n // Tag all (non replay) events that get sent to Sentry with the current\n // replay ID so that we can reference them later in the UI\n Sentry.addGlobalEventProcessor((event) => {\n event.tags = { ...event.tags, replayId: this.replayId };\n return event;\n });\n\n // XXX: this needs to be in `setupOnce` vs `constructor`, otherwise SDK is\n // not fully initialized and the event will not get properly sent to Sentry\n this.createRootEvent();\n this.createReplayEvent();\n }\n\n private addListeners() {\n document.addEventListener('visibilitychange', this.handleVisibilityChange);\n\n if ('PerformanceObserver' in window) {\n this.performanceObserver = new PerformanceObserver(\n this.handlePerformanceObserver\n );\n\n // Observe everything for now\n this.performanceObserver.observe({\n entryTypes: [...PerformanceObserver.supportedEntryTypes],\n });\n }\n }\n\n /**\n * Keep a list of performance entries that will be sent with a replay\n */\n handlePerformanceObserver = (\n list: PerformanceObserverEntryList\n // observer: PerformanceObserver\n ) => {\n this.performanceEvents = [...this.performanceEvents, ...list.getEntries()];\n };\n\n /**\n * Handle when visibility of the page changes. (e.g. new tab is opened)\n */\n handleVisibilityChange = () => {\n if (\n document.visibilityState === 'visible' &&\n this.visibilityChangeTimer === null\n ) {\n // Page has become active/visible again after `VISIBILITY_CHANGE_TIMEOUT`\n // ms have elapsed, which means we will consider this a new session\n //\n // TBD if this is the behavior we want\n this.isDebug &&\n logger.log(\n '[Replay] document has become active, creating new \"session\"'\n );\n this.triggerNewSession();\n return;\n }\n\n // Send replay when the page/tab becomes hidden\n this.finishReplayEvent();\n\n // VISIBILITY_CHANGE_TIMEOUT gives the user buffer room to come back to the\n // page before we create a new session.\n this.visibilityChangeTimer = window.setTimeout(() => {\n this.visibilityChangeTimer = null;\n }, VISIBILITY_CHANGE_TIMEOUT);\n };\n\n /**\n * Creates a new replay \"session\". This will create a new Sentry event and\n * then trigger rrweb to take a full snapshot.\n */\n triggerNewSession() {\n this.isDebug && logger.log('[Replay] taking full rrweb snapshot');\n record.takeFullSnapshot(true);\n }\n\n /**\n * Creates the Sentry event that all replays will be saved to as attachments.\n * Currently, we only expect one of these per \"replay session\" (which is not\n * explicitly defined yet).\n */\n createRootEvent() {\n // TODO: Figure out if we need to do this, when this gets called from `setupOnce`, `this.instance` is still undefined.\n // if (!this.instance) return;\n\n this.isDebug && logger.log(`[Replay] creating root replay event`);\n\n // Create a transaction to attach event to\n const transaction = Sentry.getCurrentHub().startTransaction({\n name: 'sentry-replay',\n tags: {\n hasReplay: 'yes',\n replayId: this.replayId,\n },\n });\n\n // We have to finish the transaction to get an event ID to be able to\n // upload an attachment for that event\n // @ts-expect-error This returns an eventId (string), but is not typed as such\n this.eventId = transaction.finish();\n\n return this.eventId;\n }\n\n /**\n * This is our pseudo replay event disguised as a transaction. It will be\n * used to store performance entries and breadcrumbs for every incremental\n * replay event.\n **/\n createReplayEvent() {\n console.log('createReplayEvent rootReplayId', this.eventId);\n this.replayEvent = Sentry.startTransaction({\n name: 'sentry-replay-event',\n tags: {\n rootReplayId: this.eventId,\n replayId: this.replayId,\n },\n });\n Sentry.configureScope((scope) => scope.setSpan(this.replayEvent));\n return this.replayEvent;\n }\n\n /**\n * Create a span for each performance entry. The parent transaction is `this.replayEvent`.\n */\n createPerformanceSpans(entries: ReplayPerformanceEntry[]) {\n entries.forEach(({ type, start, end, name, data }) => {\n const span = this.replayEvent?.startChild({\n op: type,\n description: name,\n startTimestamp: start,\n data,\n });\n span.finish(end);\n });\n }\n\n /**\n * Observed performance events are added to `this.performanceEvents`. These\n * are included in the replay event before it is finished and sent to Sentry.\n */\n addPerformanceEntries() {\n // Copy and reset entries before processing\n const entries = [...this.performanceEvents];\n this.performanceEvents = [];\n\n // Parse the entries\n const entryEvents = createPerformanceEntries(entries);\n\n // This current implementation is to create spans on the transaction referenced in `this.replayEvent`\n this.createPerformanceSpans(entryEvents);\n }\n\n finishReplayEvent() {\n // if (!this.instance) return;\n\n const eventId = this.eventId || this.createRootEvent();\n\n if (!eventId) {\n console.error('[Sentry]: No transaction, no replay');\n return;\n }\n\n this.sendReplay(eventId);\n\n // include performance entries\n this.addPerformanceEntries();\n\n // Close out existing replay event and create a new one\n this.replayEvent?.setStatus('ok').finish();\n this.createReplayEvent();\n }\n\n /**\n * Determine if there is browser support for `navigator.sendBeacon`\n */\n hasSendBeacon() {\n return 'navigator' in window && 'sendBeacon' in window.navigator;\n }\n\n /**\n * Send replay attachment using either `sendBeacon()` or `fetch()`\n */\n async sendReplayRequest(endpoint: string, events: RRWebEvent[]) {\n const stringifiedPayload = JSON.stringify({ events });\n const formData = new FormData();\n formData.append(\n 'rrweb',\n new Blob([stringifiedPayload], {\n type: 'application/json',\n }),\n `rrweb-${new Date().getTime()}.json`\n );\n\n // If sendBeacon is supported and payload is smol enough...\n if (this.hasSendBeacon() && stringifiedPayload.length <= 65536) {\n this.isDebug &&\n logger.log(`[Replay] uploading attachment via sendBeacon()`);\n window.navigator.sendBeacon(endpoint, formData);\n return;\n }\n\n try {\n this.isDebug && logger.log(`[Replay] uploading attachment via fetch()`);\n // Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads\n await fetch(endpoint, {\n method: 'POST',\n body: formData,\n });\n } catch (ex) {\n // we have to catch this otherwise it throws an infinite loop in Sentry\n console.error(ex);\n }\n }\n\n /**\n * Finalize and send the current replay event to Sentry\n */\n async sendReplay(eventId: string) {\n // if (!this.instance) return;\n\n try {\n // short circuit if theres no events to replay\n if (!this.events.length) return;\n\n const client = Sentry.getCurrentHub().getClient();\n const endpoint = SentryReplay.attachmentUrlFromDsn(\n client.getDsn(),\n eventId\n );\n\n await this.sendReplayRequest(endpoint, this.events);\n this.events = [];\n return true;\n } catch (ex) {\n console.error(ex);\n return false;\n }\n }\n}\n"],"names":["logger","uuid4","record","isDebugBuild","Sentry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBA;AACO,IAAI,QAAQ,GAAG,WAAW;AACjC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC,EAAE;AACrD,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC7D,YAAY,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC7B,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,SAAS;AACT,QAAQ,OAAO,CAAC,CAAC;AACjB,MAAK;AACL,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC3C,EAAC;AACD;AACO,SAAS,MAAM,CAAC,CAAC,EAAE,CA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e,EAAA;;;;;;;;AAK5B,wBAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM;4BAAE,OAAO,CAAA,CAAA,YAAA,CAAA;wBAE1B,MAAM,GAAGI,iBAAM,CAAC,aAAa,EAAE,CAAC,SAAS,EAAE,CAAC;AAC5C,wBAAA,QAAQ,GAAG,YAAY,CAAC,oBAAoB,CAChD,MAAM,CAAC,MAAM,EAAE,EACf,OAAO,CACR,CAAC;wBAEF,OAAM,CAAA,CAAA,YAAA,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA,CAAA;;AAAnD,wBAAA,EAAA,CAAA,IAAA,EAAmD,CAAC;AACpD,wBAAA,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;AACjB,wBAAA,OAAA,CAAA,CAAA,aAAO,IAAI,CAAC,CAAA;;;AAEZ,wBAAA,OAAO,CAAC,KAAK,CAAC,IAAE,CAAC,CAAC;AAClB,wBAAA,OAAA,CAAA,CAAA,aAAO,KAAK,CAAC,CAAA;;;;;AAEhB,KAAA,CAAA;AAtWD;;AAEG;IACW,YAAE,CAAA,EAAA,GAAG,QAAQ,CAAC;IAoW9B,OAAC,YAAA,CAAA;AAAA,CAxWD,EAwWC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../node_modules/.pnpm/@rollup+plugin-typescript@8.3.1_859e05ab655ea3c900a5f26a0311c0b5/node_modules/tslib/tslib.es6.js","../../src/createPerformanceEntry.ts","../../src/util/isExpired.ts","../../src/util/isSessionExpired.ts","../../src/util/logger.ts","../../src/session/constants.ts","../../src/session/saveSession.ts","../../src/session/createSession.ts","../../src/session/fetchSession.ts","../../src/session/getSession.ts","../../src/session/updateSessionActivity.ts","../../src/index.ts"],"sourcesContent":["/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n","type EntryType =\n | 'element'\n | 'navigation'\n | 'resource'\n | 'mark'\n | 'measure'\n | 'paint'\n | 'longtask';\n\nexport interface ReplayPerformanceEntry {\n /**\n * One of these types https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry/entryType\n */\n type: string;\n\n /**\n * A more specific description of the performance entry\n */\n name: string;\n\n /**\n * The start timestamp in seconds\n */\n start: number;\n\n /**\n * The end timestamp in seconds\n */\n end: number;\n\n /**\n * Additional unstructured data to be included\n */\n data?: Record<string, any>;\n}\n\n// Map entryType -> function to normalize data for event\nconst ENTRY_TYPES: Record<\n string,\n (entry: PerformanceEntry) => ReplayPerformanceEntry\n> = {\n resource: createResourceEntry,\n paint: createPaintEntry,\n navigation: createNavigationEntry,\n ['largest-contentful-paint']: createLargestContentfulPaint,\n};\n\nexport function createPerformanceEntries(entries: PerformanceEntry[]) {\n return entries.map(createPerformanceEntry).filter(Boolean);\n}\n\nfunction createPerformanceEntry(entry: PerformanceEntry) {\n if (ENTRY_TYPES[entry.entryType] === undefined) {\n return null;\n }\n\n return ENTRY_TYPES[entry.entryType](entry);\n}\n\nfunction getAbsoluteTime(time: number) {\n return (window.performance.timeOrigin + time) / 1000;\n}\n\nfunction createPaintEntry(entry: PerformancePaintTiming) {\n const { duration, entryType, name, startTime } = entry;\n\n const start = getAbsoluteTime(startTime);\n return {\n type: entryType,\n name,\n start,\n end: start + duration,\n };\n}\n\nfunction createNavigationEntry(entry: PerformanceNavigationTiming) {\n // TODO: There looks to be some more interesting bits in here (domComplete, domContentLoaded)\n\n const { entryType, name, domComplete, startTime, transferSize, type } = entry;\n\n return {\n type: `${entryType}.${type}`,\n start: getAbsoluteTime(startTime),\n end: getAbsoluteTime(domComplete),\n name,\n data: {\n size: transferSize,\n },\n };\n}\nfunction createResourceEntry(entry: PerformanceResourceTiming) {\n const {\n entryType,\n initiatorType,\n name,\n responseEnd,\n startTime,\n transferSize,\n } = entry;\n\n return {\n type: `${entryType}.${initiatorType}`,\n start: getAbsoluteTime(startTime),\n end: getAbsoluteTime(responseEnd),\n name,\n data: {\n size: transferSize,\n },\n };\n}\n\nfunction createLargestContentfulPaint(\n entry: PerformanceEntry & { size: number }\n) {\n const { duration, entryType, startTime, size } = entry;\n\n const start = getAbsoluteTime(startTime);\n return {\n type: entryType,\n name: entryType,\n start,\n end: start + duration,\n data: {\n size,\n },\n };\n}\n","/**\n * Given an initial timestamp and an expiry duration, checks to see if current\n * time should be considered as expired.\n */\nexport function isExpired(\n initialTime: number,\n expiry: number,\n targetTime: number = +new Date()\n) {\n // Always expired if < 0\n if (expiry < 0) {\n return true;\n }\n\n // Never expires if == 0\n if (expiry === 0) {\n return false;\n }\n\n return initialTime + expiry <= targetTime;\n}\n","import { ReplaySession } from '@/session';\nimport { isExpired } from './isExpired';\n\n/**\n * Checks to see if session is expired\n */\nexport function isSessionExpired(\n session: ReplaySession,\n expiry: number,\n targetTime = +new Date()\n) {\n return isExpired(session.lastActivity, expiry, targetTime);\n}\n","import { isDebugBuild, logger as sentryLogger } from '@sentry/utils';\n\nfunction wrapLogger(logFn: typeof sentryLogger[keyof typeof sentryLogger]) {\n return function wrappedLog(...args: any[]) {\n if (!isDebugBuild()) {\n return;\n }\n return logFn.call(sentryLogger, '[Replay]', ...args);\n };\n}\n\nconst logger = {\n ...sentryLogger,\n error: wrapLogger(sentryLogger.error),\n warn: wrapLogger(sentryLogger.warn),\n log: wrapLogger(sentryLogger.log),\n};\n\nexport { logger };\n","export const REPLAY_SESSION_KEY = 'sentryReplaySession';\n","import { REPLAY_SESSION_KEY } from './constants';\nimport { ReplaySession } from './types';\n\nexport function saveSession(session: ReplaySession) {\n const hasSessionStorage = 'sessionStorage' in window;\n if (!hasSessionStorage) {\n return;\n }\n\n try {\n window.sessionStorage.setItem(REPLAY_SESSION_KEY, JSON.stringify(session));\n } catch {\n // this shouldn't happen\n }\n}\n","import * as Sentry from '@sentry/browser';\n\nimport { logger } from '@/util/logger';\nimport { saveSession } from './saveSession';\nimport type { ReplaySession } from './types';\n\ninterface CreateSessionParams {\n /**\n * Should save to sessionStorage?\n */\n stickySession: boolean;\n}\n\n/**\n * Create a new session, which in its current implementation is a Sentry event\n * that all replays will be saved to as attachments. Currently, we only expect\n * one of these Sentry events per \"replay session\".\n */\nexport function createSession({\n stickySession = false,\n}: CreateSessionParams): ReplaySession {\n const currentDate = new Date().getTime();\n\n // Create root replay event, this is where attachments will be saved\n const transaction = Sentry.getCurrentHub().startTransaction({\n name: 'sentry-replay',\n tags: {\n isReplayRoot: 'yes',\n },\n });\n\n // We have to finish the transaction to get an event ID to be able to\n // upload an attachment for that event\n // @ts-expect-error This returns an eventId (string), but is not typed as such\n const id: string = transaction.finish();\n\n logger.log(`Creating new session: ${id}`);\n\n const session = {\n id,\n spanId: transaction.spanId,\n traceId: transaction.traceId,\n started: currentDate,\n lastActivity: currentDate,\n };\n\n if (stickySession) {\n saveSession(session);\n }\n\n return session;\n}\n","import { REPLAY_SESSION_KEY } from './constants';\nimport { ReplaySession } from './types';\n\nexport function fetchSession(): ReplaySession | null {\n const hasSessionStorage = 'sessionStorage' in window;\n\n if (!hasSessionStorage) {\n return null;\n }\n\n try {\n return JSON.parse(window.sessionStorage.getItem(REPLAY_SESSION_KEY));\n } catch {\n return null;\n }\n}\n","import { isSessionExpired } from '@/util/isSessionExpired';\nimport { logger } from '@/util/logger';\nimport { createSession } from './createSession';\nimport { fetchSession } from './fetchSession';\n\ninterface GetSessionParams {\n /**\n * The length of time (in ms) which we will consider the session to be expired.\n */\n expiry: number;\n /**\n * Should save session to sessionStorage?\n */\n stickySession: boolean;\n}\n\n/**\n * Get or create a session\n */\nexport function getSession({ expiry, stickySession }: GetSessionParams) {\n const session = stickySession && fetchSession();\n\n if (session) {\n // If there is a session, check if it is valid (e.g. \"last activity\" time should be within the \"session idle time\")\n // TODO: We should probably set a max age on this as well\n const isExpired = isSessionExpired(session, expiry);\n\n if (!isExpired) {\n logger.log(`Using existing session: ${session.id}`);\n return session;\n } else {\n logger.log(`Session has expired`);\n }\n // Otherwise continue to create a new session\n }\n\n const newSession = createSession({ stickySession });\n\n return newSession;\n}\n","import { createSession } from './createSession';\nimport { fetchSession } from './fetchSession';\nimport { saveSession } from './saveSession';\n\nexport function updateSessionActivity({\n stickySession,\n}: {\n stickySession: boolean;\n}) {\n // Nothing to do if there are no sticky sessions\n if (!stickySession) {\n return;\n }\n\n const existingSession = fetchSession();\n\n // If user manually deleted from session storage, create a new session\n if (!existingSession) {\n // TBD: There was an issue here where sessions weren't saving and this\n // caused lots of transactions to be created\n return createSession({ stickySession });\n }\n\n const newSession = {\n ...existingSession,\n lastActivity: new Date().getTime(),\n };\n\n saveSession(newSession);\n\n return newSession;\n}\n","import * as Sentry from '@sentry/browser';\nimport { DsnComponents, Event, Scope, Transaction } from '@sentry/types';\n\nimport { record } from 'rrweb';\nimport type { eventWithTime } from 'rrweb/typings/types';\nimport {\n createPerformanceEntries,\n ReplayPerformanceEntry,\n} from './createPerformanceEntry';\nimport { ReplaySession } from './session';\nimport { getSession } from './session/getSession';\nimport { updateSessionActivity } from './session/updateSessionActivity';\nimport { isExpired } from './util/isExpired';\nimport { isSessionExpired } from './util/isSessionExpired';\nimport { logger } from './util/logger';\n\ntype RRWebEvent = eventWithTime;\ntype RRWebOptions = Parameters<typeof record>[0];\n\ninterface PluginOptions {\n /**\n * The amount of time to wait before sending a replay\n */\n uploadMinDelay?: number;\n\n /**\n * The max amount of time to wait before sending a replay\n */\n uploadMaxDelay?: number;\n\n /**\n * If false, will create a new session per pageload\n */\n stickySession?: boolean;\n}\n\ninterface SentryReplayConfiguration extends PluginOptions {\n /**\n * Options for `rrweb.record`\n */\n rrwebConfig?: RRWebOptions;\n}\n\nconst VISIBILITY_CHANGE_TIMEOUT = 60000; // 1 minute\nconst SESSION_IDLE_DURATION = 900000; // 15 minutes\n\nexport class SentryReplay {\n /**\n * @inheritDoc\n */\n public static id = 'Replay';\n\n /**\n * @inheritDoc\n */\n public name: string = SentryReplay.id;\n\n /**\n * Buffer of rrweb events that will be serialized as JSON and saved as an attachment to a Sentry event\n */\n public events: RRWebEvent[] = [];\n\n public performanceEvents: PerformanceEntry[] = [];\n\n /**\n * A Sentry Transaction that should capture every incremental rrweb update,\n * but *not* the attachments themselves. This is currently used to capture\n * breadcrumbs and maybe other spans (e.g. network requests)\n */\n private replayEvent: Transaction | undefined;\n\n /**\n * Options to pass to `rrweb.record()`\n */\n private readonly rrwebRecordOptions: RRWebOptions;\n\n private readonly options: PluginOptions;\n\n /**\n * setTimeout id used for debouncing sending rrweb attachments\n */\n private timeout: number;\n\n /**\n * The timestamp of the first event since the last flush.\n * This is used to determine if the maximum allowed time has passed before we should flush events again.\n */\n private initialEventTimestampSinceFlush: number | null = null;\n\n private performanceObserver: PerformanceObserver | null = null;\n\n private session: ReplaySession | undefined;\n\n private static attachmentUrlFromDsn(dsn: DsnComponents, eventId: string) {\n const { host, path, projectId, port, protocol, user } = dsn;\n return `${protocol}://${host}${port !== '' ? `:${port}` : ''}${\n path !== '' ? `/${path}` : ''\n }/api/${projectId}/events/${eventId}/attachments/?sentry_key=${user}&sentry_version=7&sentry_client=replay`;\n }\n\n /**\n * Get integration's instance on the current hub\n */\n private get instance() {\n return Sentry.getCurrentHub().getIntegration(SentryReplay);\n }\n\n public constructor({\n uploadMinDelay = 5000,\n uploadMaxDelay = 15000,\n stickySession = false, // TBD: Making this opt-in for now\n rrwebConfig: { maskAllInputs = true, ...rrwebRecordOptions } = {},\n }: SentryReplayConfiguration = {}) {\n this.rrwebRecordOptions = {\n maskAllInputs,\n ...rrwebRecordOptions,\n };\n\n this.options = { uploadMinDelay, uploadMaxDelay, stickySession };\n this.events = [];\n }\n\n setupOnce() {\n this.loadSession({ expiry: SESSION_IDLE_DURATION });\n\n // If there is no session, then something bad has happened - can't continue\n if (!this.session) {\n throw new Error('Invalid session');\n }\n\n // Tag all (non replay) events that get sent to Sentry with the current\n // replay ID so that we can reference them later in the UI\n Sentry.addGlobalEventProcessor((event: Event) => {\n event.tags = { ...event.tags, replayId: this.session.id };\n return event;\n });\n\n record({\n ...this.rrwebRecordOptions,\n emit: (event: RRWebEvent, isCheckout?: boolean) => {\n // We want to batch uploads of replay events. Save events only if\n // `<uploadMinDelay>` milliseconds have elapsed since the last event\n // *OR* if `<uploadMaxDelay>` milliseconds have elapsed.\n\n const now = new Date().getTime();\n\n // Timestamp of the first replay event since the last flush, this gets\n // reset when we finish the replay event\n if (!this.initialEventTimestampSinceFlush) {\n this.initialEventTimestampSinceFlush = now;\n }\n\n const uploadMaxDelayExceeded = isExpired(\n this.initialEventTimestampSinceFlush,\n this.options.uploadMaxDelay,\n now\n );\n\n // Do not finish the replay event if we receive a new replay event\n // unless `<uploadMaxDelay>` ms have elapsed since the last time we\n // finished the replay\n if (this.timeout && !uploadMaxDelayExceeded) {\n window.clearTimeout(this.timeout);\n }\n\n // We need to clear existing events on a checkout, otherwise they are\n // incremental event updates and should be appended\n if (isCheckout) {\n this.events = [event];\n } else {\n this.events.push(event);\n }\n\n // This event type is a fullsnapshot, we should save immediately when this occurs\n // See https://github.com/rrweb-io/rrweb/blob/d8f9290ca496712aa1e7d472549480c4e7876594/packages/rrweb/src/types.ts#L16\n if (event.type === 2) {\n // A fullsnapshot happens on initial load and if we need to start a\n // new replay due to idle timeout. In the later case we will need to\n // create a new session before finishing the replay.\n this.loadSession({ expiry: SESSION_IDLE_DURATION });\n this.finishReplayEvent();\n return;\n }\n\n // Set timer to finish replay event and send replay attachment to\n // Sentry. Will be cancelled if an event happens before `uploadMinDelay`\n // elapses.\n this.timeout = window.setTimeout(() => {\n logger.log('rrweb timeout hit, finishing replay event');\n this.finishReplayEvent();\n }, this.options.uploadMinDelay);\n },\n });\n\n this.addListeners();\n\n // XXX: this needs to be in `setupOnce` vs `constructor`, otherwise SDK is\n // not fully initialized and the event will not get properly sent to Sentry\n this.createReplayEvent();\n }\n\n /**\n * Loads a session from storage, or creates a new one\n */\n loadSession({ expiry }: { expiry: number }): void {\n this.session = getSession({\n expiry,\n stickySession: this.options.stickySession,\n });\n }\n\n addListeners() {\n document.addEventListener('visibilitychange', this.handleVisibilityChange);\n\n if ('PerformanceObserver' in window) {\n this.performanceObserver = new PerformanceObserver(\n this.handlePerformanceObserver\n );\n\n // Observe everything for now\n this.performanceObserver.observe({\n entryTypes: [...PerformanceObserver.supportedEntryTypes],\n });\n }\n }\n\n /**\n * Keep a list of performance entries that will be sent with a replay\n */\n handlePerformanceObserver = (\n list: PerformanceObserverEntryList\n // observer: PerformanceObserver\n ) => {\n this.performanceEvents = [...this.performanceEvents, ...list.getEntries()];\n };\n\n /**\n * Handle when visibility of the page changes. (e.g. new tab is opened)\n */\n handleVisibilityChange = () => {\n const isExpired = isSessionExpired(this.session, VISIBILITY_CHANGE_TIMEOUT);\n\n if (isExpired) {\n if (document.visibilityState === 'visible') {\n // If the user has come back to the page within VISIBILITY_CHANGE_TIMEOUT\n // ms, we will re-use the existing session, otherwise create a new\n // session\n logger.log('Document has become active, but session has expired');\n this.triggerFullSnapshot();\n }\n // We definitely want to return if visibilityState is \"visible\", and I\n // think we also want to do the same when \"hidden\", as there shouldn't be\n // any action to take if user has gone idle for a long period and then\n // comes back to hide the tab. We don't trigger a full snapshot because\n // we don't want to start a new session as they immediately have hidden\n // the tab.\n return;\n }\n\n // Otherwise if session is not expired...\n\n // Update with current timestamp as the last session activity\n // Only updating session on visibility change to be conservative about\n // writing to session storage. This could be changed in the future.\n updateSessionActivity({\n stickySession: this.options.stickySession,\n });\n\n // Send replay when the page/tab becomes hidden. There is no reason to send\n // replay if it becomes visible, since no actions we care about were done\n // while it was hidden\n if (document.visibilityState !== 'visible') {\n this.finishReplayEvent();\n }\n };\n\n /**\n * Trigger rrweb to take a full snapshot which will cause this plugin to\n * create a new Replay event.\n */\n triggerFullSnapshot() {\n logger.log('Taking full rrweb snapshot');\n record.takeFullSnapshot(true);\n }\n\n /**\n * This is our pseudo replay event disguised as a transaction. It will be\n * used to store performance entries and breadcrumbs for every incremental\n * replay event.\n **/\n createReplayEvent() {\n logger.log('CreateReplayEvent rootReplayId', this.session.id);\n this.replayEvent = Sentry.startTransaction({\n name: 'sentry-replay-event',\n parentSpanId: this.session.spanId,\n traceId: this.session.traceId,\n tags: {\n replayId: this.session.id,\n },\n });\n Sentry.configureScope((scope: Scope) => scope.setSpan(this.replayEvent));\n return this.replayEvent;\n }\n\n /**\n * Create a span for each performance entry. The parent transaction is `this.replayEvent`.\n */\n createPerformanceSpans(entries: ReplayPerformanceEntry[]) {\n entries.forEach(({ type, start, end, name, data }) => {\n const span = this.replayEvent?.startChild({\n op: type,\n description: name,\n startTimestamp: start,\n data,\n });\n span.finish(end);\n });\n }\n\n /**\n * Observed performance events are added to `this.performanceEvents`. These\n * are included in the replay event before it is finished and sent to Sentry.\n */\n addPerformanceEntries() {\n // Copy and reset entries before processing\n const entries = [...this.performanceEvents];\n this.performanceEvents = [];\n\n // Parse the entries\n const entryEvents = createPerformanceEntries(entries);\n\n // This current implementation is to create spans on the transaction referenced in `this.replayEvent`\n this.createPerformanceSpans(entryEvents);\n }\n\n finishReplayEvent() {\n // if (!this.instance) return;\n\n // Ensure that our existing session has not expired\n const isExpired = isSessionExpired(this.session, SESSION_IDLE_DURATION);\n\n if (isExpired) {\n // TBD: If it is expired, we do not send any events...we could send to\n // the expired session, but not sure if that's great\n console.error(\n new Error('Attempting to finish replay event after session expired.')\n );\n return;\n }\n\n if (!this.session.id) {\n console.error(new Error('[Sentry]: No transaction, no replay'));\n return;\n }\n\n this.sendReplay(this.session.id);\n this.initialEventTimestampSinceFlush = null;\n // TBD: Alternatively we could update this after every rrweb event\n this.session.lastActivity = new Date().getTime();\n\n // include performance entries\n this.addPerformanceEntries();\n\n // Close out existing replay event and create a new one\n this.replayEvent?.setStatus('ok').finish();\n this.createReplayEvent();\n }\n\n /**\n * Determine if there is browser support for `navigator.sendBeacon`\n */\n hasSendBeacon() {\n return 'navigator' in window && 'sendBeacon' in window.navigator;\n }\n\n /**\n * Send replay attachment using either `sendBeacon()` or `fetch()`\n */\n async sendReplayRequest(endpoint: string, events: RRWebEvent[]) {\n const stringifiedPayload = JSON.stringify({ events });\n const formData = new FormData();\n formData.append(\n 'rrweb',\n new Blob([stringifiedPayload], {\n type: 'application/json',\n }),\n `rrweb-${new Date().getTime()}.json`\n );\n\n // If sendBeacon is supported and payload is smol enough...\n if (this.hasSendBeacon() && stringifiedPayload.length <= 65536) {\n logger.log(`uploading attachment via sendBeacon()`);\n window.navigator.sendBeacon(endpoint, formData);\n return;\n }\n\n try {\n logger.log(`uploading attachment via fetch()`);\n // Otherwise use `fetch`, which *WILL* get cancelled on page reloads/unloads\n await fetch(endpoint, {\n method: 'POST',\n body: formData,\n });\n } catch (ex) {\n // we have to catch this otherwise it throws an infinite loop in Sentry\n console.error(ex);\n }\n }\n\n /**\n * Finalize and send the current replay event to Sentry\n */\n async sendReplay(eventId: string) {\n // if (!this.instance) return;\n\n try {\n // short circuit if theres no events to replay\n if (!this.events.length) return;\n\n const client = Sentry.getCurrentHub().getClient();\n const endpoint = SentryReplay.attachmentUrlFromDsn(\n client.getDsn(),\n eventId\n );\n\n await this.sendReplayRequest(endpoint, this.events);\n this.events = [];\n return true;\n } catch (ex) {\n console.error(ex);\n return false;\n }\n }\n}\n"],"names":["isDebugBuild","sentryLogger","Sentry","record"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAiBA;AACO,IAAI,QAAQ,GAAG,WAAW;AACjC,IAAI,QAAQ,GAAG,MAAM,CAAC,MAAM,IAAI,SAAS,QAAQ,CAAC,CAAC,EAAE;AACrD,QAAQ,KAAK,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;AAC7D,YAAY,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAC7B,YAAY,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,SAAS;AACT,QAAQ,OAAO,CAAC,CAAC;AACjB,MAAK;AACL,IAAI,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC3C,EAAC;AACD;AACO,SAAS,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE;AAC7B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACf,IAAI,KAAK,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACvF,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CA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