@atlaskit/react-ufo 5.4.11 → 5.5.1
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/AGENTS.md +0 -1
- package/CHANGELOG.md +16 -0
- package/dist/cjs/interaction-metrics/index.js +125 -204
- package/dist/cjs/interaction-metrics-init/index.js +2 -2
- package/dist/cjs/segment/third-party-segment.js +2 -9
- package/dist/cjs/set-terminal-error/index.js +44 -3
- package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +1 -2
- package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +14 -16
- package/dist/es2019/interaction-metrics/index.js +128 -211
- package/dist/es2019/interaction-metrics-init/index.js +2 -2
- package/dist/es2019/segment/third-party-segment.js +2 -9
- package/dist/es2019/set-terminal-error/index.js +39 -3
- package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +1 -2
- package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +14 -16
- package/dist/esm/interaction-metrics/index.js +125 -204
- package/dist/esm/interaction-metrics-init/index.js +2 -2
- package/dist/esm/segment/third-party-segment.js +2 -9
- package/dist/esm/set-terminal-error/index.js +43 -3
- package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +1 -2
- package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +14 -16
- package/dist/types/set-terminal-error/index.d.ts +18 -2
- package/dist/types-ts4.5/set-terminal-error/index.d.ts +18 -2
- package/package.json +4 -10
|
@@ -4,11 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.isRelayNetworkError = void 0;
|
|
7
8
|
exports.setTerminalError = setTerminalError;
|
|
8
9
|
exports.sinkTerminalErrorHandler = sinkTerminalErrorHandler;
|
|
9
10
|
exports.useReportTerminalError = useReportTerminalError;
|
|
10
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
13
|
var _react = require("react");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
|
+
var _experienceTraceIdContext = require("../experience-trace-id-context");
|
|
12
16
|
var _interactionContext = require("../interaction-context");
|
|
13
17
|
var _interactionMetrics = require("../interaction-metrics");
|
|
14
18
|
var _routeNameContext = _interopRequireDefault(require("../route-name-context"));
|
|
@@ -18,19 +22,56 @@ var sinkHandlerFn = function sinkHandlerFn() {};
|
|
|
18
22
|
function sinkTerminalErrorHandler(fn) {
|
|
19
23
|
sinkHandlerFn = fn;
|
|
20
24
|
}
|
|
25
|
+
var RELAY_NETWORK_ERRORS_NAME = 'RelayNetwork';
|
|
26
|
+
/**
|
|
27
|
+
* Relay error structure
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
var isRelayNetworkError = exports.isRelayNetworkError = function isRelayNetworkError(error) {
|
|
31
|
+
return error.name === RELAY_NETWORK_ERRORS_NAME;
|
|
32
|
+
};
|
|
33
|
+
var isErrorObject = function isErrorObject(error) {
|
|
34
|
+
return (0, _typeof2.default)(error) === 'object' && error !== null;
|
|
35
|
+
};
|
|
36
|
+
var getErrorStatusCode = function getErrorStatusCode(error) {
|
|
37
|
+
if (!isErrorObject(error)) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (isRelayNetworkError(error)) {
|
|
41
|
+
var _error$source;
|
|
42
|
+
return (_error$source = error.source) === null || _error$source === void 0 || (_error$source = _error$source.errors) === null || _error$source === void 0 || (_error$source = _error$source[0]) === null || _error$source === void 0 || (_error$source = _error$source.extensions) === null || _error$source === void 0 ? void 0 : _error$source.statusCode;
|
|
43
|
+
}
|
|
44
|
+
if ('statusCode' in error && typeof error.statusCode === 'number') {
|
|
45
|
+
return error.statusCode;
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
};
|
|
49
|
+
var getErrorTraceId = function getErrorTraceId(error) {
|
|
50
|
+
return isErrorObject(error) && 'traceId' in error && typeof error.traceId === 'string' ? error.traceId : undefined;
|
|
51
|
+
};
|
|
21
52
|
function setTerminalError(error, additionalAttributes, labelStack) {
|
|
22
|
-
var _error$message, _activeInteraction$uf, _activeInteraction$id, _activeInteraction$ty, _PreviousInteractionL, _PreviousInteractionL2, _PreviousInteractionL3, _UFORouteName$current;
|
|
53
|
+
var _error$message, _getActiveTrace$trace, _getActiveTrace, _activeInteraction$uf, _activeInteraction$id, _activeInteraction$ty, _PreviousInteractionL, _PreviousInteractionL2, _PreviousInteractionL3, _UFORouteName$current;
|
|
23
54
|
if (additionalAttributes !== null && additionalAttributes !== void 0 && additionalAttributes.isClientNetworkError) {
|
|
24
55
|
// Exclude client network errors from being reported to UFO
|
|
25
56
|
return;
|
|
26
57
|
}
|
|
27
58
|
var activeInteraction = (0, _interactionMetrics.getActiveInteraction)();
|
|
28
59
|
var currentTime = performance.now();
|
|
29
|
-
var
|
|
60
|
+
var baseErrorData = {
|
|
30
61
|
errorType: error.name || 'Error',
|
|
31
62
|
errorMessage: ((_error$message = error.message) === null || _error$message === void 0 ? void 0 : _error$message.slice(0, 100)) || 'Unknown error',
|
|
32
63
|
timestamp: currentTime
|
|
33
|
-
}
|
|
64
|
+
};
|
|
65
|
+
var errorData = (0, _platformFeatureFlags.fg)('platform_ufo_terminal_errors_fix_missing_data') ? _objectSpread(_objectSpread({}, baseErrorData), {}, {
|
|
66
|
+
statusCode: getErrorStatusCode(error),
|
|
67
|
+
// Fallback to traceId from error object if it exists (e.g. FetchError)
|
|
68
|
+
traceId: (_getActiveTrace$trace = (_getActiveTrace = (0, _experienceTraceIdContext.getActiveTrace)()) === null || _getActiveTrace === void 0 ? void 0 : _getActiveTrace.traceId) !== null && _getActiveTrace$trace !== void 0 ? _getActiveTrace$trace : getErrorTraceId(error),
|
|
69
|
+
teamName: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.teamName,
|
|
70
|
+
packageName: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.packageName,
|
|
71
|
+
errorBoundaryId: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.errorBoundaryId,
|
|
72
|
+
errorHash: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.errorHash,
|
|
73
|
+
fallbackType: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.fallbackType
|
|
74
|
+
}) : _objectSpread(_objectSpread({}, baseErrorData), additionalAttributes);
|
|
34
75
|
|
|
35
76
|
// Calculate time since previous interaction
|
|
36
77
|
var timeSincePreviousInteraction = _interactionMetrics.PreviousInteractionLog.timestamp != null ? currentTime - _interactionMetrics.PreviousInteractionLog.timestamp : null;
|
|
@@ -12,7 +12,6 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _percentileCalc = require("./percentile-calc");
|
|
17
16
|
var _detectLayoutShiftCause = require("./utils/detect-layout-shift-cause");
|
|
18
17
|
var _getViewportHeight = _interopRequireDefault(require("./utils/get-viewport-height"));
|
|
@@ -253,7 +252,7 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
253
252
|
viewportPercentage: log.viewportPercentage
|
|
254
253
|
});
|
|
255
254
|
}) : []; // If 3p metric enabled - calculate the debug details
|
|
256
|
-
shouldCalculate3p = include3p
|
|
255
|
+
shouldCalculate3p = include3p; // Only calculate enhanced debug details if devtool callbacks exist
|
|
257
256
|
shouldCalculateDebugDetails = !isPostInteraction && (typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.__ufo_devtool_onVCRevisionReady__) === 'function' || typeof ((_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.__on_ufo_vc_debug_data_ready) === 'function' || typeof ((_window3 = window) === null || _window3 === void 0 ? void 0 : _window3.__ufo_devtool_vc_3p_debug_data) === 'function');
|
|
258
257
|
if (shouldCalculateDebugDetails && allEntries && vcLogs) {
|
|
259
258
|
// Pre-sort vcLogs by time for efficient lookups
|
|
@@ -366,22 +366,20 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
|
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
};
|
|
384
|
-
}
|
|
369
|
+
var _ref0 = _this.enableThirdPartyTracking ? (0, _checkWithinComponent.default)(target, 'UFOThirdPartySegment', _this.mapIs3pResult) : {
|
|
370
|
+
isWithin: false
|
|
371
|
+
},
|
|
372
|
+
isWithinThirdPartySegment = _ref0.isWithin;
|
|
373
|
+
if (isWithinThirdPartySegment) {
|
|
374
|
+
return {
|
|
375
|
+
type: 'mutation:third-party-attribute',
|
|
376
|
+
mutationData: {
|
|
377
|
+
attributeName: attributeName,
|
|
378
|
+
oldValue: oldValue,
|
|
379
|
+
newValue: newValue,
|
|
380
|
+
timestamp: timestamp
|
|
381
|
+
}
|
|
382
|
+
};
|
|
385
383
|
}
|
|
386
384
|
if (_this.shouldCheckSmartAnswersMutations() && (0, _isContainedWithinSmartAnswers.isContainedWithinSmartAnswers)(target)) {
|
|
387
385
|
return {
|