@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
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
3
|
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; }
|
|
3
4
|
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; }
|
|
4
5
|
import { useEffect, useRef } from 'react';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
import { getActiveTrace } from '../experience-trace-id-context';
|
|
5
8
|
import { useInteractionContext } from '../interaction-context';
|
|
6
9
|
import { getActiveInteraction, PreviousInteractionLog } from '../interaction-metrics';
|
|
7
10
|
import UFORouteName from '../route-name-context';
|
|
@@ -9,19 +12,56 @@ var sinkHandlerFn = function sinkHandlerFn() {};
|
|
|
9
12
|
export function sinkTerminalErrorHandler(fn) {
|
|
10
13
|
sinkHandlerFn = fn;
|
|
11
14
|
}
|
|
15
|
+
var RELAY_NETWORK_ERRORS_NAME = 'RelayNetwork';
|
|
16
|
+
/**
|
|
17
|
+
* Relay error structure
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export var isRelayNetworkError = function isRelayNetworkError(error) {
|
|
21
|
+
return error.name === RELAY_NETWORK_ERRORS_NAME;
|
|
22
|
+
};
|
|
23
|
+
var isErrorObject = function isErrorObject(error) {
|
|
24
|
+
return _typeof(error) === 'object' && error !== null;
|
|
25
|
+
};
|
|
26
|
+
var getErrorStatusCode = function getErrorStatusCode(error) {
|
|
27
|
+
if (!isErrorObject(error)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
if (isRelayNetworkError(error)) {
|
|
31
|
+
var _error$source;
|
|
32
|
+
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;
|
|
33
|
+
}
|
|
34
|
+
if ('statusCode' in error && typeof error.statusCode === 'number') {
|
|
35
|
+
return error.statusCode;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
};
|
|
39
|
+
var getErrorTraceId = function getErrorTraceId(error) {
|
|
40
|
+
return isErrorObject(error) && 'traceId' in error && typeof error.traceId === 'string' ? error.traceId : undefined;
|
|
41
|
+
};
|
|
12
42
|
export function setTerminalError(error, additionalAttributes, labelStack) {
|
|
13
|
-
var _error$message, _activeInteraction$uf, _activeInteraction$id, _activeInteraction$ty, _PreviousInteractionL, _PreviousInteractionL2, _PreviousInteractionL3, _UFORouteName$current;
|
|
43
|
+
var _error$message, _getActiveTrace$trace, _getActiveTrace, _activeInteraction$uf, _activeInteraction$id, _activeInteraction$ty, _PreviousInteractionL, _PreviousInteractionL2, _PreviousInteractionL3, _UFORouteName$current;
|
|
14
44
|
if (additionalAttributes !== null && additionalAttributes !== void 0 && additionalAttributes.isClientNetworkError) {
|
|
15
45
|
// Exclude client network errors from being reported to UFO
|
|
16
46
|
return;
|
|
17
47
|
}
|
|
18
48
|
var activeInteraction = getActiveInteraction();
|
|
19
49
|
var currentTime = performance.now();
|
|
20
|
-
var
|
|
50
|
+
var baseErrorData = {
|
|
21
51
|
errorType: error.name || 'Error',
|
|
22
52
|
errorMessage: ((_error$message = error.message) === null || _error$message === void 0 ? void 0 : _error$message.slice(0, 100)) || 'Unknown error',
|
|
23
53
|
timestamp: currentTime
|
|
24
|
-
}
|
|
54
|
+
};
|
|
55
|
+
var errorData = fg('platform_ufo_terminal_errors_fix_missing_data') ? _objectSpread(_objectSpread({}, baseErrorData), {}, {
|
|
56
|
+
statusCode: getErrorStatusCode(error),
|
|
57
|
+
// Fallback to traceId from error object if it exists (e.g. FetchError)
|
|
58
|
+
traceId: (_getActiveTrace$trace = (_getActiveTrace = getActiveTrace()) === null || _getActiveTrace === void 0 ? void 0 : _getActiveTrace.traceId) !== null && _getActiveTrace$trace !== void 0 ? _getActiveTrace$trace : getErrorTraceId(error),
|
|
59
|
+
teamName: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.teamName,
|
|
60
|
+
packageName: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.packageName,
|
|
61
|
+
errorBoundaryId: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.errorBoundaryId,
|
|
62
|
+
errorHash: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.errorHash,
|
|
63
|
+
fallbackType: additionalAttributes === null || additionalAttributes === void 0 ? void 0 : additionalAttributes.fallbackType
|
|
64
|
+
}) : _objectSpread(_objectSpread({}, baseErrorData), additionalAttributes);
|
|
25
65
|
|
|
26
66
|
// Calculate time since previous interaction
|
|
27
67
|
var timeSincePreviousInteraction = PreviousInteractionLog.timestamp != null ? currentTime - PreviousInteractionLog.timestamp : null;
|
|
@@ -10,7 +10,6 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
10
10
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
11
11
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
13
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
14
13
|
import { calculateTTVCPercentilesWithDebugInfo } from './percentile-calc';
|
|
15
14
|
import { detectLayoutShiftCause } from './utils/detect-layout-shift-cause';
|
|
16
15
|
import getViewportHeight from './utils/get-viewport-height';
|
|
@@ -247,7 +246,7 @@ var AbstractVCCalculatorBase = /*#__PURE__*/function () {
|
|
|
247
246
|
viewportPercentage: log.viewportPercentage
|
|
248
247
|
});
|
|
249
248
|
}) : []; // If 3p metric enabled - calculate the debug details
|
|
250
|
-
shouldCalculate3p = include3p
|
|
249
|
+
shouldCalculate3p = include3p; // Only calculate enhanced debug details if devtool callbacks exist
|
|
251
250
|
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');
|
|
252
251
|
if (shouldCalculateDebugDetails && allEntries && vcLogs) {
|
|
253
252
|
// Pre-sort vcLogs by time for efficient lookups
|
|
@@ -357,22 +357,20 @@ var ViewportObserver = /*#__PURE__*/function () {
|
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
359
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
};
|
|
375
|
-
}
|
|
360
|
+
var _ref0 = _this.enableThirdPartyTracking ? checkWithinComponent(target, 'UFOThirdPartySegment', _this.mapIs3pResult) : {
|
|
361
|
+
isWithin: false
|
|
362
|
+
},
|
|
363
|
+
isWithinThirdPartySegment = _ref0.isWithin;
|
|
364
|
+
if (isWithinThirdPartySegment) {
|
|
365
|
+
return {
|
|
366
|
+
type: 'mutation:third-party-attribute',
|
|
367
|
+
mutationData: {
|
|
368
|
+
attributeName: attributeName,
|
|
369
|
+
oldValue: oldValue,
|
|
370
|
+
newValue: newValue,
|
|
371
|
+
timestamp: timestamp
|
|
372
|
+
}
|
|
373
|
+
};
|
|
376
374
|
}
|
|
377
375
|
if (_this.shouldCheckSmartAnswersMutations() && isContainedWithinSmartAnswers(target)) {
|
|
378
376
|
return {
|
|
@@ -4,10 +4,10 @@ export interface TerminalErrorAdditionalAttributes {
|
|
|
4
4
|
packageName?: string;
|
|
5
5
|
errorBoundaryId?: string;
|
|
6
6
|
errorHash?: string;
|
|
7
|
-
traceId?: string;
|
|
8
7
|
fallbackType?: 'page' | 'flag' | 'custom';
|
|
9
|
-
statusCode?: number;
|
|
10
8
|
isClientNetworkError?: boolean;
|
|
9
|
+
traceId?: string;
|
|
10
|
+
statusCode?: number;
|
|
11
11
|
}
|
|
12
12
|
export interface TerminalErrorData extends TerminalErrorAdditionalAttributes {
|
|
13
13
|
errorType: string;
|
|
@@ -26,5 +26,21 @@ export interface TerminalErrorContext {
|
|
|
26
26
|
routeName: string | null;
|
|
27
27
|
}
|
|
28
28
|
export declare function sinkTerminalErrorHandler(fn: (errorData: TerminalErrorData, context: TerminalErrorContext) => void | Promise<void>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Relay error structure
|
|
31
|
+
*/
|
|
32
|
+
type RelayNetworkErrors = {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
source?: {
|
|
36
|
+
errors?: {
|
|
37
|
+
extensions?: {
|
|
38
|
+
statusCode?: number;
|
|
39
|
+
};
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const isRelayNetworkError: (error: RelayNetworkErrors | Error) => error is RelayNetworkErrors;
|
|
29
44
|
export declare function setTerminalError(error: Error, additionalAttributes?: TerminalErrorAdditionalAttributes, labelStack?: LabelStack): void;
|
|
30
45
|
export declare function useReportTerminalError(error: Error | null | undefined, additionalAttributes?: TerminalErrorAdditionalAttributes): void;
|
|
46
|
+
export {};
|
|
@@ -4,10 +4,10 @@ export interface TerminalErrorAdditionalAttributes {
|
|
|
4
4
|
packageName?: string;
|
|
5
5
|
errorBoundaryId?: string;
|
|
6
6
|
errorHash?: string;
|
|
7
|
-
traceId?: string;
|
|
8
7
|
fallbackType?: 'page' | 'flag' | 'custom';
|
|
9
|
-
statusCode?: number;
|
|
10
8
|
isClientNetworkError?: boolean;
|
|
9
|
+
traceId?: string;
|
|
10
|
+
statusCode?: number;
|
|
11
11
|
}
|
|
12
12
|
export interface TerminalErrorData extends TerminalErrorAdditionalAttributes {
|
|
13
13
|
errorType: string;
|
|
@@ -26,5 +26,21 @@ export interface TerminalErrorContext {
|
|
|
26
26
|
routeName: string | null;
|
|
27
27
|
}
|
|
28
28
|
export declare function sinkTerminalErrorHandler(fn: (errorData: TerminalErrorData, context: TerminalErrorContext) => void | Promise<void>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Relay error structure
|
|
31
|
+
*/
|
|
32
|
+
type RelayNetworkErrors = {
|
|
33
|
+
name: string;
|
|
34
|
+
type: string;
|
|
35
|
+
source?: {
|
|
36
|
+
errors?: {
|
|
37
|
+
extensions?: {
|
|
38
|
+
statusCode?: number;
|
|
39
|
+
};
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const isRelayNetworkError: (error: RelayNetworkErrors | Error) => error is RelayNetworkErrors;
|
|
29
44
|
export declare function setTerminalError(error: Error, additionalAttributes?: TerminalErrorAdditionalAttributes, labelStack?: LabelStack): void;
|
|
30
45
|
export declare function useReportTerminalError(error: Error | null | undefined, additionalAttributes?: TerminalErrorAdditionalAttributes): void;
|
|
46
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.1",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -113,9 +113,6 @@
|
|
|
113
113
|
"ufo_fix_aborting_interaction_detection_during_ssr": {
|
|
114
114
|
"type": "boolean"
|
|
115
115
|
},
|
|
116
|
-
"platform_ufo_exclude_3p_elements_from_ttai": {
|
|
117
|
-
"type": "boolean"
|
|
118
|
-
},
|
|
119
116
|
"platform_ufo_exclude_3p_elements_from_ttvc": {
|
|
120
117
|
"type": "boolean"
|
|
121
118
|
},
|
|
@@ -131,9 +128,6 @@
|
|
|
131
128
|
"platform_ufo_segment_unmount_count": {
|
|
132
129
|
"type": "boolean"
|
|
133
130
|
},
|
|
134
|
-
"platform_ufo_enable_ttai_with_3p": {
|
|
135
|
-
"type": "boolean"
|
|
136
|
-
},
|
|
137
131
|
"platform_ufo_exclude_3p_extensions_from_ttvc": {
|
|
138
132
|
"type": "boolean"
|
|
139
133
|
},
|
|
@@ -164,9 +158,6 @@
|
|
|
164
158
|
"react_ufo_battery_info": {
|
|
165
159
|
"type": "boolean"
|
|
166
160
|
},
|
|
167
|
-
"platform_ufo_exclude_3p_attribute_changes": {
|
|
168
|
-
"type": "boolean"
|
|
169
|
-
},
|
|
170
161
|
"platform_ufo_use_native_page_visibility_api": {
|
|
171
162
|
"type": "boolean"
|
|
172
163
|
},
|
|
@@ -200,6 +191,9 @@
|
|
|
200
191
|
"platform_ufo_enable_terminal_errors": {
|
|
201
192
|
"type": "boolean"
|
|
202
193
|
},
|
|
194
|
+
"platform_ufo_terminal_errors_fix_missing_data": {
|
|
195
|
+
"type": "boolean"
|
|
196
|
+
},
|
|
203
197
|
"ufo_vc_revision_trim_enabled": {
|
|
204
198
|
"type": "boolean"
|
|
205
199
|
},
|