@cloudcare/browser-rum 3.0.18 → 3.0.20
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/serializationUtils.js +13 -1
- package/cjs/domain/replay/record/serialize.js +31 -2
- package/cjs/domain/rumSessionManager.js +7 -2
- package/cjs/domain/tracing/tracer.js +4 -3
- package/cjs/domain/tracing/w3cTraceParentTracer.js +12 -1
- 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 +18 -5
- package/esm/domain/replay/record/serializationUtils.js +11 -1
- package/esm/domain/replay/record/serialize.js +32 -3
- package/esm/domain/rumSessionManager.js +8 -3
- package/esm/domain/tracing/tracer.js +4 -3
- package/esm/domain/tracing/w3cTraceParentTracer.js +11 -1
- package/esm/transport/startRumEventBridge.js +8 -0
- package/package.json +3 -3
- package/src/boot/recorderApi.js +3 -2
- 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/rumSessionManager.js +9 -3
- package/src/domain/tracing/tracer.js +3 -3
- package/src/domain/tracing/w3cTraceParentTracer.js +9 -2
- package/src/transport/startRumEventBridge.js +17 -0
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
|
}
|
|
@@ -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) {
|
|
@@ -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
|
|
|
@@ -28,9 +28,10 @@ function isTracingOption(item) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function clearTracingIfNeeded(context) {
|
|
31
|
-
if (context.status === 0 && !context.isAborted) {
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (context.status === 0 && !context.isAborted) {
|
|
32
|
+
context.traceId = undefined;
|
|
33
|
+
context.spanId = undefined;
|
|
34
|
+
context.traceSampled = undefined;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -7,6 +7,8 @@ exports.W3cTraceParentTracer = W3cTraceParentTracer;
|
|
|
7
7
|
|
|
8
8
|
var _traceIdentifier = require("./traceIdentifier");
|
|
9
9
|
|
|
10
|
+
var _browserCore = require("@cloudcare/browser-core");
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
*
|
|
12
14
|
* @param {*} traceSampled
|
|
@@ -34,8 +36,17 @@ W3cTraceParentTracer.prototype = {
|
|
|
34
36
|
return '00-0000000000000000' + this._traceId.toPaddedHexadecimalString() + '-' + this._spanId.toPaddedHexadecimalString() + '-' + (this._traceSampled ? '01' : '00');
|
|
35
37
|
},
|
|
36
38
|
makeTracingHeaders: function makeTracingHeaders() {
|
|
37
|
-
|
|
39
|
+
var baseHeaders = {
|
|
38
40
|
traceparent: this.getTraceParent()
|
|
39
41
|
};
|
|
42
|
+
|
|
43
|
+
if (this.isHexTraceId) {
|
|
44
|
+
return (0, _browserCore.assign)(baseHeaders, {
|
|
45
|
+
'x-gc-trace-id': this.getTraceId(),
|
|
46
|
+
'x-gc-span-id': this.getSpanId()
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return baseHeaders;
|
|
40
51
|
}
|
|
41
52
|
};
|
|
@@ -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,4 @@
|
|
|
1
|
-
import { makePublicApi, areCookiesAuthorized, BoundedBuffer, display, buildCookieOptions, createContextManager, CustomerDataType, clocksNow, timeStampNow, ActionType, deepClone, createHandlingStack, sanitizeUser, checkUser, noop } from '@cloudcare/browser-core';
|
|
1
|
+
import { makePublicApi, areCookiesAuthorized, BoundedBuffer, display, buildCookieOptions, createContextManager, CustomerDataType, clocksNow, timeStampNow, ActionType, deepClone, createHandlingStack, sanitizeUser, checkUser, noop, assign, canUseEventBridge } from '@cloudcare/browser-core';
|
|
2
2
|
import { validateAndBuildRumConfiguration } from '../domain/configuration';
|
|
3
3
|
import { buildCommonContext } from '../domain/contexts/commonContext';
|
|
4
4
|
export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
@@ -61,6 +61,16 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
function initRum(initConfiguration) {
|
|
64
|
+
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
65
|
+
return deepClone(initConfiguration);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
var eventBridgeAvailable = canUseEventBridge();
|
|
69
|
+
|
|
70
|
+
if (eventBridgeAvailable) {
|
|
71
|
+
initConfiguration = overrideInitConfigurationForBridge(initConfiguration);
|
|
72
|
+
}
|
|
73
|
+
|
|
64
74
|
if (!canHandleSession(initConfiguration)) {
|
|
65
75
|
return;
|
|
66
76
|
}
|
|
@@ -91,10 +101,6 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
91
101
|
beforeInitCalls.drain();
|
|
92
102
|
}
|
|
93
103
|
|
|
94
|
-
getInitConfigurationStrategy = function getInitConfigurationStrategy() {
|
|
95
|
-
return deepClone(initConfiguration);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
104
|
isAlreadyInitialized = true;
|
|
99
105
|
}
|
|
100
106
|
|
|
@@ -222,4 +228,11 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
222
228
|
function isLocalFile() {
|
|
223
229
|
return window.location.protocol === 'file:';
|
|
224
230
|
}
|
|
231
|
+
|
|
232
|
+
function overrideInitConfigurationForBridge(initConfiguration) {
|
|
233
|
+
return assign({}, initConfiguration, {
|
|
234
|
+
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
|
|
235
|
+
sessionSampleRate: 100
|
|
236
|
+
});
|
|
237
|
+
}
|
|
225
238
|
}
|
|
@@ -106,6 +106,16 @@ export function makeUrlAbsolute(url, baseUrl) {
|
|
|
106
106
|
return url;
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
+
export function validateStringifiedCssRule(cssStringified) {
|
|
110
|
+
// Safari does not escape selectors with : properly
|
|
111
|
+
if (cssStringified.includes(':')) {
|
|
112
|
+
// Replace e.g. [aa:bb] with [aa\\:bb]
|
|
113
|
+
var regex = /(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;
|
|
114
|
+
return cssStringified.replace(regex, '$1\\$2');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return cssStringified;
|
|
118
|
+
}
|
|
109
119
|
export function serializeStyleSheets(cssStyleSheets) {
|
|
110
120
|
if (cssStyleSheets === undefined || cssStyleSheets.length === 0) {
|
|
111
121
|
return undefined;
|
|
@@ -114,7 +124,7 @@ export function serializeStyleSheets(cssStyleSheets) {
|
|
|
114
124
|
return cssStyleSheets.map(function (cssStyleSheet) {
|
|
115
125
|
var rules = cssStyleSheet.cssRules || cssStyleSheet.rules;
|
|
116
126
|
var cssRules = Array.from(rules, function (cssRule) {
|
|
117
|
-
return cssRule.cssText;
|
|
127
|
+
return cssRule.cssText ? validateStringifiedCssRule(rule.cssText) : '';
|
|
118
128
|
});
|
|
119
129
|
var styleSheet = {
|
|
120
130
|
cssRules: cssRules,
|
|
@@ -3,7 +3,7 @@ import { STABLE_ATTRIBUTES } from '../../rumEventsCollection/actions/getSelector
|
|
|
3
3
|
import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_HIDDEN, CENSORED_STRING_MARK, CENSORED_IMG_MARK } from '../../../constants';
|
|
4
4
|
import { NodeType } from '../../../types';
|
|
5
5
|
import { getTextContent, shouldMaskNode, reducePrivacyLevel, getNodeSelfPrivacyLevel, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './privacy';
|
|
6
|
-
import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, absoluteToDoc, getAbsoluteSrcsetString } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
|
|
6
|
+
import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, absoluteToDoc, getAbsoluteSrcsetString, validateStringifiedCssRule } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
|
|
7
7
|
// children during serialization, since HIDDEN and IGNORE shouldn't serialize their children. This
|
|
8
8
|
// ensures that no children are serialized when they shouldn't.
|
|
9
9
|
|
|
@@ -295,6 +295,26 @@ function getValidTagName(tagName) {
|
|
|
295
295
|
|
|
296
296
|
return processedTagName;
|
|
297
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* Browsers sometimes destructively modify the css rules they receive.
|
|
300
|
+
* This function tries to rectify the modifications the browser made to make it more cross platform compatible.
|
|
301
|
+
* @param cssText - output of `CSSStyleRule.cssText`
|
|
302
|
+
* @returns `cssText` with browser inconsistencies fixed.
|
|
303
|
+
*/
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
function fixBrowserCompatibilityIssuesInCSS(cssText) {
|
|
307
|
+
/**
|
|
308
|
+
* Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
|
|
309
|
+
* But then Chrome ignores `background-clip` as css input.
|
|
310
|
+
* Re-introduce `-webkit-background-clip` to fix this issue.
|
|
311
|
+
*/
|
|
312
|
+
if (cssText.includes(' background-clip: text;') && !cssText.includes(' -webkit-background-clip: text;')) {
|
|
313
|
+
cssText = cssText.replace(' background-clip: text;', ' -webkit-background-clip: text; background-clip: text;');
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return cssText;
|
|
317
|
+
}
|
|
298
318
|
|
|
299
319
|
function getCssRulesString(cssStyleSheet) {
|
|
300
320
|
if (!cssStyleSheet) {
|
|
@@ -312,12 +332,21 @@ function getCssRulesString(cssStyleSheet) {
|
|
|
312
332
|
return null;
|
|
313
333
|
}
|
|
314
334
|
|
|
315
|
-
var styleSheetCssText = Array.from(rules, getCssRuleString).join('');
|
|
335
|
+
var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(Array.from(rules, getCssRuleString).join(''));
|
|
316
336
|
return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href);
|
|
317
337
|
}
|
|
318
338
|
|
|
319
339
|
function getCssRuleString(rule) {
|
|
320
|
-
|
|
340
|
+
var cssStringified = rule.cssText;
|
|
341
|
+
|
|
342
|
+
if (isCSSImportRule(rule)) {
|
|
343
|
+
try {
|
|
344
|
+
cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
|
|
345
|
+
} catch (_unused2) {// ignore
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
return validateStringifiedCssRule(cssStringified);
|
|
321
350
|
}
|
|
322
351
|
|
|
323
352
|
function isCSSImportRule(rule) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { performDraw, startSessionManager, LifeCycleEventType } from '@cloudcare/browser-core';
|
|
1
|
+
import { performDraw, startSessionManager, LifeCycleEventType, noop, Observable } from '@cloudcare/browser-core';
|
|
2
2
|
export var RUM_SESSION_KEY = 'rum';
|
|
3
3
|
export var RumSessionPlan = {
|
|
4
4
|
WITHOUT_SESSION_REPLAY: 1,
|
|
@@ -48,12 +48,17 @@ export function startRumSessionManager(configuration, lifeCycle) {
|
|
|
48
48
|
|
|
49
49
|
export function startRumSessionManagerStub() {
|
|
50
50
|
var session = {
|
|
51
|
-
id: '00000000-aaaa-0000-aaaa-000000000000'
|
|
51
|
+
id: '00000000-aaaa-0000-aaaa-000000000000',
|
|
52
|
+
plan: RumSessionPlan.WITHOUT_SESSION_REPLAY,
|
|
53
|
+
// plan value should not be taken into account for mobile
|
|
54
|
+
sessionReplayAllowed: false
|
|
52
55
|
};
|
|
53
56
|
return {
|
|
54
57
|
findTrackedSession: function findTrackedSession() {
|
|
55
58
|
return session;
|
|
56
|
-
}
|
|
59
|
+
},
|
|
60
|
+
expire: noop,
|
|
61
|
+
expireObservable: new Observable()
|
|
57
62
|
};
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -10,9 +10,10 @@ export function isTracingOption(item) {
|
|
|
10
10
|
return getType(expectedItem) === 'object' && isMatchOption(expectedItem.match) && isString(expectedItem.traceType);
|
|
11
11
|
}
|
|
12
12
|
export function clearTracingIfNeeded(context) {
|
|
13
|
-
if (context.status === 0 && !context.isAborted) {
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (context.status === 0 && !context.isAborted) {
|
|
14
|
+
context.traceId = undefined;
|
|
15
|
+
context.spanId = undefined;
|
|
16
|
+
context.traceSampled = undefined;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
export function startTracer(configuration, sessionManager) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TraceIdentifier, getCrypto } from './traceIdentifier';
|
|
2
|
+
import { assign } from '@cloudcare/browser-core';
|
|
2
3
|
/**
|
|
3
4
|
*
|
|
4
5
|
* @param {*} traceSampled
|
|
@@ -26,8 +27,17 @@ W3cTraceParentTracer.prototype = {
|
|
|
26
27
|
return '00-0000000000000000' + this._traceId.toPaddedHexadecimalString() + '-' + this._spanId.toPaddedHexadecimalString() + '-' + (this._traceSampled ? '01' : '00');
|
|
27
28
|
},
|
|
28
29
|
makeTracingHeaders: function makeTracingHeaders() {
|
|
29
|
-
|
|
30
|
+
var baseHeaders = {
|
|
30
31
|
traceparent: this.getTraceParent()
|
|
31
32
|
};
|
|
33
|
+
|
|
34
|
+
if (this.isHexTraceId) {
|
|
35
|
+
return assign(baseHeaders, {
|
|
36
|
+
'x-gc-trace-id': this.getTraceId(),
|
|
37
|
+
'x-gc-span-id': this.getSpanId()
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return baseHeaders;
|
|
32
42
|
}
|
|
33
43
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getEventBridge, LifeCycleEventType, processedMessageByDataMap } from '@cloudcare/browser-core';
|
|
2
|
+
export function startRumEventBridge(lifeCycle) {
|
|
3
|
+
var bridge = getEventBridge();
|
|
4
|
+
lifeCycle.subscribe(LifeCycleEventType.RUM_EVENT_COLLECTED, function (serverRumEvent) {
|
|
5
|
+
var data = processedMessageByDataMap(serverRumEvent).rowData;
|
|
6
|
+
bridge.send('rum', data);
|
|
7
|
+
});
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudcare/browser-rum",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.20",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@cloudcare/browser-core": "2.0.
|
|
7
|
+
"@cloudcare/browser-core": "2.0.18"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "webpack serve --open --mode=development",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
|
|
31
31
|
"description": "DataFlux RUM Web 端数据指标监控",
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "95a35040844e8959ebf322eeeeb1269fc369e679"
|
|
33
33
|
}
|
package/src/boot/recorderApi.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
noop,
|
|
3
3
|
runOnReadyState,
|
|
4
|
-
LifeCycleEventType
|
|
4
|
+
LifeCycleEventType,
|
|
5
|
+
canUseEventBridge
|
|
5
6
|
} from '@cloudcare/browser-core'
|
|
6
7
|
|
|
7
8
|
import { getReplayStats } from '../domain/replay/replayStats'
|
|
@@ -23,7 +24,7 @@ export function makeRecorderApi(startRecordingImpl, startDeflateWorkerImpl) {
|
|
|
23
24
|
if (typeof startDeflateWorkerImpl === 'undefined') {
|
|
24
25
|
startDeflateWorkerImpl = startDeflateWorker
|
|
25
26
|
}
|
|
26
|
-
if (!isBrowserSupported()) {
|
|
27
|
+
if (canUseEventBridge() || !isBrowserSupported()) {
|
|
27
28
|
return {
|
|
28
29
|
start: noop,
|
|
29
30
|
stop: noop,
|
package/src/boot/rum.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
startRumSessionManager,
|
|
3
|
+
startRumSessionManagerStub
|
|
4
|
+
} from '../domain/rumSessionManager'
|
|
2
5
|
import { startCacheUsrCache } from '../domain/usr'
|
|
3
6
|
import {
|
|
4
7
|
LifeCycle,
|
|
5
8
|
LifeCycleEventType,
|
|
6
|
-
createPageExitObservable
|
|
9
|
+
createPageExitObservable,
|
|
10
|
+
canUseEventBridge
|
|
7
11
|
} from '@cloudcare/browser-core'
|
|
8
12
|
import { startPerformanceCollection } from '../domain/performanceCollection'
|
|
9
13
|
import { createDOMMutationObservable } from '../domain/domMutationCollection'
|
|
@@ -11,6 +15,7 @@ import { createLocationChangeObservable } from '../domain/locationChangeObservab
|
|
|
11
15
|
import { startLongTaskCollection } from '../domain/rumEventsCollection/longTask/longTaskCollection'
|
|
12
16
|
import { startActionCollection } from '../domain/rumEventsCollection/actions/actionCollection'
|
|
13
17
|
import { startRumBatch } from '../transport/startRumBatch'
|
|
18
|
+
import { startRumEventBridge } from '../transport/startRumEventBridge'
|
|
14
19
|
import { startRumAssembly } from '../domain/assembly'
|
|
15
20
|
import { startInternalContext } from '../domain/contexts/internalContext'
|
|
16
21
|
import { startForegroundContexts } from '../domain/contexts/foregroundContexts'
|
|
@@ -37,15 +42,22 @@ export function startRum(
|
|
|
37
42
|
pageExitObservable.subscribe(function (event) {
|
|
38
43
|
lifeCycle.notify(LifeCycleEventType.PAGE_EXITED, event)
|
|
39
44
|
})
|
|
40
|
-
var session = startRumSessionManager(configuration, lifeCycle)
|
|
41
45
|
|
|
42
|
-
var
|
|
43
|
-
configuration,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
var session = !canUseEventBridge()
|
|
47
|
+
? startRumSessionManager(configuration, lifeCycle)
|
|
48
|
+
: startRumSessionManagerStub()
|
|
49
|
+
if (!canUseEventBridge()) {
|
|
50
|
+
var batch = startRumBatch(
|
|
51
|
+
configuration,
|
|
52
|
+
lifeCycle,
|
|
53
|
+
reportError,
|
|
54
|
+
pageExitObservable,
|
|
55
|
+
session.expireObservable
|
|
56
|
+
)
|
|
57
|
+
} else {
|
|
58
|
+
startRumEventBridge(lifeCycle)
|
|
59
|
+
}
|
|
60
|
+
|
|
49
61
|
var userSession = startCacheUsrCache(configuration)
|
|
50
62
|
var domMutationObservable = createDOMMutationObservable()
|
|
51
63
|
var locationChangeObservable = createLocationChangeObservable(location)
|
package/src/boot/rumPublicApi.js
CHANGED
|
@@ -13,7 +13,9 @@ import {
|
|
|
13
13
|
createHandlingStack,
|
|
14
14
|
sanitizeUser,
|
|
15
15
|
checkUser,
|
|
16
|
-
noop
|
|
16
|
+
noop,
|
|
17
|
+
assign,
|
|
18
|
+
canUseEventBridge
|
|
17
19
|
} from '@cloudcare/browser-core'
|
|
18
20
|
import { validateAndBuildRumConfiguration } from '../domain/configuration'
|
|
19
21
|
import { buildCommonContext } from '../domain/contexts/commonContext'
|
|
@@ -77,6 +79,13 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
function initRum(initConfiguration) {
|
|
82
|
+
getInitConfigurationStrategy = function () {
|
|
83
|
+
return deepClone(initConfiguration)
|
|
84
|
+
}
|
|
85
|
+
var eventBridgeAvailable = canUseEventBridge()
|
|
86
|
+
if (eventBridgeAvailable) {
|
|
87
|
+
initConfiguration = overrideInitConfigurationForBridge(initConfiguration)
|
|
88
|
+
}
|
|
80
89
|
if (!canHandleSession(initConfiguration)) {
|
|
81
90
|
return
|
|
82
91
|
}
|
|
@@ -104,9 +113,6 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
104
113
|
}
|
|
105
114
|
beforeInitCalls.drain()
|
|
106
115
|
}
|
|
107
|
-
getInitConfigurationStrategy = function () {
|
|
108
|
-
return deepClone(initConfiguration)
|
|
109
|
-
}
|
|
110
116
|
|
|
111
117
|
isAlreadyInitialized = true
|
|
112
118
|
}
|
|
@@ -235,4 +241,10 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
|
|
|
235
241
|
function isLocalFile() {
|
|
236
242
|
return window.location.protocol === 'file:'
|
|
237
243
|
}
|
|
244
|
+
function overrideInitConfigurationForBridge(initConfiguration) {
|
|
245
|
+
return assign({}, initConfiguration, {
|
|
246
|
+
applicationId: '00000000-aaaa-0000-aaaa-000000000000',
|
|
247
|
+
sessionSampleRate: 100
|
|
248
|
+
})
|
|
249
|
+
}
|
|
238
250
|
}
|