@atlaskit/react-ufo 5.0.13 → 5.1.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/CHANGELOG.md +21 -0
- package/dist/cjs/create-payload/index.js +2 -2
- package/dist/cjs/experience-trace-id-context/context-manager.js +180 -0
- package/dist/cjs/experience-trace-id-context/index.js +67 -11
- package/dist/cjs/interaction-metrics-init/index.js +15 -6
- package/dist/cjs/typing-performance-tracing/index.js +7 -14
- package/dist/cjs/vc/index.js +6 -6
- package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +1 -3
- package/dist/es2019/create-payload/index.js +1 -1
- package/dist/es2019/experience-trace-id-context/context-manager.js +142 -0
- package/dist/es2019/experience-trace-id-context/index.js +65 -9
- package/dist/es2019/interaction-metrics-init/index.js +15 -6
- package/dist/es2019/typing-performance-tracing/index.js +7 -14
- package/dist/es2019/vc/index.js +6 -6
- package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +1 -3
- package/dist/esm/create-payload/index.js +2 -2
- package/dist/esm/experience-trace-id-context/context-manager.js +172 -0
- package/dist/esm/experience-trace-id-context/index.js +67 -11
- package/dist/esm/interaction-metrics-init/index.js +15 -6
- package/dist/esm/typing-performance-tracing/index.js +7 -14
- package/dist/esm/vc/index.js +6 -6
- package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +1 -3
- package/dist/types/common/react-ufo-payload-schema.d.ts +5 -0
- package/dist/types/config/index.d.ts +6 -0
- package/dist/types/experience-trace-id-context/context-manager.d.ts +65 -0
- package/dist/types-ts4.5/common/react-ufo-payload-schema.d.ts +5 -0
- package/dist/types-ts4.5/config/index.d.ts +6 -0
- package/dist/types-ts4.5/experience-trace-id-context/context-manager.d.ts +65 -0
- package/package.json +6 -8
|
@@ -1,35 +1,91 @@
|
|
|
1
|
+
import { context, createContextKey, ROOT_CONTEXT } from '@opentelemetry/api';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
|
+
import { getContextManager, UFOContextManager } from './context-manager';
|
|
1
4
|
import { makeTraceHttpRequestHeaders } from './utils/make-trace-http-request-headers';
|
|
2
5
|
var state = {
|
|
3
6
|
context: null
|
|
4
7
|
};
|
|
8
|
+
var traceIdKey = createContextKey("traceId");
|
|
9
|
+
var spanIdKey = createContextKey("spanId");
|
|
10
|
+
var experienceTypeKey = createContextKey("type");
|
|
11
|
+
|
|
12
|
+
// DO NOT CALL THIS FUNCTION DIRECTLY!!!!
|
|
13
|
+
// It is only to be called by React UFO libraries for the automatic handling of trace context for experiences.
|
|
14
|
+
// Calling this may cause trace context to be broken
|
|
5
15
|
export function generateSpanId() {
|
|
6
16
|
return Array.from(new Array(16), function () {
|
|
7
17
|
return Math.floor(Math.random() * 16).toString(16);
|
|
8
18
|
}).join('');
|
|
9
19
|
}
|
|
20
|
+
|
|
21
|
+
// DO NOT CALL THIS FUNCTION DIRECTLY!!!!
|
|
22
|
+
// It is only to be called by React UFO libraries for the automatic handling of trace context for experiences.
|
|
23
|
+
// Calling this may cause trace context to be broken
|
|
10
24
|
export function setInteractionActiveTrace(interactionId, experienceType) {
|
|
11
25
|
setActiveTrace(interactionId.replace(/-/g, ''), generateSpanId(), experienceType);
|
|
12
26
|
}
|
|
27
|
+
|
|
28
|
+
// DO NOT CALL THIS FUNCTION DIRECTLY!!!!
|
|
29
|
+
// It is only to be called by React UFO libraries for the automatic handling of trace context for experiences.
|
|
30
|
+
// Calling this may cause trace context to be broken
|
|
13
31
|
export function setActiveTrace(traceId, spanId, type) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
if (fg('platform_ufo_enable_otel_context_manager')) {
|
|
33
|
+
var activeTraceContext = ROOT_CONTEXT.setValue(traceIdKey, traceId).setValue(spanIdKey, spanId).setValue(experienceTypeKey, type);
|
|
34
|
+
|
|
35
|
+
// Now we need to get the global Context Manager and set the active context
|
|
36
|
+
// Using type assertion because we've "extended" the ContextManager type
|
|
37
|
+
if (getContextManager() instanceof UFOContextManager) {
|
|
38
|
+
var contextManager = getContextManager();
|
|
39
|
+
contextManager.setActive(activeTraceContext);
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
state.context = {
|
|
43
|
+
traceId: traceId,
|
|
44
|
+
spanId: spanId,
|
|
45
|
+
type: type
|
|
46
|
+
};
|
|
47
|
+
}
|
|
19
48
|
}
|
|
20
49
|
export function getActiveTrace() {
|
|
21
|
-
|
|
50
|
+
if (fg('platform_ufo_enable_otel_context_manager')) {
|
|
51
|
+
// Get trace context from active context
|
|
52
|
+
var activeTraceContext = {
|
|
53
|
+
traceId: String(context.active().getValue(traceIdKey)),
|
|
54
|
+
spanId: String(context.active().getValue(spanIdKey)),
|
|
55
|
+
type: String(context.active().getValue(experienceTypeKey))
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// Return activeTraceContext if traceId and spanId are not "undefined"
|
|
59
|
+
return activeTraceContext.traceId !== 'undefined' && activeTraceContext.spanId !== 'undefined' ? activeTraceContext : undefined;
|
|
60
|
+
} else {
|
|
61
|
+
return state.context || undefined;
|
|
62
|
+
}
|
|
22
63
|
}
|
|
64
|
+
|
|
65
|
+
// DO NOT CALL THIS FUNCTION DIRECTLY!!!!
|
|
66
|
+
// It is only to be called by React UFO libraries for the automatic handling of trace context for experiences.
|
|
67
|
+
// Calling this may cause trace context to be broken
|
|
23
68
|
export function clearActiveTrace() {
|
|
24
|
-
|
|
69
|
+
if (fg('platform_ufo_enable_otel_context_manager')) {
|
|
70
|
+
// Now we need to get the global Context Manager and set the active context
|
|
71
|
+
// Using type assertion because we've "extended" the ContextManager type
|
|
72
|
+
if (getContextManager() instanceof UFOContextManager) {
|
|
73
|
+
var contextManager = getContextManager();
|
|
74
|
+
|
|
75
|
+
// ROOT_CONTEXT is an empty context used to initialise ContextManagers
|
|
76
|
+
contextManager.setActive(ROOT_CONTEXT);
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
state.context = null;
|
|
80
|
+
}
|
|
25
81
|
}
|
|
26
82
|
export function getActiveTraceHttpRequestHeaders(_url) {
|
|
27
|
-
if (
|
|
83
|
+
if (getActiveTrace() === undefined) {
|
|
28
84
|
return null;
|
|
29
85
|
}
|
|
30
|
-
var
|
|
31
|
-
traceId =
|
|
32
|
-
spanId =
|
|
86
|
+
var _ref = getActiveTrace(),
|
|
87
|
+
traceId = _ref.traceId,
|
|
88
|
+
spanId = _ref.spanId;
|
|
33
89
|
return makeTraceHttpRequestHeaders(traceId, spanId);
|
|
34
90
|
}
|
|
35
91
|
export function getActiveTraceAsQueryParams(_url) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import { context } from '@opentelemetry/api';
|
|
4
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { startLighthouseObserver } from '../additional-payload';
|
|
6
7
|
import { setUFOConfig } from '../config';
|
|
7
8
|
import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-interaction-metrics-payload';
|
|
8
9
|
import { sinkExtraSearchPageInteractionHandler } from '../create-extra-search-page-interaction-payload';
|
|
10
|
+
import { setContextManager, UFOContextManager } from '../experience-trace-id-context/context-manager';
|
|
9
11
|
import { setupHiddenTimingCapture } from '../hidden-timing';
|
|
10
12
|
import { interactionExtraMetrics, postInteractionLog, sinkInteractionHandler, sinkPostInteractionLogHandler } from '../interaction-metrics';
|
|
11
13
|
import { getPerformanceObserver } from '../interactions-performance-observer';
|
|
@@ -146,6 +148,15 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
146
148
|
initialisePressureObserver();
|
|
147
149
|
initialiseMemoryObserver();
|
|
148
150
|
setUFOConfig(config);
|
|
151
|
+
if (fg('platform_ufo_enable_otel_context_manager')) {
|
|
152
|
+
// Configure global OTel context manager
|
|
153
|
+
var contextManager = new UFOContextManager();
|
|
154
|
+
// set the contextmanager somewhere we can reference it later
|
|
155
|
+
setContextManager(contextManager);
|
|
156
|
+
// Register the context manager with the global OTel API
|
|
157
|
+
contextManager.enable();
|
|
158
|
+
context.setGlobalContextManager(contextManager);
|
|
159
|
+
}
|
|
149
160
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
150
161
|
var _config$experimentalI, _config$extraInteract;
|
|
151
162
|
var vcOptions = {
|
|
@@ -185,11 +196,10 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
185
196
|
createTerminalErrorPayloadPackage = _ref3[4];
|
|
186
197
|
if (awc.getAnalyticsWebClientPromise) {
|
|
187
198
|
awc.getAnalyticsWebClientPromise().then(function (client) {
|
|
188
|
-
var _config$experimentalI2, _config$postInteracti, _config$extraInteract2, _config$extraSearchPa;
|
|
199
|
+
var _config$terminalError, _config$experimentalI2, _config$postInteracti, _config$extraInteract2, _config$extraSearchPa;
|
|
189
200
|
var instance = client.getInstance();
|
|
190
201
|
sinkInteraction(instance, payloadPackage);
|
|
191
|
-
|
|
192
|
-
if (fg('platform_ufo_enable_terminal_errors')) {
|
|
202
|
+
if (config !== null && config !== void 0 && (_config$terminalError = config.terminalErrors) !== null && _config$terminalError !== void 0 && _config$terminalError.enabled && fg('platform_ufo_enable_terminal_errors')) {
|
|
193
203
|
sinkTerminalErrors(instance, createTerminalErrorPayloadPackage.default);
|
|
194
204
|
}
|
|
195
205
|
if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
|
|
@@ -206,10 +216,9 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
206
216
|
}
|
|
207
217
|
});
|
|
208
218
|
} else if (awc.sendOperationalEvent) {
|
|
209
|
-
var _config$experimentalI3, _config$postInteracti2, _config$extraInteract3, _config$extraSearchPa2;
|
|
219
|
+
var _config$terminalError2, _config$experimentalI3, _config$postInteracti2, _config$extraInteract3, _config$extraSearchPa2;
|
|
210
220
|
sinkInteraction(awc, payloadPackage);
|
|
211
|
-
|
|
212
|
-
if (fg('platform_ufo_enable_terminal_errors')) {
|
|
221
|
+
if (config !== null && config !== void 0 && (_config$terminalError2 = config.terminalErrors) !== null && _config$terminalError2 !== void 0 && _config$terminalError2.enabled && fg('platform_ufo_enable_terminal_errors')) {
|
|
213
222
|
sinkTerminalErrors(awc, createTerminalErrorPayloadPackage.default);
|
|
214
223
|
}
|
|
215
224
|
if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
|
|
@@ -2,7 +2,6 @@ import { useEffect, useRef } from 'react';
|
|
|
2
2
|
import { unstable_IdlePriority as idlePriority, unstable_scheduleCallback as scheduleCallback } from 'scheduler';
|
|
3
3
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
4
4
|
import { v4 as createUUID } from 'uuid';
|
|
5
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import coinflip from '../coinflip';
|
|
7
6
|
import { getInteractionRate, getTypingPerformanceTracingMethod } from '../config';
|
|
8
7
|
import { addMetadata, addNewInteraction, tryComplete } from '../interaction-metrics';
|
|
@@ -73,13 +72,13 @@ function typingPerformanceTracingTimeout(element, name, rate) {
|
|
|
73
72
|
tsubmit = setTimeout(end, 2000); // debounce
|
|
74
73
|
}, 0);
|
|
75
74
|
};
|
|
76
|
-
if (typeof (element === null || element === void 0 ? void 0 : element.addEventListener) !== 'function'
|
|
75
|
+
if (typeof (element === null || element === void 0 ? void 0 : element.addEventListener) !== 'function') {
|
|
77
76
|
return;
|
|
78
77
|
}
|
|
79
78
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
80
79
|
element.addEventListener('keypress', onKeyPressHandler);
|
|
81
80
|
return function () {
|
|
82
|
-
if (typeof (element === null || element === void 0 ? void 0 : element.removeEventListener) !== 'function'
|
|
81
|
+
if (typeof (element === null || element === void 0 ? void 0 : element.removeEventListener) !== 'function') {
|
|
83
82
|
return;
|
|
84
83
|
}
|
|
85
84
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -150,13 +149,13 @@ function typingPerformanceTracingTimeoutNoAlloc(element, name, rate) {
|
|
|
150
149
|
tsubmit = setTimeout(end, 2000); // debounce
|
|
151
150
|
}, 0);
|
|
152
151
|
};
|
|
153
|
-
if (typeof (element === null || element === void 0 ? void 0 : element.addEventListener) !== 'function'
|
|
152
|
+
if (typeof (element === null || element === void 0 ? void 0 : element.addEventListener) !== 'function') {
|
|
154
153
|
return;
|
|
155
154
|
}
|
|
156
155
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
157
156
|
element.addEventListener('keypress', onKeyPressHandler);
|
|
158
157
|
return function () {
|
|
159
|
-
if (typeof (element === null || element === void 0 ? void 0 : element.removeEventListener) !== 'function'
|
|
158
|
+
if (typeof (element === null || element === void 0 ? void 0 : element.removeEventListener) !== 'function') {
|
|
160
159
|
return;
|
|
161
160
|
}
|
|
162
161
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
@@ -243,7 +242,7 @@ function typingPerformanceTracingMutationObserver(element, name, rate) {
|
|
|
243
242
|
childList: true,
|
|
244
243
|
subtree: true
|
|
245
244
|
});
|
|
246
|
-
if (typeof (element === null || element === void 0 ? void 0 : element.addEventListener) !== 'function'
|
|
245
|
+
if (typeof (element === null || element === void 0 ? void 0 : element.addEventListener) !== 'function') {
|
|
247
246
|
return function () {
|
|
248
247
|
return mo.disconnect();
|
|
249
248
|
};
|
|
@@ -251,17 +250,11 @@ function typingPerformanceTracingMutationObserver(element, name, rate) {
|
|
|
251
250
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
252
251
|
element.addEventListener('keypress', onKeyPressHandler);
|
|
253
252
|
return function () {
|
|
254
|
-
if (
|
|
255
|
-
if (typeof (element === null || element === void 0 ? void 0 : element.removeEventListener) === 'function') {
|
|
256
|
-
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
257
|
-
element.removeEventListener('keypress', onKeyPressHandler);
|
|
258
|
-
}
|
|
259
|
-
mo.disconnect();
|
|
260
|
-
} else {
|
|
253
|
+
if (typeof (element === null || element === void 0 ? void 0 : element.removeEventListener) === 'function') {
|
|
261
254
|
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
262
255
|
element.removeEventListener('keypress', onKeyPressHandler);
|
|
263
|
-
mo.disconnect();
|
|
264
256
|
}
|
|
257
|
+
mo.disconnect();
|
|
265
258
|
};
|
|
266
259
|
}
|
|
267
260
|
var typingPerformanceTracingMethods = {
|
package/dist/esm/vc/index.js
CHANGED
|
@@ -77,7 +77,7 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
77
77
|
startTime: startTime
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
if (isVCRevisionEnabled('fy25.03', experienceKey)) {
|
|
80
|
+
if (isVCRevisionEnabled('fy25.03', experienceKey) || isVCRevisionEnabled('fy26.04', experienceKey)) {
|
|
81
81
|
var _this$newVCObserver;
|
|
82
82
|
(_this$newVCObserver = this.newVCObserver) === null || _this$newVCObserver === void 0 || _this$newVCObserver.start({
|
|
83
83
|
startTime: startTime
|
|
@@ -94,7 +94,7 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
94
94
|
var _this$oldVCObserver2;
|
|
95
95
|
(_this$oldVCObserver2 = this.oldVCObserver) === null || _this$oldVCObserver2 === void 0 || _this$oldVCObserver2.stop();
|
|
96
96
|
}
|
|
97
|
-
if (isVCRevisionEnabled('fy25.03', experienceKey)) {
|
|
97
|
+
if (isVCRevisionEnabled('fy25.03', experienceKey) || isVCRevisionEnabled('fy26.04', experienceKey)) {
|
|
98
98
|
var _this$newVCObserver2;
|
|
99
99
|
(_this$newVCObserver2 = this.newVCObserver) === null || _this$newVCObserver2 === void 0 || _this$newVCObserver2.stop();
|
|
100
100
|
}
|
|
@@ -112,7 +112,7 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
112
112
|
key: "getVCResult",
|
|
113
113
|
value: function () {
|
|
114
114
|
var _getVCResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(param) {
|
|
115
|
-
var _this$oldVCObserver4, _this$newVCObserver3, _ref2;
|
|
115
|
+
var _this$oldVCObserver4, _this$newVCObserver3, _v3v4Result$, _ref2;
|
|
116
116
|
var experienceKey, include3p, excludeSmartAnswersInSearch, includeSSRRatio, includeRawData, v1v2Result, v3v4Result, ssrRatio;
|
|
117
117
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
118
118
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -132,7 +132,7 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
132
132
|
_context.t0 = {};
|
|
133
133
|
case 8:
|
|
134
134
|
v1v2Result = _context.t0;
|
|
135
|
-
if (!isVCRevisionEnabled('fy25.03', experienceKey)) {
|
|
135
|
+
if (!(isVCRevisionEnabled('fy25.03', experienceKey) || isVCRevisionEnabled('fy26.04', experienceKey))) {
|
|
136
136
|
_context.next = 15;
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
@@ -160,13 +160,13 @@ export var VCObserverWrapper = /*#__PURE__*/function () {
|
|
|
160
160
|
_context.t1 = [];
|
|
161
161
|
case 16:
|
|
162
162
|
v3v4Result = _context.t1;
|
|
163
|
-
if (v3v4Result) {
|
|
163
|
+
if (!(!v3v4Result || v3v4Result.length === 0)) {
|
|
164
164
|
_context.next = 19;
|
|
165
165
|
break;
|
|
166
166
|
}
|
|
167
167
|
return _context.abrupt("return", v1v2Result !== null && v1v2Result !== void 0 ? v1v2Result : {});
|
|
168
168
|
case 19:
|
|
169
|
-
ssrRatio = v3v4Result[0]
|
|
169
|
+
ssrRatio = v3v4Result === null || v3v4Result === void 0 || (_v3v4Result$ = v3v4Result[0]) === null || _v3v4Result$ === void 0 ? void 0 : _v3v4Result$.ssrRatio;
|
|
170
170
|
return _context.abrupt("return", _objectSpread(_objectSpread(_objectSpread({}, includeSSRRatio && ssrRatio !== undefined ? {
|
|
171
171
|
'ufo:vc:ssrRatio': ssrRatio
|
|
172
172
|
} : {}), v1v2Result), {}, {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
4
|
var ANCESTOR_LOOKUP_LIMIT = 10;
|
|
6
5
|
var PAGE_LAYOUT_ID = 'page-layout.root';
|
|
7
6
|
export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
@@ -319,8 +318,7 @@ export var SSRPlaceholderHandlers = /*#__PURE__*/function () {
|
|
|
319
318
|
}, {
|
|
320
319
|
key: "validateReactComponentMatchToPlaceholderV4",
|
|
321
320
|
value: function validateReactComponentMatchToPlaceholderV4(el) {
|
|
322
|
-
el =
|
|
323
|
-
: this.findNearestPlaceholderContainerIfIgnored(el);
|
|
321
|
+
el = this.findNearestPlaceholderOrContainer(el, 2); // We are using 2 due to over-eagerness of the default, only check itself and 1 ancestor
|
|
324
322
|
var id = this.getPlaceholderReplacementId(el);
|
|
325
323
|
return this.staticPlaceholders.has(id);
|
|
326
324
|
}
|
|
@@ -146,6 +146,12 @@ export type Config = {
|
|
|
146
146
|
readonly rates?: Rates;
|
|
147
147
|
readonly kind?: Record<InteractionType, number>;
|
|
148
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Option to enable terminal error tracking
|
|
151
|
+
*/
|
|
152
|
+
readonly terminalErrors?: {
|
|
153
|
+
readonly enabled?: boolean;
|
|
154
|
+
};
|
|
149
155
|
/**
|
|
150
156
|
* @private
|
|
151
157
|
* @deprecated - to be removed on next major version
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Context, type ContextManager } from '@opentelemetry/api';
|
|
2
|
+
export declare function setContextManager(ctxMgr: ContextManager): void;
|
|
3
|
+
export declare function getContextManager(): ContextManager;
|
|
4
|
+
/**
|
|
5
|
+
* The below is shamelessly borrowed from StackContextManager from @opentelemetry/sdk-trace-web
|
|
6
|
+
* Using this rather than importing the entire package because this is all we need for now
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* UFO Context Manager for managing the state in web
|
|
10
|
+
* it doesn't fully support the async calls though
|
|
11
|
+
*/
|
|
12
|
+
export declare class UFOContextManager implements ContextManager {
|
|
13
|
+
/**
|
|
14
|
+
* whether the context manager is enabled or not
|
|
15
|
+
*/
|
|
16
|
+
private _enabled;
|
|
17
|
+
/**
|
|
18
|
+
* Keeps the reference to current context
|
|
19
|
+
*/
|
|
20
|
+
_currentContext: Context;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param context
|
|
24
|
+
* @param target Function to be executed within the context
|
|
25
|
+
*/
|
|
26
|
+
private _bindFunction;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the active context
|
|
29
|
+
*/
|
|
30
|
+
active(): Context;
|
|
31
|
+
/**
|
|
32
|
+
* Binds a the certain context or the active one to the target function and then returns the target
|
|
33
|
+
* @param context A context (span) to be bind to target
|
|
34
|
+
* @param target a function or event emitter. When target or one of its callbacks is called,
|
|
35
|
+
* the provided context will be used as the active context for the duration of the call.
|
|
36
|
+
*/
|
|
37
|
+
bind<T>(context: Context, target: T): T;
|
|
38
|
+
/**
|
|
39
|
+
* Disable the context manager (clears the current context)
|
|
40
|
+
*/
|
|
41
|
+
disable(): this;
|
|
42
|
+
/**
|
|
43
|
+
* Enables the context manager and creates a default(root) context
|
|
44
|
+
*/
|
|
45
|
+
enable(): this;
|
|
46
|
+
/**
|
|
47
|
+
* Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the window.
|
|
48
|
+
* The context will be set as active
|
|
49
|
+
* @param context
|
|
50
|
+
* @param fn Callback function
|
|
51
|
+
* @param thisArg optional receiver to be used for calling fn
|
|
52
|
+
* @param args optional arguments forwarded to fn
|
|
53
|
+
*/
|
|
54
|
+
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(context: Context | null, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the active context.
|
|
57
|
+
* This function is an extension of the OTel spec, in order to facilitate the current API of React UFO trace context handling.
|
|
58
|
+
* It doesn't keep track of any previously set active contexts, because it's assumed (for now) that only one trace context
|
|
59
|
+
* will ever exist at a time.
|
|
60
|
+
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
61
|
+
* hierarchy of contexts (likely using the `with()` function above).
|
|
62
|
+
* @param context The context to be made the globally active one
|
|
63
|
+
*/
|
|
64
|
+
setActive(context: Context): void;
|
|
65
|
+
}
|
|
@@ -146,6 +146,12 @@ export type Config = {
|
|
|
146
146
|
readonly rates?: Rates;
|
|
147
147
|
readonly kind?: Record<InteractionType, number>;
|
|
148
148
|
};
|
|
149
|
+
/**
|
|
150
|
+
* Option to enable terminal error tracking
|
|
151
|
+
*/
|
|
152
|
+
readonly terminalErrors?: {
|
|
153
|
+
readonly enabled?: boolean;
|
|
154
|
+
};
|
|
149
155
|
/**
|
|
150
156
|
* @private
|
|
151
157
|
* @deprecated - to be removed on next major version
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type Context, type ContextManager } from '@opentelemetry/api';
|
|
2
|
+
export declare function setContextManager(ctxMgr: ContextManager): void;
|
|
3
|
+
export declare function getContextManager(): ContextManager;
|
|
4
|
+
/**
|
|
5
|
+
* The below is shamelessly borrowed from StackContextManager from @opentelemetry/sdk-trace-web
|
|
6
|
+
* Using this rather than importing the entire package because this is all we need for now
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* UFO Context Manager for managing the state in web
|
|
10
|
+
* it doesn't fully support the async calls though
|
|
11
|
+
*/
|
|
12
|
+
export declare class UFOContextManager implements ContextManager {
|
|
13
|
+
/**
|
|
14
|
+
* whether the context manager is enabled or not
|
|
15
|
+
*/
|
|
16
|
+
private _enabled;
|
|
17
|
+
/**
|
|
18
|
+
* Keeps the reference to current context
|
|
19
|
+
*/
|
|
20
|
+
_currentContext: Context;
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param context
|
|
24
|
+
* @param target Function to be executed within the context
|
|
25
|
+
*/
|
|
26
|
+
private _bindFunction;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the active context
|
|
29
|
+
*/
|
|
30
|
+
active(): Context;
|
|
31
|
+
/**
|
|
32
|
+
* Binds a the certain context or the active one to the target function and then returns the target
|
|
33
|
+
* @param context A context (span) to be bind to target
|
|
34
|
+
* @param target a function or event emitter. When target or one of its callbacks is called,
|
|
35
|
+
* the provided context will be used as the active context for the duration of the call.
|
|
36
|
+
*/
|
|
37
|
+
bind<T>(context: Context, target: T): T;
|
|
38
|
+
/**
|
|
39
|
+
* Disable the context manager (clears the current context)
|
|
40
|
+
*/
|
|
41
|
+
disable(): this;
|
|
42
|
+
/**
|
|
43
|
+
* Enables the context manager and creates a default(root) context
|
|
44
|
+
*/
|
|
45
|
+
enable(): this;
|
|
46
|
+
/**
|
|
47
|
+
* Calls the callback function [fn] with the provided [context]. If [context] is undefined then it will use the window.
|
|
48
|
+
* The context will be set as active
|
|
49
|
+
* @param context
|
|
50
|
+
* @param fn Callback function
|
|
51
|
+
* @param thisArg optional receiver to be used for calling fn
|
|
52
|
+
* @param args optional arguments forwarded to fn
|
|
53
|
+
*/
|
|
54
|
+
with<A extends unknown[], F extends (...args: A) => ReturnType<F>>(context: Context | null, fn: F, thisArg?: ThisParameterType<F>, ...args: A): ReturnType<F>;
|
|
55
|
+
/**
|
|
56
|
+
* Sets the active context.
|
|
57
|
+
* This function is an extension of the OTel spec, in order to facilitate the current API of React UFO trace context handling.
|
|
58
|
+
* It doesn't keep track of any previously set active contexts, because it's assumed (for now) that only one trace context
|
|
59
|
+
* will ever exist at a time.
|
|
60
|
+
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
61
|
+
* hierarchy of contexts (likely using the `with()` function above).
|
|
62
|
+
* @param context The context to be made the globally active one
|
|
63
|
+
*/
|
|
64
|
+
setActive(context: Context): void;
|
|
65
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"@atlaskit/interaction-context": "^3.1.0",
|
|
33
33
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
34
34
|
"@babel/runtime": "^7.0.0",
|
|
35
|
+
"@opentelemetry/api": "^1.9.0",
|
|
35
36
|
"bind-event-listener": "^3.0.0",
|
|
36
37
|
"bowser-ultralight": "^1.0.6",
|
|
37
38
|
"scheduler": "0.23.2",
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@af/integration-testing": "workspace:^",
|
|
45
|
-
"@atlassian/a11y-jest-testing": "^0.
|
|
46
|
+
"@atlassian/a11y-jest-testing": "^0.9.0",
|
|
46
47
|
"@atlassian/feature-flags-test-utils": "^1.0.0",
|
|
47
48
|
"@testing-library/react": "^16.3.0",
|
|
48
49
|
"@types/is-ci": "^3.0.0",
|
|
@@ -103,9 +104,6 @@
|
|
|
103
104
|
"ufo_payload_use_idle_callback": {
|
|
104
105
|
"type": "boolean"
|
|
105
106
|
},
|
|
106
|
-
"platform_ufo_is_opened_in_background": {
|
|
107
|
-
"type": "boolean"
|
|
108
|
-
},
|
|
109
107
|
"platform_ufo_assets_check_for_nan": {
|
|
110
108
|
"type": "boolean"
|
|
111
109
|
},
|
|
@@ -193,6 +191,9 @@
|
|
|
193
191
|
"platform_ufo_keypress_interaction_abort": {
|
|
194
192
|
"type": "boolean"
|
|
195
193
|
},
|
|
194
|
+
"platform_ufo_enable_otel_context_manager": {
|
|
195
|
+
"type": "boolean"
|
|
196
|
+
},
|
|
196
197
|
"platform_ufo_raw_data_thirdparty": {
|
|
197
198
|
"type": "boolean"
|
|
198
199
|
},
|
|
@@ -205,9 +206,6 @@
|
|
|
205
206
|
"rovo_search_page_ttvc_ignoring_smart_answers_fix": {
|
|
206
207
|
"type": "boolean"
|
|
207
208
|
},
|
|
208
|
-
"jfp-magma-ufo-event-listener-error": {
|
|
209
|
-
"type": "boolean"
|
|
210
|
-
},
|
|
211
209
|
"platform_ufo_enable_terminal_errors": {
|
|
212
210
|
"type": "boolean"
|
|
213
211
|
}
|