@sentry/replay 7.50.0 → 7.51.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 +329 -136
- package/cjs/index.js.map +1 -1
- package/esm/index.js +329 -136
- package/esm/index.js.map +1 -1
- package/package.json +7 -7
- package/types/coreHandlers/handleAfterSendEvent.d.ts.map +1 -1
- package/types/coreHandlers/handleDom.d.ts +7 -2
- package/types/coreHandlers/handleDom.d.ts.map +1 -1
- package/types/coreHandlers/handleGlobalEvent.d.ts.map +1 -1
- package/types/coreHandlers/util/shouldSampleForBufferEvent.d.ts +9 -0
- package/types/coreHandlers/util/shouldSampleForBufferEvent.d.ts.map +1 -0
- package/types/eventBuffer/EventBufferArray.d.ts +8 -2
- package/types/eventBuffer/EventBufferArray.d.ts.map +1 -1
- package/types/eventBuffer/EventBufferCompressionWorker.d.ts +11 -6
- package/types/eventBuffer/EventBufferCompressionWorker.d.ts.map +1 -1
- package/types/eventBuffer/EventBufferProxy.d.ts +8 -2
- package/types/eventBuffer/EventBufferProxy.d.ts.map +1 -1
- package/types/integration.d.ts.map +1 -1
- package/types/replay.d.ts +4 -0
- package/types/replay.d.ts.map +1 -1
- package/types/types/rrweb.d.ts +1 -1
- package/types/types/rrweb.d.ts.map +1 -1
- package/types/types.d.ts +25 -9
- package/types/types.d.ts.map +1 -1
- package/types/util/addEvent.d.ts.map +1 -1
- package/types/util/addGlobalListeners.d.ts.map +1 -1
- package/types/util/handleRecordingEmit.d.ts +4 -0
- package/types/util/handleRecordingEmit.d.ts.map +1 -1
- package/types/util/sendReplayRequest.d.ts +1 -1
- package/types/util/sendReplayRequest.d.ts.map +1 -1
- package/types/util/timestampToMs.d.ts +5 -0
- package/types/util/timestampToMs.d.ts.map +1 -0
package/esm/index.js
CHANGED
|
@@ -73,7 +73,7 @@ function maskInputValue({ input, maskInputSelector, unmaskInputSelector, maskInp
|
|
|
73
73
|
if (unmaskInputSelector && input.matches(unmaskInputSelector)) {
|
|
74
74
|
return text;
|
|
75
75
|
}
|
|
76
|
-
if (input.hasAttribute('
|
|
76
|
+
if (input.hasAttribute('data-rr-is-password')) {
|
|
77
77
|
type = 'password';
|
|
78
78
|
}
|
|
79
79
|
if (isInputTypeMasked({ maskInputOptions, tagName, type }) ||
|
|
@@ -106,6 +106,21 @@ function is2DCanvasBlank(canvas) {
|
|
|
106
106
|
}
|
|
107
107
|
return true;
|
|
108
108
|
}
|
|
109
|
+
function getInputType(element) {
|
|
110
|
+
const type = element.type;
|
|
111
|
+
return element.hasAttribute('data-rr-is-password')
|
|
112
|
+
? 'password'
|
|
113
|
+
: type
|
|
114
|
+
? type.toLowerCase()
|
|
115
|
+
: null;
|
|
116
|
+
}
|
|
117
|
+
function getInputValue(el, tagName, type) {
|
|
118
|
+
typeof type === 'string' ? type.toLowerCase() : '';
|
|
119
|
+
if (tagName === 'INPUT' && (type === 'radio' || type === 'checkbox')) {
|
|
120
|
+
return el.getAttribute('value') || '';
|
|
121
|
+
}
|
|
122
|
+
return el.value;
|
|
123
|
+
}
|
|
109
124
|
|
|
110
125
|
let _id = 1;
|
|
111
126
|
const tagNameRegex = new RegExp('[^a-z0-9-_:]');
|
|
@@ -144,6 +159,13 @@ function getCssRuleString(rule) {
|
|
|
144
159
|
catch (_a) {
|
|
145
160
|
}
|
|
146
161
|
}
|
|
162
|
+
return validateStringifiedCssRule(cssStringified);
|
|
163
|
+
}
|
|
164
|
+
function validateStringifiedCssRule(cssStringified) {
|
|
165
|
+
if (cssStringified.indexOf(':') > -1) {
|
|
166
|
+
const regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
167
|
+
return cssStringified.replace(regex, '$1\\$2');
|
|
168
|
+
}
|
|
147
169
|
return cssStringified;
|
|
148
170
|
}
|
|
149
171
|
function isCSSImportRule(rule) {
|
|
@@ -152,7 +174,7 @@ function isCSSImportRule(rule) {
|
|
|
152
174
|
function stringifyStyleSheet(sheet) {
|
|
153
175
|
return sheet.cssRules
|
|
154
176
|
? Array.from(sheet.cssRules)
|
|
155
|
-
.map((rule) => rule.cssText
|
|
177
|
+
.map((rule) => rule.cssText ? validateStringifiedCssRule(rule.cssText) : '')
|
|
156
178
|
.join('')
|
|
157
179
|
: '';
|
|
158
180
|
}
|
|
@@ -487,14 +509,15 @@ function serializeNode(n, options) {
|
|
|
487
509
|
tagName === 'select' ||
|
|
488
510
|
tagName === 'option') {
|
|
489
511
|
const el = n;
|
|
490
|
-
const
|
|
512
|
+
const type = getInputType(el);
|
|
513
|
+
const value = getInputValue(el, tagName.toUpperCase(), type);
|
|
491
514
|
const checked = n.checked;
|
|
492
|
-
if (
|
|
493
|
-
|
|
515
|
+
if (type !== 'submit' &&
|
|
516
|
+
type !== 'button' &&
|
|
494
517
|
value) {
|
|
495
518
|
attributes.value = maskInputValue({
|
|
496
519
|
input: el,
|
|
497
|
-
type
|
|
520
|
+
type,
|
|
498
521
|
tagName,
|
|
499
522
|
value,
|
|
500
523
|
maskInputSelector,
|
|
@@ -967,15 +990,8 @@ function snapshot(n, options) {
|
|
|
967
990
|
function skipAttribute(tagName, attributeName, value) {
|
|
968
991
|
return ((tagName === 'video' || tagName === 'audio') && attributeName === 'autoplay');
|
|
969
992
|
}
|
|
970
|
-
function getInputValue(tagName, el, attributes) {
|
|
971
|
-
if (tagName === 'input' &&
|
|
972
|
-
(attributes.type === 'radio' || attributes.type === 'checkbox')) {
|
|
973
|
-
return el.getAttribute('value') || '';
|
|
974
|
-
}
|
|
975
|
-
return el.value;
|
|
976
|
-
}
|
|
977
993
|
|
|
978
|
-
var EventType;
|
|
994
|
+
var EventType$1;
|
|
979
995
|
(function (EventType) {
|
|
980
996
|
EventType[EventType["DomContentLoaded"] = 0] = "DomContentLoaded";
|
|
981
997
|
EventType[EventType["Load"] = 1] = "Load";
|
|
@@ -984,7 +1000,7 @@ var EventType;
|
|
|
984
1000
|
EventType[EventType["Meta"] = 4] = "Meta";
|
|
985
1001
|
EventType[EventType["Custom"] = 5] = "Custom";
|
|
986
1002
|
EventType[EventType["Plugin"] = 6] = "Plugin";
|
|
987
|
-
})(EventType || (EventType = {}));
|
|
1003
|
+
})(EventType$1 || (EventType$1 = {}));
|
|
988
1004
|
var IncrementalSource;
|
|
989
1005
|
(function (IncrementalSource) {
|
|
990
1006
|
IncrementalSource[IncrementalSource["Mutation"] = 0] = "Mutation";
|
|
@@ -1599,9 +1615,9 @@ class MutationBuffer {
|
|
|
1599
1615
|
this.attributes.push(item);
|
|
1600
1616
|
}
|
|
1601
1617
|
if (m.attributeName === 'type' &&
|
|
1602
|
-
|
|
1618
|
+
target.tagName === 'INPUT' &&
|
|
1603
1619
|
(m.oldValue || '').toLowerCase() === 'password') {
|
|
1604
|
-
|
|
1620
|
+
target.setAttribute('data-rr-is-password', 'true');
|
|
1605
1621
|
}
|
|
1606
1622
|
if (m.attributeName === 'style') {
|
|
1607
1623
|
const old = this.doc.createElement('span');
|
|
@@ -1998,27 +2014,25 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, un
|
|
|
1998
2014
|
isBlocked(target, blockClass, blockSelector, unblockSelector)) {
|
|
1999
2015
|
return;
|
|
2000
2016
|
}
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2017
|
+
const el = target;
|
|
2018
|
+
const type = getInputType(el);
|
|
2019
|
+
if (el.classList.contains(ignoreClass) ||
|
|
2020
|
+
(ignoreSelector && el.matches(ignoreSelector))) {
|
|
2004
2021
|
return;
|
|
2005
2022
|
}
|
|
2006
|
-
let text =
|
|
2023
|
+
let text = getInputValue(el, tagName, type);
|
|
2007
2024
|
let isChecked = false;
|
|
2008
|
-
if (target.hasAttribute('rr_is_password')) {
|
|
2009
|
-
type = 'password';
|
|
2010
|
-
}
|
|
2011
2025
|
if (type === 'radio' || type === 'checkbox') {
|
|
2012
2026
|
isChecked = target.checked;
|
|
2013
2027
|
}
|
|
2014
|
-
|
|
2028
|
+
if (hasInputMaskOptions({
|
|
2015
2029
|
maskInputOptions,
|
|
2016
2030
|
maskInputSelector,
|
|
2017
2031
|
tagName,
|
|
2018
2032
|
type,
|
|
2019
2033
|
})) {
|
|
2020
2034
|
text = maskInputValue({
|
|
2021
|
-
input:
|
|
2035
|
+
input: el,
|
|
2022
2036
|
maskInputOptions,
|
|
2023
2037
|
maskInputSelector,
|
|
2024
2038
|
unmaskInputSelector,
|
|
@@ -2035,8 +2049,18 @@ function initInputObserver({ inputCb, doc, mirror, blockClass, blockSelector, un
|
|
|
2035
2049
|
.querySelectorAll(`input[type="radio"][name="${name}"]`)
|
|
2036
2050
|
.forEach((el) => {
|
|
2037
2051
|
if (el !== target) {
|
|
2052
|
+
const text = maskInputValue({
|
|
2053
|
+
input: el,
|
|
2054
|
+
maskInputOptions,
|
|
2055
|
+
maskInputSelector,
|
|
2056
|
+
unmaskInputSelector,
|
|
2057
|
+
tagName,
|
|
2058
|
+
type,
|
|
2059
|
+
value: getInputValue(el, tagName, type),
|
|
2060
|
+
maskInputFn,
|
|
2061
|
+
});
|
|
2038
2062
|
cbWithDedup(el, callbackWrapper(wrapEventWithUserTriggeredFlag)({
|
|
2039
|
-
text
|
|
2063
|
+
text,
|
|
2040
2064
|
isChecked: !isChecked,
|
|
2041
2065
|
userTriggered: false,
|
|
2042
2066
|
}, userTriggeredOnInput));
|
|
@@ -2949,17 +2973,17 @@ function record(options = {}) {
|
|
|
2949
2973
|
wrappedEmit = (e, isCheckout) => {
|
|
2950
2974
|
var _a;
|
|
2951
2975
|
if (((_a = mutationBuffers[0]) === null || _a === void 0 ? void 0 : _a.isFrozen()) &&
|
|
2952
|
-
e.type !== EventType.FullSnapshot &&
|
|
2953
|
-
!(e.type === EventType.IncrementalSnapshot &&
|
|
2976
|
+
e.type !== EventType$1.FullSnapshot &&
|
|
2977
|
+
!(e.type === EventType$1.IncrementalSnapshot &&
|
|
2954
2978
|
e.data.source === IncrementalSource.Mutation)) {
|
|
2955
2979
|
mutationBuffers.forEach((buf) => buf.unfreeze());
|
|
2956
2980
|
}
|
|
2957
2981
|
emit(eventProcessor(e), isCheckout);
|
|
2958
|
-
if (e.type === EventType.FullSnapshot) {
|
|
2982
|
+
if (e.type === EventType$1.FullSnapshot) {
|
|
2959
2983
|
lastFullSnapshotEvent = e;
|
|
2960
2984
|
incrementalSnapshotCount = 0;
|
|
2961
2985
|
}
|
|
2962
|
-
else if (e.type === EventType.IncrementalSnapshot) {
|
|
2986
|
+
else if (e.type === EventType$1.IncrementalSnapshot) {
|
|
2963
2987
|
if (e.data.source === IncrementalSource.Mutation &&
|
|
2964
2988
|
e.data.isAttachIframe) {
|
|
2965
2989
|
return;
|
|
@@ -2975,16 +2999,16 @@ function record(options = {}) {
|
|
|
2975
2999
|
};
|
|
2976
3000
|
const wrappedMutationEmit = (m) => {
|
|
2977
3001
|
wrappedEmit(wrapEvent({
|
|
2978
|
-
type: EventType.IncrementalSnapshot,
|
|
3002
|
+
type: EventType$1.IncrementalSnapshot,
|
|
2979
3003
|
data: Object.assign({ source: IncrementalSource.Mutation }, m),
|
|
2980
3004
|
}));
|
|
2981
3005
|
};
|
|
2982
3006
|
const wrappedScrollEmit = (p) => wrappedEmit(wrapEvent({
|
|
2983
|
-
type: EventType.IncrementalSnapshot,
|
|
3007
|
+
type: EventType$1.IncrementalSnapshot,
|
|
2984
3008
|
data: Object.assign({ source: IncrementalSource.Scroll }, p),
|
|
2985
3009
|
}));
|
|
2986
3010
|
const wrappedCanvasMutationEmit = (p) => wrappedEmit(wrapEvent({
|
|
2987
|
-
type: EventType.IncrementalSnapshot,
|
|
3011
|
+
type: EventType$1.IncrementalSnapshot,
|
|
2988
3012
|
data: Object.assign({ source: IncrementalSource.CanvasMutation }, p),
|
|
2989
3013
|
}));
|
|
2990
3014
|
const iframeManager = new IframeManager({
|
|
@@ -3029,7 +3053,7 @@ function record(options = {}) {
|
|
|
3029
3053
|
takeFullSnapshot = (isCheckout = false) => {
|
|
3030
3054
|
var _a, _b, _c, _d;
|
|
3031
3055
|
wrappedEmit(wrapEvent({
|
|
3032
|
-
type: EventType.Meta,
|
|
3056
|
+
type: EventType$1.Meta,
|
|
3033
3057
|
data: {
|
|
3034
3058
|
href: window.location.href,
|
|
3035
3059
|
width: getWindowWidth(),
|
|
@@ -3072,7 +3096,7 @@ function record(options = {}) {
|
|
|
3072
3096
|
}
|
|
3073
3097
|
mirror.map = idNodeMap;
|
|
3074
3098
|
wrappedEmit(wrapEvent({
|
|
3075
|
-
type: EventType.FullSnapshot,
|
|
3099
|
+
type: EventType$1.FullSnapshot,
|
|
3076
3100
|
data: {
|
|
3077
3101
|
node,
|
|
3078
3102
|
initialOffset: {
|
|
@@ -3097,7 +3121,7 @@ function record(options = {}) {
|
|
|
3097
3121
|
const handlers = [];
|
|
3098
3122
|
handlers.push(on('DOMContentLoaded', () => {
|
|
3099
3123
|
wrappedEmit(wrapEvent({
|
|
3100
|
-
type: EventType.DomContentLoaded,
|
|
3124
|
+
type: EventType$1.DomContentLoaded,
|
|
3101
3125
|
data: {},
|
|
3102
3126
|
}));
|
|
3103
3127
|
}));
|
|
@@ -3107,40 +3131,40 @@ function record(options = {}) {
|
|
|
3107
3131
|
onMutation,
|
|
3108
3132
|
mutationCb: wrappedMutationEmit,
|
|
3109
3133
|
mousemoveCb: (positions, source) => wrappedEmit(wrapEvent({
|
|
3110
|
-
type: EventType.IncrementalSnapshot,
|
|
3134
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3111
3135
|
data: {
|
|
3112
3136
|
source,
|
|
3113
3137
|
positions,
|
|
3114
3138
|
},
|
|
3115
3139
|
})),
|
|
3116
3140
|
mouseInteractionCb: (d) => wrappedEmit(wrapEvent({
|
|
3117
|
-
type: EventType.IncrementalSnapshot,
|
|
3141
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3118
3142
|
data: Object.assign({ source: IncrementalSource.MouseInteraction }, d),
|
|
3119
3143
|
})),
|
|
3120
3144
|
scrollCb: wrappedScrollEmit,
|
|
3121
3145
|
viewportResizeCb: (d) => wrappedEmit(wrapEvent({
|
|
3122
|
-
type: EventType.IncrementalSnapshot,
|
|
3146
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3123
3147
|
data: Object.assign({ source: IncrementalSource.ViewportResize }, d),
|
|
3124
3148
|
})),
|
|
3125
3149
|
inputCb: (v) => wrappedEmit(wrapEvent({
|
|
3126
|
-
type: EventType.IncrementalSnapshot,
|
|
3150
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3127
3151
|
data: Object.assign({ source: IncrementalSource.Input }, v),
|
|
3128
3152
|
})),
|
|
3129
3153
|
mediaInteractionCb: (p) => wrappedEmit(wrapEvent({
|
|
3130
|
-
type: EventType.IncrementalSnapshot,
|
|
3154
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3131
3155
|
data: Object.assign({ source: IncrementalSource.MediaInteraction }, p),
|
|
3132
3156
|
})),
|
|
3133
3157
|
styleSheetRuleCb: (r) => wrappedEmit(wrapEvent({
|
|
3134
|
-
type: EventType.IncrementalSnapshot,
|
|
3158
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3135
3159
|
data: Object.assign({ source: IncrementalSource.StyleSheetRule }, r),
|
|
3136
3160
|
})),
|
|
3137
3161
|
styleDeclarationCb: (r) => wrappedEmit(wrapEvent({
|
|
3138
|
-
type: EventType.IncrementalSnapshot,
|
|
3162
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3139
3163
|
data: Object.assign({ source: IncrementalSource.StyleDeclaration }, r),
|
|
3140
3164
|
})),
|
|
3141
3165
|
canvasMutationCb: wrappedCanvasMutationEmit,
|
|
3142
3166
|
fontCb: (p) => wrappedEmit(wrapEvent({
|
|
3143
|
-
type: EventType.IncrementalSnapshot,
|
|
3167
|
+
type: EventType$1.IncrementalSnapshot,
|
|
3144
3168
|
data: Object.assign({ source: IncrementalSource.Font }, p),
|
|
3145
3169
|
})),
|
|
3146
3170
|
blockClass,
|
|
@@ -3173,7 +3197,7 @@ function record(options = {}) {
|
|
|
3173
3197
|
observer: p.observer,
|
|
3174
3198
|
options: p.options,
|
|
3175
3199
|
callback: (payload) => wrappedEmit(wrapEvent({
|
|
3176
|
-
type: EventType.Plugin,
|
|
3200
|
+
type: EventType$1.Plugin,
|
|
3177
3201
|
data: {
|
|
3178
3202
|
plugin: p.name,
|
|
3179
3203
|
payload,
|
|
@@ -3201,7 +3225,7 @@ function record(options = {}) {
|
|
|
3201
3225
|
else {
|
|
3202
3226
|
handlers.push(on('load', () => {
|
|
3203
3227
|
wrappedEmit(wrapEvent({
|
|
3204
|
-
type: EventType.Load,
|
|
3228
|
+
type: EventType$1.Load,
|
|
3205
3229
|
data: {},
|
|
3206
3230
|
}));
|
|
3207
3231
|
init();
|
|
@@ -3220,7 +3244,7 @@ record.addCustomEvent = (tag, payload) => {
|
|
|
3220
3244
|
throw new Error('please add custom event after start recording');
|
|
3221
3245
|
}
|
|
3222
3246
|
wrappedEmit(wrapEvent({
|
|
3223
|
-
type: EventType.Custom,
|
|
3247
|
+
type: EventType$1.Custom,
|
|
3224
3248
|
data: {
|
|
3225
3249
|
tag,
|
|
3226
3250
|
payload,
|
|
@@ -3375,6 +3399,14 @@ function t(t){let e=t.length;for(;--e>=0;)t[e]=0}const e=new Uint8Array([0,0,0,0
|
|
|
3375
3399
|
|
|
3376
3400
|
function e(){const e=new Blob([r]);return URL.createObjectURL(e)}
|
|
3377
3401
|
|
|
3402
|
+
/**
|
|
3403
|
+
* Converts a timestamp to ms, if it was in s, or keeps it as ms.
|
|
3404
|
+
*/
|
|
3405
|
+
function timestampToMs(timestamp) {
|
|
3406
|
+
const isMs = timestamp > 9999999999;
|
|
3407
|
+
return isMs ? timestamp : timestamp * 1000;
|
|
3408
|
+
}
|
|
3409
|
+
|
|
3378
3410
|
/**
|
|
3379
3411
|
* A basic event buffer that does not do any compression.
|
|
3380
3412
|
* Used as fallback if the compression worker cannot be loaded or is disabled.
|
|
@@ -3391,20 +3423,19 @@ class EventBufferArray {
|
|
|
3391
3423
|
return this.events.length > 0;
|
|
3392
3424
|
}
|
|
3393
3425
|
|
|
3426
|
+
/** @inheritdoc */
|
|
3427
|
+
get type() {
|
|
3428
|
+
return 'sync';
|
|
3429
|
+
}
|
|
3430
|
+
|
|
3394
3431
|
/** @inheritdoc */
|
|
3395
3432
|
destroy() {
|
|
3396
3433
|
this.events = [];
|
|
3397
3434
|
}
|
|
3398
3435
|
|
|
3399
3436
|
/** @inheritdoc */
|
|
3400
|
-
async addEvent(event
|
|
3401
|
-
if (isCheckout) {
|
|
3402
|
-
this.events = [event];
|
|
3403
|
-
return;
|
|
3404
|
-
}
|
|
3405
|
-
|
|
3437
|
+
async addEvent(event) {
|
|
3406
3438
|
this.events.push(event);
|
|
3407
|
-
return;
|
|
3408
3439
|
}
|
|
3409
3440
|
|
|
3410
3441
|
/** @inheritdoc */
|
|
@@ -3418,6 +3449,22 @@ class EventBufferArray {
|
|
|
3418
3449
|
resolve(JSON.stringify(eventsRet));
|
|
3419
3450
|
});
|
|
3420
3451
|
}
|
|
3452
|
+
|
|
3453
|
+
/** @inheritdoc */
|
|
3454
|
+
clear() {
|
|
3455
|
+
this.events = [];
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
/** @inheritdoc */
|
|
3459
|
+
getEarliestTimestamp() {
|
|
3460
|
+
const timestamp = this.events.map(event => event.timestamp).sort()[0];
|
|
3461
|
+
|
|
3462
|
+
if (!timestamp) {
|
|
3463
|
+
return null;
|
|
3464
|
+
}
|
|
3465
|
+
|
|
3466
|
+
return timestampToMs(timestamp);
|
|
3467
|
+
}
|
|
3421
3468
|
}
|
|
3422
3469
|
|
|
3423
3470
|
/**
|
|
@@ -3525,11 +3572,20 @@ class WorkerHandler {
|
|
|
3525
3572
|
* Exported only for testing.
|
|
3526
3573
|
*/
|
|
3527
3574
|
class EventBufferCompressionWorker {
|
|
3528
|
-
/** @inheritdoc */
|
|
3529
3575
|
|
|
3530
3576
|
constructor(worker) {
|
|
3531
3577
|
this._worker = new WorkerHandler(worker);
|
|
3532
|
-
this.
|
|
3578
|
+
this._earliestTimestamp = null;
|
|
3579
|
+
}
|
|
3580
|
+
|
|
3581
|
+
/** @inheritdoc */
|
|
3582
|
+
get hasEvents() {
|
|
3583
|
+
return !!this._earliestTimestamp;
|
|
3584
|
+
}
|
|
3585
|
+
|
|
3586
|
+
/** @inheritdoc */
|
|
3587
|
+
get type() {
|
|
3588
|
+
return 'worker';
|
|
3533
3589
|
}
|
|
3534
3590
|
|
|
3535
3591
|
/**
|
|
@@ -3552,13 +3608,10 @@ class EventBufferCompressionWorker {
|
|
|
3552
3608
|
*
|
|
3553
3609
|
* Returns true if event was successfuly received and processed by worker.
|
|
3554
3610
|
*/
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
// This event is a checkout, make sure worker buffer is cleared before
|
|
3560
|
-
// proceeding.
|
|
3561
|
-
await this._clear();
|
|
3611
|
+
addEvent(event) {
|
|
3612
|
+
const timestamp = timestampToMs(event.timestamp);
|
|
3613
|
+
if (!this._earliestTimestamp || timestamp < this._earliestTimestamp) {
|
|
3614
|
+
this._earliestTimestamp = timestamp;
|
|
3562
3615
|
}
|
|
3563
3616
|
|
|
3564
3617
|
return this._sendEventToWorker(event);
|
|
@@ -3571,6 +3624,18 @@ class EventBufferCompressionWorker {
|
|
|
3571
3624
|
return this._finishRequest();
|
|
3572
3625
|
}
|
|
3573
3626
|
|
|
3627
|
+
/** @inheritdoc */
|
|
3628
|
+
clear() {
|
|
3629
|
+
this._earliestTimestamp = null;
|
|
3630
|
+
// We do not wait on this, as we assume the order of messages is consistent for the worker
|
|
3631
|
+
void this._worker.postMessage('clear');
|
|
3632
|
+
}
|
|
3633
|
+
|
|
3634
|
+
/** @inheritdoc */
|
|
3635
|
+
getEarliestTimestamp() {
|
|
3636
|
+
return this._earliestTimestamp;
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3574
3639
|
/**
|
|
3575
3640
|
* Send the event to the worker.
|
|
3576
3641
|
*/
|
|
@@ -3584,15 +3649,10 @@ class EventBufferCompressionWorker {
|
|
|
3584
3649
|
async _finishRequest() {
|
|
3585
3650
|
const response = await this._worker.postMessage('finish');
|
|
3586
3651
|
|
|
3587
|
-
this.
|
|
3652
|
+
this._earliestTimestamp = null;
|
|
3588
3653
|
|
|
3589
3654
|
return response;
|
|
3590
3655
|
}
|
|
3591
|
-
|
|
3592
|
-
/** Clear any pending events from the worker. */
|
|
3593
|
-
_clear() {
|
|
3594
|
-
return this._worker.postMessage('clear');
|
|
3595
|
-
}
|
|
3596
3656
|
}
|
|
3597
3657
|
|
|
3598
3658
|
/**
|
|
@@ -3610,6 +3670,11 @@ class EventBufferProxy {
|
|
|
3610
3670
|
this._ensureWorkerIsLoadedPromise = this._ensureWorkerIsLoaded();
|
|
3611
3671
|
}
|
|
3612
3672
|
|
|
3673
|
+
/** @inheritdoc */
|
|
3674
|
+
get type() {
|
|
3675
|
+
return this._used.type;
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3613
3678
|
/** @inheritDoc */
|
|
3614
3679
|
get hasEvents() {
|
|
3615
3680
|
return this._used.hasEvents;
|
|
@@ -3621,13 +3686,23 @@ class EventBufferProxy {
|
|
|
3621
3686
|
this._compression.destroy();
|
|
3622
3687
|
}
|
|
3623
3688
|
|
|
3689
|
+
/** @inheritdoc */
|
|
3690
|
+
clear() {
|
|
3691
|
+
return this._used.clear();
|
|
3692
|
+
}
|
|
3693
|
+
|
|
3694
|
+
/** @inheritdoc */
|
|
3695
|
+
getEarliestTimestamp() {
|
|
3696
|
+
return this._used.getEarliestTimestamp();
|
|
3697
|
+
}
|
|
3698
|
+
|
|
3624
3699
|
/**
|
|
3625
3700
|
* Add an event to the event buffer.
|
|
3626
3701
|
*
|
|
3627
3702
|
* Returns true if event was successfully added.
|
|
3628
3703
|
*/
|
|
3629
|
-
addEvent(event
|
|
3630
|
-
return this._used.addEvent(event
|
|
3704
|
+
addEvent(event) {
|
|
3705
|
+
return this._used.addEvent(event);
|
|
3631
3706
|
}
|
|
3632
3707
|
|
|
3633
3708
|
/** @inheritDoc */
|
|
@@ -3928,10 +4003,7 @@ async function addEvent(
|
|
|
3928
4003
|
return null;
|
|
3929
4004
|
}
|
|
3930
4005
|
|
|
3931
|
-
|
|
3932
|
-
// requires coordination with frontend
|
|
3933
|
-
const isMs = event.timestamp > 9999999999;
|
|
3934
|
-
const timestampInMs = isMs ? event.timestamp : event.timestamp * 1000;
|
|
4006
|
+
const timestampInMs = timestampToMs(event.timestamp);
|
|
3935
4007
|
|
|
3936
4008
|
// Throw out events that happen more than 5 minutes ago. This can happen if
|
|
3937
4009
|
// page has been left open and idle for a long period of time and user
|
|
@@ -3941,15 +4013,12 @@ async function addEvent(
|
|
|
3941
4013
|
return null;
|
|
3942
4014
|
}
|
|
3943
4015
|
|
|
3944
|
-
// Only record earliest event if a new session was created, otherwise it
|
|
3945
|
-
// shouldn't be relevant
|
|
3946
|
-
const earliestEvent = replay.getContext().earliestEvent;
|
|
3947
|
-
if (replay.session && replay.session.segmentId === 0 && (!earliestEvent || timestampInMs < earliestEvent)) {
|
|
3948
|
-
replay.getContext().earliestEvent = timestampInMs;
|
|
3949
|
-
}
|
|
3950
|
-
|
|
3951
4016
|
try {
|
|
3952
|
-
|
|
4017
|
+
if (isCheckout) {
|
|
4018
|
+
replay.eventBuffer.clear();
|
|
4019
|
+
}
|
|
4020
|
+
|
|
4021
|
+
return await replay.eventBuffer.addEvent(event);
|
|
3953
4022
|
} catch (error) {
|
|
3954
4023
|
(typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__) && logger.error(error);
|
|
3955
4024
|
await replay.stop('addEvent');
|
|
@@ -4011,22 +4080,18 @@ function handleAfterSendEvent(replay) {
|
|
|
4011
4080
|
return;
|
|
4012
4081
|
}
|
|
4013
4082
|
|
|
4014
|
-
// Add error to list of errorIds of replay
|
|
4083
|
+
// Add error to list of errorIds of replay. This is ok to do even if not
|
|
4084
|
+
// sampled because context will get reset at next checkout.
|
|
4085
|
+
// XXX: There is also a race condition where it's possible to capture an
|
|
4086
|
+
// error to Sentry before Replay SDK has loaded, but response returns after
|
|
4087
|
+
// it was loaded, and this gets called.
|
|
4015
4088
|
if (event.event_id) {
|
|
4016
4089
|
replay.getContext().errorIds.add(event.event_id);
|
|
4017
4090
|
}
|
|
4018
4091
|
|
|
4019
|
-
//
|
|
4092
|
+
// If error event is tagged with replay id it means it was sampled (when in buffer mode)
|
|
4020
4093
|
// Need to be very careful that this does not cause an infinite loop
|
|
4021
|
-
if (
|
|
4022
|
-
replay.recordingMode === 'buffer' &&
|
|
4023
|
-
event.exception &&
|
|
4024
|
-
event.message !== UNABLE_TO_SEND_REPLAY // ignore this error because otherwise we could loop indefinitely with trying to capture replay and failing
|
|
4025
|
-
) {
|
|
4026
|
-
if (!isSampled(replay.getOptions().errorSampleRate)) {
|
|
4027
|
-
return;
|
|
4028
|
-
}
|
|
4029
|
-
|
|
4094
|
+
if (replay.recordingMode === 'buffer' && event.tags && event.tags.replayId) {
|
|
4030
4095
|
setTimeout(() => {
|
|
4031
4096
|
// Capture current event buffer as new replay
|
|
4032
4097
|
void replay.sendBufferedReplayOrFlush();
|
|
@@ -4090,7 +4155,7 @@ function addBreadcrumbEvent(replay, breadcrumb) {
|
|
|
4090
4155
|
|
|
4091
4156
|
replay.addUpdate(() => {
|
|
4092
4157
|
void addEvent(replay, {
|
|
4093
|
-
type: EventType.Custom,
|
|
4158
|
+
type: EventType$1.Custom,
|
|
4094
4159
|
// TODO: We were converting from ms to seconds for breadcrumbs, spans,
|
|
4095
4160
|
// but maybe we should just keep them as milliseconds
|
|
4096
4161
|
timestamp: (breadcrumb.timestamp || 0) * 1000,
|
|
@@ -4158,15 +4223,18 @@ const handleDomListener =
|
|
|
4158
4223
|
|
|
4159
4224
|
/**
|
|
4160
4225
|
* An event handler to react to DOM events.
|
|
4226
|
+
* Exported for tests only.
|
|
4161
4227
|
*/
|
|
4162
4228
|
function handleDom(handlerData) {
|
|
4163
4229
|
let target;
|
|
4164
4230
|
let targetNode;
|
|
4165
4231
|
|
|
4232
|
+
const isClick = handlerData.name === 'click';
|
|
4233
|
+
|
|
4166
4234
|
// Accessing event.target can throw (see getsentry/raven-js#838, #768)
|
|
4167
4235
|
try {
|
|
4168
|
-
targetNode = getTargetNode(handlerData);
|
|
4169
|
-
target = htmlTreeAsString(targetNode);
|
|
4236
|
+
targetNode = isClick ? getClickTargetNode(handlerData.event) : getTargetNode(handlerData.event);
|
|
4237
|
+
target = htmlTreeAsString(targetNode, { maxStringLength: 200 });
|
|
4170
4238
|
} catch (e) {
|
|
4171
4239
|
target = '<unknown>';
|
|
4172
4240
|
}
|
|
@@ -4200,12 +4268,29 @@ function handleDom(handlerData) {
|
|
|
4200
4268
|
});
|
|
4201
4269
|
}
|
|
4202
4270
|
|
|
4203
|
-
function getTargetNode(
|
|
4204
|
-
if (isEventWithTarget(
|
|
4205
|
-
return
|
|
4271
|
+
function getTargetNode(event) {
|
|
4272
|
+
if (isEventWithTarget(event)) {
|
|
4273
|
+
return event.target;
|
|
4206
4274
|
}
|
|
4207
4275
|
|
|
4208
|
-
return
|
|
4276
|
+
return event;
|
|
4277
|
+
}
|
|
4278
|
+
|
|
4279
|
+
const INTERACTIVE_SELECTOR = 'button,a';
|
|
4280
|
+
|
|
4281
|
+
// For clicks, we check if the target is inside of a button or link
|
|
4282
|
+
// If so, we use this as the target instead
|
|
4283
|
+
// This is useful because if you click on the image in <button><img></button>,
|
|
4284
|
+
// The target will be the image, not the button, which we don't want here
|
|
4285
|
+
function getClickTargetNode(event) {
|
|
4286
|
+
const target = getTargetNode(event);
|
|
4287
|
+
|
|
4288
|
+
if (!target || !(target instanceof Element)) {
|
|
4289
|
+
return target;
|
|
4290
|
+
}
|
|
4291
|
+
|
|
4292
|
+
const closestInteractive = target.closest(INTERACTIVE_SELECTOR);
|
|
4293
|
+
return closestInteractive || target;
|
|
4209
4294
|
}
|
|
4210
4295
|
|
|
4211
4296
|
function isEventWithTarget(event) {
|
|
@@ -4235,6 +4320,30 @@ function isRrwebError(event, hint) {
|
|
|
4235
4320
|
});
|
|
4236
4321
|
}
|
|
4237
4322
|
|
|
4323
|
+
/**
|
|
4324
|
+
* Determine if event should be sampled (only applies in buffer mode).
|
|
4325
|
+
* When an event is captured by `hanldleGlobalEvent`, when in buffer mode
|
|
4326
|
+
* we determine if we want to sample the error or not.
|
|
4327
|
+
*/
|
|
4328
|
+
function shouldSampleForBufferEvent(replay, event) {
|
|
4329
|
+
if (replay.recordingMode !== 'buffer') {
|
|
4330
|
+
return false;
|
|
4331
|
+
}
|
|
4332
|
+
|
|
4333
|
+
// ignore this error because otherwise we could loop indefinitely with
|
|
4334
|
+
// trying to capture replay and failing
|
|
4335
|
+
if (event.message === UNABLE_TO_SEND_REPLAY) {
|
|
4336
|
+
return false;
|
|
4337
|
+
}
|
|
4338
|
+
|
|
4339
|
+
// Require the event to be an error event & to have an exception
|
|
4340
|
+
if (!event.exception || event.type) {
|
|
4341
|
+
return false;
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
return isSampled(replay.getOptions().errorSampleRate);
|
|
4345
|
+
}
|
|
4346
|
+
|
|
4238
4347
|
/**
|
|
4239
4348
|
* Returns a listener to be added to `addGlobalEventProcessor(listener)`.
|
|
4240
4349
|
*/
|
|
@@ -4264,8 +4373,16 @@ function handleGlobalEventListener(
|
|
|
4264
4373
|
return null;
|
|
4265
4374
|
}
|
|
4266
4375
|
|
|
4267
|
-
//
|
|
4268
|
-
if
|
|
4376
|
+
// When in buffer mode, we decide to sample here.
|
|
4377
|
+
// Later, in `handleAfterSendEvent`, if the replayId is set, we know that we sampled
|
|
4378
|
+
// And convert the buffer session to a full session
|
|
4379
|
+
const isErrorEventSampled = shouldSampleForBufferEvent(replay, event);
|
|
4380
|
+
|
|
4381
|
+
// Tag errors if it has been sampled in buffer mode, or if it is session mode
|
|
4382
|
+
// Only tag transactions if in session mode
|
|
4383
|
+
const shouldTagReplayId = isErrorEventSampled || replay.recordingMode === 'session';
|
|
4384
|
+
|
|
4385
|
+
if (shouldTagReplayId) {
|
|
4269
4386
|
event.tags = { ...event.tags, replayId: replay.getSessionId() };
|
|
4270
4387
|
}
|
|
4271
4388
|
|
|
@@ -4315,7 +4432,7 @@ function createPerformanceSpans(
|
|
|
4315
4432
|
) {
|
|
4316
4433
|
return entries.map(({ type, start, end, name, data }) =>
|
|
4317
4434
|
addEvent(replay, {
|
|
4318
|
-
type: EventType.Custom,
|
|
4435
|
+
type: EventType$1.Custom,
|
|
4319
4436
|
timestamp: start,
|
|
4320
4437
|
data: {
|
|
4321
4438
|
tag: 'performanceSpan',
|
|
@@ -5647,7 +5764,8 @@ function addGlobalListeners(replay) {
|
|
|
5647
5764
|
client.on('afterSendEvent', handleAfterSendEvent(replay));
|
|
5648
5765
|
client.on('createDsc', (dsc) => {
|
|
5649
5766
|
const replayId = replay.getSessionId();
|
|
5650
|
-
|
|
5767
|
+
// We do not want to set the DSC when in buffer mode, as that means the replay has not been sent (yet)
|
|
5768
|
+
if (replayId && replay.isEnabled() && replay.recordingMode === 'session') {
|
|
5651
5769
|
dsc.replay_id = replayId;
|
|
5652
5770
|
}
|
|
5653
5771
|
});
|
|
@@ -5927,6 +6045,23 @@ function debounce(func, wait, options) {
|
|
|
5927
6045
|
return debounced;
|
|
5928
6046
|
}
|
|
5929
6047
|
|
|
6048
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
6049
|
+
|
|
6050
|
+
var EventType; (function (EventType) {
|
|
6051
|
+
const DomContentLoaded = 0; EventType[EventType["DomContentLoaded"] = DomContentLoaded] = "DomContentLoaded";
|
|
6052
|
+
const Load = 1; EventType[EventType["Load"] = Load] = "Load";
|
|
6053
|
+
const FullSnapshot = 2; EventType[EventType["FullSnapshot"] = FullSnapshot] = "FullSnapshot";
|
|
6054
|
+
const IncrementalSnapshot = 3; EventType[EventType["IncrementalSnapshot"] = IncrementalSnapshot] = "IncrementalSnapshot";
|
|
6055
|
+
const Meta = 4; EventType[EventType["Meta"] = Meta] = "Meta";
|
|
6056
|
+
const Custom = 5; EventType[EventType["Custom"] = Custom] = "Custom";
|
|
6057
|
+
const Plugin = 6; EventType[EventType["Plugin"] = Plugin] = "Plugin";
|
|
6058
|
+
})(EventType || (EventType = {}));
|
|
6059
|
+
|
|
6060
|
+
/**
|
|
6061
|
+
* This is a partial copy of rrweb's eventWithTime type which only contains the properties
|
|
6062
|
+
* we specifcally need in the SDK.
|
|
6063
|
+
*/
|
|
6064
|
+
|
|
5930
6065
|
/**
|
|
5931
6066
|
* Handler for recording events.
|
|
5932
6067
|
*
|
|
@@ -5969,6 +6104,14 @@ function getHandleRecordingEmit(replay) {
|
|
|
5969
6104
|
return false;
|
|
5970
6105
|
}
|
|
5971
6106
|
|
|
6107
|
+
// Additionally, create a meta event that will capture certain SDK settings.
|
|
6108
|
+
// In order to handle buffer mode, this needs to either be done when we
|
|
6109
|
+
// receive checkout events or at flush time.
|
|
6110
|
+
//
|
|
6111
|
+
// `isCheckout` is always true, but want to be explicit that it should
|
|
6112
|
+
// only be added for checkouts
|
|
6113
|
+
void addSettingsEvent(replay, isCheckout);
|
|
6114
|
+
|
|
5972
6115
|
// If there is a previousSessionId after a full snapshot occurs, then
|
|
5973
6116
|
// the replay session was started due to session expiration. The new session
|
|
5974
6117
|
// is started before triggering a new checkout and contains the id
|
|
@@ -5979,10 +6122,10 @@ function getHandleRecordingEmit(replay) {
|
|
|
5979
6122
|
return true;
|
|
5980
6123
|
}
|
|
5981
6124
|
|
|
5982
|
-
//
|
|
5983
|
-
// checkout
|
|
5984
|
-
if (replay.recordingMode === 'buffer' && replay.session) {
|
|
5985
|
-
const
|
|
6125
|
+
// When in buffer mode, make sure we adjust the session started date to the current earliest event of the buffer
|
|
6126
|
+
// this should usually be the timestamp of the checkout event, but to be safe...
|
|
6127
|
+
if (replay.recordingMode === 'buffer' && replay.session && replay.eventBuffer) {
|
|
6128
|
+
const earliestEvent = replay.eventBuffer.getEarliestTimestamp();
|
|
5986
6129
|
if (earliestEvent) {
|
|
5987
6130
|
replay.session.started = earliestEvent;
|
|
5988
6131
|
|
|
@@ -6006,6 +6149,46 @@ function getHandleRecordingEmit(replay) {
|
|
|
6006
6149
|
};
|
|
6007
6150
|
}
|
|
6008
6151
|
|
|
6152
|
+
/**
|
|
6153
|
+
* Exported for tests
|
|
6154
|
+
*/
|
|
6155
|
+
function createOptionsEvent(replay) {
|
|
6156
|
+
const options = replay.getOptions();
|
|
6157
|
+
return {
|
|
6158
|
+
type: EventType.Custom,
|
|
6159
|
+
timestamp: Date.now(),
|
|
6160
|
+
data: {
|
|
6161
|
+
tag: 'options',
|
|
6162
|
+
payload: {
|
|
6163
|
+
sessionSampleRate: options.sessionSampleRate,
|
|
6164
|
+
errorSampleRate: options.errorSampleRate,
|
|
6165
|
+
useCompressionOption: options.useCompression,
|
|
6166
|
+
blockAllMedia: options.blockAllMedia,
|
|
6167
|
+
maskAllText: options.maskAllText,
|
|
6168
|
+
maskAllInputs: options.maskAllInputs,
|
|
6169
|
+
useCompression: replay.eventBuffer ? replay.eventBuffer.type === 'worker' : false,
|
|
6170
|
+
networkDetailHasUrls: options.networkDetailAllowUrls.length > 0,
|
|
6171
|
+
networkCaptureBodies: options.networkCaptureBodies,
|
|
6172
|
+
networkRequestHasHeaders: options.networkRequestHeaders.length > 0,
|
|
6173
|
+
networkResponseHasHeaders: options.networkResponseHeaders.length > 0,
|
|
6174
|
+
},
|
|
6175
|
+
},
|
|
6176
|
+
};
|
|
6177
|
+
}
|
|
6178
|
+
|
|
6179
|
+
/**
|
|
6180
|
+
* Add a "meta" event that contains a simplified view on current configuration
|
|
6181
|
+
* options. This should only be included on the first segment of a recording.
|
|
6182
|
+
*/
|
|
6183
|
+
function addSettingsEvent(replay, isCheckout) {
|
|
6184
|
+
// Only need to add this event when sending the first segment
|
|
6185
|
+
if (!isCheckout || !replay.session || replay.session.segmentId !== 0) {
|
|
6186
|
+
return Promise.resolve(null);
|
|
6187
|
+
}
|
|
6188
|
+
|
|
6189
|
+
return addEvent(replay, createOptionsEvent(replay), false);
|
|
6190
|
+
}
|
|
6191
|
+
|
|
6009
6192
|
/**
|
|
6010
6193
|
* Create a replay envelope ready to be sent.
|
|
6011
6194
|
* This includes both the replay event, as well as the recording data.
|
|
@@ -6120,7 +6303,6 @@ async function sendReplayRequest({
|
|
|
6120
6303
|
eventContext,
|
|
6121
6304
|
timestamp,
|
|
6122
6305
|
session,
|
|
6123
|
-
options,
|
|
6124
6306
|
}) {
|
|
6125
6307
|
const preparedRecordingData = prepareRecordingData({
|
|
6126
6308
|
recordingData,
|
|
@@ -6162,15 +6344,6 @@ async function sendReplayRequest({
|
|
|
6162
6344
|
return;
|
|
6163
6345
|
}
|
|
6164
6346
|
|
|
6165
|
-
replayEvent.contexts = {
|
|
6166
|
-
...replayEvent.contexts,
|
|
6167
|
-
replay: {
|
|
6168
|
-
...(replayEvent.contexts && replayEvent.contexts.replay),
|
|
6169
|
-
session_sample_rate: options.sessionSampleRate,
|
|
6170
|
-
error_sample_rate: options.errorSampleRate,
|
|
6171
|
-
},
|
|
6172
|
-
};
|
|
6173
|
-
|
|
6174
6347
|
/*
|
|
6175
6348
|
For reference, the fully built event looks something like this:
|
|
6176
6349
|
{
|
|
@@ -6201,10 +6374,6 @@ async function sendReplayRequest({
|
|
|
6201
6374
|
},
|
|
6202
6375
|
"sdkProcessingMetadata": {},
|
|
6203
6376
|
"contexts": {
|
|
6204
|
-
"replay": {
|
|
6205
|
-
"session_sample_rate": 1,
|
|
6206
|
-
"error_sample_rate": 0,
|
|
6207
|
-
},
|
|
6208
6377
|
},
|
|
6209
6378
|
}
|
|
6210
6379
|
*/
|
|
@@ -6388,7 +6557,6 @@ class ReplayContainer {
|
|
|
6388
6557
|
errorIds: new Set(),
|
|
6389
6558
|
traceIds: new Set(),
|
|
6390
6559
|
urls: [],
|
|
6391
|
-
earliestEvent: null,
|
|
6392
6560
|
initialTimestamp: Date.now(),
|
|
6393
6561
|
initialUrl: '',
|
|
6394
6562
|
};}
|
|
@@ -6398,7 +6566,7 @@ class ReplayContainer {
|
|
|
6398
6566
|
recordingOptions,
|
|
6399
6567
|
}
|
|
6400
6568
|
|
|
6401
|
-
) {ReplayContainer.prototype.__init.call(this);ReplayContainer.prototype.__init2.call(this);ReplayContainer.prototype.__init3.call(this);ReplayContainer.prototype.__init4.call(this);ReplayContainer.prototype.__init5.call(this);ReplayContainer.prototype.__init6.call(this);ReplayContainer.prototype.__init7.call(this);ReplayContainer.prototype.__init8.call(this);ReplayContainer.prototype.__init9.call(this);ReplayContainer.prototype.__init10.call(this);ReplayContainer.prototype.__init11.call(this);ReplayContainer.prototype.__init12.call(this);ReplayContainer.prototype.__init13.call(this);ReplayContainer.prototype.__init14.call(this);ReplayContainer.prototype.__init15.call(this);ReplayContainer.prototype.__init16.call(this);ReplayContainer.prototype.__init17.call(this);
|
|
6569
|
+
) {ReplayContainer.prototype.__init.call(this);ReplayContainer.prototype.__init2.call(this);ReplayContainer.prototype.__init3.call(this);ReplayContainer.prototype.__init4.call(this);ReplayContainer.prototype.__init5.call(this);ReplayContainer.prototype.__init6.call(this);ReplayContainer.prototype.__init7.call(this);ReplayContainer.prototype.__init8.call(this);ReplayContainer.prototype.__init9.call(this);ReplayContainer.prototype.__init10.call(this);ReplayContainer.prototype.__init11.call(this);ReplayContainer.prototype.__init12.call(this);ReplayContainer.prototype.__init13.call(this);ReplayContainer.prototype.__init14.call(this);ReplayContainer.prototype.__init15.call(this);ReplayContainer.prototype.__init16.call(this);ReplayContainer.prototype.__init17.call(this);ReplayContainer.prototype.__init18.call(this);
|
|
6402
6570
|
this._recordingOptions = recordingOptions;
|
|
6403
6571
|
this._options = options;
|
|
6404
6572
|
|
|
@@ -6890,6 +7058,7 @@ class ReplayContainer {
|
|
|
6890
7058
|
WINDOW.document.addEventListener('visibilitychange', this._handleVisibilityChange);
|
|
6891
7059
|
WINDOW.addEventListener('blur', this._handleWindowBlur);
|
|
6892
7060
|
WINDOW.addEventListener('focus', this._handleWindowFocus);
|
|
7061
|
+
WINDOW.addEventListener('keydown', this._handleKeyboardEvent);
|
|
6893
7062
|
|
|
6894
7063
|
// There is no way to remove these listeners, so ensure they are only added once
|
|
6895
7064
|
if (!this._hasInitializedCoreListeners) {
|
|
@@ -6918,6 +7087,7 @@ class ReplayContainer {
|
|
|
6918
7087
|
|
|
6919
7088
|
WINDOW.removeEventListener('blur', this._handleWindowBlur);
|
|
6920
7089
|
WINDOW.removeEventListener('focus', this._handleWindowFocus);
|
|
7090
|
+
WINDOW.removeEventListener('keydown', this._handleKeyboardEvent);
|
|
6921
7091
|
|
|
6922
7092
|
if (this._performanceObserver) {
|
|
6923
7093
|
this._performanceObserver.disconnect();
|
|
@@ -6968,6 +7138,11 @@ class ReplayContainer {
|
|
|
6968
7138
|
this._doChangeToForegroundTasks(breadcrumb);
|
|
6969
7139
|
};}
|
|
6970
7140
|
|
|
7141
|
+
/** Ensure page remains active when a key is pressed. */
|
|
7142
|
+
__init16() {this._handleKeyboardEvent = () => {
|
|
7143
|
+
this.triggerUserActivity();
|
|
7144
|
+
};}
|
|
7145
|
+
|
|
6971
7146
|
/**
|
|
6972
7147
|
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
|
|
6973
7148
|
*/
|
|
@@ -7047,7 +7222,7 @@ class ReplayContainer {
|
|
|
7047
7222
|
_createCustomBreadcrumb(breadcrumb) {
|
|
7048
7223
|
this.addUpdate(() => {
|
|
7049
7224
|
void addEvent(this, {
|
|
7050
|
-
type: EventType.Custom,
|
|
7225
|
+
type: EventType$1.Custom,
|
|
7051
7226
|
timestamp: breadcrumb.timestamp || 0,
|
|
7052
7227
|
data: {
|
|
7053
7228
|
tag: 'breadcrumb',
|
|
@@ -7088,22 +7263,35 @@ class ReplayContainer {
|
|
|
7088
7263
|
this._context.errorIds.clear();
|
|
7089
7264
|
this._context.traceIds.clear();
|
|
7090
7265
|
this._context.urls = [];
|
|
7091
|
-
|
|
7266
|
+
}
|
|
7267
|
+
|
|
7268
|
+
/** Update the initial timestamp based on the buffer content. */
|
|
7269
|
+
_updateInitialTimestampFromEventBuffer() {
|
|
7270
|
+
const { session, eventBuffer } = this;
|
|
7271
|
+
if (!session || !eventBuffer) {
|
|
7272
|
+
return;
|
|
7273
|
+
}
|
|
7274
|
+
|
|
7275
|
+
// we only ever update this on the initial segment
|
|
7276
|
+
if (session.segmentId) {
|
|
7277
|
+
return;
|
|
7278
|
+
}
|
|
7279
|
+
|
|
7280
|
+
const earliestEvent = eventBuffer.getEarliestTimestamp();
|
|
7281
|
+
if (earliestEvent && earliestEvent < this._context.initialTimestamp) {
|
|
7282
|
+
this._context.initialTimestamp = earliestEvent;
|
|
7283
|
+
}
|
|
7092
7284
|
}
|
|
7093
7285
|
|
|
7094
7286
|
/**
|
|
7095
7287
|
* Return and clear _context
|
|
7096
7288
|
*/
|
|
7097
7289
|
_popEventContext() {
|
|
7098
|
-
if (this._context.earliestEvent && this._context.earliestEvent < this._context.initialTimestamp) {
|
|
7099
|
-
this._context.initialTimestamp = this._context.earliestEvent;
|
|
7100
|
-
}
|
|
7101
|
-
|
|
7102
7290
|
const _context = {
|
|
7103
7291
|
initialTimestamp: this._context.initialTimestamp,
|
|
7104
7292
|
initialUrl: this._context.initialUrl,
|
|
7105
|
-
errorIds: Array.from(this._context.errorIds)
|
|
7106
|
-
traceIds: Array.from(this._context.traceIds)
|
|
7293
|
+
errorIds: Array.from(this._context.errorIds),
|
|
7294
|
+
traceIds: Array.from(this._context.traceIds),
|
|
7107
7295
|
urls: this._context.urls,
|
|
7108
7296
|
};
|
|
7109
7297
|
|
|
@@ -7142,6 +7330,9 @@ class ReplayContainer {
|
|
|
7142
7330
|
}
|
|
7143
7331
|
|
|
7144
7332
|
try {
|
|
7333
|
+
// This uses the data from the eventBuffer, so we need to call this before `finish()
|
|
7334
|
+
this._updateInitialTimestampFromEventBuffer();
|
|
7335
|
+
|
|
7145
7336
|
// Note this empties the event buffer regardless of outcome of sending replay
|
|
7146
7337
|
const recordingData = await this.eventBuffer.finish();
|
|
7147
7338
|
|
|
@@ -7182,7 +7373,7 @@ class ReplayContainer {
|
|
|
7182
7373
|
* Flush recording data to Sentry. Creates a lock so that only a single flush
|
|
7183
7374
|
* can be active at a time. Do not call this directly.
|
|
7184
7375
|
*/
|
|
7185
|
-
|
|
7376
|
+
__init17() {this._flush = async ({
|
|
7186
7377
|
force = false,
|
|
7187
7378
|
}
|
|
7188
7379
|
|
|
@@ -7237,7 +7428,7 @@ class ReplayContainer {
|
|
|
7237
7428
|
}
|
|
7238
7429
|
|
|
7239
7430
|
/** Handler for rrweb.record.onMutation */
|
|
7240
|
-
|
|
7431
|
+
__init18() {this._onMutationHandler = (mutations) => {
|
|
7241
7432
|
const count = mutations.length;
|
|
7242
7433
|
|
|
7243
7434
|
const mutationLimit = this._options._experiments.mutationLimit || 0;
|
|
@@ -7476,6 +7667,8 @@ class Replay {
|
|
|
7476
7667
|
errorSampleRate,
|
|
7477
7668
|
useCompression,
|
|
7478
7669
|
blockAllMedia,
|
|
7670
|
+
maskAllInputs,
|
|
7671
|
+
maskAllText,
|
|
7479
7672
|
networkDetailAllowUrls,
|
|
7480
7673
|
networkCaptureBodies,
|
|
7481
7674
|
networkRequestHeaders: _getMergedNetworkHeaders(networkRequestHeaders),
|