@atlaskit/react-ufo 2.4.0 → 2.4.2
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/CHANGELOG.md +16 -0
- package/dist/cjs/create-payload/index.js +46 -3
- package/dist/cjs/global-error-handler/index.js +7 -1
- package/dist/cjs/interaction-metrics-init/index.js +0 -7
- package/dist/cjs/load-hold/UFOLoadHold.js +4 -2
- package/dist/es2019/create-payload/index.js +44 -0
- package/dist/es2019/global-error-handler/index.js +4 -0
- package/dist/es2019/interaction-metrics-init/index.js +0 -7
- package/dist/es2019/load-hold/UFOLoadHold.js +3 -2
- package/dist/esm/create-payload/index.js +46 -3
- package/dist/esm/global-error-handler/index.js +6 -0
- package/dist/esm/interaction-metrics-init/index.js +0 -7
- package/dist/esm/load-hold/UFOLoadHold.js +4 -2
- package/dist/types/create-payload/index.d.ts +3073 -1
- package/dist/types/global-error-handler/index.d.ts +1 -0
- package/dist/types/load-hold/UFOLoadHold.d.ts +2 -1
- package/dist/types-ts4.5/create-payload/index.d.ts +3073 -1
- package/dist/types-ts4.5/global-error-handler/index.d.ts +1 -0
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +2 -1
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 2.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#171586](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/171586)
|
|
8
|
+
[`abec7f72a0d71`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/abec7f72a0d71) -
|
|
9
|
+
add experimental as a noop prop to UFO hold
|
|
10
|
+
|
|
11
|
+
## 2.4.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#170689](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170689)
|
|
16
|
+
[`960d36f94739d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/960d36f94739d) -
|
|
17
|
+
[React UFO] Fix sessionStorage no access error
|
|
18
|
+
|
|
3
19
|
## 2.4.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -11,11 +11,13 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
var _bowserUltralight = _interopRequireDefault(require("bowser-ultralight"));
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _additionalPayload = require("../additional-payload");
|
|
15
16
|
var bundleEvalTiming = _interopRequireWildcard(require("../bundle-eval-timing"));
|
|
16
17
|
var _constants = require("../common/constants");
|
|
17
18
|
var _config = require("../config");
|
|
18
19
|
var _customTimings = require("../custom-timings");
|
|
20
|
+
var _globalErrorHandler = require("../global-error-handler");
|
|
19
21
|
var _hiddenTiming = require("../hidden-timing");
|
|
20
22
|
var initialPageLoadExtraTiming = _interopRequireWildcard(require("../initial-page-load-extra-timing"));
|
|
21
23
|
var _interactionMetrics = require("../interaction-metrics");
|
|
@@ -607,6 +609,45 @@ function getSSRDoneTimeValue(config) {
|
|
|
607
609
|
function getPayloadSize(payload) {
|
|
608
610
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
609
611
|
}
|
|
612
|
+
function getStylesheetMetrics() {
|
|
613
|
+
if (!(0, _platformFeatureFlags.fg)('ufo_capture_stylesheet_metrics')) {
|
|
614
|
+
return {};
|
|
615
|
+
}
|
|
616
|
+
try {
|
|
617
|
+
var stylesheets = Array.from(document.styleSheets);
|
|
618
|
+
var stylesheetCount = stylesheets.length;
|
|
619
|
+
var cssrules = Array.from(document.styleSheets).reduce(function (acc, item) {
|
|
620
|
+
// Other domain stylesheets throw a SecurityError
|
|
621
|
+
try {
|
|
622
|
+
return acc + item.cssRules.length;
|
|
623
|
+
} catch (e) {
|
|
624
|
+
return acc;
|
|
625
|
+
}
|
|
626
|
+
}, 0);
|
|
627
|
+
var styleElements = document.querySelectorAll('style').length;
|
|
628
|
+
var styleProps = document.querySelectorAll('[style]');
|
|
629
|
+
var styleDeclarations = Array.from(document.querySelectorAll('[style]')).reduce(function (acc, item) {
|
|
630
|
+
try {
|
|
631
|
+
if ('style' in item) {
|
|
632
|
+
return acc + item.style.length;
|
|
633
|
+
} else {
|
|
634
|
+
return acc;
|
|
635
|
+
}
|
|
636
|
+
} catch (e) {
|
|
637
|
+
return acc;
|
|
638
|
+
}
|
|
639
|
+
}, 0);
|
|
640
|
+
return {
|
|
641
|
+
stylesheets: stylesheetCount,
|
|
642
|
+
styleElements: styleElements,
|
|
643
|
+
styleProps: styleProps.length,
|
|
644
|
+
styleDeclarations: styleDeclarations,
|
|
645
|
+
cssrules: cssrules
|
|
646
|
+
};
|
|
647
|
+
} catch (e) {
|
|
648
|
+
return {};
|
|
649
|
+
}
|
|
650
|
+
}
|
|
610
651
|
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
611
652
|
var _window$location, _config$additionalPay;
|
|
612
653
|
var interactionPayloadStart = performance.now();
|
|
@@ -701,7 +742,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
701
742
|
source: 'measured',
|
|
702
743
|
tags: ['observability'],
|
|
703
744
|
attributes: {
|
|
704
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
745
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
705
746
|
// basic
|
|
706
747
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
707
748
|
'event:product': config.product,
|
|
@@ -715,7 +756,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
715
756
|
'event:region': config.region || 'unknown',
|
|
716
757
|
'experience:key': 'custom.interaction-metrics',
|
|
717
758
|
'experience:name': newUFOName
|
|
718
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), {}, {
|
|
759
|
+
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), {}, {
|
|
760
|
+
errorCount: (0, _globalErrorHandler.getGlobalErrorCount)(),
|
|
719
761
|
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
720
762
|
namePrefix: config.namePrefix || '',
|
|
721
763
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -746,7 +788,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
746
788
|
}),
|
|
747
789
|
marks: optimizeMarks(interaction.marks),
|
|
748
790
|
customData: optimizeCustomData(interaction),
|
|
749
|
-
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
|
|
791
|
+
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start),
|
|
792
|
+
errorCount: interaction.errors.length
|
|
750
793
|
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
751
794
|
'ufo:payloadTime': (0, _roundNumber.roundEpsilon)(performance.now() - interactionPayloadStart)
|
|
752
795
|
})
|
|
@@ -4,10 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.sinkErrorHandler = exports.default = void 0;
|
|
7
|
+
exports.sinkErrorHandler = exports.getGlobalErrorCount = exports.default = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _bindEventListener = require("bind-event-listener");
|
|
10
10
|
var shouldInitilizeGlobalErrorHandler = true;
|
|
11
|
+
var globalCount = 0;
|
|
11
12
|
var errors = [];
|
|
12
13
|
var push = function push(name, labelStack, errorType, errorMessage, errorStack) {
|
|
13
14
|
errors.push({
|
|
@@ -25,8 +26,12 @@ var sinkErrorHandler = exports.sinkErrorHandler = function sinkErrorHandler(sink
|
|
|
25
26
|
});
|
|
26
27
|
errors.length = 0;
|
|
27
28
|
};
|
|
29
|
+
var getGlobalErrorCount = exports.getGlobalErrorCount = function getGlobalErrorCount() {
|
|
30
|
+
return globalCount;
|
|
31
|
+
};
|
|
28
32
|
var handleError = function handleError(e) {
|
|
29
33
|
var _e$error;
|
|
34
|
+
globalCount++;
|
|
30
35
|
if (((_e$error = e.error) === null || _e$error === void 0 ? void 0 : _e$error.UFOhasCaught) === undefined) {
|
|
31
36
|
try {
|
|
32
37
|
if (e.error instanceof Error) {
|
|
@@ -46,6 +51,7 @@ var handleError = function handleError(e) {
|
|
|
46
51
|
}
|
|
47
52
|
};
|
|
48
53
|
var handlePromiseRejection = function handlePromiseRejection(e) {
|
|
54
|
+
globalCount++;
|
|
49
55
|
if (e.reason instanceof Error) {
|
|
50
56
|
push('GlobalErrorHandler', null, e.reason.name, e.reason.message, e.reason.stack);
|
|
51
57
|
} else if (e.reason) {
|
|
@@ -41,13 +41,6 @@ var init = exports.init = function init(analyticsWebClientAsync, config) {
|
|
|
41
41
|
if (initialized) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
try {
|
|
45
|
-
if (window !== undefined) {
|
|
46
|
-
window.__REACT_UFO_ENABLE_PERF_TRACING = Boolean(sessionStorage.getItem('additionalPerfMarks') === 'true');
|
|
47
|
-
}
|
|
48
|
-
} catch (err) {
|
|
49
|
-
/* do nothing */
|
|
50
|
-
}
|
|
51
44
|
(0, _config.setUFOConfig)(config);
|
|
52
45
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
53
46
|
var vcOptions = {
|
|
@@ -62,11 +62,13 @@ function UFOLoadHold(_ref) {
|
|
|
62
62
|
var children = _ref.children,
|
|
63
63
|
name = _ref.name,
|
|
64
64
|
_ref$hold = _ref.hold,
|
|
65
|
-
hold = _ref$hold === void 0 ? true : _ref$hold
|
|
65
|
+
hold = _ref$hold === void 0 ? true : _ref$hold,
|
|
66
|
+
_ref$experimental = _ref.experimental,
|
|
67
|
+
experimental = _ref$experimental === void 0 ? false : _ref$experimental;
|
|
66
68
|
// react-18: useId instead
|
|
67
69
|
var context = (0, _react.useContext)(_interactionContext.default);
|
|
68
70
|
useLayoutEffectSAFE(function () {
|
|
69
|
-
if (hold && context != null) {
|
|
71
|
+
if (hold && !experimental && context != null) {
|
|
70
72
|
return context.hold(name);
|
|
71
73
|
}
|
|
72
74
|
}, [hold, context, name]);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import Bowser from 'bowser-ultralight';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { getLighthouseMetrics } from '../additional-payload';
|
|
3
4
|
import * as bundleEvalTiming from '../bundle-eval-timing';
|
|
4
5
|
import { REACT_UFO_VERSION } from '../common/constants';
|
|
5
6
|
import { getConfig, getUfoNameOverrides } from '../config';
|
|
6
7
|
import { getBm3Timings } from '../custom-timings';
|
|
8
|
+
import { getGlobalErrorCount } from '../global-error-handler';
|
|
7
9
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
8
10
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
9
11
|
import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
|
|
@@ -599,6 +601,45 @@ function getSSRDoneTimeValue(config) {
|
|
|
599
601
|
function getPayloadSize(payload) {
|
|
600
602
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
601
603
|
}
|
|
604
|
+
function getStylesheetMetrics() {
|
|
605
|
+
if (!fg('ufo_capture_stylesheet_metrics')) {
|
|
606
|
+
return {};
|
|
607
|
+
}
|
|
608
|
+
try {
|
|
609
|
+
const stylesheets = Array.from(document.styleSheets);
|
|
610
|
+
const stylesheetCount = stylesheets.length;
|
|
611
|
+
const cssrules = Array.from(document.styleSheets).reduce((acc, item) => {
|
|
612
|
+
// Other domain stylesheets throw a SecurityError
|
|
613
|
+
try {
|
|
614
|
+
return acc + item.cssRules.length;
|
|
615
|
+
} catch (e) {
|
|
616
|
+
return acc;
|
|
617
|
+
}
|
|
618
|
+
}, 0);
|
|
619
|
+
const styleElements = document.querySelectorAll('style').length;
|
|
620
|
+
const styleProps = document.querySelectorAll('[style]');
|
|
621
|
+
const styleDeclarations = Array.from(document.querySelectorAll('[style]')).reduce((acc, item) => {
|
|
622
|
+
try {
|
|
623
|
+
if ('style' in item) {
|
|
624
|
+
return acc + item.style.length;
|
|
625
|
+
} else {
|
|
626
|
+
return acc;
|
|
627
|
+
}
|
|
628
|
+
} catch (e) {
|
|
629
|
+
return acc;
|
|
630
|
+
}
|
|
631
|
+
}, 0);
|
|
632
|
+
return {
|
|
633
|
+
stylesheets: stylesheetCount,
|
|
634
|
+
styleElements,
|
|
635
|
+
styleProps: styleProps.length,
|
|
636
|
+
styleDeclarations,
|
|
637
|
+
cssrules: cssrules
|
|
638
|
+
};
|
|
639
|
+
} catch (e) {
|
|
640
|
+
return {};
|
|
641
|
+
}
|
|
642
|
+
}
|
|
602
643
|
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
603
644
|
var _window$location, _config$additionalPay;
|
|
604
645
|
const interactionPayloadStart = performance.now();
|
|
@@ -717,6 +758,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
717
758
|
...getVCMetrics(interaction),
|
|
718
759
|
...((_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)),
|
|
719
760
|
...getTracingContextData(interaction),
|
|
761
|
+
...getStylesheetMetrics(),
|
|
762
|
+
errorCount: getGlobalErrorCount(),
|
|
720
763
|
interactionMetrics: {
|
|
721
764
|
namePrefix: config.namePrefix || '',
|
|
722
765
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -748,6 +791,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
748
791
|
marks: optimizeMarks(interaction.marks),
|
|
749
792
|
customData: optimizeCustomData(interaction),
|
|
750
793
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start),
|
|
794
|
+
errorCount: interaction.errors.length,
|
|
751
795
|
...labelStack,
|
|
752
796
|
...getPageLoadInteractionMetrics(),
|
|
753
797
|
...getDetailedInteractionMetrics(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { bind } from 'bind-event-listener';
|
|
2
2
|
let shouldInitilizeGlobalErrorHandler = true;
|
|
3
|
+
let globalCount = 0;
|
|
3
4
|
const errors = [];
|
|
4
5
|
let push = (name, labelStack, errorType, errorMessage, errorStack) => {
|
|
5
6
|
errors.push({
|
|
@@ -17,8 +18,10 @@ export const sinkErrorHandler = sinkFunc => {
|
|
|
17
18
|
});
|
|
18
19
|
errors.length = 0;
|
|
19
20
|
};
|
|
21
|
+
export const getGlobalErrorCount = () => globalCount;
|
|
20
22
|
const handleError = e => {
|
|
21
23
|
var _e$error;
|
|
24
|
+
globalCount++;
|
|
22
25
|
if (((_e$error = e.error) === null || _e$error === void 0 ? void 0 : _e$error.UFOhasCaught) === undefined) {
|
|
23
26
|
try {
|
|
24
27
|
if (e.error instanceof Error) {
|
|
@@ -38,6 +41,7 @@ const handleError = e => {
|
|
|
38
41
|
}
|
|
39
42
|
};
|
|
40
43
|
const handlePromiseRejection = e => {
|
|
44
|
+
globalCount++;
|
|
41
45
|
if (e.reason instanceof Error) {
|
|
42
46
|
push('GlobalErrorHandler', null, e.reason.name, e.reason.message, e.reason.stack);
|
|
43
47
|
} else if (e.reason) {
|
|
@@ -30,13 +30,6 @@ export const init = (analyticsWebClientAsync, config) => {
|
|
|
30
30
|
if (initialized) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
try {
|
|
34
|
-
if (window !== undefined) {
|
|
35
|
-
window.__REACT_UFO_ENABLE_PERF_TRACING = Boolean(sessionStorage.getItem('additionalPerfMarks') === 'true');
|
|
36
|
-
}
|
|
37
|
-
} catch (err) {
|
|
38
|
-
/* do nothing */
|
|
39
|
-
}
|
|
40
33
|
setUFOConfig(config);
|
|
41
34
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
42
35
|
const vcOptions = {
|
|
@@ -51,12 +51,13 @@ const useLayoutEffectSAFE = typeof window === 'undefined' ? useEffect : useLayou
|
|
|
51
51
|
export default function UFOLoadHold({
|
|
52
52
|
children,
|
|
53
53
|
name,
|
|
54
|
-
hold = true
|
|
54
|
+
hold = true,
|
|
55
|
+
experimental = false
|
|
55
56
|
}) {
|
|
56
57
|
// react-18: useId instead
|
|
57
58
|
const context = useContext(UFOInteractionContext);
|
|
58
59
|
useLayoutEffectSAFE(() => {
|
|
59
|
-
if (hold && context != null) {
|
|
60
|
+
if (hold && !experimental && context != null) {
|
|
60
61
|
return context.hold(name);
|
|
61
62
|
}
|
|
62
63
|
}, [hold, context, name]);
|
|
@@ -9,11 +9,13 @@ var _excluded = ["labelStack", "time"],
|
|
|
9
9
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
10
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
11
|
import Bowser from 'bowser-ultralight';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { getLighthouseMetrics } from '../additional-payload';
|
|
13
14
|
import * as bundleEvalTiming from '../bundle-eval-timing';
|
|
14
15
|
import { REACT_UFO_VERSION } from '../common/constants';
|
|
15
16
|
import { getConfig, getUfoNameOverrides } from '../config';
|
|
16
17
|
import { getBm3Timings } from '../custom-timings';
|
|
18
|
+
import { getGlobalErrorCount } from '../global-error-handler';
|
|
17
19
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
18
20
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
19
21
|
import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
|
|
@@ -597,6 +599,45 @@ function getSSRDoneTimeValue(config) {
|
|
|
597
599
|
function getPayloadSize(payload) {
|
|
598
600
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
599
601
|
}
|
|
602
|
+
function getStylesheetMetrics() {
|
|
603
|
+
if (!fg('ufo_capture_stylesheet_metrics')) {
|
|
604
|
+
return {};
|
|
605
|
+
}
|
|
606
|
+
try {
|
|
607
|
+
var stylesheets = Array.from(document.styleSheets);
|
|
608
|
+
var stylesheetCount = stylesheets.length;
|
|
609
|
+
var cssrules = Array.from(document.styleSheets).reduce(function (acc, item) {
|
|
610
|
+
// Other domain stylesheets throw a SecurityError
|
|
611
|
+
try {
|
|
612
|
+
return acc + item.cssRules.length;
|
|
613
|
+
} catch (e) {
|
|
614
|
+
return acc;
|
|
615
|
+
}
|
|
616
|
+
}, 0);
|
|
617
|
+
var styleElements = document.querySelectorAll('style').length;
|
|
618
|
+
var styleProps = document.querySelectorAll('[style]');
|
|
619
|
+
var styleDeclarations = Array.from(document.querySelectorAll('[style]')).reduce(function (acc, item) {
|
|
620
|
+
try {
|
|
621
|
+
if ('style' in item) {
|
|
622
|
+
return acc + item.style.length;
|
|
623
|
+
} else {
|
|
624
|
+
return acc;
|
|
625
|
+
}
|
|
626
|
+
} catch (e) {
|
|
627
|
+
return acc;
|
|
628
|
+
}
|
|
629
|
+
}, 0);
|
|
630
|
+
return {
|
|
631
|
+
stylesheets: stylesheetCount,
|
|
632
|
+
styleElements: styleElements,
|
|
633
|
+
styleProps: styleProps.length,
|
|
634
|
+
styleDeclarations: styleDeclarations,
|
|
635
|
+
cssrules: cssrules
|
|
636
|
+
};
|
|
637
|
+
} catch (e) {
|
|
638
|
+
return {};
|
|
639
|
+
}
|
|
640
|
+
}
|
|
600
641
|
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
601
642
|
var _window$location, _config$additionalPay;
|
|
602
643
|
var interactionPayloadStart = performance.now();
|
|
@@ -691,7 +732,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
691
732
|
source: 'measured',
|
|
692
733
|
tags: ['observability'],
|
|
693
734
|
attributes: {
|
|
694
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
735
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
695
736
|
// basic
|
|
696
737
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
697
738
|
'event:product': config.product,
|
|
@@ -705,7 +746,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
705
746
|
'event:region': config.region || 'unknown',
|
|
706
747
|
'experience:key': 'custom.interaction-metrics',
|
|
707
748
|
'experience:name': newUFOName
|
|
708
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), {}, {
|
|
749
|
+
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), {}, {
|
|
750
|
+
errorCount: getGlobalErrorCount(),
|
|
709
751
|
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
710
752
|
namePrefix: config.namePrefix || '',
|
|
711
753
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -736,7 +778,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
736
778
|
}),
|
|
737
779
|
marks: optimizeMarks(interaction.marks),
|
|
738
780
|
customData: optimizeCustomData(interaction),
|
|
739
|
-
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
|
|
781
|
+
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start),
|
|
782
|
+
errorCount: interaction.errors.length
|
|
740
783
|
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
741
784
|
'ufo:payloadTime': roundEpsilon(performance.now() - interactionPayloadStart)
|
|
742
785
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
import { bind } from 'bind-event-listener';
|
|
3
3
|
var shouldInitilizeGlobalErrorHandler = true;
|
|
4
|
+
var globalCount = 0;
|
|
4
5
|
var errors = [];
|
|
5
6
|
var push = function push(name, labelStack, errorType, errorMessage, errorStack) {
|
|
6
7
|
errors.push({
|
|
@@ -18,8 +19,12 @@ export var sinkErrorHandler = function sinkErrorHandler(sinkFunc) {
|
|
|
18
19
|
});
|
|
19
20
|
errors.length = 0;
|
|
20
21
|
};
|
|
22
|
+
export var getGlobalErrorCount = function getGlobalErrorCount() {
|
|
23
|
+
return globalCount;
|
|
24
|
+
};
|
|
21
25
|
var handleError = function handleError(e) {
|
|
22
26
|
var _e$error;
|
|
27
|
+
globalCount++;
|
|
23
28
|
if (((_e$error = e.error) === null || _e$error === void 0 ? void 0 : _e$error.UFOhasCaught) === undefined) {
|
|
24
29
|
try {
|
|
25
30
|
if (e.error instanceof Error) {
|
|
@@ -39,6 +44,7 @@ var handleError = function handleError(e) {
|
|
|
39
44
|
}
|
|
40
45
|
};
|
|
41
46
|
var handlePromiseRejection = function handlePromiseRejection(e) {
|
|
47
|
+
globalCount++;
|
|
42
48
|
if (e.reason instanceof Error) {
|
|
43
49
|
push('GlobalErrorHandler', null, e.reason.name, e.reason.message, e.reason.stack);
|
|
44
50
|
} else if (e.reason) {
|
|
@@ -31,13 +31,6 @@ export var init = function init(analyticsWebClientAsync, config) {
|
|
|
31
31
|
if (initialized) {
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
|
-
try {
|
|
35
|
-
if (window !== undefined) {
|
|
36
|
-
window.__REACT_UFO_ENABLE_PERF_TRACING = Boolean(sessionStorage.getItem('additionalPerfMarks') === 'true');
|
|
37
|
-
}
|
|
38
|
-
} catch (err) {
|
|
39
|
-
/* do nothing */
|
|
40
|
-
}
|
|
41
34
|
setUFOConfig(config);
|
|
42
35
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
43
36
|
var vcOptions = {
|
|
@@ -52,11 +52,13 @@ export default function UFOLoadHold(_ref) {
|
|
|
52
52
|
var children = _ref.children,
|
|
53
53
|
name = _ref.name,
|
|
54
54
|
_ref$hold = _ref.hold,
|
|
55
|
-
hold = _ref$hold === void 0 ? true : _ref$hold
|
|
55
|
+
hold = _ref$hold === void 0 ? true : _ref$hold,
|
|
56
|
+
_ref$experimental = _ref.experimental,
|
|
57
|
+
experimental = _ref$experimental === void 0 ? false : _ref$experimental;
|
|
56
58
|
// react-18: useId instead
|
|
57
59
|
var context = useContext(UFOInteractionContext);
|
|
58
60
|
useLayoutEffectSAFE(function () {
|
|
59
|
-
if (hold && context != null) {
|
|
61
|
+
if (hold && !experimental && context != null) {
|
|
60
62
|
return context.hold(name);
|
|
61
63
|
}
|
|
62
64
|
}, [hold, context, name]);
|