@cloudcare/browser-rum 3.0.26 → 3.0.29

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.
Files changed (40) hide show
  1. package/bundle/dataflux-rum.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/rumPublicApi.js +37 -38
  4. package/cjs/domain/assembly.js +4 -6
  5. package/cjs/domain/domMutationCollection.js +2 -2
  6. package/cjs/domain/performanceCollection.js +2 -3
  7. package/cjs/domain/replay/record/mutationBatch.js +22 -17
  8. package/cjs/domain/replay/record/mutationObserver.js +1 -1
  9. package/cjs/domain/replay/record/observers.js +1 -1
  10. package/cjs/domain/replay/record/privacy.js +15 -0
  11. package/cjs/domain/replay/record/serializationUtils.js +74 -1
  12. package/cjs/domain/replay/record/serialize.js +5 -72
  13. package/cjs/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
  14. package/cjs/domain/rumEventsCollection/resource/resourceUtils.js +2 -1
  15. package/esm/boot/buildEnv.js +1 -1
  16. package/esm/boot/rumPublicApi.js +38 -39
  17. package/esm/domain/assembly.js +4 -6
  18. package/esm/domain/domMutationCollection.js +3 -3
  19. package/esm/domain/performanceCollection.js +3 -4
  20. package/esm/domain/replay/record/mutationBatch.js +22 -17
  21. package/esm/domain/replay/record/mutationObserver.js +2 -2
  22. package/esm/domain/replay/record/observers.js +2 -2
  23. package/esm/domain/replay/record/privacy.js +14 -0
  24. package/esm/domain/replay/record/serializationUtils.js +62 -1
  25. package/esm/domain/replay/record/serialize.js +2 -69
  26. package/esm/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
  27. package/esm/domain/rumEventsCollection/resource/resourceUtils.js +2 -1
  28. package/package.json +4 -4
  29. package/src/boot/rumPublicApi.js +41 -38
  30. package/src/domain/assembly.js +4 -6
  31. package/src/domain/domMutationCollection.js +20 -17
  32. package/src/domain/performanceCollection.js +4 -3
  33. package/src/domain/replay/record/mutationBatch.js +21 -3
  34. package/src/domain/replay/record/mutationObserver.js +3 -2
  35. package/src/domain/replay/record/observers.js +5 -2
  36. package/src/domain/replay/record/privacy.js +22 -0
  37. package/src/domain/replay/record/serializationUtils.js +64 -2
  38. package/src/domain/replay/record/serialize.js +5 -68
  39. package/src/domain/rumEventsCollection/actions/getSelectorsFromElement.js +4 -4
  40. package/src/domain/rumEventsCollection/resource/resourceUtils.js +4 -1
@@ -1,6 +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
2
 
3
- import { makePublicApi, areCookiesAuthorized, BoundedBuffer, display, buildCookieOptions, createContextManager, CustomerDataType, clocksNow, timeStampNow, ActionType, deepClone, createHandlingStack, sanitizeUser, checkUser, noop, assign, canUseEventBridge } from '@cloudcare/browser-core';
3
+ import { makePublicApi, areCookiesAuthorized, BoundedBuffer, display, buildCookieOptions, createContextManager, CustomerDataType, clocksNow, timeStampNow, ActionType, deepClone, createHandlingStack, sanitizeUser, checkUser, noop, assign, canUseEventBridge, monitor } from '@cloudcare/browser-core';
4
4
  import { validateAndBuildRumConfiguration } from '../domain/configuration';
5
5
  import { buildCommonContext } from '../domain/contexts/commonContext';
6
6
  export function makeRumPublicApi(startRumImpl, recorderApi) {
@@ -118,51 +118,50 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
118
118
  recorderApi.onRumStart(startRumResults.lifeCycle, configuration, startRumResults.session, startRumResults.viewContexts);
119
119
  }
120
120
 
121
- var startView = function startView(options) {
121
+ var startView = monitor(function (options) {
122
122
  var sanitizedOptions = _typeof(options) === 'object' ? options : {
123
123
  name: options
124
124
  };
125
125
 
126
126
  _startViewStrategy(sanitizedOptions);
127
- };
128
-
127
+ });
129
128
  var rumPublicApi = makePublicApi({
130
- init: initRum,
129
+ init: monitor(initRum),
131
130
 
132
131
  /** @deprecated: use setGlobalContextProperty instead */
133
- addRumGlobalContext: globalContextManager.add,
134
- setGlobalContextProperty: globalContextManager.setContextProperty,
132
+ addRumGlobalContext: monitor(globalContextManager.add),
133
+ setGlobalContextProperty: monitor(globalContextManager.setContextProperty),
135
134
 
136
135
  /** @deprecated: use removeGlobalContextProperty instead */
137
- removeRumGlobalContext: globalContextManager.remove,
138
- removeGlobalContextProperty: globalContextManager.removeContextProperty,
136
+ removeRumGlobalContext: monitor(globalContextManager.remove),
137
+ removeGlobalContextProperty: monitor(globalContextManager.removeContextProperty),
139
138
 
140
139
  /** @deprecated: use getGlobalContext instead */
141
- getRumGlobalContext: globalContextManager.get,
142
- getGlobalContext: globalContextManager.getContext,
140
+ getRumGlobalContext: monitor(globalContextManager.get),
141
+ getGlobalContext: monitor(globalContextManager.getContext),
143
142
 
144
143
  /** @deprecated: use setGlobalContext instead */
145
- setRumGlobalContext: globalContextManager.set,
146
- setGlobalContext: globalContextManager.setContext,
147
- clearGlobalContext: globalContextManager.clearContext,
148
- getInitConfiguration: function getInitConfiguration() {
144
+ setRumGlobalContext: monitor(globalContextManager.set),
145
+ setGlobalContext: monitor(globalContextManager.setContext),
146
+ clearGlobalContext: monitor(globalContextManager.clearContext),
147
+ getInitConfiguration: monitor(function () {
149
148
  return getInitConfigurationStrategy();
150
- },
151
- getInternalContext: function getInternalContext(startTime) {
149
+ }),
150
+ getInternalContext: monitor(function (startTime) {
152
151
  return getInternalContextStrategy(startTime);
153
- },
154
- addDebugSession: function addDebugSession(id) {},
155
- clearDebugSession: function clearDebugSession() {},
156
- getDebugSession: function getDebugSession() {},
157
- addAction: function addAction(name, context) {
152
+ }),
153
+ addDebugSession: monitor(function (id) {}),
154
+ clearDebugSession: monitor(function () {}),
155
+ getDebugSession: monitor(function () {}),
156
+ addAction: monitor(function (name, context) {
158
157
  _addActionStrategy({
159
158
  name: name,
160
159
  context: deepClone(context),
161
160
  startClocks: clocksNow(),
162
161
  type: ActionType.CUSTOM
163
162
  });
164
- },
165
- addError: function addError(error, context) {
163
+ }),
164
+ addError: monitor(function (error, context) {
166
165
  var handlingStack = createHandlingStack();
167
166
 
168
167
  _addErrorStrategy({
@@ -171,33 +170,33 @@ export function makeRumPublicApi(startRumImpl, recorderApi) {
171
170
  context: deepClone(context),
172
171
  startClocks: clocksNow()
173
172
  });
174
- },
175
- addTiming: function addTiming(name, time) {
173
+ }),
174
+ addTiming: monitor(function (name, time) {
176
175
  _addTimingStrategy(name, time);
177
- },
178
- setUser: function setUser(newUser) {
176
+ }),
177
+ setUser: monitor(function (newUser) {
179
178
  if (checkUser(newUser)) {
180
179
  userContextManager.setContext(sanitizeUser(newUser));
181
180
  }
182
- },
183
- getUser: userContextManager.getContext,
184
- setUserProperty: function setUserProperty(key, property) {
181
+ }),
182
+ getUser: monitor(userContextManager.getContext),
183
+ setUserProperty: monitor(function (key, property) {
185
184
  var newUser = {};
186
185
  newUser[key] = property;
187
186
  var sanitizedProperty = sanitizeUser(newUser)[key];
188
187
  userContextManager.setContextProperty(key, sanitizedProperty);
189
- },
190
- removeUserProperty: userContextManager.removeContextProperty,
188
+ }),
189
+ removeUserProperty: monitor(userContextManager.removeContextProperty),
191
190
 
192
191
  /** @deprecated: renamed to clearUser */
193
- removeUser: userContextManager.clearContext,
194
- clearUser: userContextManager.clearContext,
192
+ removeUser: monitor(userContextManager.clearContext),
193
+ clearUser: monitor(userContextManager.clearContext),
195
194
  startView: startView,
196
- stopSession: function stopSession() {
195
+ stopSession: monitor(function () {
197
196
  stopSessionStrategy();
198
- },
199
- startSessionReplayRecording: recorderApi.start,
200
- stopSessionReplayRecording: recorderApi.stop
197
+ }),
198
+ startSessionReplayRecording: monitor(recorderApi.start),
199
+ stopSessionReplayRecording: monitor(recorderApi.stop)
201
200
  });
202
201
  return rumPublicApi;
203
202
 
@@ -8,9 +8,7 @@ var VIEW_MODIFIABLE_FIELD_PATHS = {
8
8
  'view.referrer': 'string'
9
9
  };
10
10
  var USER_CUSTOMIZABLE_FIELD_PATHS = {
11
- tags: 'object',
12
- '_gc.trace_id': 'string',
13
- '_gc.span_id': 'string'
11
+ context: 'object'
14
12
  };
15
13
  var modifiableFieldPathsByEvent = {};
16
14
  export function startRumAssembly(configuration, lifeCycle, sessionManager, userSessionManager, viewContexts, urlContexts, actionContexts, buildCommonContext, reportError) {
@@ -90,7 +88,7 @@ export function startRumAssembly(configuration, lifeCycle, sessionManager, userS
90
88
  var context = extend2Lev({}, commonContext.context, customerContext);
91
89
 
92
90
  if (!isEmptyObject(context)) {
93
- serverRumEvent.tags = context;
91
+ serverRumEvent.context = context;
94
92
  }
95
93
 
96
94
  if (!('has_replay' in serverRumEvent.session)) {
@@ -106,8 +104,8 @@ export function startRumAssembly(configuration, lifeCycle, sessionManager, userS
106
104
  }
107
105
 
108
106
  if (shouldSend(serverRumEvent, configuration.beforeSend, domainContext, eventRateLimiters)) {
109
- if (isEmptyObject(serverRumEvent.tags)) {
110
- delete serverRumEvent.tags;
107
+ if (isEmptyObject(serverRumEvent.context)) {
108
+ delete serverRumEvent.context;
111
109
  }
112
110
 
113
111
  lifeCycle.notify(LifeCycleEventType.RUM_EVENT_COLLECTED, serverRumEvent);
@@ -1,7 +1,7 @@
1
- import { noop, Observable, getZoneJsOriginalValue } from '@cloudcare/browser-core';
1
+ import { noop, Observable, getZoneJsOriginalValue, monitor } from '@cloudcare/browser-core';
2
2
  export function createDOMMutationObservable() {
3
3
  var MutationObserver = getMutationObserverConstructor();
4
- var observable = new Observable(function () {
4
+ var observable = new Observable(monitor(function () {
5
5
  if (!MutationObserver) {
6
6
  return;
7
7
  }
@@ -18,7 +18,7 @@ export function createDOMMutationObservable() {
18
18
  return function () {
19
19
  return observer.disconnect();
20
20
  };
21
- });
21
+ }));
22
22
  return observable;
23
23
  }
24
24
  export function getMutationObserverConstructor() {
@@ -1,4 +1,4 @@
1
- import { addEventListeners, getRelativeTime, isNumber, includes, each, extend, filter, dateNow, relativeNow, DOM_EVENT, LifeCycleEventType, runOnReadyState, setTimeout, addEventListener } from '@cloudcare/browser-core';
1
+ import { addEventListeners, getRelativeTime, isNumber, includes, each, extend, filter, dateNow, relativeNow, DOM_EVENT, LifeCycleEventType, runOnReadyState, setTimeout, addEventListener, monitor } from '@cloudcare/browser-core';
2
2
  import { FAKE_INITIAL_DOCUMENT, isAllowedRequestUrl } from './rumEventsCollection/resource/resourceUtils';
3
3
 
4
4
  function supportPerformanceObject() {
@@ -23,10 +23,9 @@ export function startPerformanceCollection(lifeCycle, configuration) {
23
23
  }
24
24
 
25
25
  if (window.PerformanceObserver) {
26
- var handlePerformanceEntryList = function handlePerformanceEntryList(entries) {
26
+ var handlePerformanceEntryList = monitor(function (entries) {
27
27
  handleRumPerformanceEntries(lifeCycle, configuration, entries.getEntries());
28
- };
29
-
28
+ });
30
29
  var mainEntries = ['resource', 'navigation', 'longtask', 'paint'];
31
30
  var experimentalEntries = ['largest-contentful-paint', 'first-input', 'layout-shift'];
32
31
 
@@ -1,16 +1,4 @@
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
-
13
- import { noop, requestIdleCallback } from '@cloudcare/browser-core';
1
+ import { noop, monitor } from '@cloudcare/browser-core';
14
2
  /**
15
3
  * Maximum duration to wait before processing mutations. If the browser is idle, mutations will be
16
4
  * processed more quickly. If the browser is busy executing small tasks (ex: rendering frames), the
@@ -31,20 +19,37 @@ export function createMutationBatch(processMutationBatch) {
31
19
 
32
20
  return {
33
21
  addMutations: function addMutations(mutations) {
34
- var _pendingMutations;
35
-
36
22
  if (pendingMutations.length === 0) {
37
23
  cancelScheduledFlush = requestIdleCallback(flush, {
38
24
  timeout: MUTATION_PROCESS_MAX_DELAY
39
25
  });
40
- }
26
+ } // pendingMutations.push(...mutations)
41
27
 
42
- (_pendingMutations = pendingMutations).push.apply(_pendingMutations, _toConsumableArray(mutations)); // Array.prototype.push.apply(pendingMutations, mutations)
43
28
 
29
+ Array.prototype.push.apply(pendingMutations, mutations);
44
30
  },
45
31
  flush: flush,
46
32
  stop: function stop() {
47
33
  cancelScheduledFlush();
48
34
  }
49
35
  };
36
+ }
37
+
38
+ function requestIdleCallback(callback, opts) {
39
+ // Use 'requestIdleCallback' when available: it will throttle the mutation processing if the
40
+ // browser is busy rendering frames (ex: when frames are below 60fps). When not available, the
41
+ // fallback on 'requestAnimationFrame' will still ensure the mutations are processed after any
42
+ // browser rendering process (Layout, Recalculate Style, etc.), so we can serialize DOM nodes
43
+ // efficiently.
44
+ if (window.requestIdleCallback) {
45
+ var id = window.requestIdleCallback(monitor(callback), opts);
46
+ return function () {
47
+ return window.cancelIdleCallback(id);
48
+ };
49
+ }
50
+
51
+ var id = window.requestAnimationFrame(monitor(callback));
52
+ return function () {
53
+ return window.cancelAnimationFrame(id);
54
+ };
50
55
  }
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
4
4
 
5
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
6
 
7
- import { noop, getChildNodes, isNodeShadowHost, getParentNode, isNullUndefinedDefaultValue } from '@cloudcare/browser-core';
7
+ import { noop, getChildNodes, isNodeShadowHost, getParentNode, isNullUndefinedDefaultValue, monitor } from '@cloudcare/browser-core';
8
8
  import { getMutationObserverConstructor } from '../../domMutationCollection';
9
9
  import { NodePrivacyLevel } from '../../../constants';
10
10
  import { getNodePrivacyLevel, getTextContent } from './privacy';
@@ -28,7 +28,7 @@ export function startMutationObserver(mutationCallback, configuration, shadowRoo
28
28
  var mutationBatch = createMutationBatch(function (mutations) {
29
29
  processMutations(mutations.concat(observer.takeRecords()), mutationCallback, configuration, shadowRootsController, target);
30
30
  });
31
- var observer = new MutationObserver(mutationBatch.addMutations);
31
+ var observer = new MutationObserver(monitor(mutationBatch.addMutations));
32
32
  observer.observe(target, {
33
33
  attributeOldValue: true,
34
34
  attributes: true,
@@ -2,7 +2,7 @@ var _eventTypeToMouseInte;
2
2
 
3
3
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
4
 
5
- import { instrumentSetter, instrumentMethodAndCallOriginal, assign, throttle, DOM_EVENT, addEventListeners, addEventListener, noop, LifeCycleEventType, RumEventType, ActionType, isNodeShadowHost } from '@cloudcare/browser-core';
5
+ import { instrumentSetter, instrumentMethodAndCallOriginal, assign, throttle, DOM_EVENT, addEventListeners, addEventListener, noop, LifeCycleEventType, RumEventType, ActionType, isNodeShadowHost, cssEscape } from '@cloudcare/browser-core';
6
6
  import { initViewportObservable } from '../../initViewportObservable';
7
7
  import { NodePrivacyLevel } from '../../../constants';
8
8
  import { RecordType, IncrementalSource, MediaInteractionType, MouseInteractionType } from '../../../types';
@@ -265,7 +265,7 @@ export function initInputObserver(cb, defaultPrivacyLevel, target) {
265
265
  var name = target.name;
266
266
 
267
267
  if (type === 'radio' && name && target.checked) {
268
- forEach(document.querySelectorAll("input[type=\"radio\"][name=\"".concat(name, "\"]")), function (el) {
268
+ forEach(document.querySelectorAll('input[type="radio"][name="' + cssEscape(name) + '"]'), function (el) {
269
269
  if (el !== target) {
270
270
  // TODO: Consider the privacy implications for various differing input privacy levels
271
271
  cbWithDedup(el, {
@@ -1,4 +1,5 @@
1
1
  import { isElementNode, getParentNode, isTextNode } from '@cloudcare/browser-core';
2
+ import { switchToAbsoluteUrl, getCssRulesString, getHref } from './serializationUtils';
2
3
  import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_ALLOW, PRIVACY_ATTR_VALUE_MASK, PRIVACY_ATTR_VALUE_MASK_USER_INPUT, PRIVACY_ATTR_VALUE_HIDDEN, PRIVACY_CLASS_ALLOW, PRIVACY_CLASS_MASK, PRIVACY_CLASS_MASK_USER_INPUT, PRIVACY_CLASS_HIDDEN, FORM_PRIVATE_TAG_NAMES, CENSORED_STRING_MARK } from '../../../constants';
3
4
  export var MAX_ATTRIBUTE_VALUE_CHAR_LENGTH = 100000;
4
5
  var TEXT_MASKING_CHAR = 'x';
@@ -183,6 +184,19 @@ export function getTextContent(textNode, ignoreWhiteSpace, parentNodePrivacyLeve
183
184
  } else {
184
185
  textContent = censorText(textContent);
185
186
  }
187
+ } else if (isStyle && textContent) {
188
+ try {
189
+ // try to read style sheet
190
+ if (textNode.nextSibling || textNode.previousSibling) {// This is not the only child of the stylesheet.
191
+ // We can't read all of the sheet's .cssRules and expect them
192
+ // to _only_ include the current rule(s) added by the text node.
193
+ // So we'll be conservative and keep textContent as-is.
194
+ } else if (textNode.parentNode && textNode.parentNode.sheet && textNode.parentNode.sheet.cssRules) {
195
+ textContent = getCssRulesString(textNode.parentNode.sheet);
196
+ }
197
+ } catch (err) {}
198
+
199
+ textContent = switchToAbsoluteUrl(textContent, getHref());
186
200
  }
187
201
 
188
202
  return textContent;
@@ -82,6 +82,30 @@ function extractOrigin(url) {
82
82
  export var URL_IN_CSS_REF = /url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm;
83
83
  export var ABSOLUTE_URL = /^[A-Za-z]+:|^\/\//;
84
84
  export var DATA_URI = /^data:.*,/i;
85
+ /**
86
+ * Browsers sometimes destructively modify the css rules they receive.
87
+ * This function tries to rectify the modifications the browser made to make it more cross platform compatible.
88
+ * @param cssText - output of `CSSStyleRule.cssText`
89
+ * @returns `cssText` with browser inconsistencies fixed.
90
+ */
91
+
92
+ export function fixBrowserCompatibilityIssuesInCSS(cssText) {
93
+ /**
94
+ * Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
95
+ * But then Chrome ignores `background-clip` as css input.
96
+ * Re-introduce `-webkit-background-clip` to fix this issue.
97
+ */
98
+ if (cssText.includes(' background-clip: text;') && !cssText.includes(' -webkit-background-clip: text;')) {
99
+ cssText = cssText.replace(' background-clip: text;', ' -webkit-background-clip: text; background-clip: text;');
100
+ }
101
+
102
+ return cssText;
103
+ }
104
+ export function getHref() {
105
+ var a = document.createElement('a');
106
+ a.href = '';
107
+ return a.href;
108
+ }
85
109
  export function switchToAbsoluteUrl(cssText, cssHref) {
86
110
  return cssText.replace(URL_IN_CSS_REF, function (matchingSubstring, singleQuote, urlWrappedInSingleQuotes, doubleQuote, urlWrappedInDoubleQuotes, urlNotWrappedInQuotes) {
87
111
  var url = urlWrappedInSingleQuotes || urlWrappedInDoubleQuotes || urlNotWrappedInQuotes;
@@ -99,6 +123,43 @@ export function switchToAbsoluteUrl(cssText, cssHref) {
99
123
  return "url(".concat(quote).concat(makeUrlAbsolute(url, cssHref)).concat(quote, ")");
100
124
  });
101
125
  }
126
+ export function getCssRulesString(cssStyleSheet) {
127
+ if (!cssStyleSheet) {
128
+ return null;
129
+ }
130
+
131
+ var rules;
132
+
133
+ try {
134
+ rules = cssStyleSheet.rules || cssStyleSheet.cssRules;
135
+ } catch (_unused) {// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
136
+ }
137
+
138
+ if (!rules) {
139
+ return null;
140
+ }
141
+
142
+ var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(Array.from(rules, getCssRuleString).join(''));
143
+ return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href);
144
+ }
145
+ export function isCSSImportRule(rule) {
146
+ return 'styleSheet' in rule;
147
+ }
148
+ export function isSVGElement(el) {
149
+ return el.tagName === 'svg' || el instanceof SVGElement;
150
+ }
151
+ export function getCssRuleString(rule) {
152
+ var cssStringified = rule.cssText;
153
+
154
+ if (isCSSImportRule(rule)) {
155
+ try {
156
+ cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
157
+ } catch (_unused2) {// ignore
158
+ }
159
+ }
160
+
161
+ return validateStringifiedCssRule(cssStringified);
162
+ }
102
163
  export function makeUrlAbsolute(url, baseUrl) {
103
164
  try {
104
165
  return buildUrl(url, baseUrl).href;
@@ -124,7 +185,7 @@ export function serializeStyleSheets(cssStyleSheets) {
124
185
  return cssStyleSheets.map(function (cssStyleSheet) {
125
186
  var rules = cssStyleSheet.cssRules || cssStyleSheet.rules;
126
187
  var cssRules = Array.from(rules, function (cssRule) {
127
- return cssRule.cssText ? validateStringifiedCssRule(rule.cssText) : '';
188
+ return cssRule.cssText ? validateStringifiedCssRule(cssRule.cssText) : '';
128
189
  });
129
190
  var styleSheet = {
130
191
  cssRules: cssRules,
@@ -5,7 +5,7 @@ import { STABLE_ATTRIBUTES } from '../../rumEventsCollection/actions/getSelector
5
5
  import { NodePrivacyLevel, PRIVACY_ATTR_NAME, PRIVACY_ATTR_VALUE_HIDDEN, CENSORED_STRING_MARK, CENSORED_IMG_MARK } from '../../../constants';
6
6
  import { NodeType } from '../../../types';
7
7
  import { getTextContent, shouldMaskNode, reducePrivacyLevel, getNodeSelfPrivacyLevel, MAX_ATTRIBUTE_VALUE_CHAR_LENGTH } from './privacy';
8
- import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, absoluteToDoc, getAbsoluteSrcsetString, validateStringifiedCssRule } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
8
+ import { getSerializedNodeId, setSerializedNodeId, getElementInputValue, switchToAbsoluteUrl, serializeStyleSheets, absoluteToDoc, getAbsoluteSrcsetString, isSVGElement, getHref, getCssRulesString } from './serializationUtils'; // Those values are the only one that can be used when inheriting privacy levels from parent to
9
9
  // children during serialization, since HIDDEN and IGNORE shouldn't serialize their children. This
10
10
  // ensures that no children are serialized when they shouldn't.
11
11
 
@@ -285,7 +285,7 @@ function generateNextId() {
285
285
  var TAG_NAME_REGEX = /[^a-z1-6-_]/;
286
286
 
287
287
  function getValidTagName(tagName) {
288
- var processedTagName = tagName.toLowerCase().trim();
288
+ var processedTagName = (tagName + '').toLowerCase().trim();
289
289
 
290
290
  if (TAG_NAME_REGEX.test(processedTagName)) {
291
291
  // if the tag name is odd and we cannot extract
@@ -296,67 +296,6 @@ function getValidTagName(tagName) {
296
296
 
297
297
  return processedTagName;
298
298
  }
299
- /**
300
- * Browsers sometimes destructively modify the css rules they receive.
301
- * This function tries to rectify the modifications the browser made to make it more cross platform compatible.
302
- * @param cssText - output of `CSSStyleRule.cssText`
303
- * @returns `cssText` with browser inconsistencies fixed.
304
- */
305
-
306
-
307
- function fixBrowserCompatibilityIssuesInCSS(cssText) {
308
- /**
309
- * Chrome outputs `-webkit-background-clip` as `background-clip` in `CSSStyleRule.cssText`.
310
- * But then Chrome ignores `background-clip` as css input.
311
- * Re-introduce `-webkit-background-clip` to fix this issue.
312
- */
313
- if (cssText.includes(' background-clip: text;') && !cssText.includes(' -webkit-background-clip: text;')) {
314
- cssText = cssText.replace(' background-clip: text;', ' -webkit-background-clip: text; background-clip: text;');
315
- }
316
-
317
- return cssText;
318
- }
319
-
320
- function getCssRulesString(cssStyleSheet) {
321
- if (!cssStyleSheet) {
322
- return null;
323
- }
324
-
325
- var rules;
326
-
327
- try {
328
- rules = cssStyleSheet.rules || cssStyleSheet.cssRules;
329
- } catch (_unused) {// if css is protected by CORS we cannot access cssRules see: https://www.w3.org/TR/cssom-1/#the-cssstylesheet-interface
330
- }
331
-
332
- if (!rules) {
333
- return null;
334
- }
335
-
336
- var styleSheetCssText = fixBrowserCompatibilityIssuesInCSS(Array.from(rules, getCssRuleString).join(''));
337
- return switchToAbsoluteUrl(styleSheetCssText, cssStyleSheet.href);
338
- }
339
-
340
- function getCssRuleString(rule) {
341
- var cssStringified = rule.cssText;
342
-
343
- if (isCSSImportRule(rule)) {
344
- try {
345
- cssStringified = getCssRulesString(rule.styleSheet) || cssStringified;
346
- } catch (_unused2) {// ignore
347
- }
348
- }
349
-
350
- return validateStringifiedCssRule(cssStringified);
351
- }
352
-
353
- function isCSSImportRule(rule) {
354
- return 'styleSheet' in rule;
355
- }
356
-
357
- function isSVGElement(el) {
358
- return el.tagName === 'svg' || el instanceof SVGElement;
359
- }
360
299
 
361
300
  function transformAttribute(doc, tagName, name, value) {
362
301
  if (!value) return value;
@@ -378,12 +317,6 @@ function transformAttribute(doc, tagName, name, value) {
378
317
  }
379
318
  }
380
319
 
381
- function getHref() {
382
- var a = document.createElement('a');
383
- a.href = '';
384
- return a.href;
385
- }
386
-
387
320
  function getAttributesForPrivacyLevel(element, nodePrivacyLevel, options) {
388
321
  if (nodePrivacyLevel === NodePrivacyLevel.HIDDEN) {
389
322
  return {};
@@ -67,13 +67,13 @@ function getClassSelector(element) {
67
67
  continue;
68
68
  }
69
69
 
70
- return element.tagName + '.' + cssEscape(className);
70
+ return cssEscape(element.tagName) + '.' + cssEscape(className);
71
71
  }
72
72
  }
73
73
  }
74
74
 
75
75
  function getTagNameSelector(element) {
76
- return element.tagName;
76
+ return cssEscape(element.tagName);
77
77
  }
78
78
 
79
79
  function getStableAttributeSelector(element, actionNameAttribute) {
@@ -96,7 +96,7 @@ function getStableAttributeSelector(element, actionNameAttribute) {
96
96
 
97
97
  function getAttributeSelector(attributeName) {
98
98
  if (element.hasAttribute(attributeName)) {
99
- return element.tagName + '[' + attributeName + '="' + cssEscape(element.getAttribute(attributeName)) + '"]';
99
+ return cssEscape(element.tagName) + '[' + attributeName + '="' + cssEscape(element.getAttribute(attributeName)) + '"]';
100
100
  }
101
101
  }
102
102
  }
@@ -113,7 +113,7 @@ function getPositionSelector(element) {
113
113
  sibling = sibling.nextElementSibling;
114
114
  }
115
115
 
116
- var tagName = element.tagName; // 伪元素需要做特殊处理,没有nth-of-type选择器
116
+ var tagName = cssEscape(element.tagName); // 伪元素需要做特殊处理,没有nth-of-type选择器
117
117
 
118
118
  if (/^::/.test(tagName)) {
119
119
  return tagName;
@@ -269,7 +269,8 @@ export function computeSize(entry) {
269
269
  if (entry.startTime < entry.responseStart) {
270
270
  return {
271
271
  size: entry.decodedBodySize,
272
- encodeSize: entry.encodedBodySize
272
+ encodeSize: Number.MAX_SAFE_INTEGER < entry.encodedBodySize ? 0 : entry.encodedBodySize // max safe interger
273
+
273
274
  };
274
275
  }
275
276
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@cloudcare/browser-rum",
3
- "version": "3.0.26",
3
+ "version": "3.0.29",
4
4
  "main": "cjs/index.js",
5
5
  "module": "esm/index.js",
6
6
  "dependencies": {
7
- "@cloudcare/browser-core": "^3.0.23",
8
- "@cloudcare/browser-worker": "^3.0.23"
7
+ "@cloudcare/browser-core": "3.0.29",
8
+ "@cloudcare/browser-worker": "3.0.29"
9
9
  },
10
10
  "scripts": {
11
11
  "dev": "webpack serve --open --mode=development",
@@ -30,5 +30,5 @@
30
30
  "license": "MIT",
31
31
  "homepage": "https://github.com/CloudCare/dataflux-rum-sdk-javascript/blob/master/packages/rum/README.md",
32
32
  "description": "DataFlux RUM Web 端数据指标监控",
33
- "gitHead": "ad0a0cb08867e5af50d42866011d6d8c033dab99"
33
+ "gitHead": "104fa066dfa70d87d54c3002bc6651c64d168478"
34
34
  }