@cloudcare/browser-rum 3.3.12 → 3.3.14
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/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/recorderApi.js +22 -2
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/startRecording.js +54 -1
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/assembly.js +15 -2
- package/cjs/domain/assembly.js.map +1 -1
- package/cjs/domain/configuration.js +1 -0
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/privacy.js +278 -0
- package/cjs/domain/privacy.js.map +1 -0
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +16 -6
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/privacy.js +11 -272
- package/cjs/domain/replay/record/privacy.js.map +1 -1
- package/cjs/domain/replay/record/record.js +94 -8
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +45 -17
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/replay/timeAnchor.js +27 -0
- package/cjs/domain/replay/timeAnchor.js.map +1 -0
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js +81 -19
- package/cjs/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
- package/cjs/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackViews.js +45 -7
- package/cjs/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/cjs/domain/rumSessionManager.js +2 -2
- package/cjs/domain/rumSessionManager.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/recorderApi.js +23 -3
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/startRecording.js +54 -1
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/assembly.js +16 -3
- package/esm/domain/assembly.js.map +1 -1
- package/esm/domain/configuration.js +1 -0
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/privacy.js +266 -0
- package/esm/domain/privacy.js.map +1 -0
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/record/mutationObserver.js +16 -6
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/privacy.js +1 -266
- package/esm/domain/replay/record/privacy.js.map +1 -1
- package/esm/domain/replay/record/record.js +78 -9
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +45 -17
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/replay/timeAnchor.js +20 -0
- package/esm/domain/replay/timeAnchor.js.map +1 -0
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js +80 -18
- package/esm/domain/rumEventsCollection/actions/getActionNameFromElement.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js +11 -4
- package/esm/domain/rumEventsCollection/actions/trackClickActions.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackViews.js +46 -8
- package/esm/domain/rumEventsCollection/view/trackViews.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/domain/rumSessionManager.js +2 -2
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/recorderApi.js +25 -3
- package/src/boot/startRecording.js +61 -1
- package/src/domain/assembly.js +18 -4
- package/src/domain/configuration.js +4 -0
- package/src/domain/privacy.js +356 -0
- package/src/domain/replay/record/mutationObserver.js +21 -11
- package/src/domain/replay/record/privacy.js +1 -356
- package/src/domain/replay/record/record.js +129 -8
- package/src/domain/replay/segmentCollection/segmentCollection.js +83 -18
- package/src/domain/replay/timeAnchor.js +33 -0
- package/src/domain/rumEventsCollection/actions/getActionNameFromElement.js +148 -21
- package/src/domain/rumEventsCollection/actions/trackClickActions.js +19 -5
- package/src/domain/rumEventsCollection/view/trackViews.js +83 -12
- package/src/domain/rumEventsCollection/view/viewCollection.js +2 -1
- package/src/domain/rumSessionManager.js +2 -2
|
@@ -3,276 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports
|
|
10
|
-
exports
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var MAX_PRIVACY_ANCESTOR_DEPTH = exports.MAX_PRIVACY_ANCESTOR_DEPTH = 1000;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get node privacy level by iterating over its ancestors. When the direct parent privacy level is
|
|
21
|
-
* know, it is best to use something like:
|
|
22
|
-
*
|
|
23
|
-
* derivePrivacyLevelGivenParent(getNodeSelfPrivacyLevel(node), parentNodePrivacyLevel)
|
|
24
|
-
*/
|
|
25
|
-
function getNodePrivacyLevel(node, defaultPrivacyLevel, cache) {
|
|
26
|
-
if (cache && cache.has(node)) {
|
|
27
|
-
return cache.get(node);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Resolve ancestors iteratively so an adversarially deep DOM cannot grow the
|
|
31
|
-
// JavaScript stack. If the watermark is crossed, fail closed: hiding the
|
|
32
|
-
// branch is safer than spending unbounded time resolving its privacy chain.
|
|
33
|
-
var unresolvedNodes = [];
|
|
34
|
-
var currentNode = node;
|
|
35
|
-
var inheritedPrivacyLevel;
|
|
36
|
-
while (currentNode) {
|
|
37
|
-
if (cache && cache.has(currentNode)) {
|
|
38
|
-
inheritedPrivacyLevel = cache.get(currentNode);
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
if (unresolvedNodes.length >= MAX_PRIVACY_ANCESTOR_DEPTH) {
|
|
42
|
-
inheritedPrivacyLevel = _constants.NodePrivacyLevel.HIDDEN;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
unresolvedNodes.push(currentNode);
|
|
46
|
-
currentNode = (0, _browserCore.getParentNode)(currentNode);
|
|
47
|
-
}
|
|
48
|
-
if (inheritedPrivacyLevel === undefined) {
|
|
49
|
-
inheritedPrivacyLevel = defaultPrivacyLevel;
|
|
50
|
-
}
|
|
51
|
-
while (unresolvedNodes.length) {
|
|
52
|
-
var unresolvedNode = unresolvedNodes.pop();
|
|
53
|
-
inheritedPrivacyLevel = reducePrivacyLevel(getNodeSelfPrivacyLevel(unresolvedNode), inheritedPrivacyLevel);
|
|
54
|
-
if (cache) {
|
|
55
|
-
cache.set(unresolvedNode, inheritedPrivacyLevel);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return inheritedPrivacyLevel;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Reduces the next privacy level based on self + parent privacy levels
|
|
63
|
-
*/
|
|
64
|
-
function reducePrivacyLevel(childPrivacyLevel, parentNodePrivacyLevel) {
|
|
65
|
-
switch (parentNodePrivacyLevel) {
|
|
66
|
-
// These values cannot be overridden
|
|
67
|
-
case _constants.NodePrivacyLevel.HIDDEN:
|
|
68
|
-
case _constants.NodePrivacyLevel.IGNORE:
|
|
69
|
-
return parentNodePrivacyLevel;
|
|
70
|
-
}
|
|
71
|
-
switch (childPrivacyLevel) {
|
|
72
|
-
case _constants.NodePrivacyLevel.ALLOW:
|
|
73
|
-
case _constants.NodePrivacyLevel.MASK:
|
|
74
|
-
case _constants.NodePrivacyLevel.MASK_USER_INPUT:
|
|
75
|
-
case _constants.NodePrivacyLevel.HIDDEN:
|
|
76
|
-
case _constants.NodePrivacyLevel.IGNORE:
|
|
77
|
-
return childPrivacyLevel;
|
|
78
|
-
default:
|
|
79
|
-
return parentNodePrivacyLevel;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Determines the node's own privacy level without checking for ancestors.
|
|
85
|
-
*/
|
|
86
|
-
function getNodeSelfPrivacyLevel(node) {
|
|
87
|
-
// Only Element types can have a privacy level set
|
|
88
|
-
if (!(0, _browserCore.isElementNode)(node)) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
var privAttr = node.getAttribute(_constants.PRIVACY_ATTR_NAME);
|
|
92
|
-
|
|
93
|
-
// Overrules for replay purpose
|
|
94
|
-
if (node.tagName === 'BASE') {
|
|
95
|
-
return _constants.NodePrivacyLevel.ALLOW;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Overrules to enforce end-user protection
|
|
99
|
-
if (node.tagName === 'INPUT') {
|
|
100
|
-
var inputElement = node;
|
|
101
|
-
if (inputElement.type === 'password' || inputElement.type === 'email' || inputElement.type === 'tel') {
|
|
102
|
-
return _constants.NodePrivacyLevel.MASK;
|
|
103
|
-
}
|
|
104
|
-
if (inputElement.type === 'hidden') {
|
|
105
|
-
return _constants.NodePrivacyLevel.MASK;
|
|
106
|
-
}
|
|
107
|
-
var autocomplete = inputElement.getAttribute('autocomplete');
|
|
108
|
-
// Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year]
|
|
109
|
-
if (autocomplete && autocomplete.indexOf('cc-') === 0) {
|
|
110
|
-
return _constants.NodePrivacyLevel.MASK;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Check HTML privacy attributes and classes
|
|
115
|
-
if (privAttr === _constants.PRIVACY_ATTR_VALUE_HIDDEN || node.classList.contains(_constants.PRIVACY_CLASS_HIDDEN)) {
|
|
116
|
-
return _constants.NodePrivacyLevel.HIDDEN;
|
|
117
|
-
}
|
|
118
|
-
if (privAttr === _constants.PRIVACY_ATTR_VALUE_MASK || node.classList.contains(_constants.PRIVACY_CLASS_MASK)) {
|
|
119
|
-
return _constants.NodePrivacyLevel.MASK;
|
|
120
|
-
}
|
|
121
|
-
if (privAttr === _constants.PRIVACY_ATTR_VALUE_MASK_USER_INPUT || node.classList.contains(_constants.PRIVACY_CLASS_MASK_USER_INPUT)) {
|
|
122
|
-
return _constants.NodePrivacyLevel.MASK_USER_INPUT;
|
|
123
|
-
}
|
|
124
|
-
if (privAttr === _constants.PRIVACY_ATTR_VALUE_ALLOW || node.classList.contains(_constants.PRIVACY_CLASS_ALLOW)) {
|
|
125
|
-
return _constants.NodePrivacyLevel.ALLOW;
|
|
126
|
-
}
|
|
127
|
-
if (shouldIgnoreElement(node)) {
|
|
128
|
-
return _constants.NodePrivacyLevel.IGNORE;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Helper aiming to unify `mask` and `mask-user-input` privacy levels:
|
|
134
|
-
*
|
|
135
|
-
* In the `mask` case, it is trivial: we should mask the element.
|
|
136
|
-
*
|
|
137
|
-
* In the `mask-user-input` case, we should mask the element only if it is a "form" element or the
|
|
138
|
-
* direct parent is a form element for text nodes).
|
|
139
|
-
*
|
|
140
|
-
* Other `shouldMaskNode` cases are edge cases that should not matter too much (ex: should we mask a
|
|
141
|
-
* node if it is ignored or hidden? it doesn't matter since it won't be serialized).
|
|
142
|
-
*/
|
|
143
|
-
function shouldMaskNode(configuration, node, privacyLevel) {
|
|
144
|
-
if (configuration.shouldMaskNode && configuration.shouldMaskNode(node, privacyLevel) === true) return true;
|
|
145
|
-
switch (privacyLevel) {
|
|
146
|
-
case _constants.NodePrivacyLevel.MASK:
|
|
147
|
-
case _constants.NodePrivacyLevel.HIDDEN:
|
|
148
|
-
case _constants.NodePrivacyLevel.IGNORE:
|
|
149
|
-
return true;
|
|
150
|
-
case _constants.NodePrivacyLevel.MASK_USER_INPUT:
|
|
151
|
-
return (0, _browserCore.isTextNode)(node) ? isFormElement(node.parentNode) : isFormElement(node);
|
|
152
|
-
default:
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function isFormElement(node) {
|
|
157
|
-
if (!node || node.nodeType !== node.ELEMENT_NODE) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
var element = node;
|
|
161
|
-
if (element.tagName === 'INPUT') {
|
|
162
|
-
switch (element.type) {
|
|
163
|
-
case 'button':
|
|
164
|
-
case 'color':
|
|
165
|
-
case 'reset':
|
|
166
|
-
case 'submit':
|
|
167
|
-
return false;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return !!_constants.FORM_PRIVATE_TAG_NAMES[element.tagName];
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Text censoring non-destructively maintains whitespace characters in order to preserve text shape
|
|
175
|
-
* during replay.
|
|
176
|
-
*/
|
|
177
|
-
var censorText = exports.censorText = function censorText(text) {
|
|
178
|
-
return text.replace(/\S/g, TEXT_MASKING_CHAR);
|
|
179
|
-
};
|
|
180
|
-
function getTextContent(configuration, textNode, ignoreWhiteSpace, parentNodePrivacyLevel) {
|
|
181
|
-
// The parent node may not be a html element which has a tagName attribute.
|
|
182
|
-
// So just let it be undefined which is ok in this use case.
|
|
183
|
-
var parentTagName = textNode.parentElement && textNode.parentElement.tagName;
|
|
184
|
-
var textContent = textNode.textContent || '';
|
|
185
|
-
if (ignoreWhiteSpace && !textContent.trim()) {
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
var nodePrivacyLevel = parentNodePrivacyLevel;
|
|
189
|
-
|
|
190
|
-
// var isStyle = parentTagName === 'STYLE' ? true : undefined
|
|
191
|
-
var isScript = parentTagName === 'SCRIPT';
|
|
192
|
-
if (isScript) {
|
|
193
|
-
// For perf reasons, we don't record script (heuristic)
|
|
194
|
-
textContent = _constants.CENSORED_STRING_MARK;
|
|
195
|
-
} else if (nodePrivacyLevel === _constants.NodePrivacyLevel.HIDDEN) {
|
|
196
|
-
// Should never occur, but just in case, we set to CENSORED_MARK.
|
|
197
|
-
textContent = _constants.CENSORED_STRING_MARK;
|
|
198
|
-
} else if (shouldMaskNode(configuration, textNode, nodePrivacyLevel)) {
|
|
199
|
-
if (
|
|
200
|
-
// Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP
|
|
201
|
-
parentTagName === 'DATALIST' || parentTagName === 'SELECT' || parentTagName === 'OPTGROUP') {
|
|
202
|
-
if (!textContent.trim()) {
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
} else if (parentTagName === 'OPTION') {
|
|
206
|
-
// <Option> has low entropy in charset + text length, so use `CENSORED_STRING_MARK` when masked
|
|
207
|
-
textContent = _constants.CENSORED_STRING_MARK;
|
|
208
|
-
} else {
|
|
209
|
-
textContent = censorText(textContent);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
// else if (isStyle && textContent) {
|
|
213
|
-
// try {
|
|
214
|
-
// // try to read style sheet
|
|
215
|
-
// if (textNode.nextSibling || textNode.previousSibling) {
|
|
216
|
-
// // This is not the only child of the stylesheet.
|
|
217
|
-
// // We can't read all of the sheet's .cssRules and expect them
|
|
218
|
-
// // to _only_ include the current rule(s) added by the text node.
|
|
219
|
-
// // So we'll be conservative and keep textContent as-is.
|
|
220
|
-
// } else if (
|
|
221
|
-
// textNode.parentNode &&
|
|
222
|
-
// textNode.parentNode.sheet &&
|
|
223
|
-
// textNode.parentNode.sheet.cssRules
|
|
224
|
-
// ) {
|
|
225
|
-
// textContent = getCssRulesString(textNode.parentNode.sheet)
|
|
226
|
-
// }
|
|
227
|
-
// } catch (err) {}
|
|
228
|
-
// textContent = switchToAbsoluteUrl(textContent, getHref())
|
|
229
|
-
// }
|
|
230
|
-
return textContent;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* We don't need this logic on the recorder side.
|
|
235
|
-
* For security related meta's, customer can mask themmanually given they
|
|
236
|
-
* are easy to identify in the HEAD tag.
|
|
237
|
-
*/
|
|
238
|
-
function shouldIgnoreElement(element) {
|
|
239
|
-
if (element.nodeName === 'SCRIPT') {
|
|
240
|
-
return true;
|
|
241
|
-
}
|
|
242
|
-
if (element.nodeName === 'LINK') {
|
|
243
|
-
var relAttribute = getLowerCaseAttribute('rel');
|
|
244
|
-
return (
|
|
245
|
-
// Link as script - Ignore only when rel=preload, modulepreload or prefetch
|
|
246
|
-
/preload|prefetch/i.test(relAttribute) && getLowerCaseAttribute('as') === 'script' ||
|
|
247
|
-
// Favicons
|
|
248
|
-
relAttribute === 'shortcut icon' || relAttribute === 'icon'
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
if (element.nodeName === 'META') {
|
|
252
|
-
var nameAttribute = getLowerCaseAttribute('name');
|
|
253
|
-
var relAttribute = getLowerCaseAttribute('rel');
|
|
254
|
-
var propertyAttribute = getLowerCaseAttribute('property');
|
|
255
|
-
return (
|
|
256
|
-
// Favicons
|
|
257
|
-
/^msapplication-tile(image|color)$/.test(nameAttribute) || nameAttribute === 'application-name' || relAttribute === 'icon' || relAttribute === 'apple-touch-icon' || relAttribute === 'shortcut icon' ||
|
|
258
|
-
// Description
|
|
259
|
-
nameAttribute === 'keywords' || nameAttribute === 'description' ||
|
|
260
|
-
// Social
|
|
261
|
-
/^(og|twitter|fb):/.test(propertyAttribute) || /^(og|twitter):/.test(nameAttribute) || nameAttribute === 'pinterest' ||
|
|
262
|
-
// Robots
|
|
263
|
-
nameAttribute === 'robots' || nameAttribute === 'googlebot' || nameAttribute === 'bingbot' ||
|
|
264
|
-
// Http headers. Ex: X-UA-Compatible, Content-Type, Content-Language, cache-control,
|
|
265
|
-
// X-Translated-By
|
|
266
|
-
element.hasAttribute('http-equiv') ||
|
|
267
|
-
// Authorship
|
|
268
|
-
nameAttribute === 'author' || nameAttribute === 'generator' || nameAttribute === 'framework' || nameAttribute === 'publisher' || nameAttribute === 'progid' || /^article:/.test(propertyAttribute) || /^product:/.test(propertyAttribute) ||
|
|
269
|
-
// Verification
|
|
270
|
-
nameAttribute === 'google-site-verification' || nameAttribute === 'yandex-verification' || nameAttribute === 'csrf-token' || nameAttribute === 'p:domain_verify' || nameAttribute === 'verify-v1' || nameAttribute === 'verification' || nameAttribute === 'shopify-checkout-api-token'
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
function getLowerCaseAttribute(name) {
|
|
274
|
-
return (element.getAttribute(name) || '').toLowerCase();
|
|
275
|
-
}
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
6
|
+
var _privacy = require("../../privacy");
|
|
7
|
+
Object.keys(_privacy).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _privacy[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _privacy[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
278
17
|
//# sourceMappingURL=privacy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"privacy.js","names":["
|
|
1
|
+
{"version":3,"file":"privacy.js","names":["_privacy","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../../src/domain/replay/record/privacy.js"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -4,9 +4,28 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.MAX_FULL_SNAPSHOT_CANVAS_BASELINE_COUNT = exports.MAX_DEFERRED_RECORD_APPROX_BYTES = exports.MAX_DEFERRED_RECORDS = void 0;
|
|
7
|
+
Object.defineProperty(exports, "SESSION_REPLAY_TIME_ANCHOR_INTERVAL", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _timeAnchor.SESSION_REPLAY_TIME_ANCHOR_INTERVAL;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "SESSION_REPLAY_TIME_ANCHOR_RECORD_TYPE", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _timeAnchor.SESSION_REPLAY_TIME_ANCHOR_RECORD_TYPE;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "SESSION_REPLAY_TIME_ANCHOR_TAG", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function get() {
|
|
22
|
+
return _timeAnchor.SESSION_REPLAY_TIME_ANCHOR_TAG;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
7
25
|
exports.record = record;
|
|
8
26
|
var _browserCore = require("@cloudcare/browser-core");
|
|
9
27
|
var _initViewportObservable = require("../../initViewportObservable");
|
|
28
|
+
var _timeAnchor = require("../timeAnchor");
|
|
10
29
|
var _types = require("../../../types");
|
|
11
30
|
var _constants = require("../../../constants");
|
|
12
31
|
var _serialize = require("./serialize");
|
|
@@ -49,6 +68,8 @@ var FULL_SNAPSHOT_MAX_RESTART_COUNT = 3;
|
|
|
49
68
|
var FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS = 1000;
|
|
50
69
|
var FULL_SNAPSHOT_MAX_WALL_DURATION_MS = 30000;
|
|
51
70
|
var FULL_SNAPSHOT_MUTATION_QUIET_DELAY_MS = 250;
|
|
71
|
+
var REPLAY_MEMORY_BUDGET_BYTES = 48 * 1024 * 1024;
|
|
72
|
+
var REPLAY_MEMORY_HIGH_WATERMARK_BYTES = 32 * 1024 * 1024;
|
|
52
73
|
var MAX_FULL_SNAPSHOT_CANVAS_BASELINE_COUNT = exports.MAX_FULL_SNAPSHOT_CANVAS_BASELINE_COUNT = 64;
|
|
53
74
|
var FULL_SNAPSHOT_CANVAS_BASELINE_TOTAL_TIMEOUT_MS = 2000;
|
|
54
75
|
var FULL_SNAPSHOT_CANVAS_BASELINE_ITEM_TIMEOUT_MS = 1000;
|
|
@@ -348,6 +369,55 @@ function record(options) {
|
|
|
348
369
|
var pendingFullSnapshotBaselineRecords;
|
|
349
370
|
var pendingFullSnapshotBaselineMutationVersion;
|
|
350
371
|
var fullSnapshotWasPublished = false;
|
|
372
|
+
var replayMemoryBudget = options.$rMemoryBudget;
|
|
373
|
+
if (replayMemoryBudget) {
|
|
374
|
+
replayMemoryBudget.$rRecord = function () {
|
|
375
|
+
return pendingMutationAdmissionApproxBytes;
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
var lastReplayTimeAnchorTimestamp;
|
|
379
|
+
function emitReplayTimeAnchor() {
|
|
380
|
+
if (!fullSnapshotWasPublished || recordStopping || recordStopped || options.$rShouldEmitTimeAnchor && !options.$rShouldEmitTimeAnchor()) {
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
// A time anchor carries no replay state and is safe to drop. Do not put it
|
|
384
|
+
// on the shared deferred queue: `true` must mean that the segment layer
|
|
385
|
+
// actually admitted it, especially for the final stop boundary.
|
|
386
|
+
if (suppressRecordsUntilFullSnapshot || mutationPublicationBarrier || deferredRecords.length || deferredRecordAdmissionTimeout !== undefined || pendingMutationPayload || pendingMutationAdmissionQueue.length || mutationAdmissionEmitInProgress || mutationSourceFlushInProgress) {
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
var timestamp = (0, _browserCore.timeStampNow)();
|
|
390
|
+
if (timestamp === lastReplayTimeAnchorTimestamp) {
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
lastEmitWasLocallyBackpressured = false;
|
|
394
|
+
var accepted = rawEmit({
|
|
395
|
+
type: _timeAnchor.SESSION_REPLAY_TIME_ANCHOR_RECORD_TYPE,
|
|
396
|
+
timestamp: timestamp,
|
|
397
|
+
data: {
|
|
398
|
+
tag: _timeAnchor.SESSION_REPLAY_TIME_ANCHOR_TAG,
|
|
399
|
+
payload: {}
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
if (accepted === false) {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
lastReplayTimeAnchorTimestamp = timestamp;
|
|
406
|
+
return true;
|
|
407
|
+
}
|
|
408
|
+
function emitPeriodicReplayTimeAnchor() {
|
|
409
|
+
// Keep the explicit page-exit anchor as the hidden boundary, but do not let
|
|
410
|
+
// the background timer extend the replay timeline while the Session is no
|
|
411
|
+
// longer renewed by visible-page activity.
|
|
412
|
+
if (document.visibilityState !== 'visible') {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
emitReplayTimeAnchor();
|
|
416
|
+
}
|
|
417
|
+
var replayTimeAnchorIntervalId = (0, _browserCore.setInterval)(emitPeriodicReplayTimeAnchor, _timeAnchor.SESSION_REPLAY_TIME_ANCHOR_INTERVAL);
|
|
418
|
+
registerInitializationCleanup(function () {
|
|
419
|
+
(0, _browserCore.clearInterval)(replayTimeAnchorIntervalId);
|
|
420
|
+
});
|
|
351
421
|
var domMutationVersion = 0;
|
|
352
422
|
var mutationActivityTargets = new Set();
|
|
353
423
|
var mutationActivityFlushScheduled = false;
|
|
@@ -451,9 +521,14 @@ function record(options) {
|
|
|
451
521
|
if (pendingPublicationToken.$rPublished || pendingPublicationToken.$rQueued) {
|
|
452
522
|
return true;
|
|
453
523
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
524
|
+
// Serializing a newly added ancestor can stage an already-published
|
|
525
|
+
// descendant before the paired remove is normalized. This is the
|
|
526
|
+
// common DOM shape used by Cocos Creator when it inserts a wrapper and
|
|
527
|
+
// moves its existing GameCanvas into it. Until the destination add is
|
|
528
|
+
// queued, the node still belongs to the previously published replay
|
|
529
|
+
// tree and must remain eligible for the atomic remove + add transition.
|
|
530
|
+
// A genuinely new node has no previous publication token and therefore
|
|
531
|
+
// still falls through to false below.
|
|
457
532
|
}
|
|
458
533
|
var publicationToken = publicationTokenByNode.get(node);
|
|
459
534
|
return Boolean(publicationToken && (publicationToken.$rPublished || publicationToken.$rQueued));
|
|
@@ -788,10 +863,10 @@ function record(options) {
|
|
|
788
863
|
function isPureAddMutationPayload(mutationPayload) {
|
|
789
864
|
return Boolean(mutationPayload && mutationPayload.adds.length && !mutationPayload.removes.length && !mutationPayload.texts.length && !mutationPayload.attributes.length);
|
|
790
865
|
}
|
|
791
|
-
function tryMergePendingPureAddMutationAdmission(entry) {
|
|
866
|
+
function tryMergePendingPureAddMutationAdmission(entry, admissionBytesLimit) {
|
|
792
867
|
var previousEntry = pendingMutationAdmissionQueue[pendingMutationAdmissionQueue.length - 1];
|
|
793
868
|
var mutationPayload = entry[0];
|
|
794
|
-
if (!previousEntry || previousEntry[3] || previousEntry.$rReferencedByDeferredRecord || !isPureAddMutationPayload(previousEntry[0]) || !isPureAddMutationPayload(mutationPayload) || previousEntry[1] + entry[1] > MAX_MUTATION_EMIT_APPROX_BYTES || pendingMutationAdmissionApproxBytes + entry[1] >
|
|
869
|
+
if (!previousEntry || previousEntry[3] || previousEntry.$rReferencedByDeferredRecord || !isPureAddMutationPayload(previousEntry[0]) || !isPureAddMutationPayload(mutationPayload) || previousEntry[1] + entry[1] > MAX_MUTATION_EMIT_APPROX_BYTES || pendingMutationAdmissionApproxBytes + entry[1] > admissionBytesLimit) {
|
|
795
870
|
return false;
|
|
796
871
|
}
|
|
797
872
|
|
|
@@ -818,12 +893,13 @@ function record(options) {
|
|
|
818
893
|
});
|
|
819
894
|
return;
|
|
820
895
|
}
|
|
896
|
+
var admissionBytesLimit = replayMemoryBudget ? Math.min(MAX_PENDING_MUTATION_ADMISSION_APPROX_BYTES, REPLAY_MEMORY_BUDGET_BYTES - replayMemoryBudget.$rSegment()) : MAX_PENDING_MUTATION_ADMISSION_APPROX_BYTES;
|
|
821
897
|
for (var entryIndex = 0; entryIndex < mutationEntries.length; entryIndex += 1) {
|
|
822
898
|
var entry = mutationEntries[entryIndex];
|
|
823
|
-
if (tryMergePendingPureAddMutationAdmission(entry)) {
|
|
899
|
+
if (tryMergePendingPureAddMutationAdmission(entry, admissionBytesLimit)) {
|
|
824
900
|
continue;
|
|
825
901
|
}
|
|
826
|
-
if (pendingMutationAdmissionQueue.length + 1 > MAX_PENDING_MUTATION_ADMISSION_PAYLOADS || pendingMutationAdmissionApproxBytes + entry[1] >
|
|
902
|
+
if (pendingMutationAdmissionQueue.length + 1 > MAX_PENDING_MUTATION_ADMISSION_PAYLOADS || pendingMutationAdmissionApproxBytes + entry[1] > admissionBytesLimit) {
|
|
827
903
|
var rejectedTail = mutationEntries.slice(entryIndex);
|
|
828
904
|
rejectedTail.forEach(function (rejectedEntry) {
|
|
829
905
|
discardMutationMembership(rejectedEntry[0]);
|
|
@@ -1226,6 +1302,12 @@ function record(options) {
|
|
|
1226
1302
|
}
|
|
1227
1303
|
}
|
|
1228
1304
|
function snapshotCanvasIfActive(canvas, snapshotOptions) {
|
|
1305
|
+
if (replayMemoryBudget && pendingMutationAdmissionApproxBytes + replayMemoryBudget.$rSegment() >= REPLAY_MEMORY_HIGH_WATERMARK_BYTES && snapshotOptions && (snapshotOptions.scheduler === 'continuous_snapshot' || snapshotOptions.scheduler === 'webgl_snapshot')) {
|
|
1306
|
+
return Promise.resolve({
|
|
1307
|
+
ok: false,
|
|
1308
|
+
reason: 'memory_pressure'
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1229
1311
|
if (isNodeIgnored(canvas)) {
|
|
1230
1312
|
return Promise.resolve({
|
|
1231
1313
|
ok: false,
|
|
@@ -2528,7 +2610,9 @@ function record(options) {
|
|
|
2528
2610
|
firstCleanupError = error;
|
|
2529
2611
|
}
|
|
2530
2612
|
recordStopped = true;
|
|
2531
|
-
[
|
|
2613
|
+
[function () {
|
|
2614
|
+
(0, _browserCore.clearInterval)(replayTimeAnchorIntervalId);
|
|
2615
|
+
}, discardPendingMutationAdmissions, cancelMutationSourceFlushContinuation, cancelScheduledFullSnapshot, invalidateFullSnapshotCanvasBaseline, function () {
|
|
2532
2616
|
suppressRecordsUntilFullSnapshot = false;
|
|
2533
2617
|
previousReplayTreeAdmissionActive = false;
|
|
2534
2618
|
captureRecordsAgainstPreviousReplayTree = false;
|
|
@@ -2552,6 +2636,7 @@ function record(options) {
|
|
|
2552
2636
|
}
|
|
2553
2637
|
var recorder = {
|
|
2554
2638
|
stop: stopRecording,
|
|
2639
|
+
$rEmitTimeAnchor: emitReplayTimeAnchor,
|
|
2555
2640
|
$rFlushCanvasCommands: function $rFlushCanvasCommands() {
|
|
2556
2641
|
// A previous boundary pass may have preserved the exact Canvas record
|
|
2557
2642
|
// after transient segment/encoder backpressure. Retry that object before
|
|
@@ -2612,6 +2697,7 @@ function createInactiveRecorder() {
|
|
|
2612
2697
|
var noop = function noop() {};
|
|
2613
2698
|
var recorder = {
|
|
2614
2699
|
stop: noop,
|
|
2700
|
+
$rEmitTimeAnchor: noop,
|
|
2615
2701
|
$rFlushCanvasCommands: noop,
|
|
2616
2702
|
snapshotCanvas: noop,
|
|
2617
2703
|
getSerializedNodeIdForDebug: noop,
|