@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
package/cjs/boot/buildEnv.js
CHANGED
package/cjs/boot/recorderApi.js
CHANGED
|
@@ -28,7 +28,7 @@ function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
|
|
|
28
28
|
startDeflateWorkerImpl = _segmentCollection.startDeflateWorker;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (!isBrowserSupported()) {
|
|
31
|
+
if ((0, _browserCore.canUseEventBridge)() || !isBrowserSupported()) {
|
|
32
32
|
return {
|
|
33
33
|
start: _browserCore.noop,
|
|
34
34
|
stop: _browserCore.noop,
|
package/cjs/boot/rum.js
CHANGED
|
@@ -24,6 +24,8 @@ var _actionCollection = require("../domain/rumEventsCollection/actions/actionCol
|
|
|
24
24
|
|
|
25
25
|
var _startRumBatch = require("../transport/startRumBatch");
|
|
26
26
|
|
|
27
|
+
var _startRumEventBridge = require("../transport/startRumEventBridge");
|
|
28
|
+
|
|
27
29
|
var _assembly = require("../domain/assembly");
|
|
28
30
|
|
|
29
31
|
var _internalContext = require("../domain/contexts/internalContext");
|
|
@@ -57,8 +59,14 @@ function startRum(configuration, recorderApi, globalContextManager, userContextM
|
|
|
57
59
|
pageExitObservable.subscribe(function (event) {
|
|
58
60
|
lifeCycle.notify(_browserCore.LifeCycleEventType.PAGE_EXITED, event);
|
|
59
61
|
});
|
|
60
|
-
var session = (0, _rumSessionManager.startRumSessionManager)(configuration, lifeCycle);
|
|
61
|
-
|
|
62
|
+
var session = !(0, _browserCore.canUseEventBridge)() ? (0, _rumSessionManager.startRumSessionManager)(configuration, lifeCycle) : (0, _rumSessionManager.startRumSessionManagerStub)();
|
|
63
|
+
|
|
64
|
+
if (!(0, _browserCore.canUseEventBridge)()) {
|
|
65
|
+
var batch = (0, _startRumBatch.startRumBatch)(configuration, lifeCycle, reportError, pageExitObservable, session.expireObservable);
|
|
66
|
+
} else {
|
|
67
|
+
(0, _startRumEventBridge.startRumEventBridge)(lifeCycle);
|
|
68
|
+
}
|
|
69
|
+
|
|
62
70
|
var userSession = (0, _usr.startCacheUsrCache)(configuration);
|
|
63
71
|
var domMutationObservable = (0, _domMutationCollection.createDOMMutationObservable)();
|
|
64
72
|
var locationChangeObservable = (0, _locationChangeObservable.createLocationChangeObservable)(location);
|
package/cjs/boot/rumPublicApi.js
CHANGED
|
@@ -73,6 +73,16 @@ function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
function initRum(initConfiguration) {
|
|
76
|
+
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
77
|
+
return (0, _browserCore.deepClone)(initConfiguration);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
var eventBridgeAvailable = (0, _browserCore.canUseEventBridge)();
|
|
81
|
+
|
|
82
|
+
if (eventBridgeAvailable) {
|
|
83
|
+
initConfiguration = overrideInitConfigurationForBridge(initConfiguration);
|
|
84
|
+
}
|
|
85
|
+
|
|
76
86
|
if (!canHandleSession(initConfiguration)) {
|
|
77
87
|
return;
|
|
78
88
|
}
|
|
@@ -103,10 +113,6 @@ function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
103
113
|
beforeInitCalls.drain();
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
107
|
-
return (0, _browserCore.deepClone)(initConfiguration);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
116
|
isAlreadyInitialized = true;
|
|
111
117
|
}
|
|
112
118
|
|
|
@@ -236,4 +242,11 @@ function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
236
242
|
function isLocalFile() {
|
|
237
243
|
return window.location.protocol === 'file:';
|
|
238
244
|
}
|
|
245
|
+
|
|
246
|
+
function overrideInitConfigurationForBridge(initConfiguration) {
|
|
247
|
+
return (0, _browserCore.assign)({}, initConfiguration, {
|
|
248
|
+
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
|
|
249
|
+
sessionSampleRate: 100
|
|
250
|
+
});
|
|
251
|
+
}
|
|
239
252
|
}
|
|
@@ -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
|
|
@@ -14,6 +14,7 @@ exports.nodeAndAncestorsHaveSerializedNode = nodeAndAncestorsHaveSerializedNode;
|
|
|
14
14
|
exports.serializeStyleSheets = serializeStyleSheets;
|
|
15
15
|
exports.setSerializedNodeId = setSerializedNodeId;
|
|
16
16
|
exports.switchToAbsoluteUrl = switchToAbsoluteUrl;
|
|
17
|
+
exports.validateStringifiedCssRule = validateStringifiedCssRule;
|
|
17
18
|
|
|
18
19
|
var _browserCore = require("@cloudcare/browser-core");
|
|
19
20
|
|
|
@@ -137,6 +138,17 @@ function makeUrlAbsolute(url, baseUrl) {
|
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
function validateStringifiedCssRule(cssStringified) {
|
|
142
|
+
// Safari does not escape selectors with : properly
|
|
143
|
+
if (cssStringified.includes(':')) {
|
|
144
|
+
// Replace e.g. [aa:bb] with [aa\\:bb]
|
|
145
|
+
var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
146
|
+
return cssStringified.replace(regex, '$1\\$2');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return cssStringified;
|
|
150
|
+
}
|
|
151
|
+
|
|
140
152
|
function serializeStyleSheets(cssStyleSheets) {
|
|
141
153
|
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
|
|
142
154
|
return undefined;
|
|
@@ -145,7 +157,7 @@ function serializeStyleSheets(cssStyleSheets) {
|
|
|
145
157
|
return cssStyleSheets.map(function (cssStyleSheet) {
|
|
146
158
|
var rules = cssStyleSheet.cssRules || cssStyleSheet.rules;
|
|
147
159
|
var cssRules = Array.from(rules, function (cssRule) {
|
|
148
|
-
return cssRule.cssText;
|
|
160
|
+
return cssRule.cssText ? validateStringifiedCssRule(rule.cssText) : '';
|
|
149
161
|
});
|
|
150
162
|
var styleSheet = {
|
|
151
163
|
cssRules: cssRules,
|
|
@@ -321,6 +321,26 @@ function getValidTagName(tagName) {
|
|
|
321
321
|
|
|
322
322
|
return processedTagName;
|
|
323
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Browsers sometimes destructively modify the css rules they receive.
|
|
326
|
+
* This function tries to rectify the modifications the browser made to make it more cross platform compatible.
|
|
327
|
+
* @param cssText - output of `CSSStyleRule.cssText`
|
|
328
|
+
* @returns `cssText` with browser inconsistencies fixed.
|
|
329
|
+
*/
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
333
|
+
/**
|
|
334
|
+
* Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
|
|
335
|
+
* But then Chrome ignores `background-clip` as css input.
|
|
336
|
+
* Re-introduce `-webkit-background-clip` to fix this issue.
|
|
337
|
+
*/
|
|
338
|
+
if (cssText.includes(' background-clip: text;') && !cssText.includes(' -webkit-background-clip: text;')) {
|
|
339
|
+
cssText = cssText.replace(' background-clip: text;', ' -webkit-background-clip: text; background-clip: text;');
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return cssText;
|
|
343
|
+
}
|
|
324
344
|
|
|
325
345
|
function getCssRulesString(cssStyleSheet) {
|
|
326
346
|
if (!cssStyleSheet) {
|
|
@@ -338,12 +358,21 @@ function getCssRulesString(cssStyleSheet) {
|
|
|
338
358
|
return null;
|
|
339
359
|
}
|
|
340
360
|
|
|
341
|
-
var styleSheetCssText = Array.from(rules, getCssRuleString).join('');
|
|
361
|
+
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(Array.from(rules, getCssRuleString).join(''));
|
|
342
362
|
return (0, _serializationUtils.switchToAbsoluteUrl)(styleSheetCssText, cssStyleSheet.href);
|
|
343
363
|
}
|
|
344
364
|
|
|
345
365
|
function getCssRuleString(rule) {
|
|
346
|
-
|
|
366
|
+
var cssStringified = rule.cssText;
|
|
367
|
+
|
|
368
|
+
if (isCSSImportRule(rule)) {
|
|
369
|
+
try {
|
|
370
|
+
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
371
|
+
} catch (_unused2) {// ignore
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
return (0, _serializationUtils.validateStringifiedCssRule)(cssStringified);
|
|
347
376
|
}
|
|
348
377
|
|
|
349
378
|
function isCSSImportRule(rule) {
|
|
@@ -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
|
}
|
|
@@ -63,12 +63,17 @@ function startRumSessionManager(configuration, lifeCycle) {
|
|
|
63
63
|
|
|
64
64
|
function startRumSessionManagerStub() {
|
|
65
65
|
var session = {
|
|
66
|
-
id: '00000000-aaaa-0000-aaaa-000000000000'
|
|
66
|
+
id: '00000000-aaaa-0000-aaaa-000000000000',
|
|
67
|
+
plan: RumSessionPlan.WITHOUT_SESSION_REPLAY,
|
|
68
|
+
// plan value should not be taken into account for mobile
|
|
69
|
+
sessionReplayAllowed: false
|
|
67
70
|
};
|
|
68
71
|
return {
|
|
69
72
|
findTrackedSession: function findTrackedSession() {
|
|
70
73
|
return session;
|
|
71
|
-
}
|
|
74
|
+
},
|
|
75
|
+
expire: _browserCore.noop,
|
|
76
|
+
expireObservable: new _browserCore.Observable()
|
|
72
77
|
};
|
|
73
78
|
}
|
|
74
79
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.startRumEventBridge = startRumEventBridge;
|
|
7
|
+
|
|
8
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
9
|
+
|
|
10
|
+
function startRumEventBridge(lifeCycle) {
|
|
11
|
+
var bridge = (0, _browserCore.getEventBridge)();
|
|
12
|
+
lifeCycle.subscribe(_browserCore.LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
|
|
13
|
+
var data = (0, _browserCore.processedMessageByDataMap)(serverRumEvent).rowData;
|
|
14
|
+
bridge.send('rum', data);
|
|
15
|
+
});
|
|
16
|
+
}
|
package/esm/boot/buildEnv.js
CHANGED
package/esm/boot/recorderApi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { noop, runOnReadyState, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
1
|
+
import { noop, runOnReadyState, LifeCycleEventType, canUseEventBridge } from '@cloudcare/browser-core';
|
|
2
2
|
import { getReplayStats } from '../domain/replay/replayStats';
|
|
3
3
|
import { startDeflateWorker } from '../domain/replay/segmentCollection';
|
|
4
4
|
var RecorderStatus = {
|
|
@@ -17,7 +17,7 @@ export function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
|
|
|
17
17
|
startDeflateWorkerImpl = startDeflateWorker;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
if (!isBrowserSupported()) {
|
|
20
|
+
if (canUseEventBridge() || !isBrowserSupported()) {
|
|
21
21
|
return {
|
|
22
22
|
start: noop,
|
|
23
23
|
stop: noop,
|
package/esm/boot/rum.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { startRumSessionManager } from '../domain/rumSessionManager';
|
|
1
|
+
import { startRumSessionManager, startRumSessionManagerStub } from '../domain/rumSessionManager';
|
|
2
2
|
import { startCacheUsrCache } from '../domain/usr';
|
|
3
|
-
import { LifeCycle, LifeCycleEventType, createPageExitObservable } from '@cloudcare/browser-core';
|
|
3
|
+
import { LifeCycle, LifeCycleEventType, createPageExitObservable, canUseEventBridge } from '@cloudcare/browser-core';
|
|
4
4
|
import { startPerformanceCollection } from '../domain/performanceCollection';
|
|
5
5
|
import { createDOMMutationObservable } from '../domain/domMutationCollection';
|
|
6
6
|
import { createLocationChangeObservable } from '../domain/locationChangeObservable';
|
|
7
7
|
import { startLongTaskCollection } from '../domain/rumEventsCollection/longTask/longTaskCollection';
|
|
8
8
|
import { startActionCollection } from '../domain/rumEventsCollection/actions/actionCollection';
|
|
9
9
|
import { startRumBatch } from '../transport/startRumBatch';
|
|
10
|
+
import { startRumEventBridge } from '../transport/startRumEventBridge';
|
|
10
11
|
import { startRumAssembly } from '../domain/assembly';
|
|
11
12
|
import { startInternalContext } from '../domain/contexts/internalContext';
|
|
12
13
|
import { startForegroundContexts } from '../domain/contexts/foregroundContexts';
|
|
@@ -30,8 +31,14 @@ export function startRum(configuration, recorderApi, globalContextManager, userC
|
|
|
30
31
|
pageExitObservable.subscribe(function (event) {
|
|
31
32
|
lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event);
|
|
32
33
|
});
|
|
33
|
-
var session = startRumSessionManager(configuration, lifeCycle);
|
|
34
|
-
|
|
34
|
+
var session = !canUseEventBridge() ? startRumSessionManager(configuration, lifeCycle) : startRumSessionManagerStub();
|
|
35
|
+
|
|
36
|
+
if (!canUseEventBridge()) {
|
|
37
|
+
var batch = startRumBatch(configuration, lifeCycle, reportError, pageExitObservable, session.expireObservable);
|
|
38
|
+
} else {
|
|
39
|
+
startRumEventBridge(lifeCycle);
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
var userSession = startCacheUsrCache(configuration);
|
|
36
43
|
var domMutationObservable = createDOMMutationObservable();
|
|
37
44
|
var locationChangeObservable = createLocationChangeObservable(location);
|
package/esm/boot/rumPublicApi.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
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
|
+
|
|
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';
|
|
4
6
|
export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
@@ -61,6 +63,16 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
function initRum(initConfiguration) {
|
|
66
|
+
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
67
|
+
return deepClone(initConfiguration);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var eventBridgeAvailable = canUseEventBridge();
|
|
71
|
+
|
|
72
|
+
if (eventBridgeAvailable) {
|
|
73
|
+
initConfiguration = overrideInitConfigurationForBridge(initConfiguration);
|
|
74
|
+
}
|
|
75
|
+
|
|
64
76
|
if (!canHandleSession(initConfiguration)) {
|
|
65
77
|
return;
|
|
66
78
|
}
|
|
@@ -91,10 +103,6 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
91
103
|
beforeInitCalls.drain();
|
|
92
104
|
}
|
|
93
105
|
|
|
94
|
-
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
95
|
-
return deepClone(initConfiguration);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
106
|
isAlreadyInitialized = true;
|
|
99
107
|
}
|
|
100
108
|
|
|
@@ -111,7 +119,7 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
111
119
|
}
|
|
112
120
|
|
|
113
121
|
var startView = function startView(options) {
|
|
114
|
-
var sanitizedOptions =
|
|
122
|
+
var sanitizedOptions = _typeof(options) === 'object' ? options : {
|
|
115
123
|
name: options
|
|
116
124
|
};
|
|
117
125
|
|
|
@@ -222,4 +230,11 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
222
230
|
function isLocalFile() {
|
|
223
231
|
return window.location.protocol === 'file:';
|
|
224
232
|
}
|
|
233
|
+
|
|
234
|
+
function overrideInitConfigurationForBridge(initConfiguration) {
|
|
235
|
+
return assign({}, initConfiguration, {
|
|
236
|
+
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
|
|
237
|
+
sessionSampleRate: 100
|
|
238
|
+
});
|
|
239
|
+
}
|
|
225
240
|
}
|
|
@@ -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() {
|