@cloudcare/browser-rum 3.0.20 → 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/domain/replay/record/mutationBatch.js +1 -1
- package/cjs/domain/replay/record/mutationObserver.js +1 -1
- package/cjs/domain/replay/segmentCollection/segment.js +34 -22
- package/cjs/domain/replay/segmentCollection/startDeflateWorker.js +28 -9
- package/esm/boot/buildEnv.js +1 -1
- package/esm/boot/rumPublicApi.js +3 -1
- 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/serialize.js +10 -8
- 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/tracing/traceIdentifier.js +1 -2
- package/package.json +8 -7
- package/src/boot/buildEnv.js +1 -1
- package/src/boot/recorderApi.js +0 -1
- package/src/domain/replay/segmentCollection/segment.js +41 -22
- package/src/domain/replay/segmentCollection/startDeflateWorker.js +26 -8
- 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
package/cjs/boot/buildEnv.js
CHANGED
|
@@ -17,7 +17,7 @@ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.it
|
|
|
17
17
|
|
|
18
18
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
19
19
|
|
|
20
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
20
|
+
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; }
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Maximum duration to wait before processing mutations. If the browser is idle, mutations will be
|
|
@@ -24,7 +24,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symb
|
|
|
24
24
|
|
|
25
25
|
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); }
|
|
26
26
|
|
|
27
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
27
|
+
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; }
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Buffers and aggregate mutations generated by a MutationObserver into MutationPayload
|
|
@@ -17,10 +17,12 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
19
|
|
|
20
|
+
var STREAM_ID = 1;
|
|
20
21
|
var nextId = 0;
|
|
21
22
|
|
|
22
23
|
function Segment(worker, context, creationReason, initialRecord, onWrote, onFlushed) {
|
|
23
24
|
this.worker = worker;
|
|
25
|
+
this.pendingWriteCount = 0;
|
|
24
26
|
this.id = nextId++;
|
|
25
27
|
var viewId = context.view.id;
|
|
26
28
|
this.metadata = (0, _browserCore.assign)({
|
|
@@ -34,24 +36,32 @@ function Segment(worker, context, creationReason, initialRecord, onWrote, onFlus
|
|
|
34
36
|
}, context);
|
|
35
37
|
replayStats.addSegment(viewId);
|
|
36
38
|
replayStats.addRecord(viewId);
|
|
39
|
+
var rawBytesCount = 0;
|
|
40
|
+
var compressedBytesCount = 0;
|
|
41
|
+
var compressedData = [];
|
|
37
42
|
|
|
38
43
|
var _this = this;
|
|
39
44
|
|
|
40
|
-
var
|
|
45
|
+
var wokerListener = (0, _browserCore.addEventListener)(worker, 'message', function (params) {
|
|
41
46
|
var data = params.data;
|
|
42
47
|
|
|
43
|
-
if (data.type
|
|
48
|
+
if (data.type !== 'wrote') {
|
|
44
49
|
return;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
if (data.id === _this.id) {
|
|
53
|
+
_this.pendingWriteCount -= 1;
|
|
48
54
|
replayStats.addWroteData(viewId, data.additionalBytesCount);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
rawBytesCount += data.additionalBytesCount;
|
|
56
|
+
compressedBytesCount += data.result.length;
|
|
57
|
+
compressedData.push(data.result);
|
|
58
|
+
|
|
59
|
+
if (_this.flushReason && _this.pendingWriteCount === 0) {
|
|
60
|
+
compressedData.push(data.trailer);
|
|
61
|
+
onFlushed((0, _browserCore.concatBuffers)(compressedData), rawBytesCount);
|
|
62
|
+
removeMessageListener();
|
|
53
63
|
} else {
|
|
54
|
-
onWrote(
|
|
64
|
+
onWrote(compressedBytesCount);
|
|
55
65
|
}
|
|
56
66
|
} else if (data.id > _this.id) {
|
|
57
67
|
// Messages should be received in the same order as they are sent, so if we receive a
|
|
@@ -62,16 +72,12 @@ function Segment(worker, context, creationReason, initialRecord, onWrote, onFlus
|
|
|
62
72
|
// should already have been removed. But if something goes wrong and we didn't receive a
|
|
63
73
|
// "flush" response, remove the listener to avoid any leak, and send a monitor message to
|
|
64
74
|
// help investigate the issue.
|
|
65
|
-
|
|
75
|
+
removeMessageListener();
|
|
66
76
|
}
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
worker.addEventListener('message', listener);
|
|
70
|
-
this.worker.postMessage({
|
|
71
|
-
data: '{"records":[' + JSON.stringify(initialRecord),
|
|
72
|
-
id: this.id,
|
|
73
|
-
action: 'write'
|
|
74
77
|
});
|
|
78
|
+
var removeMessageListener = wokerListener.stop; // worker.addEventListener('message', listener)
|
|
79
|
+
|
|
80
|
+
this.write('{"records":[' + JSON.stringify(initialRecord));
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
Segment.prototype.addRecord = function (record) {
|
|
@@ -84,18 +90,24 @@ Segment.prototype.addRecord = function (record) {
|
|
|
84
90
|
this.metadata.has_full_snapshot = record.type === _types.RecordType.FullSnapshot;
|
|
85
91
|
}
|
|
86
92
|
|
|
93
|
+
this.write(',' + JSON.stringify(record));
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
Segment.prototype.flush = function (reason) {
|
|
97
|
+
this.write('],' + JSON.stringify(this.metadata).slice(1) + '\n');
|
|
87
98
|
this.worker.postMessage({
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
action: 'write'
|
|
99
|
+
action: 'reset',
|
|
100
|
+
streamId: STREAM_ID
|
|
91
101
|
});
|
|
102
|
+
this.flushReason = reason;
|
|
92
103
|
};
|
|
93
104
|
|
|
94
|
-
Segment.prototype.
|
|
105
|
+
Segment.prototype.write = function (data) {
|
|
106
|
+
this.pendingWriteCount += 1;
|
|
95
107
|
this.worker.postMessage({
|
|
96
|
-
data:
|
|
108
|
+
data: data,
|
|
97
109
|
id: this.id,
|
|
98
|
-
|
|
110
|
+
streamId: STREAM_ID,
|
|
111
|
+
action: 'write'
|
|
99
112
|
});
|
|
100
|
-
this.flushReason = reason;
|
|
101
113
|
};
|
|
@@ -3,19 +3,32 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.createDeflateWorker = createDeflateWorker;
|
|
6
7
|
exports.doStartDeflateWorker = doStartDeflateWorker;
|
|
7
8
|
exports.resetDeflateWorkerState = resetDeflateWorkerState;
|
|
8
9
|
exports.startDeflateWorker = startDeflateWorker;
|
|
9
10
|
|
|
10
11
|
var _browserCore = require("@cloudcare/browser-core");
|
|
11
12
|
|
|
12
|
-
var
|
|
13
|
+
var _string = require("@cloudcare/browser-worker/string");
|
|
13
14
|
|
|
15
|
+
var workerURL;
|
|
16
|
+
|
|
17
|
+
function createDeflateWorker() {
|
|
18
|
+
// Lazily compute the worker URL to allow importing the SDK in NodeJS
|
|
19
|
+
if (!workerURL) {
|
|
20
|
+
workerURL = URL.createObjectURL(new Blob([_string.workerString]));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return new Worker(workerURL);
|
|
24
|
+
}
|
|
14
25
|
/**
|
|
15
26
|
* In order to be sure that the worker is correctly working, we need a round trip of
|
|
16
27
|
* initialization messages, making the creation asynchronous.
|
|
17
28
|
* These worker lifecycle states handle this case.
|
|
18
29
|
*/
|
|
30
|
+
|
|
31
|
+
|
|
19
32
|
var DeflateWorkerStatus = {
|
|
20
33
|
Nil: 0,
|
|
21
34
|
Loading: 1,
|
|
@@ -28,7 +41,7 @@ var state = {
|
|
|
28
41
|
|
|
29
42
|
function startDeflateWorker(callback, createDeflateWorkerImpl) {
|
|
30
43
|
if (createDeflateWorkerImpl === undefined) {
|
|
31
|
-
createDeflateWorkerImpl =
|
|
44
|
+
createDeflateWorkerImpl = createDeflateWorker;
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
switch (state.status) {
|
|
@@ -72,7 +85,7 @@ function resetDeflateWorkerState() {
|
|
|
72
85
|
|
|
73
86
|
function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
74
87
|
if (createDeflateWorkerImpl === undefined) {
|
|
75
|
-
createDeflateWorkerImpl =
|
|
88
|
+
createDeflateWorkerImpl = createDeflateWorker;
|
|
76
89
|
}
|
|
77
90
|
|
|
78
91
|
try {
|
|
@@ -82,9 +95,9 @@ function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
|
82
95
|
var data = event.data;
|
|
83
96
|
|
|
84
97
|
if (data.type === 'errored') {
|
|
85
|
-
onError(data.error);
|
|
98
|
+
onError(data.error, data.streamId);
|
|
86
99
|
} else if (data.type === 'initialized') {
|
|
87
|
-
onInitialized(worker);
|
|
100
|
+
onInitialized(worker, data.version);
|
|
88
101
|
}
|
|
89
102
|
});
|
|
90
103
|
worker.postMessage({
|
|
@@ -96,23 +109,24 @@ function doStartDeflateWorker(createDeflateWorkerImpl) {
|
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
111
|
|
|
99
|
-
function onInitialized(worker) {
|
|
112
|
+
function onInitialized(worker, version) {
|
|
100
113
|
if (state.status === DeflateWorkerStatus.Loading) {
|
|
101
114
|
(0, _browserCore.each)(state.callbacks, function (callback) {
|
|
102
115
|
callback(worker);
|
|
103
116
|
});
|
|
104
117
|
state = {
|
|
105
118
|
status: DeflateWorkerStatus.Initialized,
|
|
106
|
-
worker: worker
|
|
119
|
+
worker: worker,
|
|
120
|
+
version: version
|
|
107
121
|
};
|
|
108
122
|
}
|
|
109
123
|
}
|
|
110
124
|
|
|
111
|
-
function onError(error) {
|
|
125
|
+
function onError(error, streamId) {
|
|
112
126
|
if (state.status === DeflateWorkerStatus.Loading) {
|
|
113
127
|
_browserCore.display.error('Session Replay recording failed to start: an error occurred while creating the Worker:', error);
|
|
114
128
|
|
|
115
|
-
if (error instanceof Event || error instanceof Error && (
|
|
129
|
+
if (error instanceof Event || error instanceof Error && isMessageCspRelated(error.message)) {
|
|
116
130
|
_browserCore.display.error('Please make sure CSP is correctly configured !!!');
|
|
117
131
|
}
|
|
118
132
|
|
|
@@ -123,4 +137,9 @@ function onError(error) {
|
|
|
123
137
|
status: DeflateWorkerStatus.Error
|
|
124
138
|
};
|
|
125
139
|
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function isMessageCspRelated(message) {
|
|
143
|
+
return (0, _browserCore.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
|
|
144
|
+
(0, _browserCore.includes)(message, "requires 'TrustedScriptURL'");
|
|
126
145
|
}
|
package/esm/boot/buildEnv.js
CHANGED
package/esm/boot/rumPublicApi.js
CHANGED
|
@@ -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 { makePublicApi, areCookiesAuthorized, BoundedBuffer, display, buildCookieOptions, createContextManager, CustomerDataType, clocksNow, timeStampNow, ActionType, deepClone, createHandlingStack, sanitizeUser, checkUser, noop, assign, canUseEventBridge } from '@cloudcare/browser-core';
|
|
2
4
|
import { validateAndBuildRumConfiguration } from '../domain/configuration';
|
|
3
5
|
import { buildCommonContext } from '../domain/contexts/commonContext';
|
|
@@ -117,7 +119,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
var startView = function startView(options) {
|
|
120
|
-
var sanitizedOptions =
|
|
122
|
+
var sanitizedOptions = _typeof(options) === 'object' ? options : {
|
|
121
123
|
name: options
|
|
122
124
|
};
|
|
123
125
|
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
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); }
|
|
6
|
+
|
|
7
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
8
|
+
|
|
9
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
+
|
|
11
|
+
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; }
|
|
12
|
+
|
|
1
13
|
import { noop, requestIdleCallback } from '@cloudcare/browser-core';
|
|
2
14
|
/**
|
|
3
15
|
* Maximum duration to wait before processing mutations. If the browser is idle, mutations will be
|
|
@@ -19,13 +31,16 @@ export function createMutationBatch(processMutationBatch) {
|
|
|
19
31
|
|
|
20
32
|
return {
|
|
21
33
|
addMutations: function addMutations(mutations) {
|
|
34
|
+
var _pendingMutations;
|
|
35
|
+
|
|
22
36
|
if (pendingMutations.length === 0) {
|
|
23
37
|
cancelScheduledFlush = requestIdleCallback(flush, {
|
|
24
38
|
timeout: MUTATION_PROCESS_MAX_DELAY
|
|
25
39
|
});
|
|
26
40
|
}
|
|
27
41
|
|
|
28
|
-
pendingMutations.push(
|
|
42
|
+
(_pendingMutations = pendingMutations).push.apply(_pendingMutations, _toConsumableArray(mutations)); // Array.prototype.push.apply(pendingMutations, mutations)
|
|
43
|
+
|
|
29
44
|
},
|
|
30
45
|
flush: flush,
|
|
31
46
|
stop: function stop() {
|
|
@@ -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) {
|
|
@@ -1,3 +1,5 @@
|
|
|
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';
|
|
@@ -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
|
};
|
|
@@ -498,10 +499,11 @@ function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
|
|
|
498
499
|
case SerializationContextStatus.SUBSEQUENT_FULL_SNAPSHOT:
|
|
499
500
|
if (serializationContext.elementsScrollPositions.has(element)) {
|
|
500
501
|
;
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
502
|
+
|
|
503
|
+
var _serializationContext = serializationContext.elementsScrollPositions.get(element);
|
|
504
|
+
|
|
505
|
+
scrollTop = _serializationContext.scrollTop;
|
|
506
|
+
scrollLeft = _serializationContext.scrollLeft;
|
|
505
507
|
}
|
|
506
508
|
|
|
507
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));
|