@sentry/replay 7.93.0 → 7.94.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 +83 -67
- package/cjs/index.js.map +1 -1
- package/esm/index.js +83 -67
- package/esm/index.js.map +1 -1
- package/package.json +8 -8
- package/types/constants.d.ts +0 -29
- package/types/constants.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/integration.d.ts +2 -0
- package/types/integration.d.ts.map +1 -1
- package/types/replay.d.ts +8 -0
- package/types/replay.d.ts.map +1 -1
- package/types/types/replay.d.ts +14 -5
- package/types/types/replay.d.ts.map +1 -1
- package/types/types/replayFrame.d.ts +1 -0
- package/types/types/replayFrame.d.ts.map +1 -1
- package/types/types/rrweb.d.ts +6 -1
- package/types/types/rrweb.d.ts.map +1 -1
- package/types/util/handleRecordingEmit.d.ts.map +1 -1
- package/types-ts3.8/constants.d.ts +0 -29
- package/types-ts3.8/index.d.ts +1 -1
- package/types-ts3.8/integration.d.ts +2 -0
- package/types-ts3.8/replay.d.ts +8 -0
- package/types-ts3.8/types/replay.d.ts +14 -5
- package/types-ts3.8/types/replayFrame.d.ts +1 -0
- package/types-ts3.8/types/rrweb.d.ts +6 -1
package/cjs/index.js
CHANGED
|
@@ -59,36 +59,6 @@ const MIN_REPLAY_DURATION_LIMIT = 15000;
|
|
|
59
59
|
/** The max. length of a replay. */
|
|
60
60
|
const MAX_REPLAY_DURATION = 3600000; // 60 minutes in ms;
|
|
61
61
|
|
|
62
|
-
const CANVAS_QUALITY = {
|
|
63
|
-
low: {
|
|
64
|
-
sampling: {
|
|
65
|
-
canvas: 1,
|
|
66
|
-
},
|
|
67
|
-
dataURLOptions: {
|
|
68
|
-
type: 'image/webp',
|
|
69
|
-
quality: 0.25,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
medium: {
|
|
73
|
-
sampling: {
|
|
74
|
-
canvas: 2,
|
|
75
|
-
},
|
|
76
|
-
dataURLOptions: {
|
|
77
|
-
type: 'image/webp',
|
|
78
|
-
quality: 0.4,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
high: {
|
|
82
|
-
sampling: {
|
|
83
|
-
canvas: 4,
|
|
84
|
-
},
|
|
85
|
-
dataURLOptions: {
|
|
86
|
-
type: 'image/webp',
|
|
87
|
-
quality: 0.5,
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
62
|
function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }function _optionalChain$5(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var NodeType$1;
|
|
93
63
|
(function (NodeType) {
|
|
94
64
|
NodeType[NodeType["Document"] = 0] = "Document";
|
|
@@ -512,18 +482,23 @@ function createMatchPredicate(className, selector) {
|
|
|
512
482
|
const el = node;
|
|
513
483
|
if (el === null)
|
|
514
484
|
return false;
|
|
515
|
-
|
|
516
|
-
if (
|
|
517
|
-
if (
|
|
485
|
+
try {
|
|
486
|
+
if (className) {
|
|
487
|
+
if (typeof className === 'string') {
|
|
488
|
+
if (el.matches(`.${className}`))
|
|
489
|
+
return true;
|
|
490
|
+
}
|
|
491
|
+
else if (elementClassMatchesRegex(el, className)) {
|
|
518
492
|
return true;
|
|
493
|
+
}
|
|
519
494
|
}
|
|
520
|
-
|
|
495
|
+
if (selector && el.matches(selector))
|
|
521
496
|
return true;
|
|
522
|
-
|
|
497
|
+
return false;
|
|
498
|
+
}
|
|
499
|
+
catch (e2) {
|
|
500
|
+
return false;
|
|
523
501
|
}
|
|
524
|
-
if (selector && el.matches(selector))
|
|
525
|
-
return true;
|
|
526
|
-
return false;
|
|
527
502
|
};
|
|
528
503
|
}
|
|
529
504
|
function needMaskingText(node, maskTextClass, maskTextSelector, unmaskTextClass, unmaskTextSelector, maskAllText) {
|
|
@@ -3418,6 +3393,8 @@ class CanvasManagerNoop {
|
|
|
3418
3393
|
}
|
|
3419
3394
|
unlock() {
|
|
3420
3395
|
}
|
|
3396
|
+
snapshot() {
|
|
3397
|
+
}
|
|
3421
3398
|
}
|
|
3422
3399
|
|
|
3423
3400
|
class StylesheetManager {
|
|
@@ -3518,7 +3495,6 @@ function wrapEvent(e) {
|
|
|
3518
3495
|
eWithTime.timestamp = nowTimestamp();
|
|
3519
3496
|
return eWithTime;
|
|
3520
3497
|
}
|
|
3521
|
-
let _wrappedEmit;
|
|
3522
3498
|
let _takeFullSnapshot;
|
|
3523
3499
|
const mirror = createMirror();
|
|
3524
3500
|
function record(options = {}) {
|
|
@@ -3638,7 +3614,6 @@ function record(options = {}) {
|
|
|
3638
3614
|
}
|
|
3639
3615
|
}
|
|
3640
3616
|
};
|
|
3641
|
-
_wrappedEmit = wrappedEmit;
|
|
3642
3617
|
const wrappedMutationEmit = (m) => {
|
|
3643
3618
|
wrappedEmit(wrapEvent({
|
|
3644
3619
|
type: EventType.IncrementalSnapshot,
|
|
@@ -3692,6 +3667,15 @@ function record(options = {}) {
|
|
|
3692
3667
|
}
|
|
3693
3668
|
const processedNodeManager = new ProcessedNodeManager();
|
|
3694
3669
|
const canvasManager = _getCanvasManager(getCanvasManager, {
|
|
3670
|
+
mirror,
|
|
3671
|
+
win: window,
|
|
3672
|
+
mutationCb: (p) => wrappedEmit(wrapEvent({
|
|
3673
|
+
type: EventType.IncrementalSnapshot,
|
|
3674
|
+
data: {
|
|
3675
|
+
source: IncrementalSource.CanvasMutation,
|
|
3676
|
+
...p,
|
|
3677
|
+
},
|
|
3678
|
+
})),
|
|
3695
3679
|
recordCanvas,
|
|
3696
3680
|
blockClass,
|
|
3697
3681
|
blockSelector,
|
|
@@ -3978,29 +3962,18 @@ function takeFullSnapshot(isCheckout) {
|
|
|
3978
3962
|
}
|
|
3979
3963
|
_takeFullSnapshot(isCheckout);
|
|
3980
3964
|
}
|
|
3981
|
-
function wrappedEmit(e) {
|
|
3982
|
-
if (!_wrappedEmit) {
|
|
3983
|
-
return;
|
|
3984
|
-
}
|
|
3985
|
-
_wrappedEmit(e);
|
|
3986
|
-
}
|
|
3987
3965
|
record.mirror = mirror;
|
|
3988
3966
|
record.takeFullSnapshot = takeFullSnapshot;
|
|
3989
3967
|
function _getCanvasManager(getCanvasManagerFn, options) {
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
...p,
|
|
4000
|
-
},
|
|
4001
|
-
})),
|
|
4002
|
-
})
|
|
4003
|
-
: new CanvasManagerNoop();
|
|
3968
|
+
try {
|
|
3969
|
+
return getCanvasManagerFn
|
|
3970
|
+
? getCanvasManagerFn(options)
|
|
3971
|
+
: new CanvasManagerNoop();
|
|
3972
|
+
}
|
|
3973
|
+
catch (e2) {
|
|
3974
|
+
console.warn('Unable to initialize CanvasManager');
|
|
3975
|
+
return new CanvasManagerNoop();
|
|
3976
|
+
}
|
|
4004
3977
|
}
|
|
4005
3978
|
|
|
4006
3979
|
const ReplayEventTypeIncrementalSnapshot = 3;
|
|
@@ -7438,6 +7411,7 @@ function createOptionsEvent(replay) {
|
|
|
7438
7411
|
data: {
|
|
7439
7412
|
tag: 'options',
|
|
7440
7413
|
payload: {
|
|
7414
|
+
shouldRecordCanvas: replay.isRecordingCanvas(),
|
|
7441
7415
|
sessionSampleRate: options.sessionSampleRate,
|
|
7442
7416
|
errorSampleRate: options.errorSampleRate,
|
|
7443
7417
|
useCompressionOption: options.useCompression,
|
|
@@ -7901,6 +7875,10 @@ class ReplayContainer {
|
|
|
7901
7875
|
* Function to stop recording
|
|
7902
7876
|
*/
|
|
7903
7877
|
|
|
7878
|
+
/**
|
|
7879
|
+
* Internal use for canvas recording options
|
|
7880
|
+
*/
|
|
7881
|
+
|
|
7904
7882
|
constructor({
|
|
7905
7883
|
options,
|
|
7906
7884
|
recordingOptions,
|
|
@@ -7973,6 +7951,13 @@ class ReplayContainer {
|
|
|
7973
7951
|
return this._isPaused;
|
|
7974
7952
|
}
|
|
7975
7953
|
|
|
7954
|
+
/**
|
|
7955
|
+
* Determine if canvas recording is enabled
|
|
7956
|
+
*/
|
|
7957
|
+
isRecordingCanvas() {
|
|
7958
|
+
return Boolean(this._canvas);
|
|
7959
|
+
}
|
|
7960
|
+
|
|
7976
7961
|
/** Get the replay integration options. */
|
|
7977
7962
|
getOptions() {
|
|
7978
7963
|
return this._options;
|
|
@@ -8093,7 +8078,8 @@ class ReplayContainer {
|
|
|
8093
8078
|
*/
|
|
8094
8079
|
startRecording() {
|
|
8095
8080
|
try {
|
|
8096
|
-
const
|
|
8081
|
+
const canvasOptions = this._canvas;
|
|
8082
|
+
|
|
8097
8083
|
this._stopRecording = record({
|
|
8098
8084
|
...this._recordingOptions,
|
|
8099
8085
|
// When running in error sampling mode, we need to overwrite `checkoutEveryNms`
|
|
@@ -8102,12 +8088,14 @@ class ReplayContainer {
|
|
|
8102
8088
|
...(this.recordingMode === 'buffer' && { checkoutEveryNms: BUFFER_CHECKOUT_TIME }),
|
|
8103
8089
|
emit: getHandleRecordingEmit(this),
|
|
8104
8090
|
onMutation: this._onMutationHandler,
|
|
8105
|
-
...(
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8091
|
+
...(canvasOptions
|
|
8092
|
+
? {
|
|
8093
|
+
recordCanvas: canvasOptions.recordCanvas,
|
|
8094
|
+
getCanvasManager: canvasOptions.getCanvasManager,
|
|
8095
|
+
sampling: canvasOptions.sampling,
|
|
8096
|
+
dataURLOptions: canvasOptions.dataURLOptions,
|
|
8097
|
+
}
|
|
8098
|
+
: {}),
|
|
8111
8099
|
});
|
|
8112
8100
|
} catch (err) {
|
|
8113
8101
|
this._handleException(err);
|
|
@@ -9433,6 +9421,7 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
|
|
|
9433
9421
|
|
|
9434
9422
|
return this._replay.getSessionId();
|
|
9435
9423
|
}
|
|
9424
|
+
|
|
9436
9425
|
/**
|
|
9437
9426
|
* Initializes replay.
|
|
9438
9427
|
*/
|
|
@@ -9441,6 +9430,12 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
|
|
|
9441
9430
|
return;
|
|
9442
9431
|
}
|
|
9443
9432
|
|
|
9433
|
+
// We have to run this in _initialize, because this runs in setTimeout
|
|
9434
|
+
// So when this runs all integrations have been added
|
|
9435
|
+
// Before this, we cannot access integrations on the client,
|
|
9436
|
+
// so we need to mutate the options here
|
|
9437
|
+
this._maybeLoadFromReplayCanvasIntegration();
|
|
9438
|
+
|
|
9444
9439
|
this._replay.initializeSampling();
|
|
9445
9440
|
}
|
|
9446
9441
|
|
|
@@ -9454,6 +9449,27 @@ Sentry.init({ replaysOnErrorSampleRate: ${errorSampleRate} })`,
|
|
|
9454
9449
|
recordingOptions: this._recordingOptions,
|
|
9455
9450
|
});
|
|
9456
9451
|
}
|
|
9452
|
+
|
|
9453
|
+
/** Get canvas options from ReplayCanvas integration, if it is also added. */
|
|
9454
|
+
_maybeLoadFromReplayCanvasIntegration() {
|
|
9455
|
+
// To save bundle size, we skip checking for stuff here
|
|
9456
|
+
// and instead just try-catch everything - as generally this should all be defined
|
|
9457
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
9458
|
+
try {
|
|
9459
|
+
const client = core.getClient();
|
|
9460
|
+
const canvasIntegration = client.getIntegrationByName('ReplayCanvas')
|
|
9461
|
+
|
|
9462
|
+
;
|
|
9463
|
+
if (!canvasIntegration) {
|
|
9464
|
+
return;
|
|
9465
|
+
}
|
|
9466
|
+
|
|
9467
|
+
this._replay['_canvas'] = canvasIntegration.getOptions();
|
|
9468
|
+
} catch (e) {
|
|
9469
|
+
// ignore errors here
|
|
9470
|
+
}
|
|
9471
|
+
/* eslint-enable @typescript-eslint/no-non-null-assertion */
|
|
9472
|
+
}
|
|
9457
9473
|
}Replay.__initStatic();
|
|
9458
9474
|
|
|
9459
9475
|
/** Parse Replay-related options from SDK options */
|