@cloudcare/browser-rum 3.0.19 → 3.0.22
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 +1 -1
- package/cjs/boot/rum.js +10 -2
- package/cjs/boot/rumPublicApi.js +17 -4
- package/cjs/domain/replay/record/mutationBatch.js +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +1 -1
- package/cjs/domain/replay/record/serializationUtils.js +13 -1
- package/cjs/domain/replay/record/serialize.js +31 -2
- package/cjs/domain/replay/segmentCollection/segment.js +34 -22
- package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +28 -9
- package/cjs/domain/rumSessionManager.js +7 -2
- package/cjs/transport/startRumEventBridge.js +16 -0
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/recorderApi.js +2 -2
- package/esm/boot/rum.js +11 -4
- package/esm/boot/rumPublicApi.js +21 -6
- package/esm/domain/replay/record/mutationBatch.js +16 -1
- package/esm/domain/replay/record/mutationObserver.js +102 -64
- package/esm/domain/replay/record/observers.js +5 -19
- package/esm/domain/replay/record/record.js +2 -2
- package/esm/domain/replay/record/serializationUtils.js +11 -1
- package/esm/domain/replay/record/serialize.js +42 -11
- package/esm/domain/replay/record/shadowRootsController.js +1 -1
- package/esm/domain/replay/replayStats.js +2 -2
- package/esm/domain/replay/segmentCollection/buildReplayPayload.js +3 -1
- package/esm/domain/replay/segmentCollection/segment.js +34 -22
- package/esm/domain/replay/segmentCollection/startDeflateWorker.js +22 -7
- package/esm/domain/rumEventsCollection/error/errorCollection.js +1 -1
- package/esm/domain/rumSessionManager.js +8 -3
- package/esm/domain/tracing/traceIdentifier.js +1 -2
- package/esm/transport/startRumEventBridge.js +8 -0
- package/package.json +8 -7
- package/src/boot/buildEnv.js +1 -1
- package/src/boot/recorderApi.js +3 -3
- package/src/boot/rum.js +22 -10
- package/src/boot/rumPublicApi.js +16 -4
- package/src/domain/replay/record/serializationUtils.js +10 -1
- package/src/domain/replay/record/serialize.js +37 -5
- package/src/domain/replay/segmentCollection/segment.js +41 -22
- package/src/domain/replay/segmentCollection/startDeflateWorker.js +26 -8
- package/src/domain/rumSessionManager.js +9 -3
- package/src/transport/startRumEventBridge.js +17 -0
- package/cjs/domain/replay/segmentCollection/deflateWorker.js +0 -4398
- package/esm/domain/replay/segmentCollection/deflateWorker.js +0 -4391
- package/src/domain/replay/segmentCollection/deflateWorker.js +0 -4583
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
|
|
1
7
|
import { noop, getChildNodes, isNodeShadowHost, getParentNode, isNullUndefinedDefaultValue } from '@cloudcare/browser-core';
|
|
2
8
|
import { getMutationObserverConstructor } from '../../domMutationCollection';
|
|
3
9
|
import { NodePrivacyLevel } from '../../../constants';
|
|
@@ -105,28 +111,38 @@ function processChildListMutations(mutations, configuration, shadowRootsControll
|
|
|
105
111
|
var addedAndMovedNodes = new Set();
|
|
106
112
|
var removedNodes = new Map();
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
addedAndMovedNodes.add(node);
|
|
111
|
-
});
|
|
112
|
-
mutation.removedNodes.forEach(function (node) {
|
|
113
|
-
if (!addedAndMovedNodes.has(node)) {
|
|
114
|
-
removedNodes.set(node, mutation.target);
|
|
115
|
-
}
|
|
114
|
+
var _iterator = _createForOfIteratorHelper(mutations),
|
|
115
|
+
_step;
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
// siblings, we want to iterate from last to first. This will ensure that any "next" node is
|
|
128
|
-
// already serialized and have an id.
|
|
117
|
+
try {
|
|
118
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
119
|
+
var mutation = _step.value;
|
|
120
|
+
mutation.addedNodes.forEach(function (node) {
|
|
121
|
+
addedAndMovedNodes.add(node);
|
|
122
|
+
});
|
|
123
|
+
mutation.removedNodes.forEach(function (node) {
|
|
124
|
+
if (!addedAndMovedNodes.has(node)) {
|
|
125
|
+
removedNodes.set(node, mutation.target);
|
|
126
|
+
}
|
|
129
127
|
|
|
128
|
+
addedAndMovedNodes["delete"](node);
|
|
129
|
+
});
|
|
130
|
+
} // Then, we sort nodes that are still in the document by topological order, for two reasons:
|
|
131
|
+
//
|
|
132
|
+
// * We will serialize each added nodes with their descendants. We don't want to serialize a node
|
|
133
|
+
// twice, so we need to iterate over the parent nodes first and skip any node that is contained in
|
|
134
|
+
// a precedent node.
|
|
135
|
+
//
|
|
136
|
+
// * To emit "add" mutations, we need references to the parent and potential next sibling of each
|
|
137
|
+
// added node. So we need to iterate over the parent nodes first, and when multiple nodes are
|
|
138
|
+
// siblings, we want to iterate from last to first. This will ensure that any "next" node is
|
|
139
|
+
// already serialized and have an id.
|
|
140
|
+
|
|
141
|
+
} catch (err) {
|
|
142
|
+
_iterator.e(err);
|
|
143
|
+
} finally {
|
|
144
|
+
_iterator.f();
|
|
145
|
+
}
|
|
130
146
|
|
|
131
147
|
var sortedAddedAndMovedNodes = Array.from(addedAndMovedNodes);
|
|
132
148
|
sortAddedAndMovedNodes(sortedAddedAndMovedNodes); // Then, we iterate over our sorted node sets to emit mutations. We collect the newly serialized
|
|
@@ -135,7 +151,9 @@ function processChildListMutations(mutations, configuration, shadowRootsControll
|
|
|
135
151
|
var serializedNodeIds = new Set();
|
|
136
152
|
var addedNodeMutations = [];
|
|
137
153
|
|
|
138
|
-
for (var
|
|
154
|
+
for (var _i = 0, _sortedAddedAndMovedN = sortedAddedAndMovedNodes; _i < _sortedAddedAndMovedN.length; _i++) {
|
|
155
|
+
var node = _sortedAddedAndMovedN[_i];
|
|
156
|
+
|
|
139
157
|
if (hasBeenSerialized(node)) {
|
|
140
158
|
continue;
|
|
141
159
|
}
|
|
@@ -153,7 +171,7 @@ function processChildListMutations(mutations, configuration, shadowRootsControll
|
|
|
153
171
|
status: SerializationContextStatus.MUTATION,
|
|
154
172
|
shadowRootsController: shadowRootsController
|
|
155
173
|
},
|
|
156
|
-
configuration
|
|
174
|
+
configuration: configuration
|
|
157
175
|
});
|
|
158
176
|
|
|
159
177
|
if (!serializedNode) {
|
|
@@ -217,24 +235,34 @@ function processCharacterDataMutations(mutations, configuration) {
|
|
|
217
235
|
return true;
|
|
218
236
|
}); // Emit mutations
|
|
219
237
|
|
|
220
|
-
|
|
221
|
-
|
|
238
|
+
var _iterator2 = _createForOfIteratorHelper(filteredMutations),
|
|
239
|
+
_step2;
|
|
222
240
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
241
|
+
try {
|
|
242
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
243
|
+
var mutation = _step2.value;
|
|
244
|
+
var value = mutation.target.textContent;
|
|
226
245
|
|
|
227
|
-
|
|
246
|
+
if (value === mutation.oldValue) {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
228
249
|
|
|
229
|
-
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
250
|
+
var parentNodePrivacyLevel = getNodePrivacyLevel(getParentNode(mutation.target), configuration.defaultPrivacyLevel);
|
|
232
251
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
252
|
+
if (parentNodePrivacyLevel === NodePrivacyLevel.HIDDEN || parentNodePrivacyLevel === NodePrivacyLevel.IGNORE) {
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
textMutations.push({
|
|
257
|
+
id: getSerializedNodeId(mutation.target),
|
|
258
|
+
// TODO: pass a valid "ignoreWhiteSpace" argument
|
|
259
|
+
value: isNullUndefinedDefaultValue(getTextContent(mutation.target, false, parentNodePrivacyLevel, null))
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
} catch (err) {
|
|
263
|
+
_iterator2.e(err);
|
|
264
|
+
} finally {
|
|
265
|
+
_iterator2.f();
|
|
238
266
|
}
|
|
239
267
|
|
|
240
268
|
return textMutations;
|
|
@@ -262,43 +290,53 @@ function processAttributesMutations(mutations, configuration) {
|
|
|
262
290
|
|
|
263
291
|
var emittedMutations = new Map();
|
|
264
292
|
|
|
265
|
-
|
|
266
|
-
|
|
293
|
+
var _iterator3 = _createForOfIteratorHelper(filteredMutations),
|
|
294
|
+
_step3;
|
|
267
295
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
296
|
+
try {
|
|
297
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
298
|
+
var mutation = _step3.value;
|
|
299
|
+
var uncensoredValue = mutation.target.getAttribute(mutation.attributeName);
|
|
271
300
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
301
|
+
if (uncensoredValue === mutation.oldValue) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
275
304
|
|
|
276
|
-
|
|
277
|
-
var
|
|
305
|
+
var privacyLevel = getNodePrivacyLevel(mutation.target, configuration.defaultPrivacyLevel);
|
|
306
|
+
var attributeValue = serializeAttribute(mutation.target, privacyLevel, mutation.attributeName, configuration);
|
|
307
|
+
var transformedValue;
|
|
278
308
|
|
|
279
|
-
if (
|
|
280
|
-
|
|
309
|
+
if (mutation.attributeName === 'value') {
|
|
310
|
+
var inputValue = getElementInputValue(mutation.target, privacyLevel);
|
|
311
|
+
|
|
312
|
+
if (inputValue === undefined) {
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
transformedValue = inputValue;
|
|
317
|
+
} else if (typeof attributeValue === 'string') {
|
|
318
|
+
transformedValue = attributeValue;
|
|
319
|
+
} else {
|
|
320
|
+
transformedValue = null;
|
|
281
321
|
}
|
|
282
322
|
|
|
283
|
-
|
|
284
|
-
} else if (typeof attributeValue === 'string') {
|
|
285
|
-
transformedValue = attributeValue;
|
|
286
|
-
} else {
|
|
287
|
-
transformedValue = null;
|
|
288
|
-
}
|
|
323
|
+
var emittedMutation = emittedMutations.get(mutation.target);
|
|
289
324
|
|
|
290
|
-
|
|
325
|
+
if (!emittedMutation) {
|
|
326
|
+
emittedMutation = {
|
|
327
|
+
id: getSerializedNodeId(mutation.target),
|
|
328
|
+
attributes: {}
|
|
329
|
+
};
|
|
330
|
+
attributeMutations.push(emittedMutation);
|
|
331
|
+
emittedMutations.set(mutation.target, emittedMutation);
|
|
332
|
+
}
|
|
291
333
|
|
|
292
|
-
|
|
293
|
-
emittedMutation = {
|
|
294
|
-
id: getSerializedNodeId(mutation.target),
|
|
295
|
-
attributes: {}
|
|
296
|
-
};
|
|
297
|
-
attributeMutations.push(emittedMutation);
|
|
298
|
-
emittedMutations.set(mutation.target, emittedMutation);
|
|
334
|
+
emittedMutation.attributes[mutation.attributeName] = transformedValue;
|
|
299
335
|
}
|
|
300
|
-
|
|
301
|
-
|
|
336
|
+
} catch (err) {
|
|
337
|
+
_iterator3.e(err);
|
|
338
|
+
} finally {
|
|
339
|
+
_iterator3.f();
|
|
302
340
|
}
|
|
303
341
|
|
|
304
342
|
return attributeMutations;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
var _eventTypeToMouseInte;
|
|
2
|
+
|
|
3
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
4
|
+
|
|
1
5
|
import { instrumentSetter, instrumentMethodAndCallOriginal, assign, throttle, DOM_EVENT, addEventListeners, addEventListener, noop, LifeCycleEventType, RumEventType, ActionType, isNodeShadowHost } from '@cloudcare/browser-core';
|
|
2
6
|
import { initViewportObservable } from '../../initViewportObservable';
|
|
3
7
|
import { NodePrivacyLevel } from '../../../constants';
|
|
@@ -81,25 +85,7 @@ export function initMoveObserver(cb) {
|
|
|
81
85
|
passive: true
|
|
82
86
|
}).stop;
|
|
83
87
|
}
|
|
84
|
-
var eventTypeToMouseInteraction = {
|
|
85
|
-
// Listen for pointerup DOM events instead of mouseup for MouseInteraction/MouseUp records. This
|
|
86
|
-
// allows to reference such records from Frustration records.
|
|
87
|
-
//
|
|
88
|
-
// In the context of supporting Mobile Session Replay, we introduced `PointerInteraction` records
|
|
89
|
-
// used by the Mobile SDKs in place of `MouseInteraction`. In the future, we should replace
|
|
90
|
-
// `MouseInteraction` by `PointerInteraction` in the Browser SDK so we have an uniform way to
|
|
91
|
-
// convey such interaction. This would cleanly solve the issue since we would have
|
|
92
|
-
// `PointerInteraction/Up` records that we could reference from `Frustration` records.
|
|
93
|
-
[DOM_EVENT.POINTER_UP]: MouseInteractionType.MouseUp,
|
|
94
|
-
[DOM_EVENT.MOUSE_DOWN]: MouseInteractionType.MouseDown,
|
|
95
|
-
[DOM_EVENT.CLICK]: MouseInteractionType.Click,
|
|
96
|
-
[DOM_EVENT.CONTEXT_MENU]: MouseInteractionType.ContextMenu,
|
|
97
|
-
[DOM_EVENT.DBL_CLICK]: MouseInteractionType.DblClick,
|
|
98
|
-
[DOM_EVENT.FOCUS]: MouseInteractionType.Focus,
|
|
99
|
-
[DOM_EVENT.BLUR]: MouseInteractionType.Blur,
|
|
100
|
-
[DOM_EVENT.TOUCH_START]: MouseInteractionType.TouchStart,
|
|
101
|
-
[DOM_EVENT.TOUCH_END]: MouseInteractionType.TouchEnd
|
|
102
|
-
};
|
|
88
|
+
var eventTypeToMouseInteraction = (_eventTypeToMouseInte = {}, _defineProperty(_eventTypeToMouseInte, DOM_EVENT.POINTER_UP, MouseInteractionType.MouseUp), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.MOUSE_DOWN, MouseInteractionType.MouseDown), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.CLICK, MouseInteractionType.Click), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.CONTEXT_MENU, MouseInteractionType.ContextMenu), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.DBL_CLICK, MouseInteractionType.DblClick), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.FOCUS, MouseInteractionType.Focus), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.BLUR, MouseInteractionType.Blur), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.TOUCH_START, MouseInteractionType.TouchStart), _defineProperty(_eventTypeToMouseInte, DOM_EVENT.TOUCH_END, MouseInteractionType.TouchEnd), _eventTypeToMouseInte);
|
|
103
89
|
export function initMouseInteractionObserver(cb, defaultPrivacyLevel) {
|
|
104
90
|
var handler = function handler(event) {
|
|
105
91
|
var target = getEventTarget(event);
|
|
@@ -25,8 +25,8 @@ export function record(options) {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
var shadowRootsController = initShadowRootsController(options.configuration, {
|
|
28
|
-
mutationCb,
|
|
29
|
-
inputCb
|
|
28
|
+
mutationCb: mutationCb,
|
|
29
|
+
inputCb: inputCb
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
var takeFullSnapshot = function takeFullSnapshot(timestamp, serializationContext) {
|
|
@@ -106,6 +106,16 @@ export function makeUrlAbsolute(url, baseUrl) {
|
|
|
106
106
|
return url;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
export function validateStringifiedCssRule(cssStringified) {
|
|
110
|
+
// Safari does not escape selectors with : properly
|
|
111
|
+
if (cssStringified.includes(':')) {
|
|
112
|
+
// Replace e.g. [aa:bb] with [aa\\:bb]
|
|
113
|
+
var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
114
|
+
return cssStringified.replace(regex, '$1\\$2');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return cssStringified;
|
|
118
|
+
}
|
|
109
119
|
export function serializeStyleSheets(cssStyleSheets) {
|
|
110
120
|
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
|
|
111
121
|
return undefined;
|
|
@@ -114,7 +124,7 @@ export function serializeStyleSheets(cssStyleSheets) {
|
|
|
114
124
|
return cssStyleSheets.map(function (cssStyleSheet) {
|
|
115
125
|
var rules = cssStyleSheet.cssRules || cssStyleSheet.rules;
|
|
116
126
|
var cssRules = Array.from(rules, function (cssRule) {
|
|
117
|
-
return cssRule.cssText;
|
|
127
|
+
return cssRule.cssText ? validateStringifiedCssRule(rule.cssText) : '';
|
|
118
128
|
});
|
|
119
129
|
var styleSheet = {
|
|
120
130
|
cssRules: cssRules,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
+
|
|
1
3
|
import { assign, startsWith, isNodeShadowHost, isNodeShadowRoot } from '@cloudcare/browser-core';
|
|
2
4
|
import { STABLE_ATTRIBUTES } from '../../rumEventsCollection/actions/getSelectorsFromElement';
|
|
3
5
|
import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_HIDDEN, CENSORED_STRING_MARK, CENSORED_IMG_MARK } from '../../../constants';
|
|
4
6
|
import { NodeType } from '../../../types';
|
|
5
7
|
import { getTextContent, shouldMaskNode, reducePrivacyLevel, getNodeSelfPrivacyLevel, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './privacy';
|
|
6
|
-
import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, absoluteToDoc, getAbsoluteSrcsetString } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
|
|
8
|
+
import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, absoluteToDoc, getAbsoluteSrcsetString, validateStringifiedCssRule } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
|
|
7
9
|
// children during serialization, since HIDDEN and IGNORE shouldn't serialize their children. This
|
|
8
10
|
// ensures that no children are serialized when they shouldn't.
|
|
9
11
|
|
|
@@ -133,11 +135,10 @@ export function serializeElementNode(element, options) {
|
|
|
133
135
|
return {
|
|
134
136
|
type: NodeType.Element,
|
|
135
137
|
tagName: tagName,
|
|
136
|
-
attributes: {
|
|
138
|
+
attributes: _defineProperty({
|
|
137
139
|
rr_width: width + 'px',
|
|
138
|
-
rr_height: height + 'px'
|
|
139
|
-
|
|
140
|
-
},
|
|
140
|
+
rr_height: height + 'px'
|
|
141
|
+
}, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_HIDDEN),
|
|
141
142
|
childNodes: [],
|
|
142
143
|
isSVG: isSVG
|
|
143
144
|
};
|
|
@@ -295,6 +296,26 @@ function getValidTagName(tagName) {
|
|
|
295
296
|
|
|
296
297
|
return processedTagName;
|
|
297
298
|
}
|
|
299
|
+
/**
|
|
300
|
+
* Browsers sometimes destructively modify the css rules they receive.
|
|
301
|
+
* This function tries to rectify the modifications the browser made to make it more cross platform compatible.
|
|
302
|
+
* @param cssText - output of `CSSStyleRule.cssText`
|
|
303
|
+
* @returns `cssText` with browser inconsistencies fixed.
|
|
304
|
+
*/
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
308
|
+
/**
|
|
309
|
+
* Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
|
|
310
|
+
* But then Chrome ignores `background-clip` as css input.
|
|
311
|
+
* Re-introduce `-webkit-background-clip` to fix this issue.
|
|
312
|
+
*/
|
|
313
|
+
if (cssText.includes(' background-clip: text;') && !cssText.includes(' -webkit-background-clip: text;')) {
|
|
314
|
+
cssText = cssText.replace(' background-clip: text;', ' -webkit-background-clip: text; background-clip: text;');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return cssText;
|
|
318
|
+
}
|
|
298
319
|
|
|
299
320
|
function getCssRulesString(cssStyleSheet) {
|
|
300
321
|
if (!cssStyleSheet) {
|
|
@@ -312,12 +333,21 @@ function getCssRulesString(cssStyleSheet) {
|
|
|
312
333
|
return null;
|
|
313
334
|
}
|
|
314
335
|
|
|
315
|
-
var styleSheetCssText = Array.from(rules, getCssRuleString).join('');
|
|
336
|
+
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(Array.from(rules, getCssRuleString).join(''));
|
|
316
337
|
return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href);
|
|
317
338
|
}
|
|
318
339
|
|
|
319
340
|
function getCssRuleString(rule) {
|
|
320
|
-
|
|
341
|
+
var cssStringified = rule.cssText;
|
|
342
|
+
|
|
343
|
+
if (isCSSImportRule(rule)) {
|
|
344
|
+
try {
|
|
345
|
+
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
346
|
+
} catch (_unused2) {// ignore
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
return validateStringifiedCssRule(cssStringified);
|
|
321
351
|
}
|
|
322
352
|
|
|
323
353
|
function isCSSImportRule(rule) {
|
|
@@ -469,10 +499,11 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
469
499
|
case SerializationContextStatus.SUBSEQUENT_FULL_SNAPSHOT:
|
|
470
500
|
if (serializationContext.elementsScrollPositions.has(element)) {
|
|
471
501
|
;
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
502
|
+
|
|
503
|
+
var _serializationContext = serializationContext.elementsScrollPositions.get(element);
|
|
504
|
+
|
|
505
|
+
scrollTop = _serializationContext.scrollTop;
|
|
506
|
+
scrollLeft = _serializationContext.scrollLeft;
|
|
476
507
|
}
|
|
477
508
|
|
|
478
509
|
break;
|
|
@@ -29,7 +29,7 @@ export var initShadowRootsController = function initShadowRootsController(config
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
entry.stop();
|
|
32
|
-
controllerByShadowRoot
|
|
32
|
+
controllerByShadowRoot["delete"](shadowRoot);
|
|
33
33
|
},
|
|
34
34
|
stop: function stop() {
|
|
35
35
|
controllerByShadowRoot.forEach(function (event) {
|
|
@@ -50,13 +50,13 @@ function deleteOldestStats() {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
if (statsPerView.keys) {
|
|
53
|
-
statsPerView
|
|
53
|
+
statsPerView["delete"](statsPerView.keys().next().value);
|
|
54
54
|
} else {
|
|
55
55
|
// IE11 doesn't support map.keys
|
|
56
56
|
var isFirst = true;
|
|
57
57
|
statsPerView.forEach(function (_value, key) {
|
|
58
58
|
if (isFirst) {
|
|
59
|
-
statsPerView
|
|
59
|
+
statsPerView["delete"](key);
|
|
60
60
|
isFirst = false;
|
|
61
61
|
}
|
|
62
62
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
|
+
|
|
1
3
|
import { objectEntries, each } from '@cloudcare/browser-core';
|
|
2
4
|
export function buildReplayPayload(data, metadata, rawSegmentBytesCount) {
|
|
3
5
|
var formData = new FormData();
|
|
@@ -22,7 +24,7 @@ export function toFormEntries(input, onEntry, prefix) {
|
|
|
22
24
|
var value = item[1];
|
|
23
25
|
var key = item[0];
|
|
24
26
|
|
|
25
|
-
if (
|
|
27
|
+
if (_typeof(value) === 'object' && value !== null) {
|
|
26
28
|
toFormEntries(value, onEntry, '' + prefix + key + '_');
|
|
27
29
|
} else {
|
|
28
30
|
onEntry('' + prefix + key, String(value));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { assign } from '@cloudcare/browser-core';
|
|
1
|
+
import { assign, addEventListener, concatBuffers } from '@cloudcare/browser-core';
|
|
2
2
|
import { RecordType } from '../../../types';
|
|
3
3
|
import * as replayStats from '../replayStats';
|
|
4
|
+
var STREAM_ID = 1;
|
|
4
5
|
var nextId = 0;
|
|
5
6
|
export function Segment(worker, context, creationReason, initialRecord, onWrote, onFlushed) {
|
|
6
7
|
this.worker = worker;
|
|
8
|
+
this.pendingWriteCount = 0;
|
|
7
9
|
this.id = nextId++;
|
|
8
10
|
var viewId = context.view.id;
|
|
9
11
|
this.metadata = assign({
|
|
@@ -17,24 +19,32 @@ export function Segment(worker, context, creationReason, initialRecord, onWrote,
|
|
|
17
19
|
}, context);
|
|
18
20
|
replayStats.addSegment(viewId);
|
|
19
21
|
replayStats.addRecord(viewId);
|
|
22
|
+
var rawBytesCount = 0;
|
|
23
|
+
var compressedBytesCount = 0;
|
|
24
|
+
var compressedData = [];
|
|
20
25
|
|
|
21
26
|
var _this = this;
|
|
22
27
|
|
|
23
|
-
var
|
|
28
|
+
var wokerListener = addEventListener(worker, 'message', function (params) {
|
|
24
29
|
var data = params.data;
|
|
25
30
|
|
|
26
|
-
if (data.type
|
|
31
|
+
if (data.type !== 'wrote') {
|
|
27
32
|
return;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
if (data.id === _this.id) {
|
|
36
|
+
_this.pendingWriteCount -= 1;
|
|
31
37
|
replayStats.addWroteData(viewId, data.additionalBytesCount);
|
|
38
|
+
rawBytesCount += data.additionalBytesCount;
|
|
39
|
+
compressedBytesCount += data.result.length;
|
|
40
|
+
compressedData.push(data.result);
|
|
32
41
|
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
if (_this.flushReason && _this.pendingWriteCount === 0) {
|
|
43
|
+
compressedData.push(data.trailer);
|
|
44
|
+
onFlushed(concatBuffers(compressedData), rawBytesCount);
|
|
45
|
+
removeMessageListener();
|
|
36
46
|
} else {
|
|
37
|
-
onWrote(
|
|
47
|
+
onWrote(compressedBytesCount);
|
|
38
48
|
}
|
|
39
49
|
} else if (data.id > _this.id) {
|
|
40
50
|
// Messages should be received in the same order as they are sent, so if we receive a
|
|
@@ -45,16 +55,12 @@ export function Segment(worker, context, creationReason, initialRecord, onWrote,
|
|
|
45
55
|
// should already have been removed. But if something goes wrong and we didn't receive a
|
|
46
56
|
// "flush" response, remove the listener to avoid any leak, and send a monitor message to
|
|
47
57
|
// help investigate the issue.
|
|
48
|
-
|
|
58
|
+
removeMessageListener();
|
|
49
59
|
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
worker.addEventListener('message', listener);
|
|
53
|
-
this.worker.postMessage({
|
|
54
|
-
data: '{"records":[' + JSON.stringify(initialRecord),
|
|
55
|
-
id: this.id,
|
|
56
|
-
action: 'write'
|
|
57
60
|
});
|
|
61
|
+
var removeMessageListener = wokerListener.stop; // worker.addEventListener('message', listener)
|
|
62
|
+
|
|
63
|
+
this.write('{"records":[' + JSON.stringify(initialRecord));
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
Segment.prototype.addRecord = function (record) {
|
|
@@ -67,18 +73,24 @@ Segment.prototype.addRecord = function (record) {
|
|
|
67
73
|
this.metadata.has_full_snapshot = record.type === RecordType.FullSnapshot;
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
this.write(',' + JSON.stringify(record));
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
Segment.prototype.flush = function (reason) {
|
|
80
|
+
this.write('],' + JSON.stringify(this.metadata).slice(1) + '\n');
|
|
70
81
|
this.worker.postMessage({
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
action: 'write'
|
|
82
|
+
action: 'reset',
|
|
83
|
+
streamId: STREAM_ID
|
|
74
84
|
});
|
|
85
|
+
this.flushReason = reason;
|
|
75
86
|
};
|
|
76
87
|
|
|
77
|
-
Segment.prototype.
|
|
88
|
+
Segment.prototype.write = function (data) {
|
|
89
|
+
this.pendingWriteCount += 1;
|
|
78
90
|
this.worker.postMessage({
|
|
79
|
-
data:
|
|
91
|
+
data: data,
|
|
80
92
|
id: this.id,
|
|
81
|
-
|
|
93
|
+
streamId: STREAM_ID,
|
|
94
|
+
action: 'write'
|
|
82
95
|
});
|
|
83
|
-
this.flushReason = reason;
|
|
84
96
|
};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { display, includes, each, addEventListener } from '@cloudcare/browser-core';
|
|
2
|
-
import {
|
|
2
|
+
import { workerString } from '@cloudcare/browser-worker/string';
|
|
3
|
+
var workerURL;
|
|
4
|
+
export function createDeflateWorker() {
|
|
5
|
+
// Lazily compute the worker URL to allow importing the SDK in NodeJS
|
|
6
|
+
if (!workerURL) {
|
|
7
|
+
workerURL = URL.createObjectURL(new Blob([workerString]));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return new Worker(workerURL);
|
|
11
|
+
}
|
|
3
12
|
/**
|
|
4
13
|
* In order to be sure that the worker is correctly working, we need a round trip of
|
|
5
14
|
* initialization messages, making the creation asynchronous.
|
|
@@ -69,9 +78,9 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
|
69
78
|
var data = event.data;
|
|
70
79
|
|
|
71
80
|
if (data.type === 'errored') {
|
|
72
|
-
onError(data.error);
|
|
81
|
+
onError(data.error, data.streamId);
|
|
73
82
|
} else if (data.type === 'initialized') {
|
|
74
|
-
onInitialized(worker);
|
|
83
|
+
onInitialized(worker, data.version);
|
|
75
84
|
}
|
|
76
85
|
});
|
|
77
86
|
worker.postMessage({
|
|
@@ -83,23 +92,24 @@ export function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
|
83
92
|
}
|
|
84
93
|
}
|
|
85
94
|
|
|
86
|
-
function onInitialized(worker) {
|
|
95
|
+
function onInitialized(worker, version) {
|
|
87
96
|
if (state.status === DeflateWorkerStatus.Loading) {
|
|
88
97
|
each(state.callbacks, function (callback) {
|
|
89
98
|
callback(worker);
|
|
90
99
|
});
|
|
91
100
|
state = {
|
|
92
101
|
status: DeflateWorkerStatus.Initialized,
|
|
93
|
-
worker: worker
|
|
102
|
+
worker: worker,
|
|
103
|
+
version: version
|
|
94
104
|
};
|
|
95
105
|
}
|
|
96
106
|
}
|
|
97
107
|
|
|
98
|
-
function onError(error) {
|
|
108
|
+
function onError(error, streamId) {
|
|
99
109
|
if (state.status === DeflateWorkerStatus.Loading) {
|
|
100
110
|
display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error);
|
|
101
111
|
|
|
102
|
-
if (error instanceof Event || error instanceof Error &&
|
|
112
|
+
if (error instanceof Event || error instanceof Error && isMessageCspRelated(error.message)) {
|
|
103
113
|
display.error('Please make sure CSP is correctly configured !!!');
|
|
104
114
|
}
|
|
105
115
|
|
|
@@ -110,4 +120,9 @@ function onError(error) {
|
|
|
110
120
|
status: DeflateWorkerStatus.Error
|
|
111
121
|
};
|
|
112
122
|
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function isMessageCspRelated(message) {
|
|
126
|
+
return includes(message, 'Content Security Policy') || // Related to `require-trusted-types-for` CSP: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/require-trusted-types-for
|
|
127
|
+
includes(message, "requires 'TrustedScriptURL'");
|
|
113
128
|
}
|
|
@@ -25,7 +25,7 @@ export function doStartErrorCollection(lifeCycle, foregroundContexts) {
|
|
|
25
25
|
var error = providedError.error;
|
|
26
26
|
var stackTrace = error instanceof Error ? computeStackTrace(error) : undefined;
|
|
27
27
|
var rawError = computeRawError({
|
|
28
|
-
stackTrace,
|
|
28
|
+
stackTrace: stackTrace,
|
|
29
29
|
originalError: error,
|
|
30
30
|
handlingStack: providedError.handlingStack,
|
|
31
31
|
startClocks: providedError.startClocks,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { performDraw, startSessionManager, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
1
|
+
import { performDraw, startSessionManager, LifeCycleEventType, noop, Observable } from '@cloudcare/browser-core';
|
|
2
2
|
export var RUM_SESSION_KEY = 'rum';
|
|
3
3
|
export var RumSessionPlan = {
|
|
4
4
|
WITHOUT_SESSION_REPLAY: 1,
|
|
@@ -48,12 +48,17 @@ export function startRumSessionManager(configuration, lifeCycle) {
|
|
|
48
48
|
|
|
49
49
|
export function startRumSessionManagerStub() {
|
|
50
50
|
var session = {
|
|
51
|
-
id: '00000000-aaaa-0000-aaaa-000000000000'
|
|
51
|
+
id: '00000000-aaaa-0000-aaaa-000000000000',
|
|
52
|
+
plan: RumSessionPlan.WITHOUT_SESSION_REPLAY,
|
|
53
|
+
// plan value should not be taken into account for mobile
|
|
54
|
+
sessionReplayAllowed: false
|
|
52
55
|
};
|
|
53
56
|
return {
|
|
54
57
|
findTrackedSession: function findTrackedSession() {
|
|
55
58
|
return session;
|
|
56
|
-
}
|
|
59
|
+
},
|
|
60
|
+
expire: noop,
|
|
61
|
+
expireObservable: new Observable()
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -26,11 +26,10 @@ TraceIdentifier.prototype = {
|
|
|
26
26
|
/**
|
|
27
27
|
* Format used by OTel headers
|
|
28
28
|
*/
|
|
29
|
-
toPaddedHexadecimalString() {
|
|
29
|
+
toPaddedHexadecimalString: function toPaddedHexadecimalString() {
|
|
30
30
|
var traceId = this.toString(16);
|
|
31
31
|
return Array(17 - traceId.length).join('0') + traceId;
|
|
32
32
|
},
|
|
33
|
-
|
|
34
33
|
readInt32: function readInt32(offset) {
|
|
35
34
|
return this.buffer[offset] * 16777216 + (this.buffer[offset + 1] << 16) + (this.buffer[offset + 2] << 8) + this.buffer[offset + 3];
|
|
36
35
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getEventBridge, LifeCycleEventType, processedMessageByDataMap } from '@cloudcare/browser-core';
|
|
2
|
+
export function startRumEventBridge(lifeCycle) {
|
|
3
|
+
var bridge = getEventBridge();
|
|
4
|
+
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
|
|
5
|
+
var data = processedMessageByDataMap(serverRumEvent).rowData;
|
|
6
|
+
bridge.send('rum', data);
|
|
7
|
+
});
|
|
8
|
+
}
|