@cloudcare/browser-rum 3.3.25 → 3.3.26
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 +36 -1
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/rum.js +2 -6
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/privacy.js +71 -102
- package/cjs/domain/privacy.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandCapture.js +12 -16
- package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/cjs/domain/replay/record/canvasCommandObserver.js +10 -6
- package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -1
- package/cjs/domain/replay/record/canvasContext.js +8 -18
- package/cjs/domain/replay/record/canvasContext.js.map +1 -1
- package/cjs/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/cjs/domain/replay/record/canvasObserver.js +1 -1
- package/cjs/domain/replay/record/canvasObserver.js.map +1 -1
- package/cjs/domain/replay/record/canvasWebGLPluginHost.js +5 -1
- package/cjs/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
- package/cjs/domain/replay/record/observers.js +3 -7
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/replay/record/record.js +14 -1
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +8 -23
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +5 -21
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +17 -24
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +5 -10
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/cjs/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/recorderApi.js +1 -1
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/rum.js +1 -1
- package/esm/boot/rum.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/privacy.js +1 -1
- package/esm/domain/privacy.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js +1 -1
- package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -1
- package/esm/domain/replay/record/canvasCommandObserver.js +1 -1
- package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasContext.js +1 -1
- package/esm/domain/replay/record/canvasContext.js.map +1 -1
- package/esm/domain/replay/record/canvasEncodeWorker.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js +1 -1
- package/esm/domain/replay/record/canvasObserver.js.map +1 -1
- package/esm/domain/replay/record/canvasWebGLPluginHost.js +1 -1
- package/esm/domain/replay/record/canvasWebGLPluginHost.js.map +1 -1
- package/esm/domain/replay/record/observers.js +1 -1
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/record.js +1 -1
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +1 -1
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +1 -1
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -1
- package/esm/domain/rumEventsCollection/view/viewCollection.js.map +1 -1
- package/package.json +4 -4
- package/src/boot/recorderApi.js +51 -2
- package/src/boot/rum.js +6 -15
- package/src/domain/privacy.js +84 -148
- package/src/domain/replay/record/canvasCommandCapture.js +14 -17
- package/src/domain/replay/record/canvasCommandObserver.js +11 -18
- package/src/domain/replay/record/canvasContext.js +10 -24
- package/src/domain/replay/record/canvasObserver.js +2 -2
- package/src/domain/replay/record/canvasWebGLPluginHost.js +4 -1
- package/src/domain/replay/record/observers.js +4 -8
- package/src/domain/replay/record/record.js +19 -4
- package/src/domain/replay/record/serializationUtils.js +10 -33
- package/src/domain/replay/record/serialize.js +7 -28
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +19 -27
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +5 -10
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +1 -1
- package/src/domain/rumEventsCollection/view/viewCollection.js +2 -3
package/src/domain/privacy.js
CHANGED
|
@@ -7,14 +7,6 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
NodePrivacyLevel,
|
|
9
9
|
PRIVACY_ATTR_NAME,
|
|
10
|
-
PRIVACY_ATTR_VALUE_ALLOW,
|
|
11
|
-
PRIVACY_ATTR_VALUE_MASK,
|
|
12
|
-
PRIVACY_ATTR_VALUE_MASK_USER_INPUT,
|
|
13
|
-
PRIVACY_ATTR_VALUE_HIDDEN,
|
|
14
|
-
PRIVACY_CLASS_ALLOW,
|
|
15
|
-
PRIVACY_CLASS_MASK,
|
|
16
|
-
PRIVACY_CLASS_MASK_USER_INPUT,
|
|
17
|
-
PRIVACY_CLASS_HIDDEN,
|
|
18
10
|
FORM_PRIVATE_TAG_NAMES,
|
|
19
11
|
CENSORED_STRING_MARK
|
|
20
12
|
} from '../constants'
|
|
@@ -30,7 +22,7 @@ export var MAX_PRIVACY_ANCESTOR_DEPTH = 1000
|
|
|
30
22
|
*
|
|
31
23
|
* derivePrivacyLevelGivenParent(getNodeSelfPrivacyLevel(node), parentNodePrivacyLevel)
|
|
32
24
|
*/
|
|
33
|
-
export function getNodePrivacyLevel(node, defaultPrivacyLevel, cache) {
|
|
25
|
+
export function getNodePrivacyLevel(node, defaultPrivacyLevel, cache, selector) {
|
|
34
26
|
if (cache && cache.has(node)) {
|
|
35
27
|
return cache.get(node)
|
|
36
28
|
}
|
|
@@ -39,19 +31,26 @@ export function getNodePrivacyLevel(node, defaultPrivacyLevel, cache) {
|
|
|
39
31
|
// JavaScript stack. If the watermark is crossed, fail closed: hiding the
|
|
40
32
|
// branch is safer than spending unbounded time resolving its privacy chain.
|
|
41
33
|
var unresolvedNodes = []
|
|
42
|
-
var currentNode = node
|
|
43
34
|
var inheritedPrivacyLevel
|
|
44
|
-
|
|
35
|
+
var depth = 0
|
|
36
|
+
var match
|
|
37
|
+
for (var currentNode = node; currentNode; currentNode = getParentNode(currentNode)) {
|
|
45
38
|
if (cache && cache.has(currentNode)) {
|
|
46
39
|
inheritedPrivacyLevel = cache.get(currentNode)
|
|
47
40
|
break
|
|
48
41
|
}
|
|
49
|
-
if (
|
|
42
|
+
if (depth++ >= MAX_PRIVACY_ANCESTOR_DEPTH) {
|
|
50
43
|
inheritedPrivacyLevel = NodePrivacyLevel.HIDDEN
|
|
51
44
|
break
|
|
52
45
|
}
|
|
46
|
+
// Canvas draws only need the elements that can change privacy. Keep counting
|
|
47
|
+
// skipped ancestors and restart native matching when crossing a shadow root.
|
|
48
|
+
if (selector && typeof currentNode.closest === 'function') {
|
|
49
|
+
if (match === undefined) match = currentNode.closest(selector)
|
|
50
|
+
if (currentNode !== match) continue
|
|
51
|
+
}
|
|
53
52
|
unresolvedNodes.push(currentNode)
|
|
54
|
-
|
|
53
|
+
match = undefined
|
|
55
54
|
}
|
|
56
55
|
if (inheritedPrivacyLevel === undefined) {
|
|
57
56
|
inheritedPrivacyLevel = defaultPrivacyLevel
|
|
@@ -92,6 +91,9 @@ export function reducePrivacyLevel(childPrivacyLevel, parentNodePrivacyLevel) {
|
|
|
92
91
|
}
|
|
93
92
|
}
|
|
94
93
|
|
|
94
|
+
// Explicit privacy attributes and their class aliases use the same level names.
|
|
95
|
+
var overridablePrivacyLevels = [NodePrivacyLevel.MASK, NodePrivacyLevel.MASK_USER_INPUT, NodePrivacyLevel.ALLOW]
|
|
96
|
+
|
|
95
97
|
/**
|
|
96
98
|
* Determines the node's own privacy level without checking for ancestors.
|
|
97
99
|
*/
|
|
@@ -103,58 +105,34 @@ export function getNodeSelfPrivacyLevel(node) {
|
|
|
103
105
|
|
|
104
106
|
var privAttr = node.getAttribute(PRIVACY_ATTR_NAME)
|
|
105
107
|
|
|
108
|
+
function matchesPrivacyLevel(level) {
|
|
109
|
+
return privAttr === level || node.classList.contains('gc-privacy-' + level)
|
|
110
|
+
}
|
|
111
|
+
|
|
106
112
|
// Overrules for replay purpose
|
|
107
113
|
if (node.tagName === 'BASE') {
|
|
108
114
|
return NodePrivacyLevel.ALLOW
|
|
109
115
|
}
|
|
110
116
|
|
|
111
|
-
if (
|
|
112
|
-
privAttr === PRIVACY_ATTR_VALUE_HIDDEN ||
|
|
113
|
-
node.classList.contains(PRIVACY_CLASS_HIDDEN)
|
|
114
|
-
) {
|
|
117
|
+
if (matchesPrivacyLevel(NodePrivacyLevel.HIDDEN)) {
|
|
115
118
|
return NodePrivacyLevel.HIDDEN
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
// Overrules to enforce end-user protection
|
|
119
|
-
if (node.
|
|
120
|
-
|
|
121
|
-
if (
|
|
122
|
-
inputElement.type === 'password' ||
|
|
123
|
-
inputElement.type === 'email' ||
|
|
124
|
-
inputElement.type === 'tel'
|
|
125
|
-
) {
|
|
122
|
+
if (node.localName === 'input') {
|
|
123
|
+
if (/^(password|email|tel|hidden)$/.test(node.type)) {
|
|
126
124
|
return NodePrivacyLevel.MASK
|
|
127
125
|
}
|
|
128
|
-
|
|
129
|
-
return NodePrivacyLevel.MASK
|
|
130
|
-
}
|
|
131
|
-
var autocomplete = inputElement.getAttribute('autocomplete')
|
|
126
|
+
var autocomplete = node.getAttribute('autocomplete')
|
|
132
127
|
// Handle input[autocomplete=cc-number/cc-csc/cc-exp/cc-exp-month/cc-exp-year]
|
|
133
128
|
if (autocomplete && /(?:^|[\t\n\f\r ])cc-/i.test(autocomplete)) {
|
|
134
129
|
return NodePrivacyLevel.MASK
|
|
135
130
|
}
|
|
136
131
|
}
|
|
137
132
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
node.classList.contains(PRIVACY_CLASS_MASK)
|
|
142
|
-
) {
|
|
143
|
-
return NodePrivacyLevel.MASK
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
privAttr === PRIVACY_ATTR_VALUE_MASK_USER_INPUT ||
|
|
148
|
-
node.classList.contains(PRIVACY_CLASS_MASK_USER_INPUT)
|
|
149
|
-
) {
|
|
150
|
-
return NodePrivacyLevel.MASK_USER_INPUT
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (
|
|
154
|
-
privAttr === PRIVACY_ATTR_VALUE_ALLOW ||
|
|
155
|
-
node.classList.contains(PRIVACY_CLASS_ALLOW)
|
|
156
|
-
) {
|
|
157
|
-
return NodePrivacyLevel.ALLOW
|
|
133
|
+
for (var i = 0; i < overridablePrivacyLevels.length; i++) {
|
|
134
|
+
var level = overridablePrivacyLevels[i]
|
|
135
|
+
if (matchesPrivacyLevel(level)) return level
|
|
158
136
|
}
|
|
159
137
|
|
|
160
138
|
if (shouldIgnoreElement(node)) {
|
|
@@ -193,21 +171,17 @@ export function shouldMaskNode(configuration, node, privacyLevel) {
|
|
|
193
171
|
}
|
|
194
172
|
}
|
|
195
173
|
|
|
174
|
+
export function getElementTagName(node) {
|
|
175
|
+
// Named form controls can shadow the form's tagName property.
|
|
176
|
+
return typeof node.tagName === 'string' ? node.tagName : 'FORM'
|
|
177
|
+
}
|
|
178
|
+
|
|
196
179
|
function isFormElement(node) {
|
|
197
|
-
|
|
198
|
-
|
|
180
|
+
var tagName = getElementTagName(node).toUpperCase()
|
|
181
|
+
if (tagName === 'INPUT') {
|
|
182
|
+
return !/^(button|color|reset|submit)$/.test(node.type)
|
|
199
183
|
}
|
|
200
|
-
|
|
201
|
-
if (element.tagName === 'INPUT') {
|
|
202
|
-
switch (element.type) {
|
|
203
|
-
case 'button':
|
|
204
|
-
case 'color':
|
|
205
|
-
case 'reset':
|
|
206
|
-
case 'submit':
|
|
207
|
-
return false
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return !!FORM_PRIVATE_TAG_NAMES[element.tagName]
|
|
184
|
+
return !!FORM_PRIVATE_TAG_NAMES[tagName]
|
|
211
185
|
}
|
|
212
186
|
|
|
213
187
|
/**
|
|
@@ -224,64 +198,56 @@ export function getTextContent(
|
|
|
224
198
|
ignoreWhiteSpace,
|
|
225
199
|
parentNodePrivacyLevel
|
|
226
200
|
) {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
var
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return
|
|
201
|
+
var parent = textNode.parentElement
|
|
202
|
+
var tagName = parent && parent.localName
|
|
203
|
+
var text = textNode.textContent || ''
|
|
204
|
+
if (ignoreWhiteSpace && !text.trim()) return
|
|
205
|
+
if (tagName === 'script' || parentNodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
206
|
+
return CENSORED_STRING_MARK
|
|
234
207
|
}
|
|
235
|
-
|
|
236
|
-
var
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
textContent = CENSORED_STRING_MARK
|
|
244
|
-
} else if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
245
|
-
// Should never occur, but just in case, we set to CENSORED_MARK.
|
|
246
|
-
textContent = CENSORED_STRING_MARK
|
|
247
|
-
} else if (shouldMaskNode(configuration, textNode, nodePrivacyLevel)) {
|
|
248
|
-
if (
|
|
249
|
-
// Scrambling the child list breaks text nodes for DATALIST/SELECT/OPTGROUP
|
|
250
|
-
parentTagName === 'DATALIST' ||
|
|
251
|
-
parentTagName === 'SELECT' ||
|
|
252
|
-
parentTagName === 'OPTGROUP'
|
|
253
|
-
) {
|
|
254
|
-
if (!textContent.trim()) {
|
|
255
|
-
return
|
|
256
|
-
}
|
|
257
|
-
} else if (parentTagName === 'OPTION') {
|
|
258
|
-
// <Option> has low entropy in charset + text length, so use `CENSORED_STRING_MARK` when masked
|
|
259
|
-
textContent = CENSORED_STRING_MARK
|
|
260
|
-
} else {
|
|
261
|
-
textContent = censorText(textContent)
|
|
208
|
+
// Option and textarea text can itself be the control's value.
|
|
209
|
+
var control = parent && closestTextControl(parent)
|
|
210
|
+
if (control) {
|
|
211
|
+
var controlPrivacyLevel = control === parent
|
|
212
|
+
? parentNodePrivacyLevel
|
|
213
|
+
: getNodePrivacyLevel(control, configuration.defaultPrivacyLevel || parentNodePrivacyLevel)
|
|
214
|
+
if (shouldMaskNode(configuration, control, controlPrivacyLevel)) {
|
|
215
|
+
return control.localName === 'option' ? CENSORED_STRING_MARK : censorText(text)
|
|
262
216
|
}
|
|
263
217
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
// textContent = getCssRulesString(textNode.parentNode.sheet)
|
|
278
|
-
// }
|
|
279
|
-
// } catch (err) {}
|
|
280
|
-
// textContent = switchToAbsoluteUrl(textContent, getHref())
|
|
281
|
-
// }
|
|
282
|
-
return textContent
|
|
218
|
+
if (!shouldMaskNode(configuration, textNode, parentNodePrivacyLevel)) {
|
|
219
|
+
return text
|
|
220
|
+
}
|
|
221
|
+
switch (tagName) {
|
|
222
|
+
case 'datalist':
|
|
223
|
+
case 'select':
|
|
224
|
+
case 'optgroup':
|
|
225
|
+
return text.trim() ? text : undefined
|
|
226
|
+
case 'option':
|
|
227
|
+
return CENSORED_STRING_MARK
|
|
228
|
+
default:
|
|
229
|
+
return censorText(text)
|
|
230
|
+
}
|
|
283
231
|
}
|
|
284
232
|
|
|
233
|
+
function closestTextControl(element) {
|
|
234
|
+
if (Element.prototype.closest) {
|
|
235
|
+
return Element.prototype.closest.call(element, 'option,textarea')
|
|
236
|
+
}
|
|
237
|
+
while (element && element.localName !== 'option' && element.localName !== 'textarea') {
|
|
238
|
+
element = element.parentElement
|
|
239
|
+
}
|
|
240
|
+
return element
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
var ignoredMetaNames = [
|
|
244
|
+
'msapplication-tileimage', 'msapplication-tilecolor', 'application-name',
|
|
245
|
+
'keywords', 'description', 'pinterest', 'robots', 'googlebot', 'bingbot',
|
|
246
|
+
'author', 'generator', 'framework', 'publisher', 'progid',
|
|
247
|
+
'google-site-verification', 'yandex-verification', 'csrf-token',
|
|
248
|
+
'p:domain_verify', 'verify-v1', 'verification', 'shopify-checkout-api-token'
|
|
249
|
+
]
|
|
250
|
+
|
|
285
251
|
/**
|
|
286
252
|
* We don't need this logic on the recorder side.
|
|
287
253
|
* For security related meta's, customer can mask themmanually given they
|
|
@@ -307,44 +273,14 @@ export function shouldIgnoreElement(element) {
|
|
|
307
273
|
if (element.nodeName === 'META') {
|
|
308
274
|
var nameAttribute = getLowerCaseAttribute('name')
|
|
309
275
|
var relAttribute = getLowerCaseAttribute('rel')
|
|
310
|
-
var propertyAttribute = getLowerCaseAttribute('property')
|
|
311
276
|
return (
|
|
312
|
-
|
|
313
|
-
/^
|
|
314
|
-
|
|
277
|
+
ignoredMetaNames.indexOf(nameAttribute) !== -1 ||
|
|
278
|
+
/^(og|twitter):/.test(nameAttribute) ||
|
|
279
|
+
/^(og|twitter|fb|article|product):/.test(getLowerCaseAttribute('property')) ||
|
|
315
280
|
relAttribute === 'icon' ||
|
|
316
281
|
relAttribute === 'apple-touch-icon' ||
|
|
317
282
|
relAttribute === 'shortcut icon' ||
|
|
318
|
-
|
|
319
|
-
nameAttribute === 'keywords' ||
|
|
320
|
-
nameAttribute === 'description' ||
|
|
321
|
-
// Social
|
|
322
|
-
/^(og|twitter|fb):/.test(propertyAttribute) ||
|
|
323
|
-
/^(og|twitter):/.test(nameAttribute) ||
|
|
324
|
-
nameAttribute === 'pinterest' ||
|
|
325
|
-
// Robots
|
|
326
|
-
nameAttribute === 'robots' ||
|
|
327
|
-
nameAttribute === 'googlebot' ||
|
|
328
|
-
nameAttribute === 'bingbot' ||
|
|
329
|
-
// Http headers. Ex: X-UA-Compatible, Content-Type, Content-Language, cache-control,
|
|
330
|
-
// X-Translated-By
|
|
331
|
-
element.hasAttribute('http-equiv') ||
|
|
332
|
-
// Authorship
|
|
333
|
-
nameAttribute === 'author' ||
|
|
334
|
-
nameAttribute === 'generator' ||
|
|
335
|
-
nameAttribute === 'framework' ||
|
|
336
|
-
nameAttribute === 'publisher' ||
|
|
337
|
-
nameAttribute === 'progid' ||
|
|
338
|
-
/^article:/.test(propertyAttribute) ||
|
|
339
|
-
/^product:/.test(propertyAttribute) ||
|
|
340
|
-
// Verification
|
|
341
|
-
nameAttribute === 'google-site-verification' ||
|
|
342
|
-
nameAttribute === 'yandex-verification' ||
|
|
343
|
-
nameAttribute === 'csrf-token' ||
|
|
344
|
-
nameAttribute === 'p:domain_verify' ||
|
|
345
|
-
nameAttribute === 'verify-v1' ||
|
|
346
|
-
nameAttribute === 'verification' ||
|
|
347
|
-
nameAttribute === 'shopify-checkout-api-token'
|
|
283
|
+
element.hasAttribute('http-equiv')
|
|
348
284
|
)
|
|
349
285
|
}
|
|
350
286
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isCanvasPrivate } from './canvasContext'
|
|
2
2
|
import { noop, SDKMap } from '@cloudcare/browser-core'
|
|
3
3
|
import { createCanvasCommandObjectRefRegistry, isSerializedTypedArray } from './canvasCommandSerializeArgs'
|
|
4
4
|
import { createCanvasMutationRecord } from './canvasMutationRecord'
|
|
@@ -464,6 +464,7 @@ function isUnsupportedDrawImageSource(value) {
|
|
|
464
464
|
|
|
465
465
|
export function createCanvas2DCommandRecorder(options) {
|
|
466
466
|
options = options || {}
|
|
467
|
+
var configuration = options.configuration || {}
|
|
467
468
|
var emit = options.emit || noop
|
|
468
469
|
var now = __BUILD_ENV__REPLAY_DEBUG_ENABLED__
|
|
469
470
|
? options.now || Date.now
|
|
@@ -897,15 +898,21 @@ export function createCanvas2DCommandRecorder(options) {
|
|
|
897
898
|
scheduleFlush()
|
|
898
899
|
}
|
|
899
900
|
|
|
901
|
+
function discardPrivateCommands(context) {
|
|
902
|
+
if (!isCanvasPrivate(context.canvas, configuration)) return false
|
|
903
|
+
// Private draws change the live bitmap. Resume from pixels when allowed.
|
|
904
|
+
if (!persistentFallbackReasonByContext.has(context) || pendingCommandsByContext.has(context)) {
|
|
905
|
+
markPersistentSnapshotFallback(context, 'canvas_state_reset')
|
|
906
|
+
}
|
|
907
|
+
return true
|
|
908
|
+
}
|
|
909
|
+
|
|
900
910
|
function flushPendingContext(context, flushedAt) {
|
|
901
911
|
var batch = pendingCommandsByContext.get(context)
|
|
902
912
|
if (!batch) {
|
|
903
913
|
return
|
|
904
914
|
}
|
|
905
|
-
if (
|
|
906
|
-
markPersistentSnapshotFallback(context, 'canvas_state_reset')
|
|
907
|
-
return
|
|
908
|
-
}
|
|
915
|
+
if (discardPrivateCommands(context)) return
|
|
909
916
|
if (isSnapshotFallbackContext(context)) {
|
|
910
917
|
if (batch.fallbackDirty && !batch.fallbackSnapshotRequested) {
|
|
911
918
|
requestSnapshotFallback(
|
|
@@ -1018,14 +1025,7 @@ export function createCanvas2DCommandRecorder(options) {
|
|
|
1018
1025
|
if (!trackedContextSet.has(context)) {
|
|
1019
1026
|
return false
|
|
1020
1027
|
}
|
|
1021
|
-
if (
|
|
1022
|
-
// Drawing will still change the live context while its commands are private.
|
|
1023
|
-
// Resume with pixels once visible, as the previous command state is stale.
|
|
1024
|
-
if (!persistentFallbackReasonByContext.has(context)) {
|
|
1025
|
-
markPersistentSnapshotFallback(context, 'canvas_state_reset')
|
|
1026
|
-
}
|
|
1027
|
-
return false
|
|
1028
|
-
}
|
|
1028
|
+
if (discardPrivateCommands(context)) return false
|
|
1029
1029
|
if (captureGenerationByContext.get(context) !== captureGeneration) {
|
|
1030
1030
|
captureGenerationByContext.set(context, captureGeneration)
|
|
1031
1031
|
// reset() accompanies a new replay/full-snapshot canvas baseline, but
|
|
@@ -1133,10 +1133,7 @@ export function createCanvas2DCommandRecorder(options) {
|
|
|
1133
1133
|
return
|
|
1134
1134
|
}
|
|
1135
1135
|
// A hidden region can become visible while the same context stays alive.
|
|
1136
|
-
if (
|
|
1137
|
-
markPersistentSnapshotFallback(context, 'canvas_state_reset')
|
|
1138
|
-
return
|
|
1139
|
-
}
|
|
1136
|
+
if (discardPrivateCommands(context)) return
|
|
1140
1137
|
rejectedContextSet.add(context)
|
|
1141
1138
|
clearContext(context)
|
|
1142
1139
|
}
|
|
@@ -54,6 +54,10 @@ export function startCanvasCommandCapture(options) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
function getRecordingDecision(canvas) {
|
|
58
|
+
return getReplayCanvasRecordingDecision(configuration, canvas)
|
|
59
|
+
}
|
|
60
|
+
|
|
57
61
|
var emit = options.emit
|
|
58
62
|
var now = __BUILD_ENV__REPLAY_DEBUG_ENABLED__
|
|
59
63
|
? options.now || Date.now
|
|
@@ -737,10 +741,7 @@ export function startCanvasCommandCapture(options) {
|
|
|
737
741
|
return
|
|
738
742
|
}
|
|
739
743
|
|
|
740
|
-
var recordingDecision =
|
|
741
|
-
configuration,
|
|
742
|
-
canvas
|
|
743
|
-
)
|
|
744
|
+
var recordingDecision = getRecordingDecision(canvas)
|
|
744
745
|
if (recordingDecision === false) {
|
|
745
746
|
state.$rDirty = false
|
|
746
747
|
state.$rReason = undefined
|
|
@@ -904,10 +905,7 @@ export function startCanvasCommandCapture(options) {
|
|
|
904
905
|
}
|
|
905
906
|
var canvas = context.canvas
|
|
906
907
|
var state = getFallbackState(canvas)
|
|
907
|
-
var recordingDecision =
|
|
908
|
-
configuration,
|
|
909
|
-
canvas
|
|
910
|
-
)
|
|
908
|
+
var recordingDecision = getRecordingDecision(canvas)
|
|
911
909
|
if (recordingDecision === false) {
|
|
912
910
|
clearFallbackTimer(state)
|
|
913
911
|
state.$rDirty = false
|
|
@@ -1002,15 +1000,13 @@ export function startCanvasCommandCapture(options) {
|
|
|
1002
1000
|
var recorder =
|
|
1003
1001
|
(__BUILD_ENV__REPLAY_DEBUG_ENABLED__ && options.commandRecorder) ||
|
|
1004
1002
|
createCanvas2DCommandRecorder({
|
|
1003
|
+
configuration: configuration,
|
|
1005
1004
|
shouldRecordContext: function (context) {
|
|
1006
1005
|
return (
|
|
1007
1006
|
context &&
|
|
1008
1007
|
context.canvas &&
|
|
1009
1008
|
!isReplayInternalCanvas(context.canvas) &&
|
|
1010
|
-
|
|
1011
|
-
configuration,
|
|
1012
|
-
context.canvas
|
|
1013
|
-
) !== false
|
|
1009
|
+
getRecordingDecision(context.canvas) !== false
|
|
1014
1010
|
)
|
|
1015
1011
|
},
|
|
1016
1012
|
getCanvasId: function (context) {
|
|
@@ -1360,7 +1356,7 @@ export function startCanvasCommandCapture(options) {
|
|
|
1360
1356
|
foundUnseenCanvas = true
|
|
1361
1357
|
if (
|
|
1362
1358
|
stopped ||
|
|
1363
|
-
|
|
1359
|
+
getRecordingDecision(canvas) === false
|
|
1364
1360
|
) {
|
|
1365
1361
|
return
|
|
1366
1362
|
}
|
|
@@ -1474,10 +1470,7 @@ export function startCanvasCommandCapture(options) {
|
|
|
1474
1470
|
continue
|
|
1475
1471
|
}
|
|
1476
1472
|
canvasId = getSerializedNodeId(canvas)
|
|
1477
|
-
recordingDecision =
|
|
1478
|
-
configuration,
|
|
1479
|
-
canvas
|
|
1480
|
-
)
|
|
1473
|
+
recordingDecision = getRecordingDecision(canvas)
|
|
1481
1474
|
if (
|
|
1482
1475
|
(!canvasId && canvasId !== 0) ||
|
|
1483
1476
|
initialSnapshotCanvases.has(canvas) ||
|
|
@@ -1639,7 +1632,7 @@ export function startCanvasCommandCapture(options) {
|
|
|
1639
1632
|
!isReplayInternalCanvas(this)
|
|
1640
1633
|
if (
|
|
1641
1634
|
shouldRecordContext &&
|
|
1642
|
-
|
|
1635
|
+
getRecordingDecision(this) === false
|
|
1643
1636
|
) {
|
|
1644
1637
|
shouldRecordContext = false
|
|
1645
1638
|
}
|
|
@@ -1,29 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
NodePrivacyLevel,
|
|
4
|
-
PRIVACY_ATTR_NAME,
|
|
5
|
-
PRIVACY_ATTR_VALUE_HIDDEN,
|
|
6
|
-
PRIVACY_CLASS_HIDDEN
|
|
7
|
-
} from '../../../constants'
|
|
8
|
-
import { getNodePrivacyLevel } from './privacy'
|
|
1
|
+
import { PRIVACY_ATTR_NAME } from '../../../constants'
|
|
2
|
+
import { getNodePrivacyLevel, shouldMaskNode } from './privacy'
|
|
9
3
|
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
// Most drawing commands have no privacy-marked ancestor. Native matching
|
|
5
|
+
// skips unrelated ancestors on that hot path, including for an allowed canvas.
|
|
6
|
+
var privacySelector =
|
|
7
|
+
`[${PRIVACY_ATTR_NAME}],.gc-privacy-hidden,.gc-privacy-mask,.gc-privacy-mask-user-input,.gc-privacy-allow,input,base,script,link,meta`
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
// boundaries without allocating a privacy cache for every drawing command.
|
|
15
|
-
export function isCanvasHidden(canvas) {
|
|
9
|
+
export function isCanvasPrivate(canvas, configuration) {
|
|
16
10
|
try {
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
if (!element.closest || !element.getRootNode) {
|
|
20
|
-
return getNodePrivacyLevel(element) === NodePrivacyLevel.HIDDEN
|
|
21
|
-
}
|
|
22
|
-
if (element.closest(hiddenCanvasSelector)) return true
|
|
23
|
-
var root = element.getRootNode()
|
|
24
|
-
element = isNodeShadowRoot(root) ? root.host : null
|
|
25
|
-
}
|
|
26
|
-
return false
|
|
11
|
+
var level = getNodePrivacyLevel(canvas, configuration.defaultPrivacyLevel, undefined, privacySelector)
|
|
12
|
+
return shouldMaskNode(configuration, canvas, level)
|
|
27
13
|
} catch (_) {
|
|
28
14
|
return true
|
|
29
15
|
}
|
|
@@ -89,7 +75,7 @@ export function isWebGLReplayCanvas(canvas) {
|
|
|
89
75
|
|
|
90
76
|
export function getReplayCanvasRecordingDecision(configuration, canvas) {
|
|
91
77
|
try {
|
|
92
|
-
if (
|
|
78
|
+
if (isCanvasPrivate(canvas, configuration)) return false
|
|
93
79
|
return configuration.shouldRecordCanvas
|
|
94
80
|
? configuration.shouldRecordCanvas(canvas)
|
|
95
81
|
: true
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from './canvasFrameSignature'
|
|
15
15
|
import {
|
|
16
16
|
getReplayCanvasRecordingDecision,
|
|
17
|
-
|
|
17
|
+
isCanvasPrivate
|
|
18
18
|
} from './canvasContext'
|
|
19
19
|
|
|
20
20
|
var DEFAULT_ENCODED_DATA_URL_CACHE_MAX_CHARACTERS = 1024 * 1024
|
|
@@ -403,7 +403,7 @@ export function createCanvasObserver(options) {
|
|
|
403
403
|
) {
|
|
404
404
|
return createSnapshotFailureResult('resized_during_snapshot')
|
|
405
405
|
}
|
|
406
|
-
if (
|
|
406
|
+
if (isCanvasPrivate(canvas, configuration)) {
|
|
407
407
|
return createSnapshotFailureResult('rejected_by_should_record_canvas')
|
|
408
408
|
}
|
|
409
409
|
if (!isNodeActive(canvas)) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
getReplayCanvasRecordingDecision,
|
|
2
3
|
isWebGLReplayCanvas,
|
|
3
4
|
markReplayInternalCanvas
|
|
4
5
|
} from './canvasContext'
|
|
@@ -20,9 +21,11 @@ export function createSessionReplayWebGLRuntime(
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
try {
|
|
24
|
+
var webGLConfiguration = Object.create(configuration)
|
|
25
|
+
webGLConfiguration.shouldRecordCanvas = canvas => getReplayCanvasRecordingDecision(configuration, canvas)
|
|
23
26
|
return (
|
|
24
27
|
createRuntime(
|
|
25
|
-
|
|
28
|
+
webGLConfiguration,
|
|
26
29
|
baseEncodeBridge,
|
|
27
30
|
markReplayInternalCanvas,
|
|
28
31
|
report
|
|
@@ -46,11 +46,6 @@ var SCROLL_OBSERVER_THRESHOLD = 100
|
|
|
46
46
|
var VISUAL_VIEWPORT_OBSERVER_THRESHOLD = 200
|
|
47
47
|
var MAX_TRACKED_RADIO_GROUPS = 256
|
|
48
48
|
var MAX_INPUT_SETTER_PROTOTYPES = 36
|
|
49
|
-
var INPUT_TAG_NAMES = {
|
|
50
|
-
INPUT: true,
|
|
51
|
-
TEXTAREA: true,
|
|
52
|
-
SELECT: true
|
|
53
|
-
}
|
|
54
49
|
|
|
55
50
|
var recordIds = new WeakMap()
|
|
56
51
|
let nextId = 1
|
|
@@ -530,11 +525,11 @@ export function initInputObserver(
|
|
|
530
525
|
instrumentedInputPrototypes.add(prototype)
|
|
531
526
|
instrumentedInputPrototypeCount += 1
|
|
532
527
|
var properties =
|
|
533
|
-
node.
|
|
528
|
+
node.localName === 'textarea'
|
|
534
529
|
? ['value']
|
|
535
530
|
: [
|
|
536
531
|
'value',
|
|
537
|
-
node.
|
|
532
|
+
node.localName === 'input' ? 'checked' : 'selectedIndex'
|
|
538
533
|
]
|
|
539
534
|
properties.forEach(function (property) {
|
|
540
535
|
setterInstrumentationStoppers.push(
|
|
@@ -713,7 +708,8 @@ export function initInputObserver(
|
|
|
713
708
|
}
|
|
714
709
|
|
|
715
710
|
function isInputElement(target) {
|
|
716
|
-
|
|
711
|
+
var tagName = target && target.localName
|
|
712
|
+
return tagName === 'input' || tagName === 'textarea' || tagName === 'select'
|
|
717
713
|
}
|
|
718
714
|
|
|
719
715
|
export function initStyleSheetObserver(
|
|
@@ -88,6 +88,7 @@ var FULL_SNAPSHOT_SERIALIZATION_MAX_NODE_COUNT =
|
|
|
88
88
|
SERIALIZATION_MAX_NODE_COUNT * 4
|
|
89
89
|
var FULL_SNAPSHOT_MAX_RESTART_COUNT = 3
|
|
90
90
|
var FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS = 1000
|
|
91
|
+
var INITIAL_FULL_SNAPSHOT_THROTTLED_SLICE_DELAY_MS = 16
|
|
91
92
|
var FULL_SNAPSHOT_MAX_WALL_DURATION_MS = 30000
|
|
92
93
|
var FULL_SNAPSHOT_MUTATION_QUIET_DELAY_MS = 250
|
|
93
94
|
var REPLAY_MEMORY_BUDGET_BYTES = 48 * 1024 * 1024
|
|
@@ -3002,6 +3003,14 @@ export function record(options) {
|
|
|
3002
3003
|
return
|
|
3003
3004
|
}
|
|
3004
3005
|
delay = delay || 0
|
|
3006
|
+
if (
|
|
3007
|
+
pendingFullSnapshotIsInitial &&
|
|
3008
|
+
pendingFullSnapshotActiveDuration > FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS
|
|
3009
|
+
) {
|
|
3010
|
+
// Finishing the first baseline makes the whole view playable. Keep the
|
|
3011
|
+
// traversal, but leave time for input and paint between its 4 ms slices.
|
|
3012
|
+
delay = Math.max(delay, INITIAL_FULL_SNAPSHOT_THROTTLED_SLICE_DELAY_MS)
|
|
3013
|
+
}
|
|
3005
3014
|
pendingFullSnapshotTimeout = setTimeout(function () {
|
|
3006
3015
|
pendingFullSnapshotTimeout = undefined
|
|
3007
3016
|
if (failPendingFullSnapshotOnTimeout()) {
|
|
@@ -3333,15 +3342,21 @@ export function record(options) {
|
|
|
3333
3342
|
}
|
|
3334
3343
|
|
|
3335
3344
|
function failPendingFullSnapshotOnTimeout() {
|
|
3345
|
+
var elapsedMs = getPerformanceTime() - pendingFullSnapshotStartedAt
|
|
3336
3346
|
if (
|
|
3337
3347
|
pendingFullSnapshotTimestamp === undefined ||
|
|
3338
|
-
(
|
|
3339
|
-
FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS &&
|
|
3340
|
-
|
|
3341
|
-
FULL_SNAPSHOT_MAX_WALL_DURATION_MS)
|
|
3348
|
+
((pendingFullSnapshotIsInitial ||
|
|
3349
|
+
pendingFullSnapshotActiveDuration <= FULL_SNAPSHOT_MAX_TOTAL_DURATION_MS) &&
|
|
3350
|
+
elapsedMs <= FULL_SNAPSHOT_MAX_WALL_DURATION_MS)
|
|
3342
3351
|
) {
|
|
3343
3352
|
return false
|
|
3344
3353
|
}
|
|
3354
|
+
if (pendingFullSnapshotIsInitial) {
|
|
3355
|
+
addTelemetryDebug('initial_full_snapshot_serialization_timeout', {
|
|
3356
|
+
activeDurationMs: Math.round(pendingFullSnapshotActiveDuration),
|
|
3357
|
+
elapsedMs: Math.round(elapsedMs)
|
|
3358
|
+
})
|
|
3359
|
+
}
|
|
3345
3360
|
failOrAbandonFullSnapshot('full_snapshot_serialization_timeout')
|
|
3346
3361
|
return true
|
|
3347
3362
|
}
|