@atlaskit/react-ufo 5.0.8 → 5.0.9
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 +7 -0
- package/dist/cjs/create-terminal-error-payload/index.js +40 -0
- package/dist/cjs/interaction-metrics-init/index.js +30 -2
- package/dist/cjs/set-terminal-error/index.js +45 -0
- package/dist/es2019/create-terminal-error-payload/index.js +31 -0
- package/dist/es2019/interaction-metrics-init/index.js +26 -1
- package/dist/es2019/set-terminal-error/index.js +34 -0
- package/dist/esm/create-terminal-error-payload/index.js +33 -0
- package/dist/esm/interaction-metrics-init/index.js +29 -3
- package/dist/esm/set-terminal-error/index.js +36 -0
- package/dist/types/create-terminal-error-payload/index.d.ts +29 -0
- package/dist/types/set-terminal-error/index.d.ts +24 -0
- package/dist/types-ts4.5/create-terminal-error-payload/index.d.ts +29 -0
- package/dist/types-ts4.5/set-terminal-error/index.d.ts +24 -0
- package/package.json +4 -1
- package/set-terminal-error/package.json +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 5.0.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ff09fea96cf45`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ff09fea96cf45) -
|
|
8
|
+
Add custom terminal error reporting metric
|
|
9
|
+
|
|
3
10
|
## 5.0.8
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _config = require("../config");
|
|
10
|
+
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; }
|
|
11
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
12
|
+
function createTerminalErrorPayload(errorData, context) {
|
|
13
|
+
var _window$location;
|
|
14
|
+
var config = (0, _config.getConfig)();
|
|
15
|
+
if (!config) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
actionSubject: 'experience',
|
|
20
|
+
action: 'measured',
|
|
21
|
+
eventType: 'operational',
|
|
22
|
+
source: 'measured',
|
|
23
|
+
tags: ['observability'],
|
|
24
|
+
attributes: {
|
|
25
|
+
properties: _objectSpread({
|
|
26
|
+
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
27
|
+
'event:product': config.product,
|
|
28
|
+
'event:schema': '1.0.0',
|
|
29
|
+
'event:source': {
|
|
30
|
+
name: 'react-ufo/web',
|
|
31
|
+
version: '1.0.1'
|
|
32
|
+
},
|
|
33
|
+
'event:region': config.region || 'unknown',
|
|
34
|
+
'experience:key': 'custom.terminal-error',
|
|
35
|
+
terminalError: errorData
|
|
36
|
+
}, context)
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var _default = exports.default = createTerminalErrorPayload;
|
|
@@ -18,6 +18,7 @@ var _hiddenTiming = require("../hidden-timing");
|
|
|
18
18
|
var _interactionMetrics = require("../interaction-metrics");
|
|
19
19
|
var _interactionsPerformanceObserver = require("../interactions-performance-observer");
|
|
20
20
|
var _machineUtilisation = require("../machine-utilisation");
|
|
21
|
+
var _setTerminalError = require("../set-terminal-error");
|
|
21
22
|
var _scheduleIdleCallback = _interopRequireDefault(require("./schedule-idle-callback"));
|
|
22
23
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
23
24
|
var initialized = false;
|
|
@@ -79,6 +80,22 @@ function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
|
79
80
|
});
|
|
80
81
|
});
|
|
81
82
|
}
|
|
83
|
+
function sinkTerminalErrors(instance, createTerminalErrorPayload) {
|
|
84
|
+
(0, _setTerminalError.sinkTerminalErrorHandler)(function (errorData, context) {
|
|
85
|
+
(0, _scheduleIdleCallback.default)(function () {
|
|
86
|
+
var payload = createTerminalErrorPayload(errorData, context);
|
|
87
|
+
if (payload) {
|
|
88
|
+
if ((0, _platformFeatureFlags.fg)('enable_ufo_devtools_api_for_extra_events')) {
|
|
89
|
+
var devToolObserver = globalThis.__ufo_devtool_onUfoPayload;
|
|
90
|
+
if (typeof devToolObserver === 'function') {
|
|
91
|
+
devToolObserver === null || devToolObserver === void 0 || devToolObserver(payload);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
instance.sendOperationalEvent(payload);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
82
99
|
function sinkInteractionExtraMetrics(instance, createInteractionExtraLogPayload) {
|
|
83
100
|
_interactionMetrics.interactionExtraMetrics.sinkHandler(function (interactionId, interaction, lastInteractionFinish, lastInteractionFinishVCResult) {
|
|
84
101
|
(0, _scheduleIdleCallback.default)( /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
@@ -174,17 +191,24 @@ function init(analyticsWebClientAsync, config) {
|
|
|
174
191
|
return _interopRequireWildcard(require( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload'));
|
|
175
192
|
}), Promise.resolve().then(function () {
|
|
176
193
|
return _interopRequireWildcard(require( /* webpackChunkName: "create-interaction-extra-metrics-payload" */'../create-interaction-extra-metrics-payload'));
|
|
194
|
+
}), Promise.resolve().then(function () {
|
|
195
|
+
return _interopRequireWildcard(require( /* webpackChunkName: "create-terminal-error-payload@atlaskit-internal_terminal_errors" */'../create-terminal-error-payload'));
|
|
177
196
|
})]).then(function (_ref2) {
|
|
178
|
-
var _ref3 = (0, _slicedToArray2.default)(_ref2,
|
|
197
|
+
var _ref3 = (0, _slicedToArray2.default)(_ref2, 5),
|
|
179
198
|
awc = _ref3[0],
|
|
180
199
|
payloadPackage = _ref3[1],
|
|
181
200
|
createPostInteractionLogPayloadPackage = _ref3[2],
|
|
182
|
-
createInteractionExtraMetricsPayloadPackage = _ref3[3]
|
|
201
|
+
createInteractionExtraMetricsPayloadPackage = _ref3[3],
|
|
202
|
+
createTerminalErrorPayloadPackage = _ref3[4];
|
|
183
203
|
if (awc.getAnalyticsWebClientPromise) {
|
|
184
204
|
awc.getAnalyticsWebClientPromise().then(function (client) {
|
|
185
205
|
var _config$experimentalI2, _config$postInteracti, _config$extraInteract2, _config$extraSearchPa;
|
|
186
206
|
var instance = client.getInstance();
|
|
187
207
|
sinkInteraction(instance, payloadPackage);
|
|
208
|
+
// TODO: make this configurable
|
|
209
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_terminal_errors')) {
|
|
210
|
+
sinkTerminalErrors(instance, createTerminalErrorPayloadPackage.default);
|
|
211
|
+
}
|
|
188
212
|
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
189
213
|
sinkExperimentalInteractionMetrics(instance, payloadPackage);
|
|
190
214
|
}
|
|
@@ -201,6 +225,10 @@ function init(analyticsWebClientAsync, config) {
|
|
|
201
225
|
} else if (awc.sendOperationalEvent) {
|
|
202
226
|
var _config$experimentalI3, _config$postInteracti2, _config$extraInteract3, _config$extraSearchPa2;
|
|
203
227
|
sinkInteraction(awc, payloadPackage);
|
|
228
|
+
// TODO: make this configurable
|
|
229
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_terminal_errors')) {
|
|
230
|
+
sinkTerminalErrors(awc, createTerminalErrorPayloadPackage.default);
|
|
231
|
+
}
|
|
204
232
|
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
205
233
|
sinkExperimentalInteractionMetrics(awc, payloadPackage);
|
|
206
234
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.setTerminalError = setTerminalError;
|
|
8
|
+
exports.sinkTerminalErrorHandler = sinkTerminalErrorHandler;
|
|
9
|
+
exports.useReportTerminalError = useReportTerminalError;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _react = require("react");
|
|
12
|
+
var _interactionContext = require("../interaction-context");
|
|
13
|
+
var _interactionMetrics = require("../interaction-metrics");
|
|
14
|
+
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; }
|
|
15
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
16
|
+
var sinkHandlerFn = function sinkHandlerFn() {};
|
|
17
|
+
function sinkTerminalErrorHandler(fn) {
|
|
18
|
+
sinkHandlerFn = fn;
|
|
19
|
+
}
|
|
20
|
+
function setTerminalError(error, additionalAttributes, labelStack) {
|
|
21
|
+
var _activeInteraction$uf, _activeInteraction$id, _activeInteraction$ty;
|
|
22
|
+
var activeInteraction = (0, _interactionMetrics.getActiveInteraction)();
|
|
23
|
+
var errorData = _objectSpread({
|
|
24
|
+
errorType: error.name || 'Error',
|
|
25
|
+
errorMessage: error.message.slice(0, 100),
|
|
26
|
+
timestamp: performance.now()
|
|
27
|
+
}, additionalAttributes);
|
|
28
|
+
var context = {
|
|
29
|
+
labelStack: labelStack !== null && labelStack !== void 0 ? labelStack : null,
|
|
30
|
+
activeInteractionName: (_activeInteraction$uf = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.ufoName) !== null && _activeInteraction$uf !== void 0 ? _activeInteraction$uf : null,
|
|
31
|
+
activeInteractionId: (_activeInteraction$id = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.id) !== null && _activeInteraction$id !== void 0 ? _activeInteraction$id : null,
|
|
32
|
+
activeInteractionType: (_activeInteraction$ty = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.type) !== null && _activeInteraction$ty !== void 0 ? _activeInteraction$ty : null
|
|
33
|
+
};
|
|
34
|
+
sinkHandlerFn(errorData, context);
|
|
35
|
+
}
|
|
36
|
+
function useReportTerminalError(error, additionalAttributes) {
|
|
37
|
+
var interactionContext = (0, _interactionContext.useInteractionContext)();
|
|
38
|
+
var hasReportedRef = (0, _react.useRef)(false);
|
|
39
|
+
(0, _react.useEffect)(function () {
|
|
40
|
+
if (error && !hasReportedRef.current) {
|
|
41
|
+
hasReportedRef.current = true;
|
|
42
|
+
setTerminalError(error, additionalAttributes, interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.labelStack);
|
|
43
|
+
}
|
|
44
|
+
}, [error, additionalAttributes, interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.labelStack]);
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getConfig } from '../config';
|
|
2
|
+
function createTerminalErrorPayload(errorData, context) {
|
|
3
|
+
var _window$location;
|
|
4
|
+
const config = getConfig();
|
|
5
|
+
if (!config) {
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
actionSubject: 'experience',
|
|
10
|
+
action: 'measured',
|
|
11
|
+
eventType: 'operational',
|
|
12
|
+
source: 'measured',
|
|
13
|
+
tags: ['observability'],
|
|
14
|
+
attributes: {
|
|
15
|
+
properties: {
|
|
16
|
+
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
17
|
+
'event:product': config.product,
|
|
18
|
+
'event:schema': '1.0.0',
|
|
19
|
+
'event:source': {
|
|
20
|
+
name: 'react-ufo/web',
|
|
21
|
+
version: '1.0.1'
|
|
22
|
+
},
|
|
23
|
+
'event:region': config.region || 'unknown',
|
|
24
|
+
'experience:key': 'custom.terminal-error',
|
|
25
|
+
terminalError: errorData,
|
|
26
|
+
...context
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export default createTerminalErrorPayload;
|
|
@@ -7,6 +7,7 @@ import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
|
7
7
|
import { interactionExtraMetrics, postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
8
8
|
import { getPerformanceObserver } from '../interactions-performance-observer';
|
|
9
9
|
import { initialiseMemoryObserver, initialisePressureObserver } from '../machine-utilisation';
|
|
10
|
+
import { sinkTerminalErrorHandler } from '../set-terminal-error';
|
|
10
11
|
import scheduleIdleCallback from './schedule-idle-callback';
|
|
11
12
|
let initialized = false;
|
|
12
13
|
function sinkInteraction(instance, payloadPackage) {
|
|
@@ -67,6 +68,22 @@ function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
|
67
68
|
});
|
|
68
69
|
});
|
|
69
70
|
}
|
|
71
|
+
function sinkTerminalErrors(instance, createTerminalErrorPayload) {
|
|
72
|
+
sinkTerminalErrorHandler((errorData, context) => {
|
|
73
|
+
scheduleIdleCallback(() => {
|
|
74
|
+
const payload = createTerminalErrorPayload(errorData, context);
|
|
75
|
+
if (payload) {
|
|
76
|
+
if (fg('enable_ufo_devtools_api_for_extra_events')) {
|
|
77
|
+
const devToolObserver = globalThis.__ufo_devtool_onUfoPayload;
|
|
78
|
+
if (typeof devToolObserver === 'function') {
|
|
79
|
+
devToolObserver === null || devToolObserver === void 0 ? void 0 : devToolObserver(payload);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
instance.sendOperationalEvent(payload);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
70
87
|
function sinkInteractionExtraMetrics(instance, createInteractionExtraLogPayload) {
|
|
71
88
|
interactionExtraMetrics.sinkHandler((interactionId, interaction, lastInteractionFinish, lastInteractionFinishVCResult) => {
|
|
72
89
|
scheduleIdleCallback(async () => {
|
|
@@ -144,12 +161,16 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
144
161
|
durationThreshold: 16
|
|
145
162
|
});
|
|
146
163
|
}
|
|
147
|
-
Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload'), import( /* webpackChunkName: "create-interaction-extra-metrics-payload" */'../create-interaction-extra-metrics-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage, createInteractionExtraMetricsPayloadPackage]) => {
|
|
164
|
+
Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload'), import( /* webpackChunkName: "create-interaction-extra-metrics-payload" */'../create-interaction-extra-metrics-payload'), import( /* webpackChunkName: "create-terminal-error-payload@atlaskit-internal_terminal_errors" */'../create-terminal-error-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage, createInteractionExtraMetricsPayloadPackage, createTerminalErrorPayloadPackage]) => {
|
|
148
165
|
if (awc.getAnalyticsWebClientPromise) {
|
|
149
166
|
awc.getAnalyticsWebClientPromise().then(client => {
|
|
150
167
|
var _config$experimentalI2, _config$postInteracti, _config$extraInteract2, _config$extraSearchPa;
|
|
151
168
|
const instance = client.getInstance();
|
|
152
169
|
sinkInteraction(instance, payloadPackage);
|
|
170
|
+
// TODO: make this configurable
|
|
171
|
+
if (fg('platform_ufo_enable_terminal_errors')) {
|
|
172
|
+
sinkTerminalErrors(instance, createTerminalErrorPayloadPackage.default);
|
|
173
|
+
}
|
|
153
174
|
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
154
175
|
sinkExperimentalInteractionMetrics(instance, payloadPackage);
|
|
155
176
|
}
|
|
@@ -166,6 +187,10 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
166
187
|
} else if (awc.sendOperationalEvent) {
|
|
167
188
|
var _config$experimentalI3, _config$postInteracti2, _config$extraInteract3, _config$extraSearchPa2;
|
|
168
189
|
sinkInteraction(awc, payloadPackage);
|
|
190
|
+
// TODO: make this configurable
|
|
191
|
+
if (fg('platform_ufo_enable_terminal_errors')) {
|
|
192
|
+
sinkTerminalErrors(awc, createTerminalErrorPayloadPackage.default);
|
|
193
|
+
}
|
|
169
194
|
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
170
195
|
sinkExperimentalInteractionMetrics(awc, payloadPackage);
|
|
171
196
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useInteractionContext } from '../interaction-context';
|
|
3
|
+
import { getActiveInteraction } from '../interaction-metrics';
|
|
4
|
+
let sinkHandlerFn = () => {};
|
|
5
|
+
export function sinkTerminalErrorHandler(fn) {
|
|
6
|
+
sinkHandlerFn = fn;
|
|
7
|
+
}
|
|
8
|
+
export function setTerminalError(error, additionalAttributes, labelStack) {
|
|
9
|
+
var _activeInteraction$uf, _activeInteraction$id, _activeInteraction$ty;
|
|
10
|
+
const activeInteraction = getActiveInteraction();
|
|
11
|
+
const errorData = {
|
|
12
|
+
errorType: error.name || 'Error',
|
|
13
|
+
errorMessage: error.message.slice(0, 100),
|
|
14
|
+
timestamp: performance.now(),
|
|
15
|
+
...additionalAttributes
|
|
16
|
+
};
|
|
17
|
+
const context = {
|
|
18
|
+
labelStack: labelStack !== null && labelStack !== void 0 ? labelStack : null,
|
|
19
|
+
activeInteractionName: (_activeInteraction$uf = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.ufoName) !== null && _activeInteraction$uf !== void 0 ? _activeInteraction$uf : null,
|
|
20
|
+
activeInteractionId: (_activeInteraction$id = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.id) !== null && _activeInteraction$id !== void 0 ? _activeInteraction$id : null,
|
|
21
|
+
activeInteractionType: (_activeInteraction$ty = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.type) !== null && _activeInteraction$ty !== void 0 ? _activeInteraction$ty : null
|
|
22
|
+
};
|
|
23
|
+
sinkHandlerFn(errorData, context);
|
|
24
|
+
}
|
|
25
|
+
export function useReportTerminalError(error, additionalAttributes) {
|
|
26
|
+
const interactionContext = useInteractionContext();
|
|
27
|
+
const hasReportedRef = useRef(false);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (error && !hasReportedRef.current) {
|
|
30
|
+
hasReportedRef.current = true;
|
|
31
|
+
setTerminalError(error, additionalAttributes, interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.labelStack);
|
|
32
|
+
}
|
|
33
|
+
}, [error, additionalAttributes, interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.labelStack]);
|
|
34
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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
|
+
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
|
+
import { getConfig } from '../config';
|
|
5
|
+
function createTerminalErrorPayload(errorData, context) {
|
|
6
|
+
var _window$location;
|
|
7
|
+
var config = getConfig();
|
|
8
|
+
if (!config) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
actionSubject: 'experience',
|
|
13
|
+
action: 'measured',
|
|
14
|
+
eventType: 'operational',
|
|
15
|
+
source: 'measured',
|
|
16
|
+
tags: ['observability'],
|
|
17
|
+
attributes: {
|
|
18
|
+
properties: _objectSpread({
|
|
19
|
+
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
20
|
+
'event:product': config.product,
|
|
21
|
+
'event:schema': '1.0.0',
|
|
22
|
+
'event:source': {
|
|
23
|
+
name: 'react-ufo/web',
|
|
24
|
+
version: '1.0.1'
|
|
25
|
+
},
|
|
26
|
+
'event:region': config.region || 'unknown',
|
|
27
|
+
'experience:key': 'custom.terminal-error',
|
|
28
|
+
terminalError: errorData
|
|
29
|
+
}, context)
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export default createTerminalErrorPayload;
|
|
@@ -10,6 +10,7 @@ import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
|
10
10
|
import { interactionExtraMetrics, postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
11
11
|
import { getPerformanceObserver } from '../interactions-performance-observer';
|
|
12
12
|
import { initialiseMemoryObserver, initialisePressureObserver } from '../machine-utilisation';
|
|
13
|
+
import { sinkTerminalErrorHandler } from '../set-terminal-error';
|
|
13
14
|
import scheduleIdleCallback from './schedule-idle-callback';
|
|
14
15
|
var initialized = false;
|
|
15
16
|
function sinkInteraction(instance, payloadPackage) {
|
|
@@ -70,6 +71,22 @@ function sinkPostInteractionLog(instance, createPostInteractionLogPayload) {
|
|
|
70
71
|
});
|
|
71
72
|
});
|
|
72
73
|
}
|
|
74
|
+
function sinkTerminalErrors(instance, createTerminalErrorPayload) {
|
|
75
|
+
sinkTerminalErrorHandler(function (errorData, context) {
|
|
76
|
+
scheduleIdleCallback(function () {
|
|
77
|
+
var payload = createTerminalErrorPayload(errorData, context);
|
|
78
|
+
if (payload) {
|
|
79
|
+
if (fg('enable_ufo_devtools_api_for_extra_events')) {
|
|
80
|
+
var devToolObserver = globalThis.__ufo_devtool_onUfoPayload;
|
|
81
|
+
if (typeof devToolObserver === 'function') {
|
|
82
|
+
devToolObserver === null || devToolObserver === void 0 || devToolObserver(payload);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
instance.sendOperationalEvent(payload);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
73
90
|
function sinkInteractionExtraMetrics(instance, createInteractionExtraLogPayload) {
|
|
74
91
|
interactionExtraMetrics.sinkHandler(function (interactionId, interaction, lastInteractionFinish, lastInteractionFinishVCResult) {
|
|
75
92
|
scheduleIdleCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
@@ -159,17 +176,22 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
159
176
|
durationThreshold: 16
|
|
160
177
|
});
|
|
161
178
|
}
|
|
162
|
-
Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload'), import( /* webpackChunkName: "create-interaction-extra-metrics-payload" */'../create-interaction-extra-metrics-payload')]).then(function (_ref2) {
|
|
163
|
-
var _ref3 = _slicedToArray(_ref2,
|
|
179
|
+
Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload'), import( /* webpackChunkName: "create-interaction-extra-metrics-payload" */'../create-interaction-extra-metrics-payload'), import( /* webpackChunkName: "create-terminal-error-payload@atlaskit-internal_terminal_errors" */'../create-terminal-error-payload')]).then(function (_ref2) {
|
|
180
|
+
var _ref3 = _slicedToArray(_ref2, 5),
|
|
164
181
|
awc = _ref3[0],
|
|
165
182
|
payloadPackage = _ref3[1],
|
|
166
183
|
createPostInteractionLogPayloadPackage = _ref3[2],
|
|
167
|
-
createInteractionExtraMetricsPayloadPackage = _ref3[3]
|
|
184
|
+
createInteractionExtraMetricsPayloadPackage = _ref3[3],
|
|
185
|
+
createTerminalErrorPayloadPackage = _ref3[4];
|
|
168
186
|
if (awc.getAnalyticsWebClientPromise) {
|
|
169
187
|
awc.getAnalyticsWebClientPromise().then(function (client) {
|
|
170
188
|
var _config$experimentalI2, _config$postInteracti, _config$extraInteract2, _config$extraSearchPa;
|
|
171
189
|
var instance = client.getInstance();
|
|
172
190
|
sinkInteraction(instance, payloadPackage);
|
|
191
|
+
// TODO: make this configurable
|
|
192
|
+
if (fg('platform_ufo_enable_terminal_errors')) {
|
|
193
|
+
sinkTerminalErrors(instance, createTerminalErrorPayloadPackage.default);
|
|
194
|
+
}
|
|
173
195
|
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
174
196
|
sinkExperimentalInteractionMetrics(instance, payloadPackage);
|
|
175
197
|
}
|
|
@@ -186,6 +208,10 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
186
208
|
} else if (awc.sendOperationalEvent) {
|
|
187
209
|
var _config$experimentalI3, _config$postInteracti2, _config$extraInteract3, _config$extraSearchPa2;
|
|
188
210
|
sinkInteraction(awc, payloadPackage);
|
|
211
|
+
// TODO: make this configurable
|
|
212
|
+
if (fg('platform_ufo_enable_terminal_errors')) {
|
|
213
|
+
sinkTerminalErrors(awc, createTerminalErrorPayloadPackage.default);
|
|
214
|
+
}
|
|
189
215
|
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
190
216
|
sinkExperimentalInteractionMetrics(awc, payloadPackage);
|
|
191
217
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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
|
+
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
|
+
import { useEffect, useRef } from 'react';
|
|
5
|
+
import { useInteractionContext } from '../interaction-context';
|
|
6
|
+
import { getActiveInteraction } from '../interaction-metrics';
|
|
7
|
+
var sinkHandlerFn = function sinkHandlerFn() {};
|
|
8
|
+
export function sinkTerminalErrorHandler(fn) {
|
|
9
|
+
sinkHandlerFn = fn;
|
|
10
|
+
}
|
|
11
|
+
export function setTerminalError(error, additionalAttributes, labelStack) {
|
|
12
|
+
var _activeInteraction$uf, _activeInteraction$id, _activeInteraction$ty;
|
|
13
|
+
var activeInteraction = getActiveInteraction();
|
|
14
|
+
var errorData = _objectSpread({
|
|
15
|
+
errorType: error.name || 'Error',
|
|
16
|
+
errorMessage: error.message.slice(0, 100),
|
|
17
|
+
timestamp: performance.now()
|
|
18
|
+
}, additionalAttributes);
|
|
19
|
+
var context = {
|
|
20
|
+
labelStack: labelStack !== null && labelStack !== void 0 ? labelStack : null,
|
|
21
|
+
activeInteractionName: (_activeInteraction$uf = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.ufoName) !== null && _activeInteraction$uf !== void 0 ? _activeInteraction$uf : null,
|
|
22
|
+
activeInteractionId: (_activeInteraction$id = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.id) !== null && _activeInteraction$id !== void 0 ? _activeInteraction$id : null,
|
|
23
|
+
activeInteractionType: (_activeInteraction$ty = activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.type) !== null && _activeInteraction$ty !== void 0 ? _activeInteraction$ty : null
|
|
24
|
+
};
|
|
25
|
+
sinkHandlerFn(errorData, context);
|
|
26
|
+
}
|
|
27
|
+
export function useReportTerminalError(error, additionalAttributes) {
|
|
28
|
+
var interactionContext = useInteractionContext();
|
|
29
|
+
var hasReportedRef = useRef(false);
|
|
30
|
+
useEffect(function () {
|
|
31
|
+
if (error && !hasReportedRef.current) {
|
|
32
|
+
hasReportedRef.current = true;
|
|
33
|
+
setTerminalError(error, additionalAttributes, interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.labelStack);
|
|
34
|
+
}
|
|
35
|
+
}, [error, additionalAttributes, interactionContext === null || interactionContext === void 0 ? void 0 : interactionContext.labelStack]);
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LabelStack } from '../interaction-context';
|
|
2
|
+
import type { TerminalErrorContext, TerminalErrorData } from '../set-terminal-error';
|
|
3
|
+
export interface TerminalErrorPayload {
|
|
4
|
+
actionSubject: string;
|
|
5
|
+
action: string;
|
|
6
|
+
eventType: string;
|
|
7
|
+
source: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
attributes: {
|
|
10
|
+
properties: {
|
|
11
|
+
'event:hostname': string;
|
|
12
|
+
'event:product': string;
|
|
13
|
+
'event:schema': string;
|
|
14
|
+
'event:source': {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
};
|
|
18
|
+
'event:region': string;
|
|
19
|
+
'experience:key': string;
|
|
20
|
+
terminalError: TerminalErrorData;
|
|
21
|
+
activeInteractionName: string | null;
|
|
22
|
+
activeInteractionId: string | null;
|
|
23
|
+
activeInteractionType: string | null;
|
|
24
|
+
labelStack: LabelStack | null;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
declare function createTerminalErrorPayload(errorData: TerminalErrorData, context: TerminalErrorContext): TerminalErrorPayload | null;
|
|
29
|
+
export default createTerminalErrorPayload;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type LabelStack } from '../interaction-context';
|
|
2
|
+
export interface TerminalErrorAdditionalAttributes {
|
|
3
|
+
teamName?: string;
|
|
4
|
+
packageName?: string;
|
|
5
|
+
errorBoundaryId?: string;
|
|
6
|
+
errorHash?: string;
|
|
7
|
+
traceId?: string;
|
|
8
|
+
fallbackType?: 'page' | 'flag' | 'custom';
|
|
9
|
+
statusCode?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TerminalErrorData extends TerminalErrorAdditionalAttributes {
|
|
12
|
+
errorType: string;
|
|
13
|
+
errorMessage: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TerminalErrorContext {
|
|
17
|
+
labelStack: LabelStack | null;
|
|
18
|
+
activeInteractionName: string | null;
|
|
19
|
+
activeInteractionId: string | null;
|
|
20
|
+
activeInteractionType: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function sinkTerminalErrorHandler(fn: (errorData: TerminalErrorData, context: TerminalErrorContext) => void | Promise<void>): void;
|
|
23
|
+
export declare function setTerminalError(error: Error, additionalAttributes?: TerminalErrorAdditionalAttributes, labelStack?: LabelStack): void;
|
|
24
|
+
export declare function useReportTerminalError(error: Error | null | undefined, additionalAttributes?: TerminalErrorAdditionalAttributes): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LabelStack } from '../interaction-context';
|
|
2
|
+
import type { TerminalErrorContext, TerminalErrorData } from '../set-terminal-error';
|
|
3
|
+
export interface TerminalErrorPayload {
|
|
4
|
+
actionSubject: string;
|
|
5
|
+
action: string;
|
|
6
|
+
eventType: string;
|
|
7
|
+
source: string;
|
|
8
|
+
tags: string[];
|
|
9
|
+
attributes: {
|
|
10
|
+
properties: {
|
|
11
|
+
'event:hostname': string;
|
|
12
|
+
'event:product': string;
|
|
13
|
+
'event:schema': string;
|
|
14
|
+
'event:source': {
|
|
15
|
+
name: string;
|
|
16
|
+
version: string;
|
|
17
|
+
};
|
|
18
|
+
'event:region': string;
|
|
19
|
+
'experience:key': string;
|
|
20
|
+
terminalError: TerminalErrorData;
|
|
21
|
+
activeInteractionName: string | null;
|
|
22
|
+
activeInteractionId: string | null;
|
|
23
|
+
activeInteractionType: string | null;
|
|
24
|
+
labelStack: LabelStack | null;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
declare function createTerminalErrorPayload(errorData: TerminalErrorData, context: TerminalErrorContext): TerminalErrorPayload | null;
|
|
29
|
+
export default createTerminalErrorPayload;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type LabelStack } from '../interaction-context';
|
|
2
|
+
export interface TerminalErrorAdditionalAttributes {
|
|
3
|
+
teamName?: string;
|
|
4
|
+
packageName?: string;
|
|
5
|
+
errorBoundaryId?: string;
|
|
6
|
+
errorHash?: string;
|
|
7
|
+
traceId?: string;
|
|
8
|
+
fallbackType?: 'page' | 'flag' | 'custom';
|
|
9
|
+
statusCode?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TerminalErrorData extends TerminalErrorAdditionalAttributes {
|
|
12
|
+
errorType: string;
|
|
13
|
+
errorMessage: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
}
|
|
16
|
+
export interface TerminalErrorContext {
|
|
17
|
+
labelStack: LabelStack | null;
|
|
18
|
+
activeInteractionName: string | null;
|
|
19
|
+
activeInteractionId: string | null;
|
|
20
|
+
activeInteractionType: string | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function sinkTerminalErrorHandler(fn: (errorData: TerminalErrorData, context: TerminalErrorContext) => void | Promise<void>): void;
|
|
23
|
+
export declare function setTerminalError(error: Error, additionalAttributes?: TerminalErrorAdditionalAttributes, labelStack?: LabelStack): void;
|
|
24
|
+
export declare function useReportTerminalError(error: Error | null | undefined, additionalAttributes?: TerminalErrorAdditionalAttributes): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.9",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -219,6 +219,9 @@
|
|
|
219
219
|
},
|
|
220
220
|
"jfp-magma-ufo-event-listener-error": {
|
|
221
221
|
"type": "boolean"
|
|
222
|
+
},
|
|
223
|
+
"platform_ufo_enable_terminal_errors": {
|
|
224
|
+
"type": "boolean"
|
|
222
225
|
}
|
|
223
226
|
}
|
|
224
227
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/react-ufo/set-terminal-error",
|
|
3
|
+
"main": "../dist/cjs/set-terminal-error/index.js",
|
|
4
|
+
"module": "../dist/esm/set-terminal-error/index.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/set-terminal-error/index.js",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "../dist/types/set-terminal-error/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.5 <5.9": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.5/set-terminal-error/index.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|