@cloudcare/browser-rum 3.2.49 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +89 -1
- package/README.zh.md +105 -0
- package/bundle/dataflux-rum.js +1 -1
- package/cjs/boot/buildEnv.js +1 -1
- package/cjs/boot/perStartRum.js +16 -0
- package/cjs/boot/perStartRum.js.map +1 -1
- package/cjs/boot/recorderApi.js +154 -1
- package/cjs/boot/recorderApi.js.map +1 -1
- package/cjs/boot/rum.js +17 -2
- package/cjs/boot/rum.js.map +1 -1
- package/cjs/boot/rumPublicApi.js +52 -3
- package/cjs/boot/rumPublicApi.js.map +1 -1
- package/cjs/boot/startRecording.js +69 -4
- package/cjs/boot/startRecording.js.map +1 -1
- package/cjs/domain/configuration.js +99 -1
- package/cjs/domain/configuration.js.map +1 -1
- package/cjs/domain/deflate/deflateWorker.js +1 -1
- package/cjs/domain/replay/record/canvasAutoSnapshot.js +15 -0
- package/cjs/domain/replay/record/canvasAutoSnapshot.js.map +1 -0
- package/cjs/domain/replay/record/canvasCommandCapture.js +480 -0
- package/cjs/domain/replay/record/canvasCommandCapture.js.map +1 -0
- package/cjs/domain/replay/record/canvasCommandObserver.js +274 -0
- package/cjs/domain/replay/record/canvasCommandObserver.js.map +1 -0
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js +94 -0
- package/cjs/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -0
- package/cjs/domain/replay/record/canvasContinuousScheduler.js +255 -0
- package/cjs/domain/replay/record/canvasContinuousScheduler.js.map +1 -0
- package/cjs/domain/replay/record/canvasEncodeBridge.js +247 -0
- package/cjs/domain/replay/record/canvasEncodeBridge.js.map +1 -0
- package/cjs/domain/replay/record/canvasEncodeWorker.js +154 -0
- package/cjs/domain/replay/record/canvasEncodeWorker.js.map +1 -0
- package/cjs/domain/replay/record/canvasFrameSignature.js +50 -0
- package/cjs/domain/replay/record/canvasFrameSignature.js.map +1 -0
- package/cjs/domain/replay/record/canvasMutationRecord.js +33 -0
- package/cjs/domain/replay/record/canvasMutationRecord.js.map +1 -0
- package/cjs/domain/replay/record/canvasObserver.js +190 -0
- package/cjs/domain/replay/record/canvasObserver.js.map +1 -0
- package/cjs/domain/replay/record/canvasReplayFixtures.js +105 -0
- package/cjs/domain/replay/record/canvasReplayFixtures.js.map +1 -0
- package/cjs/domain/replay/record/canvasSerializeArgs.js +110 -0
- package/cjs/domain/replay/record/canvasSerializeArgs.js.map +1 -0
- package/cjs/domain/replay/record/mutationBatch.js +7 -2
- package/cjs/domain/replay/record/mutationBatch.js.map +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +369 -55
- package/cjs/domain/replay/record/mutationObserver.js.map +1 -1
- package/cjs/domain/replay/record/observers.js +8 -3
- package/cjs/domain/replay/record/observers.js.map +1 -1
- package/cjs/domain/replay/record/record.js +478 -1
- package/cjs/domain/replay/record/record.js.map +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +60 -4
- package/cjs/domain/replay/record/serializationUtils.js.map +1 -1
- package/cjs/domain/replay/record/serialize.js +169 -46
- package/cjs/domain/replay/record/serialize.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segment.js +58 -1
- package/cjs/domain/replay/segmentCollection/segment.js.map +1 -1
- package/cjs/domain/replay/segmentCollection/segmentCollection.js +29 -3
- package/cjs/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/cjs/domain/requestCollection.js +1 -1
- package/cjs/domain/requestCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/clickChain.js +1 -1
- package/cjs/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -1
- package/cjs/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/cjs/domain/rumEventsCollection/error/trackReportError.js +2 -2
- package/cjs/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +43 -39
- package/cjs/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js +48 -8
- package/cjs/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js +237 -0
- package/cjs/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -0
- package/cjs/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/cjs/domain/rumSessionManager.js +2 -0
- package/cjs/domain/rumSessionManager.js.map +1 -1
- package/cjs/domain/tracing/skywalkingTracer.js +1 -1
- package/cjs/domain/tracing/skywalkingTracer.js.map +1 -1
- package/cjs/types/sessionReplayConstants.js +2 -2
- package/cjs/types/sessionReplayConstants.js.map +1 -1
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/perStartRum.js +16 -0
- package/esm/boot/perStartRum.js.map +1 -1
- package/esm/boot/recorderApi.js +154 -1
- package/esm/boot/recorderApi.js.map +1 -1
- package/esm/boot/rum.js +17 -2
- package/esm/boot/rum.js.map +1 -1
- package/esm/boot/rumPublicApi.js +52 -3
- package/esm/boot/rumPublicApi.js.map +1 -1
- package/esm/boot/startRecording.js +70 -5
- package/esm/boot/startRecording.js.map +1 -1
- package/esm/domain/configuration.js +100 -2
- package/esm/domain/configuration.js.map +1 -1
- package/esm/domain/deflate/deflateWorker.js +1 -1
- package/esm/domain/replay/record/canvasAutoSnapshot.js +9 -0
- package/esm/domain/replay/record/canvasAutoSnapshot.js.map +1 -0
- package/esm/domain/replay/record/canvasCommandCapture.js +474 -0
- package/esm/domain/replay/record/canvasCommandCapture.js.map +1 -0
- package/esm/domain/replay/record/canvasCommandObserver.js +268 -0
- package/esm/domain/replay/record/canvasCommandObserver.js.map +1 -0
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js +87 -0
- package/esm/domain/replay/record/canvasCommandSerializeArgs.js.map +1 -0
- package/esm/domain/replay/record/canvasContinuousScheduler.js +249 -0
- package/esm/domain/replay/record/canvasContinuousScheduler.js.map +1 -0
- package/esm/domain/replay/record/canvasEncodeBridge.js +240 -0
- package/esm/domain/replay/record/canvasEncodeBridge.js.map +1 -0
- package/esm/domain/replay/record/canvasEncodeWorker.js +146 -0
- package/esm/domain/replay/record/canvasEncodeWorker.js.map +1 -0
- package/esm/domain/replay/record/canvasFrameSignature.js +42 -0
- package/esm/domain/replay/record/canvasFrameSignature.js.map +1 -0
- package/esm/domain/replay/record/canvasMutationRecord.js +26 -0
- package/esm/domain/replay/record/canvasMutationRecord.js.map +1 -0
- package/esm/domain/replay/record/canvasObserver.js +184 -0
- package/esm/domain/replay/record/canvasObserver.js.map +1 -0
- package/esm/domain/replay/record/canvasReplayFixtures.js +96 -0
- package/esm/domain/replay/record/canvasReplayFixtures.js.map +1 -0
- package/esm/domain/replay/record/canvasSerializeArgs.js +101 -0
- package/esm/domain/replay/record/canvasSerializeArgs.js.map +1 -0
- package/esm/domain/replay/record/mutationBatch.js +7 -2
- package/esm/domain/replay/record/mutationBatch.js.map +1 -1
- package/esm/domain/replay/record/mutationObserver.js +369 -56
- package/esm/domain/replay/record/mutationObserver.js.map +1 -1
- package/esm/domain/replay/record/observers.js +8 -3
- package/esm/domain/replay/record/observers.js.map +1 -1
- package/esm/domain/replay/record/record.js +479 -2
- package/esm/domain/replay/record/record.js.map +1 -1
- package/esm/domain/replay/record/serializationUtils.js +58 -4
- package/esm/domain/replay/record/serializationUtils.js.map +1 -1
- package/esm/domain/replay/record/serialize.js +168 -47
- package/esm/domain/replay/record/serialize.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segment.js +59 -2
- package/esm/domain/replay/segmentCollection/segment.js.map +1 -1
- package/esm/domain/replay/segmentCollection/segmentCollection.js +30 -4
- package/esm/domain/replay/segmentCollection/segmentCollection.js.map +1 -1
- package/esm/domain/requestCollection.js +1 -1
- package/esm/domain/requestCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/clickChain.js +1 -1
- package/esm/domain/rumEventsCollection/actions/clickChain.js.map +1 -1
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -1
- package/esm/domain/rumEventsCollection/actions/interactionSelectorCache.js.map +1 -1
- package/esm/domain/rumEventsCollection/error/trackReportError.js +2 -2
- package/esm/domain/rumEventsCollection/error/trackReportError.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +43 -38
- package/esm/domain/rumEventsCollection/resource/matchRequestResourceEntry.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +50 -10
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js.map +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js +231 -0
- package/esm/domain/rumEventsCollection/resource/resourceTrackerManager.js.map +1 -0
- package/esm/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js.map +1 -1
- package/esm/domain/rumSessionManager.js +2 -0
- package/esm/domain/rumSessionManager.js.map +1 -1
- package/esm/domain/tracing/skywalkingTracer.js +1 -1
- package/esm/domain/tracing/skywalkingTracer.js.map +1 -1
- package/esm/types/sessionReplayConstants.js +2 -2
- package/esm/types/sessionReplayConstants.js.map +1 -1
- package/package.json +5 -5
- package/src/boot/perStartRum.js +16 -0
- package/src/boot/recorderApi.js +162 -1
- package/src/boot/rum.js +21 -2
- package/src/boot/rumPublicApi.js +59 -3
- package/src/boot/startRecording.js +94 -5
- package/src/domain/configuration.js +229 -1
- package/src/domain/replay/record/canvasAutoSnapshot.js +8 -0
- package/src/domain/replay/record/canvasCommandCapture.js +621 -0
- package/src/domain/replay/record/canvasCommandObserver.js +355 -0
- package/src/domain/replay/record/canvasCommandSerializeArgs.js +124 -0
- package/src/domain/replay/record/canvasContinuousScheduler.js +295 -0
- package/src/domain/replay/record/canvasEncodeBridge.js +299 -0
- package/src/domain/replay/record/canvasEncodeWorker.js +211 -0
- package/src/domain/replay/record/canvasFrameSignature.js +83 -0
- package/src/domain/replay/record/canvasMutationRecord.js +29 -0
- package/src/domain/replay/record/canvasObserver.js +279 -0
- package/src/domain/replay/record/canvasReplayFixtures.js +113 -0
- package/src/domain/replay/record/canvasSerializeArgs.js +129 -0
- package/src/domain/replay/record/mutationBatch.js +8 -2
- package/src/domain/replay/record/mutationObserver.js +449 -66
- package/src/domain/replay/record/observers.js +15 -3
- package/src/domain/replay/record/record.js +658 -2
- package/src/domain/replay/record/serializationUtils.js +75 -4
- package/src/domain/replay/record/serialize.js +217 -49
- package/src/domain/replay/segmentCollection/segment.js +65 -2
- package/src/domain/replay/segmentCollection/segmentCollection.js +46 -4
- package/src/domain/requestCollection.js +5 -1
- package/src/domain/rumEventsCollection/actions/clickChain.js +1 -1
- package/src/domain/rumEventsCollection/actions/interactionSelectorCache.js +2 -1
- package/src/domain/rumEventsCollection/error/trackReportError.js +3 -2
- package/src/domain/rumEventsCollection/resource/matchRequestResourceEntry.js +51 -46
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +69 -10
- package/src/domain/rumEventsCollection/resource/resourceTrackerManager.js +264 -0
- package/src/domain/rumEventsCollection/view/trackCumulativeLayoutShift.js +0 -1
- package/src/domain/rumSessionManager.js +2 -0
- package/src/domain/tracing/skywalkingTracer.js +1 -1
- package/src/types/sessionReplayConstants.js +2 -2
- package/types/index.d.ts +133 -1
|
@@ -8,6 +8,25 @@ import { CENSORED_STRING_MARK } from '../../../constants'
|
|
|
8
8
|
import { shouldMaskNode } from './privacy'
|
|
9
9
|
|
|
10
10
|
var serializedNodeIds = new WeakMap()
|
|
11
|
+
var serializedCanvasNodes = new Set()
|
|
12
|
+
var anchorElementByDocument = new WeakMap()
|
|
13
|
+
var hrefByDocument = new WeakMap()
|
|
14
|
+
|
|
15
|
+
export function getHiddenElementPlaceholderSize(element) {
|
|
16
|
+
var width =
|
|
17
|
+
element.getAttribute('width') ||
|
|
18
|
+
(element.style && element.style.width) ||
|
|
19
|
+
undefined
|
|
20
|
+
var height =
|
|
21
|
+
element.getAttribute('height') ||
|
|
22
|
+
(element.style && element.style.height) ||
|
|
23
|
+
undefined
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
width: width,
|
|
27
|
+
height: height
|
|
28
|
+
}
|
|
29
|
+
}
|
|
11
30
|
|
|
12
31
|
export function hasSerializedNode(node) {
|
|
13
32
|
return serializedNodeIds.has(node)
|
|
@@ -30,6 +49,40 @@ export function getSerializedNodeId(node) {
|
|
|
30
49
|
|
|
31
50
|
export function setSerializedNodeId(node, serializeNodeId) {
|
|
32
51
|
serializedNodeIds.set(node, serializeNodeId)
|
|
52
|
+
if (node instanceof HTMLCanvasElement) {
|
|
53
|
+
serializedCanvasNodes.add(node)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isSerializedCanvasConnectedToDocument(node) {
|
|
58
|
+
if (document.documentElement && document.documentElement.contains) {
|
|
59
|
+
return document.documentElement.contains(node)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
var current = node
|
|
63
|
+
|
|
64
|
+
while (current) {
|
|
65
|
+
if (current === document) {
|
|
66
|
+
return true
|
|
67
|
+
}
|
|
68
|
+
current = getParentNode(current)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return false
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function getSerializedCanvasNodes() {
|
|
75
|
+
var connectedSerializedCanvasNodes = []
|
|
76
|
+
|
|
77
|
+
serializedCanvasNodes.forEach(function (node) {
|
|
78
|
+
if (hasSerializedNode(node) && isSerializedCanvasConnectedToDocument(node)) {
|
|
79
|
+
connectedSerializedCanvasNodes.push(node)
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
serializedCanvasNodes.delete(node)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
return connectedSerializedCanvasNodes
|
|
33
86
|
}
|
|
34
87
|
|
|
35
88
|
/**
|
|
@@ -112,9 +165,7 @@ export function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
|
112
165
|
return cssText
|
|
113
166
|
}
|
|
114
167
|
export function getHref() {
|
|
115
|
-
|
|
116
|
-
a.href = ''
|
|
117
|
-
return a.href
|
|
168
|
+
return getDocumentHref(document)
|
|
118
169
|
}
|
|
119
170
|
export function switchToAbsoluteUrl(cssText, cssHref) {
|
|
120
171
|
return cssText.replace(
|
|
@@ -227,11 +278,31 @@ export function absoluteToDoc(doc, attributeValue) {
|
|
|
227
278
|
if (!attributeValue || attributeValue.trim() === '') {
|
|
228
279
|
return attributeValue
|
|
229
280
|
}
|
|
230
|
-
var a = doc
|
|
281
|
+
var a = getAnchorElement(doc)
|
|
231
282
|
a.href = attributeValue
|
|
232
283
|
return a.href
|
|
233
284
|
}
|
|
234
285
|
|
|
286
|
+
function getAnchorElement(doc) {
|
|
287
|
+
var anchor = anchorElementByDocument.get(doc)
|
|
288
|
+
if (!anchor) {
|
|
289
|
+
anchor = doc.createElement('a')
|
|
290
|
+
anchorElementByDocument.set(doc, anchor)
|
|
291
|
+
}
|
|
292
|
+
return anchor
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
function getDocumentHref(doc) {
|
|
296
|
+
var href = hrefByDocument.get(doc)
|
|
297
|
+
if (!href) {
|
|
298
|
+
var anchor = getAnchorElement(doc)
|
|
299
|
+
anchor.href = ''
|
|
300
|
+
href = anchor.href
|
|
301
|
+
hrefByDocument.set(doc, href)
|
|
302
|
+
}
|
|
303
|
+
return href
|
|
304
|
+
}
|
|
305
|
+
|
|
235
306
|
var SRCSET_NOT_SPACES = /^[^ \t\n\r\u000c]+/
|
|
236
307
|
var SRCSET_COMMAS_OR_SPACES = /^[, \t\n\r\u000c]+/
|
|
237
308
|
export function getAbsoluteSrcsetString(doc, attributeValue) {
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
getSerializedNodeId,
|
|
26
26
|
setSerializedNodeId,
|
|
27
27
|
getElementInputValue,
|
|
28
|
+
getHiddenElementPlaceholderSize,
|
|
28
29
|
switchToAbsoluteUrl,
|
|
29
30
|
serializeStyleSheets,
|
|
30
31
|
absoluteToDoc,
|
|
@@ -61,44 +62,147 @@ export function serializeDocument(
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
export function serializeNodeWithId(node, options) {
|
|
64
|
-
var
|
|
65
|
-
if (!
|
|
65
|
+
var serializedNodeDescription = describeSerializedNode(node, options)
|
|
66
|
+
if (!serializedNodeDescription) {
|
|
66
67
|
return null
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (
|
|
75
|
-
|
|
70
|
+
var serializedNodeWithId = assignSerializedNodeId(
|
|
71
|
+
node,
|
|
72
|
+
serializedNodeDescription.serializedNode,
|
|
73
|
+
options
|
|
74
|
+
)
|
|
75
|
+
if (serializedNodeDescription.shouldSerializeChildren) {
|
|
76
|
+
serializedNodeWithId.childNodes = serializeChildNodes(
|
|
77
|
+
node,
|
|
78
|
+
serializedNodeDescription.childNodesOptions
|
|
79
|
+
)
|
|
76
80
|
}
|
|
77
81
|
return serializedNodeWithId
|
|
78
82
|
}
|
|
79
83
|
|
|
80
|
-
function
|
|
84
|
+
export function serializeNodeWithIdForMutation(node, options) {
|
|
85
|
+
var mutationSerializerTask = createMutationSerializerTask(node, options)
|
|
86
|
+
if (!mutationSerializerTask) {
|
|
87
|
+
return null
|
|
88
|
+
}
|
|
89
|
+
mutationSerializerTask.advance(Infinity)
|
|
90
|
+
return mutationSerializerTask.serializedNode
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function createMutationSerializerTask(node, options) {
|
|
94
|
+
var rootNodeDescription = describeSerializedNode(node, options)
|
|
95
|
+
if (!rootNodeDescription) {
|
|
96
|
+
return null
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var serializedRootNode = assignSerializedNodeId(
|
|
100
|
+
node,
|
|
101
|
+
rootNodeDescription.serializedNode,
|
|
102
|
+
options
|
|
103
|
+
)
|
|
104
|
+
var stack = []
|
|
105
|
+
|
|
106
|
+
if (rootNodeDescription.shouldSerializeChildren) {
|
|
107
|
+
pushChildNodes(node, serializedRootNode, rootNodeDescription.childNodesOptions)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
serializedNode: serializedRootNode,
|
|
112
|
+
isComplete: stack.length === 0,
|
|
113
|
+
advance: function (deadline) {
|
|
114
|
+
while (stack.length && getCurrentTime() < deadline) {
|
|
115
|
+
var current = stack.pop()
|
|
116
|
+
var childNodeDescription = describeSerializedNode(
|
|
117
|
+
current.node,
|
|
118
|
+
current.options
|
|
119
|
+
)
|
|
120
|
+
if (!childNodeDescription) {
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var serializedChildNode = assignSerializedNodeId(
|
|
125
|
+
current.node,
|
|
126
|
+
childNodeDescription.serializedNode,
|
|
127
|
+
current.options
|
|
128
|
+
)
|
|
129
|
+
current.parentSerializedNode.childNodes.push(serializedChildNode)
|
|
130
|
+
|
|
131
|
+
if (childNodeDescription.shouldSerializeChildren) {
|
|
132
|
+
pushChildNodes(
|
|
133
|
+
current.node,
|
|
134
|
+
serializedChildNode,
|
|
135
|
+
childNodeDescription.childNodesOptions
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
this.isComplete = stack.length === 0
|
|
140
|
+
return this.isComplete
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function pushChildNodes(parentNode, parentSerializedNode, childNodesOptions) {
|
|
145
|
+
var childNodes = []
|
|
146
|
+
forEachChildNodes(parentNode, function (childNode) {
|
|
147
|
+
childNodes.push(childNode)
|
|
148
|
+
})
|
|
149
|
+
for (var i = childNodes.length - 1; i >= 0; i--) {
|
|
150
|
+
stack.push({
|
|
151
|
+
node: childNodes[i],
|
|
152
|
+
options: childNodesOptions,
|
|
153
|
+
parentSerializedNode: parentSerializedNode
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function describeSerializedNode(node, options) {
|
|
81
160
|
switch (node.nodeType) {
|
|
82
161
|
case node.DOCUMENT_NODE:
|
|
83
|
-
return
|
|
162
|
+
return describeDocumentNode(node, options)
|
|
84
163
|
case node.DOCUMENT_FRAGMENT_NODE:
|
|
85
|
-
return
|
|
164
|
+
return describeDocumentFragmentNode(node, options)
|
|
86
165
|
case node.DOCUMENT_TYPE_NODE:
|
|
87
|
-
return
|
|
166
|
+
return {
|
|
167
|
+
serializedNode: serializeDocumentTypeNode(node),
|
|
168
|
+
shouldSerializeChildren: false
|
|
169
|
+
}
|
|
88
170
|
case node.ELEMENT_NODE:
|
|
89
|
-
return
|
|
90
|
-
case node.TEXT_NODE:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
171
|
+
return describeElementNode(node, options)
|
|
172
|
+
case node.TEXT_NODE: {
|
|
173
|
+
var serializedTextNode = serializeTextNode(node, options)
|
|
174
|
+
return serializedTextNode
|
|
175
|
+
? {
|
|
176
|
+
serializedNode: serializedTextNode,
|
|
177
|
+
shouldSerializeChildren: false
|
|
178
|
+
}
|
|
179
|
+
: null
|
|
180
|
+
}
|
|
181
|
+
case node.CDATA_SECTION_NODE: {
|
|
182
|
+
var serializedCDataNode = serializeCDataNode()
|
|
183
|
+
return serializedCDataNode
|
|
184
|
+
? {
|
|
185
|
+
serializedNode: serializedCDataNode,
|
|
186
|
+
shouldSerializeChildren: false
|
|
187
|
+
}
|
|
188
|
+
: null
|
|
189
|
+
}
|
|
94
190
|
}
|
|
95
191
|
}
|
|
96
192
|
|
|
97
193
|
export function serializeDocumentNode(document, options) {
|
|
194
|
+
return describeDocumentNode(document, options).serializedNode
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function describeDocumentNode(document, options) {
|
|
98
198
|
return {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
199
|
+
serializedNode: {
|
|
200
|
+
type: NodeType.Document,
|
|
201
|
+
childNodes: [],
|
|
202
|
+
adoptedStyleSheets: serializeStyleSheets(document.adoptedStyleSheets)
|
|
203
|
+
},
|
|
204
|
+
shouldSerializeChildren: true,
|
|
205
|
+
childNodesOptions: options
|
|
102
206
|
}
|
|
103
207
|
}
|
|
104
208
|
|
|
@@ -112,17 +216,25 @@ function serializeDocumentTypeNode(documentType) {
|
|
|
112
216
|
}
|
|
113
217
|
|
|
114
218
|
function serializeDocumentFragmentNode(element, options) {
|
|
219
|
+
return describeDocumentFragmentNode(element, options).serializedNode
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function describeDocumentFragmentNode(element, options) {
|
|
115
223
|
var isShadowRoot = isNodeShadowRoot(element)
|
|
116
224
|
if (isShadowRoot) {
|
|
117
225
|
options.serializationContext.shadowRootsController.addShadowRoot(element)
|
|
118
226
|
}
|
|
119
227
|
return {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
228
|
+
serializedNode: {
|
|
229
|
+
type: NodeType.DocumentFragment,
|
|
230
|
+
childNodes: [],
|
|
231
|
+
isShadowRoot: isShadowRoot,
|
|
232
|
+
adoptedStyleSheets: isShadowRoot
|
|
233
|
+
? serializeStyleSheets(element.adoptedStyleSheets)
|
|
234
|
+
: undefined
|
|
235
|
+
},
|
|
236
|
+
shouldSerializeChildren: true,
|
|
237
|
+
childNodesOptions: options
|
|
126
238
|
}
|
|
127
239
|
}
|
|
128
240
|
|
|
@@ -144,6 +256,11 @@ function serializeDocumentFragmentNode(element, options) {
|
|
|
144
256
|
* - fullscreen mode
|
|
145
257
|
*/
|
|
146
258
|
export function serializeElementNode(element, options) {
|
|
259
|
+
var serializedNodeDescription = describeElementNode(element, options)
|
|
260
|
+
return serializedNodeDescription && serializedNodeDescription.serializedNode
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function describeElementNode(element, options) {
|
|
147
264
|
var tagName = getValidTagName(element.tagName)
|
|
148
265
|
var isSVG = isSVGElement(element) || undefined
|
|
149
266
|
|
|
@@ -155,25 +272,31 @@ export function serializeElementNode(element, options) {
|
|
|
155
272
|
)
|
|
156
273
|
|
|
157
274
|
if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
|
|
158
|
-
var
|
|
159
|
-
var
|
|
160
|
-
|
|
275
|
+
var placeholderSize = getHiddenElementPlaceholderSize(element)
|
|
276
|
+
var attributes = {
|
|
277
|
+
[PRIVACY_ATTR_NAME]: PRIVACY_ATTR_VALUE_HIDDEN
|
|
278
|
+
}
|
|
279
|
+
if (placeholderSize.width) {
|
|
280
|
+
attributes.rr_width = placeholderSize.width
|
|
281
|
+
}
|
|
282
|
+
if (placeholderSize.height) {
|
|
283
|
+
attributes.rr_height = placeholderSize.height
|
|
284
|
+
}
|
|
161
285
|
return {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
286
|
+
serializedNode: {
|
|
287
|
+
type: NodeType.Element,
|
|
288
|
+
tagName: tagName,
|
|
289
|
+
attributes: attributes,
|
|
290
|
+
childNodes: [],
|
|
291
|
+
isSVG: isSVG
|
|
168
292
|
},
|
|
169
|
-
|
|
170
|
-
isSVG: isSVG
|
|
293
|
+
shouldSerializeChildren: false
|
|
171
294
|
}
|
|
172
295
|
}
|
|
173
296
|
|
|
174
297
|
// Ignore Elements like Script and some Link, Metas
|
|
175
298
|
if (nodePrivacyLevel === NodePrivacyLevel.IGNORE) {
|
|
176
|
-
return
|
|
299
|
+
return null
|
|
177
300
|
}
|
|
178
301
|
|
|
179
302
|
var attributes = getAttributesForPrivacyLevel(
|
|
@@ -182,7 +305,8 @@ export function serializeElementNode(element, options) {
|
|
|
182
305
|
options
|
|
183
306
|
)
|
|
184
307
|
|
|
185
|
-
var
|
|
308
|
+
var shouldSerializeChildren = false
|
|
309
|
+
var childNodesSerializationOptions
|
|
186
310
|
if (hasChildNodes(element) && tagName !== 'style') {
|
|
187
311
|
// OBJECT POOLING OPTIMIZATION:
|
|
188
312
|
// We should not create a new object systematically as it could impact performances. Try to reuse
|
|
@@ -199,7 +323,7 @@ export function serializeElementNode(element, options) {
|
|
|
199
323
|
ignoreWhiteSpace: tagName === 'head'
|
|
200
324
|
})
|
|
201
325
|
}
|
|
202
|
-
|
|
326
|
+
shouldSerializeChildren = true
|
|
203
327
|
}
|
|
204
328
|
|
|
205
329
|
// if (isNodeShadowHost(element)) {
|
|
@@ -210,11 +334,15 @@ export function serializeElementNode(element, options) {
|
|
|
210
334
|
// }
|
|
211
335
|
|
|
212
336
|
return {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
337
|
+
serializedNode: {
|
|
338
|
+
type: NodeType.Element,
|
|
339
|
+
tagName: tagName,
|
|
340
|
+
attributes: attributes,
|
|
341
|
+
childNodes: [],
|
|
342
|
+
isSVG: isSVG
|
|
343
|
+
},
|
|
344
|
+
shouldSerializeChildren: shouldSerializeChildren,
|
|
345
|
+
childNodesOptions: childNodesSerializationOptions
|
|
218
346
|
}
|
|
219
347
|
}
|
|
220
348
|
|
|
@@ -262,6 +390,24 @@ export function serializeChildNodes(node, options) {
|
|
|
262
390
|
return result
|
|
263
391
|
}
|
|
264
392
|
|
|
393
|
+
function assignSerializedNodeId(node, serializedNode, options) {
|
|
394
|
+
var id = getSerializedNodeId(node) || generateNextId()
|
|
395
|
+
var serializedNodeWithId = serializedNode
|
|
396
|
+
serializedNodeWithId.id = id
|
|
397
|
+
setSerializedNodeId(node, id)
|
|
398
|
+
if (options.serializedNodeIds) {
|
|
399
|
+
options.serializedNodeIds.add(id)
|
|
400
|
+
}
|
|
401
|
+
return serializedNodeWithId
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
function getCurrentTime() {
|
|
405
|
+
if (typeof performance !== 'undefined' && performance.now) {
|
|
406
|
+
return performance.now()
|
|
407
|
+
}
|
|
408
|
+
return Date.now()
|
|
409
|
+
}
|
|
410
|
+
|
|
265
411
|
export function serializeAttribute(
|
|
266
412
|
element,
|
|
267
413
|
nodePrivacyLevel,
|
|
@@ -431,9 +577,11 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
431
577
|
|
|
432
578
|
// remote css
|
|
433
579
|
if (tagName === 'link') {
|
|
434
|
-
var stylesheet =
|
|
435
|
-
|
|
436
|
-
|
|
580
|
+
var stylesheet = getStyleSheetByHref(
|
|
581
|
+
options.serializationContext,
|
|
582
|
+
doc,
|
|
583
|
+
element.href
|
|
584
|
+
)
|
|
437
585
|
var cssText = getCssRulesString(stylesheet)
|
|
438
586
|
if (cssText && stylesheet) {
|
|
439
587
|
safeAttrs._cssText = cssText
|
|
@@ -512,3 +660,23 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
512
660
|
|
|
513
661
|
return safeAttrs
|
|
514
662
|
}
|
|
663
|
+
|
|
664
|
+
function getStyleSheetByHref(serializationContext, doc, href) {
|
|
665
|
+
if (!href) {
|
|
666
|
+
return undefined
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
var styleSheetByHref = serializationContext.styleSheetByHref
|
|
670
|
+
if (!styleSheetByHref) {
|
|
671
|
+
styleSheetByHref = new Map()
|
|
672
|
+
for (var i = 0; i < doc.styleSheets.length; i += 1) {
|
|
673
|
+
var styleSheet = doc.styleSheets[i]
|
|
674
|
+
if (styleSheet.href) {
|
|
675
|
+
styleSheetByHref.set(styleSheet.href, styleSheet)
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
serializationContext.styleSheetByHref = styleSheetByHref
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return styleSheetByHref.get(href)
|
|
682
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assign } from '@cloudcare/browser-core'
|
|
2
|
-
import { RecordType } from '../../../types'
|
|
2
|
+
import { IncrementalSource, RecordType } from '../../../types'
|
|
3
3
|
import * as replayStats from '../replayStats'
|
|
4
4
|
|
|
5
5
|
export function createSegment(options) {
|
|
@@ -8,6 +8,7 @@ export function createSegment(options) {
|
|
|
8
8
|
const encoder = options.encoder
|
|
9
9
|
let encodedBytesCount = 0
|
|
10
10
|
const viewId = context.view.id
|
|
11
|
+
const recordCountsByType = {}
|
|
11
12
|
|
|
12
13
|
const metadata = assign(
|
|
13
14
|
{
|
|
@@ -26,6 +27,7 @@ export function createSegment(options) {
|
|
|
26
27
|
metadata.start = Math.min(metadata.start, record.timestamp)
|
|
27
28
|
metadata.end = Math.max(metadata.end, record.timestamp)
|
|
28
29
|
metadata.records_count += 1
|
|
30
|
+
incrementRecordCount(recordCountsByType, getRecordDebugType(record))
|
|
29
31
|
if (!metadata.has_full_snapshot) {
|
|
30
32
|
metadata.has_full_snapshot = record.type === RecordType.FullSnapshot
|
|
31
33
|
}
|
|
@@ -46,7 +48,7 @@ export function createSegment(options) {
|
|
|
46
48
|
encoder.write('],' + JSON.stringify(metadata).slice(1) + '\n')
|
|
47
49
|
encoder.finish(function (encoderResult) {
|
|
48
50
|
replayStats.addWroteData(metadata.view.id, encoderResult.rawBytesCount)
|
|
49
|
-
callback(metadata, encoderResult)
|
|
51
|
+
callback(metadata, encoderResult, assign({}, recordCountsByType))
|
|
50
52
|
})
|
|
51
53
|
}
|
|
52
54
|
return {
|
|
@@ -54,3 +56,64 @@ export function createSegment(options) {
|
|
|
54
56
|
flush: flush
|
|
55
57
|
}
|
|
56
58
|
}
|
|
59
|
+
|
|
60
|
+
function incrementRecordCount(recordCountsByType, recordDebugType) {
|
|
61
|
+
recordCountsByType[recordDebugType] =
|
|
62
|
+
(recordCountsByType[recordDebugType] || 0) + 1
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getRecordDebugType(record) {
|
|
66
|
+
if (!record) {
|
|
67
|
+
return 'other'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
switch (record.type) {
|
|
71
|
+
case RecordType.FullSnapshot:
|
|
72
|
+
return 'full_snapshot'
|
|
73
|
+
case RecordType.Meta:
|
|
74
|
+
return 'meta'
|
|
75
|
+
case RecordType.Focus:
|
|
76
|
+
return 'focus'
|
|
77
|
+
case RecordType.ViewEnd:
|
|
78
|
+
return 'view_end'
|
|
79
|
+
case RecordType.VisualViewport:
|
|
80
|
+
return 'visual_viewport'
|
|
81
|
+
case RecordType.FrustrationRecord:
|
|
82
|
+
return 'frustration_record'
|
|
83
|
+
case RecordType.IncrementalSnapshot:
|
|
84
|
+
return getIncrementalRecordDebugType(record)
|
|
85
|
+
default:
|
|
86
|
+
return 'other'
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getIncrementalRecordDebugType(record) {
|
|
91
|
+
if (!record.data) {
|
|
92
|
+
return 'incremental_unknown'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
switch (record.data.source) {
|
|
96
|
+
case IncrementalSource.Mutation:
|
|
97
|
+
return 'mutation'
|
|
98
|
+
case IncrementalSource.MouseMove:
|
|
99
|
+
return 'mouse_move'
|
|
100
|
+
case IncrementalSource.MouseInteraction:
|
|
101
|
+
return 'mouse_interaction'
|
|
102
|
+
case IncrementalSource.Scroll:
|
|
103
|
+
return 'scroll'
|
|
104
|
+
case IncrementalSource.ViewportResize:
|
|
105
|
+
return 'viewport_resize'
|
|
106
|
+
case IncrementalSource.Input:
|
|
107
|
+
return 'input'
|
|
108
|
+
case IncrementalSource.TouchMove:
|
|
109
|
+
return 'touch_move'
|
|
110
|
+
case IncrementalSource.MediaInteraction:
|
|
111
|
+
return 'media_interaction'
|
|
112
|
+
case IncrementalSource.StyleSheetRule:
|
|
113
|
+
return 'style_sheet_rule'
|
|
114
|
+
case IncrementalSource.CanvasMutation:
|
|
115
|
+
return 'canvas_mutation'
|
|
116
|
+
default:
|
|
117
|
+
return 'incremental_unknown'
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -2,9 +2,11 @@ import {
|
|
|
2
2
|
ONE_SECOND,
|
|
3
3
|
LifeCycleEventType,
|
|
4
4
|
isPageExitReason,
|
|
5
|
+
assign,
|
|
5
6
|
setTimeout,
|
|
6
7
|
clearTimeout
|
|
7
8
|
} from '@cloudcare/browser-core'
|
|
9
|
+
import { IncrementalSource, RecordType } from '../../../types'
|
|
8
10
|
import { buildReplayPayload } from './buildReplayPayload'
|
|
9
11
|
import { createSegment } from './segment'
|
|
10
12
|
|
|
@@ -47,7 +49,8 @@ export function startSegmentCollection(
|
|
|
47
49
|
viewContexts,
|
|
48
50
|
httpRequest,
|
|
49
51
|
encoder,
|
|
50
|
-
isLocked = false
|
|
52
|
+
isLocked = false,
|
|
53
|
+
additionalOptions
|
|
51
54
|
) {
|
|
52
55
|
return doStartSegmentCollection(
|
|
53
56
|
lifeCycle,
|
|
@@ -56,7 +59,14 @@ export function startSegmentCollection(
|
|
|
56
59
|
},
|
|
57
60
|
httpRequest,
|
|
58
61
|
encoder,
|
|
59
|
-
isLocked
|
|
62
|
+
isLocked,
|
|
63
|
+
assign(
|
|
64
|
+
{
|
|
65
|
+
flushCanvasImmediately: configuration.replayCanvasFlushImmediately,
|
|
66
|
+
onSegmentFlushed: undefined
|
|
67
|
+
},
|
|
68
|
+
additionalOptions
|
|
69
|
+
)
|
|
60
70
|
)
|
|
61
71
|
}
|
|
62
72
|
|
|
@@ -71,8 +81,12 @@ export function doStartSegmentCollection(
|
|
|
71
81
|
getSegmentContext,
|
|
72
82
|
httpRequest,
|
|
73
83
|
encoder,
|
|
74
|
-
isLocked
|
|
84
|
+
isLocked,
|
|
85
|
+
options
|
|
75
86
|
) {
|
|
87
|
+
if (options === undefined) {
|
|
88
|
+
options = {}
|
|
89
|
+
}
|
|
76
90
|
var state = {
|
|
77
91
|
status: SegmentCollectionStatus.WaitingForInitialRecord,
|
|
78
92
|
nextSegmentCreationReason: 'init',
|
|
@@ -105,7 +119,19 @@ export function doStartSegmentCollection(
|
|
|
105
119
|
if (isLocked) {
|
|
106
120
|
return
|
|
107
121
|
}
|
|
108
|
-
state.segment.flush(function (metadata, encoderResult) {
|
|
122
|
+
state.segment.flush(function (metadata, encoderResult, recordCountsByType) {
|
|
123
|
+
if (options.onSegmentFlushed) {
|
|
124
|
+
options.onSegmentFlushed({
|
|
125
|
+
creationReason: metadata.creation_reason,
|
|
126
|
+
flushReason: flushReason,
|
|
127
|
+
recordsCount: metadata.records_count,
|
|
128
|
+
recordCountsByType: recordCountsByType,
|
|
129
|
+
start: metadata.start,
|
|
130
|
+
end: metadata.end,
|
|
131
|
+
indexInView: metadata.index_in_view,
|
|
132
|
+
rawBytesCount: encoderResult.rawBytesCount
|
|
133
|
+
})
|
|
134
|
+
}
|
|
109
135
|
var payload = buildReplayPayload(
|
|
110
136
|
encoderResult.output,
|
|
111
137
|
metadata,
|
|
@@ -167,6 +193,13 @@ export function doStartSegmentCollection(
|
|
|
167
193
|
flushSegment('segment_bytes_limit')
|
|
168
194
|
}
|
|
169
195
|
})
|
|
196
|
+
if (
|
|
197
|
+
options.flushCanvasImmediately &&
|
|
198
|
+
isCanvasMutationRecord(record) &&
|
|
199
|
+
state.status === SegmentCollectionStatus.SegmentPending
|
|
200
|
+
) {
|
|
201
|
+
flushSegment('canvas_snapshot')
|
|
202
|
+
}
|
|
170
203
|
},
|
|
171
204
|
|
|
172
205
|
unlockSegment: function () {
|
|
@@ -186,6 +219,15 @@ export function doStartSegmentCollection(
|
|
|
186
219
|
}
|
|
187
220
|
}
|
|
188
221
|
|
|
222
|
+
function isCanvasMutationRecord(record) {
|
|
223
|
+
return (
|
|
224
|
+
record &&
|
|
225
|
+
record.type === RecordType.IncrementalSnapshot &&
|
|
226
|
+
record.data &&
|
|
227
|
+
record.data.source === IncrementalSource.CanvasMutation
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
|
|
189
231
|
export function computeSegmentContext(
|
|
190
232
|
configuration,
|
|
191
233
|
sessionManager,
|
|
@@ -99,7 +99,11 @@ export function trackFetch(lifeCycle, configuration, tracer) {
|
|
|
99
99
|
status: context.status,
|
|
100
100
|
traceId: context.traceId,
|
|
101
101
|
traceSampled: context.traceSampled,
|
|
102
|
-
requestHeaderContexts:
|
|
102
|
+
requestHeaderContexts:
|
|
103
|
+
context.init?.headers ||
|
|
104
|
+
(context.input instanceof Request
|
|
105
|
+
? context.input.headers
|
|
106
|
+
: undefined),
|
|
103
107
|
type: RequestType.FETCH,
|
|
104
108
|
url: context.url,
|
|
105
109
|
response: context.response,
|
|
@@ -83,7 +83,7 @@ function areEventsSimilar(first, second) {
|
|
|
83
83
|
return (
|
|
84
84
|
first.target === second.target &&
|
|
85
85
|
mouseEventDistance(first, second) <= MAX_DISTANCE_BETWEEN_CLICKS &&
|
|
86
|
-
|
|
86
|
+
second.timeStamp - first.timeStamp <= MAX_DURATION_BETWEEN_CLICKS
|
|
87
87
|
)
|
|
88
88
|
}
|
|
89
89
|
|