@sentry/replay 7.59.3 → 7.60.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/cjs/index.js +64 -14
- package/cjs/index.js.map +1 -1
- package/esm/index.js +64 -14
- package/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/types/constants.d.ts +3 -0
- package/types/constants.d.ts.map +1 -1
- package/types/coreHandlers/handleClick.d.ts.map +1 -1
- package/types/coreHandlers/handleDom.d.ts.map +1 -1
- package/types/integration.d.ts +1 -1
- package/types/integration.d.ts.map +1 -1
- package/types/replay.d.ts.map +1 -1
- package/types/types/replay.d.ts +6 -0
- package/types/types/replay.d.ts.map +1 -1
- package/types/util/handleRecordingEmit.d.ts.map +1 -1
- package/types/util/timestamp.d.ts +9 -0
- package/types/util/timestamp.d.ts.map +1 -0
- package/types/util/timestampToMs.d.ts +0 -5
- package/types/util/timestampToMs.d.ts.map +0 -1
package/esm/index.js
CHANGED
|
@@ -46,6 +46,11 @@ const SLOW_CLICK_SCROLL_TIMEOUT = 300;
|
|
|
46
46
|
/** When encountering a total segment size exceeding this size, stop the replay (as we cannot properly ingest it). */
|
|
47
47
|
const REPLAY_MAX_EVENT_BUFFER_SIZE = 20000000; // ~20MB
|
|
48
48
|
|
|
49
|
+
/** Replays must be min. 5s long before we send them. */
|
|
50
|
+
const MIN_REPLAY_DURATION = 4999;
|
|
51
|
+
/* The max. allowed value that the minReplayDuration can be set to. */
|
|
52
|
+
const MIN_REPLAY_DURATION_LIMIT = 15000;
|
|
53
|
+
|
|
49
54
|
var NodeType$1;
|
|
50
55
|
(function (NodeType) {
|
|
51
56
|
NodeType[NodeType["Document"] = 0] = "Document";
|
|
@@ -3270,6 +3275,22 @@ record.takeFullSnapshot = (isCheckout) => {
|
|
|
3270
3275
|
};
|
|
3271
3276
|
record.mirror = mirror;
|
|
3272
3277
|
|
|
3278
|
+
/**
|
|
3279
|
+
* Converts a timestamp to ms, if it was in s, or keeps it as ms.
|
|
3280
|
+
*/
|
|
3281
|
+
function timestampToMs(timestamp) {
|
|
3282
|
+
const isMs = timestamp > 9999999999;
|
|
3283
|
+
return isMs ? timestamp : timestamp * 1000;
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3286
|
+
/**
|
|
3287
|
+
* Converts a timestamp to s, if it was in ms, or keeps it as s.
|
|
3288
|
+
*/
|
|
3289
|
+
function timestampToS(timestamp) {
|
|
3290
|
+
const isMs = timestamp > 9999999999;
|
|
3291
|
+
return isMs ? timestamp / 1000 : timestamp;
|
|
3292
|
+
}
|
|
3293
|
+
|
|
3273
3294
|
/**
|
|
3274
3295
|
* Add a breadcrumb event to replay.
|
|
3275
3296
|
*/
|
|
@@ -3469,7 +3490,7 @@ class ClickDetector {
|
|
|
3469
3490
|
}
|
|
3470
3491
|
|
|
3471
3492
|
const newClick = {
|
|
3472
|
-
timestamp: breadcrumb.timestamp,
|
|
3493
|
+
timestamp: timestampToS(breadcrumb.timestamp),
|
|
3473
3494
|
clickBreadcrumb: breadcrumb,
|
|
3474
3495
|
// Set this to 0 so we know it originates from the click breadcrumb
|
|
3475
3496
|
clickCount: 0,
|
|
@@ -3509,6 +3530,7 @@ class ClickDetector {
|
|
|
3509
3530
|
click.scrollAfter = click.timestamp <= this._lastScroll ? this._lastScroll - click.timestamp : undefined;
|
|
3510
3531
|
}
|
|
3511
3532
|
|
|
3533
|
+
// All of these are in seconds!
|
|
3512
3534
|
if (click.timestamp + this._timeout <= now) {
|
|
3513
3535
|
timedOutClicks.push(click);
|
|
3514
3536
|
}
|
|
@@ -3516,10 +3538,10 @@ class ClickDetector {
|
|
|
3516
3538
|
|
|
3517
3539
|
// Remove "old" clicks
|
|
3518
3540
|
for (const click of timedOutClicks) {
|
|
3519
|
-
this._generateBreadcrumbs(click);
|
|
3520
|
-
|
|
3521
3541
|
const pos = this._clicks.indexOf(click);
|
|
3522
|
-
|
|
3542
|
+
|
|
3543
|
+
if (pos > -1) {
|
|
3544
|
+
this._generateBreadcrumbs(click);
|
|
3523
3545
|
this._clicks.splice(pos, 1);
|
|
3524
3546
|
}
|
|
3525
3547
|
}
|
|
@@ -3711,8 +3733,16 @@ const handleDomListener = (
|
|
|
3711
3733
|
|
|
3712
3734
|
const isClick = handlerData.name === 'click';
|
|
3713
3735
|
const event = isClick && (handlerData.event );
|
|
3714
|
-
// Ignore clicks if ctrl/alt/meta keys are held down as they alter behavior of clicks (e.g. open in new tab)
|
|
3715
|
-
if (
|
|
3736
|
+
// Ignore clicks if ctrl/alt/meta/shift keys are held down as they alter behavior of clicks (e.g. open in new tab)
|
|
3737
|
+
if (
|
|
3738
|
+
isClick &&
|
|
3739
|
+
replay.clickDetector &&
|
|
3740
|
+
event &&
|
|
3741
|
+
!event.altKey &&
|
|
3742
|
+
!event.metaKey &&
|
|
3743
|
+
!event.ctrlKey &&
|
|
3744
|
+
!event.shiftKey
|
|
3745
|
+
) {
|
|
3716
3746
|
handleClick(
|
|
3717
3747
|
replay.clickDetector,
|
|
3718
3748
|
result ,
|
|
@@ -3984,14 +4014,6 @@ function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([0,0,0,0
|
|
|
3984
4014
|
|
|
3985
4015
|
function e(){const e=new Blob([r]);return URL.createObjectURL(e)}
|
|
3986
4016
|
|
|
3987
|
-
/**
|
|
3988
|
-
* Converts a timestamp to ms, if it was in s, or keeps it as ms.
|
|
3989
|
-
*/
|
|
3990
|
-
function timestampToMs(timestamp) {
|
|
3991
|
-
const isMs = timestamp > 9999999999;
|
|
3992
|
-
return isMs ? timestamp : timestamp * 1000;
|
|
3993
|
-
}
|
|
3994
|
-
|
|
3995
4017
|
/** This error indicates that the event buffer size exceeded the limit.. */
|
|
3996
4018
|
class EventBufferSizeExceededError extends Error {
|
|
3997
4019
|
constructor() {
|
|
@@ -6604,6 +6626,11 @@ function getHandleRecordingEmit(replay) {
|
|
|
6604
6626
|
if (replay.recordingMode === 'buffer' && replay.session && replay.eventBuffer) {
|
|
6605
6627
|
const earliestEvent = replay.eventBuffer.getEarliestTimestamp();
|
|
6606
6628
|
if (earliestEvent) {
|
|
6629
|
+
// eslint-disable-next-line no-console
|
|
6630
|
+
const log = replay.getOptions()._experiments.traceInternals ? console.info : logger.info;
|
|
6631
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
6632
|
+
log(`[Replay] Updating session start time to earliest event in buffer at ${earliestEvent}`);
|
|
6633
|
+
|
|
6607
6634
|
replay.session.started = earliestEvent;
|
|
6608
6635
|
|
|
6609
6636
|
if (replay.getOptions().stickySession) {
|
|
@@ -7385,6 +7412,10 @@ class ReplayContainer {
|
|
|
7385
7412
|
|
|
7386
7413
|
const activityTime = Date.now();
|
|
7387
7414
|
|
|
7415
|
+
// eslint-disable-next-line no-console
|
|
7416
|
+
const log = this.getOptions()._experiments.traceInternals ? console.info : logger.info;
|
|
7417
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && log(`[Replay] Converting buffer to session, starting at ${activityTime}`);
|
|
7418
|
+
|
|
7388
7419
|
// Allow flush to complete before resuming as a session recording, otherwise
|
|
7389
7420
|
// the checkout from `startRecording` may be included in the payload.
|
|
7390
7421
|
// Prefer to keep the error replay as a separate (and smaller) segment
|
|
@@ -8054,6 +8085,23 @@ class ReplayContainer {
|
|
|
8054
8085
|
return;
|
|
8055
8086
|
}
|
|
8056
8087
|
|
|
8088
|
+
const start = this.session.started;
|
|
8089
|
+
const now = Date.now();
|
|
8090
|
+
const duration = now - start;
|
|
8091
|
+
|
|
8092
|
+
// If session is too short, or too long (allow some wiggle room over maxSessionLife), do not send it
|
|
8093
|
+
// This _should_ not happen, but it may happen if flush is triggered due to a page activity change or similar
|
|
8094
|
+
if (duration < this._options.minReplayDuration || duration > this.timeouts.maxSessionLife + 5000) {
|
|
8095
|
+
// eslint-disable-next-line no-console
|
|
8096
|
+
const log = this.getOptions()._experiments.traceInternals ? console.warn : logger.warn;
|
|
8097
|
+
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) &&
|
|
8098
|
+
log(
|
|
8099
|
+
`[Replay] Session duration (${Math.floor(duration / 1000)}s) is too short or too long, not sending replay.`,
|
|
8100
|
+
);
|
|
8101
|
+
|
|
8102
|
+
return;
|
|
8103
|
+
}
|
|
8104
|
+
|
|
8057
8105
|
// A flush is about to happen, cancel any queued flushes
|
|
8058
8106
|
this._debouncedFlush.cancel();
|
|
8059
8107
|
|
|
@@ -8256,6 +8304,7 @@ class Replay {
|
|
|
8256
8304
|
constructor({
|
|
8257
8305
|
flushMinDelay = DEFAULT_FLUSH_MIN_DELAY,
|
|
8258
8306
|
flushMaxDelay = DEFAULT_FLUSH_MAX_DELAY,
|
|
8307
|
+
minReplayDuration = MIN_REPLAY_DURATION,
|
|
8259
8308
|
stickySession = true,
|
|
8260
8309
|
useCompression = true,
|
|
8261
8310
|
_experiments = {},
|
|
@@ -8332,6 +8381,7 @@ class Replay {
|
|
|
8332
8381
|
this._initialOptions = {
|
|
8333
8382
|
flushMinDelay,
|
|
8334
8383
|
flushMaxDelay,
|
|
8384
|
+
minReplayDuration: Math.min(minReplayDuration, MIN_REPLAY_DURATION_LIMIT),
|
|
8335
8385
|
stickySession,
|
|
8336
8386
|
sessionSampleRate,
|
|
8337
8387
|
errorSampleRate,
|