@sentry/replay 7.66.0 → 7.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +47 -24
- package/cjs/index.js.map +1 -1
- package/esm/index.js +47 -24
- package/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/types/constants.d.ts +2 -1
- package/types/constants.d.ts.map +1 -1
- package/types/coreHandlers/handleClick.d.ts.map +1 -1
- package/types/index.d.ts +2 -1
- package/types/index.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/session/loadOrCreateSession.d.ts +4 -3
- package/types/session/loadOrCreateSession.d.ts.map +1 -1
- package/types/session/maybeRefreshSession.d.ts +4 -3
- package/types/session/maybeRefreshSession.d.ts.map +1 -1
- package/types/types/deprecated.d.ts +16 -0
- package/types/types/deprecated.d.ts.map +1 -0
- package/types/types/replay.d.ts +8 -4
- package/types/types/replay.d.ts.map +1 -1
- package/types/types/replayFrame.d.ts +45 -45
- package/types/types/replayFrame.d.ts.map +1 -1
- package/types/types/rrweb.d.ts +14 -16
- package/types/types/rrweb.d.ts.map +1 -1
- package/types/util/createBreadcrumb.d.ts +2 -2
- package/types/util/createBreadcrumb.d.ts.map +1 -1
- package/types/util/handleRecordingEmit.d.ts +2 -2
- package/types/util/handleRecordingEmit.d.ts.map +1 -1
- package/types/util/isSessionExpired.d.ts +6 -2
- package/types/util/isSessionExpired.d.ts.map +1 -1
package/cjs/index.js
CHANGED
|
@@ -19,9 +19,6 @@ const SESSION_IDLE_PAUSE_DURATION = 300000; // 5 minutes in ms
|
|
|
19
19
|
// The idle limit for a session after which the session expires.
|
|
20
20
|
const SESSION_IDLE_EXPIRE_DURATION = 900000; // 15 minutes in ms
|
|
21
21
|
|
|
22
|
-
// The maximum length of a session
|
|
23
|
-
const MAX_SESSION_LIFE = 3600000; // 60 minutes in ms
|
|
24
|
-
|
|
25
22
|
/** Default flush delays */
|
|
26
23
|
const DEFAULT_FLUSH_MIN_DELAY = 5000;
|
|
27
24
|
// XXX: Temp fix for our debounce logic where `maxWait` would never occur if it
|
|
@@ -53,6 +50,9 @@ const MIN_REPLAY_DURATION = 4999;
|
|
|
53
50
|
/* The max. allowed value that the minReplayDuration can be set to. */
|
|
54
51
|
const MIN_REPLAY_DURATION_LIMIT = 15000;
|
|
55
52
|
|
|
53
|
+
/** The max. length of a replay. */
|
|
54
|
+
const MAX_REPLAY_DURATION = 3600000; // 60 minutes in ms;
|
|
55
|
+
|
|
56
56
|
var NodeType$1;
|
|
57
57
|
(function (NodeType) {
|
|
58
58
|
NodeType[NodeType["Document"] = 0] = "Document";
|
|
@@ -4656,13 +4656,20 @@ function isExpired(
|
|
|
4656
4656
|
/**
|
|
4657
4657
|
* Checks to see if session is expired
|
|
4658
4658
|
*/
|
|
4659
|
-
function isSessionExpired(
|
|
4659
|
+
function isSessionExpired(
|
|
4660
|
+
session,
|
|
4661
|
+
{
|
|
4662
|
+
maxReplayDuration,
|
|
4663
|
+
sessionIdleExpire,
|
|
4664
|
+
targetTime = Date.now(),
|
|
4665
|
+
},
|
|
4666
|
+
) {
|
|
4660
4667
|
return (
|
|
4661
4668
|
// First, check that maximum session length has not been exceeded
|
|
4662
|
-
isExpired(session.started,
|
|
4669
|
+
isExpired(session.started, maxReplayDuration, targetTime) ||
|
|
4663
4670
|
// check that the idle timeout has not been exceeded (i.e. user has
|
|
4664
4671
|
// performed an action within the last `sessionIdleExpire` ms)
|
|
4665
|
-
isExpired(session.lastActivity,
|
|
4672
|
+
isExpired(session.lastActivity, sessionIdleExpire, targetTime)
|
|
4666
4673
|
);
|
|
4667
4674
|
}
|
|
4668
4675
|
|
|
@@ -4674,15 +4681,16 @@ function isSessionExpired(session, timeouts, targetTime = +new Date()) {
|
|
|
4674
4681
|
function maybeRefreshSession(
|
|
4675
4682
|
session,
|
|
4676
4683
|
{
|
|
4677
|
-
timeouts,
|
|
4678
4684
|
traceInternals,
|
|
4685
|
+
maxReplayDuration,
|
|
4686
|
+
sessionIdleExpire,
|
|
4679
4687
|
}
|
|
4680
4688
|
|
|
4681
4689
|
,
|
|
4682
4690
|
sessionOptions,
|
|
4683
4691
|
) {
|
|
4684
4692
|
// If not expired, all good, just keep the session
|
|
4685
|
-
if (!isSessionExpired(session,
|
|
4693
|
+
if (!isSessionExpired(session, { sessionIdleExpire, maxReplayDuration })) {
|
|
4686
4694
|
return session;
|
|
4687
4695
|
}
|
|
4688
4696
|
|
|
@@ -4715,8 +4723,9 @@ function maybeRefreshSession(
|
|
|
4715
4723
|
function loadOrCreateSession(
|
|
4716
4724
|
currentSession,
|
|
4717
4725
|
{
|
|
4718
|
-
timeouts,
|
|
4719
4726
|
traceInternals,
|
|
4727
|
+
sessionIdleExpire,
|
|
4728
|
+
maxReplayDuration,
|
|
4720
4729
|
}
|
|
4721
4730
|
|
|
4722
4731
|
,
|
|
@@ -4731,9 +4740,11 @@ function loadOrCreateSession(
|
|
|
4731
4740
|
return createSession(sessionOptions);
|
|
4732
4741
|
}
|
|
4733
4742
|
|
|
4734
|
-
return maybeRefreshSession(existingSession, {
|
|
4743
|
+
return maybeRefreshSession(existingSession, { sessionIdleExpire, traceInternals, maxReplayDuration }, sessionOptions);
|
|
4735
4744
|
}
|
|
4736
4745
|
|
|
4746
|
+
const ReplayEventTypeCustom = 5;
|
|
4747
|
+
|
|
4737
4748
|
function isCustomEvent(event) {
|
|
4738
4749
|
return event.type === EventType.Custom;
|
|
4739
4750
|
}
|
|
@@ -4768,9 +4779,9 @@ async function addEvent(
|
|
|
4768
4779
|
}
|
|
4769
4780
|
|
|
4770
4781
|
// Throw out events that are +60min from the initial timestamp
|
|
4771
|
-
if (timestampInMs > replay.getContext().initialTimestamp + replay.
|
|
4782
|
+
if (timestampInMs > replay.getContext().initialTimestamp + replay.getOptions().maxReplayDuration) {
|
|
4772
4783
|
logInfo(
|
|
4773
|
-
`[Replay] Skipping event with timestamp ${timestampInMs} because it is after
|
|
4784
|
+
`[Replay] Skipping event with timestamp ${timestampInMs} because it is after maxReplayDuration`,
|
|
4774
4785
|
replay.getOptions()._experiments.traceInternals,
|
|
4775
4786
|
);
|
|
4776
4787
|
return null;
|
|
@@ -7256,7 +7267,6 @@ class ReplayContainer {
|
|
|
7256
7267
|
this.timeouts = {
|
|
7257
7268
|
sessionIdlePause: SESSION_IDLE_PAUSE_DURATION,
|
|
7258
7269
|
sessionIdleExpire: SESSION_IDLE_EXPIRE_DURATION,
|
|
7259
|
-
maxSessionLife: MAX_SESSION_LIFE,
|
|
7260
7270
|
} ;
|
|
7261
7271
|
this._lastActivity = Date.now();
|
|
7262
7272
|
this._isEnabled = false;
|
|
@@ -7383,7 +7393,8 @@ class ReplayContainer {
|
|
|
7383
7393
|
const session = loadOrCreateSession(
|
|
7384
7394
|
this.session,
|
|
7385
7395
|
{
|
|
7386
|
-
|
|
7396
|
+
maxReplayDuration: this._options.maxReplayDuration,
|
|
7397
|
+
sessionIdleExpire: this.timeouts.sessionIdleExpire,
|
|
7387
7398
|
traceInternals: this._options._experiments.traceInternals,
|
|
7388
7399
|
},
|
|
7389
7400
|
{
|
|
@@ -7413,7 +7424,8 @@ class ReplayContainer {
|
|
|
7413
7424
|
const session = loadOrCreateSession(
|
|
7414
7425
|
this.session,
|
|
7415
7426
|
{
|
|
7416
|
-
|
|
7427
|
+
sessionIdleExpire: this.timeouts.sessionIdleExpire,
|
|
7428
|
+
maxReplayDuration: this._options.maxReplayDuration,
|
|
7417
7429
|
traceInternals: this._options._experiments.traceInternals,
|
|
7418
7430
|
},
|
|
7419
7431
|
{
|
|
@@ -7589,7 +7601,7 @@ class ReplayContainer {
|
|
|
7589
7601
|
// `shouldRefresh`, the session could be considered expired due to
|
|
7590
7602
|
// lifespan, which is not what we want. Update session start date to be
|
|
7591
7603
|
// the current timestamp, so that session is not considered to be
|
|
7592
|
-
// expired. This means that max replay duration can be
|
|
7604
|
+
// expired. This means that max replay duration can be MAX_REPLAY_DURATION +
|
|
7593
7605
|
// (length of buffer), which we are ok with.
|
|
7594
7606
|
this._updateUserActivity(activityTime);
|
|
7595
7607
|
this._updateSessionActivity(activityTime);
|
|
@@ -7752,7 +7764,11 @@ class ReplayContainer {
|
|
|
7752
7764
|
}
|
|
7753
7765
|
|
|
7754
7766
|
// Session is expired, trigger a full snapshot (which will create a new session)
|
|
7755
|
-
this.
|
|
7767
|
+
if (this.isPaused()) {
|
|
7768
|
+
this.resume();
|
|
7769
|
+
} else {
|
|
7770
|
+
this._triggerFullSnapshot();
|
|
7771
|
+
}
|
|
7756
7772
|
|
|
7757
7773
|
return false;
|
|
7758
7774
|
}
|
|
@@ -7795,7 +7811,7 @@ class ReplayContainer {
|
|
|
7795
7811
|
|
|
7796
7812
|
this.addUpdate(() => {
|
|
7797
7813
|
void addEvent(this, {
|
|
7798
|
-
type:
|
|
7814
|
+
type: ReplayEventTypeCustom,
|
|
7799
7815
|
timestamp: breadcrumb.timestamp || 0,
|
|
7800
7816
|
data: {
|
|
7801
7817
|
tag: 'breadcrumb',
|
|
@@ -7866,7 +7882,8 @@ class ReplayContainer {
|
|
|
7866
7882
|
const session = loadOrCreateSession(
|
|
7867
7883
|
this.session,
|
|
7868
7884
|
{
|
|
7869
|
-
|
|
7885
|
+
sessionIdleExpire: this.timeouts.sessionIdleExpire,
|
|
7886
|
+
maxReplayDuration: this._options.maxReplayDuration,
|
|
7870
7887
|
traceInternals: this._options._experiments.traceInternals,
|
|
7871
7888
|
},
|
|
7872
7889
|
{
|
|
@@ -7895,8 +7912,9 @@ class ReplayContainer {
|
|
|
7895
7912
|
const newSession = maybeRefreshSession(
|
|
7896
7913
|
currentSession,
|
|
7897
7914
|
{
|
|
7898
|
-
|
|
7915
|
+
sessionIdleExpire: this.timeouts.sessionIdleExpire,
|
|
7899
7916
|
traceInternals: this._options._experiments.traceInternals,
|
|
7917
|
+
maxReplayDuration: this._options.maxReplayDuration,
|
|
7900
7918
|
},
|
|
7901
7919
|
{
|
|
7902
7920
|
stickySession: Boolean(this._options.stickySession),
|
|
@@ -8031,7 +8049,10 @@ class ReplayContainer {
|
|
|
8031
8049
|
return;
|
|
8032
8050
|
}
|
|
8033
8051
|
|
|
8034
|
-
const expired = isSessionExpired(this.session,
|
|
8052
|
+
const expired = isSessionExpired(this.session, {
|
|
8053
|
+
maxReplayDuration: this._options.maxReplayDuration,
|
|
8054
|
+
...this.timeouts,
|
|
8055
|
+
});
|
|
8035
8056
|
|
|
8036
8057
|
if (breadcrumb && !expired) {
|
|
8037
8058
|
this._createCustomBreadcrumb(breadcrumb);
|
|
@@ -8210,7 +8231,7 @@ class ReplayContainer {
|
|
|
8210
8231
|
// Check total duration again, to avoid sending outdated stuff
|
|
8211
8232
|
// We leave 30s wiggle room to accomodate late flushing etc.
|
|
8212
8233
|
// This _could_ happen when the browser is suspended during flushing, in which case we just want to stop
|
|
8213
|
-
if (timestamp - this._context.initialTimestamp > this.
|
|
8234
|
+
if (timestamp - this._context.initialTimestamp > this._options.maxReplayDuration + 30000) {
|
|
8214
8235
|
throw new Error('Session is too long, not sending replay');
|
|
8215
8236
|
}
|
|
8216
8237
|
|
|
@@ -8278,10 +8299,10 @@ class ReplayContainer {
|
|
|
8278
8299
|
// A flush is about to happen, cancel any queued flushes
|
|
8279
8300
|
this._debouncedFlush.cancel();
|
|
8280
8301
|
|
|
8281
|
-
// If session is too short, or too long (allow some wiggle room over
|
|
8302
|
+
// If session is too short, or too long (allow some wiggle room over maxReplayDuration), do not send it
|
|
8282
8303
|
// This _should_ not happen, but it may happen if flush is triggered due to a page activity change or similar
|
|
8283
8304
|
const tooShort = duration < this._options.minReplayDuration;
|
|
8284
|
-
const tooLong = duration > this.
|
|
8305
|
+
const tooLong = duration > this._options.maxReplayDuration + 5000;
|
|
8285
8306
|
if (tooShort || tooLong) {
|
|
8286
8307
|
logInfo(
|
|
8287
8308
|
`[Replay] Session duration (${Math.floor(duration / 1000)}s) is too ${
|
|
@@ -8501,6 +8522,7 @@ class Replay {
|
|
|
8501
8522
|
flushMinDelay = DEFAULT_FLUSH_MIN_DELAY,
|
|
8502
8523
|
flushMaxDelay = DEFAULT_FLUSH_MAX_DELAY,
|
|
8503
8524
|
minReplayDuration = MIN_REPLAY_DURATION,
|
|
8525
|
+
maxReplayDuration = MAX_REPLAY_DURATION,
|
|
8504
8526
|
stickySession = true,
|
|
8505
8527
|
useCompression = true,
|
|
8506
8528
|
_experiments = {},
|
|
@@ -8580,6 +8602,7 @@ class Replay {
|
|
|
8580
8602
|
flushMinDelay,
|
|
8581
8603
|
flushMaxDelay,
|
|
8582
8604
|
minReplayDuration: Math.min(minReplayDuration, MIN_REPLAY_DURATION_LIMIT),
|
|
8605
|
+
maxReplayDuration: Math.min(maxReplayDuration, MAX_REPLAY_DURATION),
|
|
8583
8606
|
stickySession,
|
|
8584
8607
|
sessionSampleRate,
|
|
8585
8608
|
errorSampleRate,
|