@cloudcare/browser-rum 3.0.20 → 3.0.23
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/cjs/domain/rumEventsCollection/resource/resourceCollection.js +2 -3
- package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +9 -1
- package/cjs/domain/rumEventsCollection/view/trackInitialViewTimings.js +15 -4
- package/cjs/domain/rumEventsCollection/view/trackViews.js +2 -0
- package/cjs/domain/rumEventsCollection/view/viewCollection.js +1 -0
- 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/actions/getSelectorsFromElement.js +1 -1
- package/esm/domain/rumEventsCollection/error/errorCollection.js +1 -1
- package/esm/domain/rumEventsCollection/resource/resourceCollection.js +2 -3
- package/esm/domain/rumEventsCollection/resource/resourceUtils.js +9 -1
- package/esm/domain/rumEventsCollection/view/trackInitialViewTimings.js +15 -5
- package/esm/domain/rumEventsCollection/view/trackViews.js +2 -0
- package/esm/domain/rumEventsCollection/view/viewCollection.js +1 -0
- 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/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +1 -6
- package/src/domain/rumEventsCollection/resource/resourceCollection.js +2 -2
- package/src/domain/rumEventsCollection/resource/resourceUtils.js +8 -1
- package/src/domain/rumEventsCollection/view/trackInitialViewTimings.js +19 -4
- package/src/domain/rumEventsCollection/view/trackViews.js +2 -1
- package/src/domain/rumEventsCollection/view/viewCollection.js +2 -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
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
|
}
|
|
@@ -108,9 +108,8 @@ function processResourceEntry(entry) {
|
|
|
108
108
|
function computePerformanceEntryMetrics(timing) {
|
|
109
109
|
return {
|
|
110
110
|
resource: (0, _browserCore.extend2Lev)({}, {
|
|
111
|
-
duration: (0, _resourceUtils.computePerformanceResourceDuration)(timing)
|
|
112
|
-
|
|
113
|
-
}, (0, _resourceUtils.computePerformanceResourceDetails)(timing))
|
|
111
|
+
duration: (0, _resourceUtils.computePerformanceResourceDuration)(timing)
|
|
112
|
+
}, (0, _resourceUtils.computeSize)(timing), (0, _resourceUtils.computePerformanceResourceDetails)(timing))
|
|
114
113
|
};
|
|
115
114
|
}
|
|
116
115
|
|
|
@@ -218,6 +218,11 @@ function computePerformanceResourceDetails(entry) {
|
|
|
218
218
|
if (hasRedirection(entry)) {
|
|
219
219
|
details.redirect = (0, _browserCore.msToNs)(redirectEnd - redirectStart);
|
|
220
220
|
details.redirectTime = formatTiming(startTime, redirectStart, redirectEnd);
|
|
221
|
+
} // renderBlockstatus
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
if (entry.renderBlockingStatus) {
|
|
225
|
+
details.renderBlockingStatus = entry.renderBlockingStatus;
|
|
221
226
|
}
|
|
222
227
|
|
|
223
228
|
return details;
|
|
@@ -291,7 +296,10 @@ function formatTiming(origin, start, end) {
|
|
|
291
296
|
function computeSize(entry) {
|
|
292
297
|
// Make sure a request actually occurred
|
|
293
298
|
if (entry.startTime < entry.responseStart) {
|
|
294
|
-
return
|
|
299
|
+
return {
|
|
300
|
+
size: entry.decodedBodySize,
|
|
301
|
+
encodeSize: entry.encodedBodySize
|
|
302
|
+
};
|
|
295
303
|
}
|
|
296
304
|
|
|
297
305
|
return undefined;
|
|
@@ -14,6 +14,8 @@ var _browserCore = require("@cloudcare/browser-core");
|
|
|
14
14
|
|
|
15
15
|
var _trackFirstHidden = require("./trackFirstHidden");
|
|
16
16
|
|
|
17
|
+
var _getSelectorsFromElement = require("../actions/getSelectorsFromElement");
|
|
18
|
+
|
|
17
19
|
// Discard LCP and FCP timings above a certain delay to avoid incorrect data
|
|
18
20
|
// It happens in some cases like sleep mode or some browser implementations
|
|
19
21
|
var TIMING_MAXIMUM_DELAY = 10 * _browserCore.ONE_MINUTE;
|
|
@@ -30,9 +32,15 @@ exports.KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY = KEEP_TRACKING_TIMINGS_AFTER_VIE
|
|
|
30
32
|
|
|
31
33
|
function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) {
|
|
32
34
|
var timings = {};
|
|
35
|
+
var timingsElementSelector = {};
|
|
33
36
|
|
|
34
|
-
function setTimings(newTimings) {
|
|
37
|
+
function setTimings(newTimings, timingSelectors) {
|
|
35
38
|
timings = (0, _browserCore.extend)(timings, newTimings);
|
|
39
|
+
|
|
40
|
+
if (timingSelectors) {
|
|
41
|
+
timingsElementSelector = (0, _browserCore.extend)(timingsElementSelector, timingSelectors);
|
|
42
|
+
}
|
|
43
|
+
|
|
36
44
|
scheduleViewUpdate();
|
|
37
45
|
}
|
|
38
46
|
|
|
@@ -51,10 +59,12 @@ function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) {
|
|
|
51
59
|
|
|
52
60
|
var stopFCPTracking = _trackFirstContentfulPaintTiming.stop;
|
|
53
61
|
|
|
54
|
-
var _trackLargestContentfulPaintTiming = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint) {
|
|
62
|
+
var _trackLargestContentfulPaintTiming = trackLargestContentfulPaintTiming(lifeCycle, window, function (largestContentfulPaint, largestContentfulPaintElement) {
|
|
55
63
|
setTimings({
|
|
56
64
|
largestContentfulPaint: largestContentfulPaint
|
|
57
|
-
}
|
|
65
|
+
}, largestContentfulPaintElement ? {
|
|
66
|
+
largestContentfulPaint: (0, _getSelectorsFromElement.getSelectorFromElement)(largestContentfulPaintElement)
|
|
67
|
+
} : undefined);
|
|
58
68
|
});
|
|
59
69
|
|
|
60
70
|
var stopLCPTracking = _trackLargestContentfulPaintTiming.stop;
|
|
@@ -78,6 +88,7 @@ function trackInitialViewTimings(lifeCycle, setLoadEvent, scheduleViewUpdate) {
|
|
|
78
88
|
return {
|
|
79
89
|
stop: stop,
|
|
80
90
|
timings: timings,
|
|
91
|
+
timingsElementSelector: timingsElementSelector,
|
|
81
92
|
scheduleStop: function scheduleStop() {
|
|
82
93
|
(0, _browserCore.setTimeout)(stop, KEEP_TRACKING_TIMINGS_AFTER_VIEW_DELAY);
|
|
83
94
|
}
|
|
@@ -159,7 +170,7 @@ function trackLargestContentfulPaintTiming(lifeCycle, emitter, callback) {
|
|
|
159
170
|
});
|
|
160
171
|
|
|
161
172
|
if (lcpEntry) {
|
|
162
|
-
callback(lcpEntry.startTime);
|
|
173
|
+
callback(lcpEntry.startTime, lcpEntry.element);
|
|
163
174
|
}
|
|
164
175
|
});
|
|
165
176
|
var unsubscribeLifeCycle = subscribe.unsubscribe;
|
|
@@ -140,6 +140,7 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
|
|
|
140
140
|
|
|
141
141
|
var scheduleStopInitialViewTimingsTracking = _trackInitialViewTimings.scheduleStop;
|
|
142
142
|
var timings = _trackInitialViewTimings.timings;
|
|
143
|
+
var timingsElementSelector = _trackInitialViewTimings.timingsElementSelector;
|
|
143
144
|
|
|
144
145
|
var _trackViewEventCounts = (0, _trackViewEventCounts2.trackViewEventCounts)(lifeCycle, id, scheduleViewUpdate);
|
|
145
146
|
|
|
@@ -165,6 +166,7 @@ function newView(lifeCycle, domMutationObservable, configuration, initialLocatio
|
|
|
165
166
|
location: location,
|
|
166
167
|
startClocks: startClocks,
|
|
167
168
|
timings: timings,
|
|
169
|
+
timingsElementSelector: timingsElementSelector,
|
|
168
170
|
duration: (0, _browserCore.elapsed)(startClocks.timeStamp, currentEnd),
|
|
169
171
|
isActive: endClocks === undefined,
|
|
170
172
|
sessionIsActive: sessionIsActive,
|
|
@@ -96,6 +96,7 @@ function processViewUpdate(view, foregroundContexts, recorderApi) {
|
|
|
96
96
|
is_active: view.isActive,
|
|
97
97
|
name: view.name,
|
|
98
98
|
largest_contentful_paint: (0, _browserCore.toServerDuration)(view.timings.largestContentfulPaint),
|
|
99
|
+
largest_contentful_paint_element_selector: view.timingsElementSelector.largestContentfulPaint,
|
|
99
100
|
load_event: (0, _browserCore.toServerDuration)(view.timings.loadEvent),
|
|
100
101
|
loading_time: discardNegativeDuration((0, _browserCore.toServerDuration)(view.loadingTime)),
|
|
101
102
|
loading_type: view.loadingType,
|
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;
|