@atlaskit/react-ufo 5.2.6 → 5.2.7
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/config/index.js +48 -28
- package/dist/cjs/experience-trace-id-context/context-manager.js +4 -4
- package/dist/cjs/ignore-holds/index.js +1 -2
- package/dist/cjs/interaction-metrics-init/index.js +10 -1
- package/dist/cjs/load-hold/UFOLoadHold.js +9 -1
- package/dist/cjs/segment/segment.js +10 -2
- package/dist/cjs/segment/third-party-segment.js +1 -2
- package/dist/cjs/trace-interaction/internal/trace-ufo-interaction.js +4 -0
- package/dist/cjs/trace-pageload/index.js +8 -0
- package/dist/cjs/trace-transition/index.js +4 -0
- package/dist/es2019/config/index.js +21 -2
- package/dist/es2019/experience-trace-id-context/context-manager.js +4 -4
- package/dist/es2019/ignore-holds/index.js +1 -2
- package/dist/es2019/interaction-metrics-init/index.js +11 -2
- package/dist/es2019/load-hold/UFOLoadHold.js +9 -1
- package/dist/es2019/segment/segment.js +11 -3
- package/dist/es2019/segment/third-party-segment.js +1 -2
- package/dist/es2019/trace-interaction/internal/trace-ufo-interaction.js +5 -1
- package/dist/es2019/trace-pageload/index.js +9 -1
- package/dist/es2019/trace-transition/index.js +5 -1
- package/dist/esm/config/index.js +47 -28
- package/dist/esm/experience-trace-id-context/context-manager.js +4 -4
- package/dist/esm/ignore-holds/index.js +1 -2
- package/dist/esm/interaction-metrics-init/index.js +11 -2
- package/dist/esm/load-hold/UFOLoadHold.js +9 -1
- package/dist/esm/segment/segment.js +11 -3
- package/dist/esm/segment/third-party-segment.js +1 -2
- package/dist/esm/trace-interaction/internal/trace-ufo-interaction.js +5 -1
- package/dist/esm/trace-pageload/index.js +9 -1
- package/dist/esm/trace-transition/index.js +5 -1
- package/dist/types/config/index.d.ts +10 -0
- package/dist/types/ignore-holds/index.d.ts +1 -5
- package/dist/types/segment/segment.d.ts +1 -5
- package/dist/types/segment/third-party-segment.d.ts +0 -3
- package/dist/types-ts4.5/config/index.d.ts +10 -0
- package/dist/types-ts4.5/ignore-holds/index.d.ts +1 -5
- package/dist/types-ts4.5/segment/segment.d.ts +1 -5
- package/dist/types-ts4.5/segment/third-party-segment.d.ts +0 -3
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/config/index.js
CHANGED
|
@@ -23,6 +23,7 @@ exports.getReactHydrationStats = getReactHydrationStats;
|
|
|
23
23
|
exports.getTypingPerformanceTracingMethod = getTypingPerformanceTracingMethod;
|
|
24
24
|
exports.getUfoNameOverrides = getUfoNameOverrides;
|
|
25
25
|
exports.getVCRawDataInteractionRate = getVCRawDataInteractionRate;
|
|
26
|
+
exports.isUFOEnabled = isUFOEnabled;
|
|
26
27
|
exports.isVCRevisionEnabled = isVCRevisionEnabled;
|
|
27
28
|
exports.setUFOConfig = setUFOConfig;
|
|
28
29
|
exports.shouldUseRawDataThirdPartyBehavior = shouldUseRawDataThirdPartyBehavior;
|
|
@@ -61,6 +62,25 @@ function setUFOConfig(newConfig) {
|
|
|
61
62
|
function getConfig() {
|
|
62
63
|
return config;
|
|
63
64
|
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Check if UFO is enabled based on the config.enabled field.
|
|
68
|
+
*
|
|
69
|
+
* This function is gated behind the platform_ufo_enable_killswitch_config feature flag.
|
|
70
|
+
* When the feature flag is disabled, UFO is always considered enabled (default behavior).
|
|
71
|
+
* When the feature flag is enabled, the config.enabled field is respected.
|
|
72
|
+
*
|
|
73
|
+
* @returns true if UFO is enabled, false if disabled
|
|
74
|
+
*/
|
|
75
|
+
function isUFOEnabled() {
|
|
76
|
+
var _config;
|
|
77
|
+
// Only respect the config.enabled field when the killswitch feature flag is enabled
|
|
78
|
+
if (!(0, _platformFeatureFlags.fg)('platform_ufo_enable_killswitch_config')) {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
// Default to enabled if config is not set or enabled is not explicitly false
|
|
82
|
+
return ((_config = config) === null || _config === void 0 ? void 0 : _config.enabled) !== false;
|
|
83
|
+
}
|
|
64
84
|
var isValidConfigArray = function isValidConfigArray(array) {
|
|
65
85
|
return Array.isArray(array) && array.length > 0;
|
|
66
86
|
};
|
|
@@ -102,8 +122,8 @@ function getReactHydrationStats() {
|
|
|
102
122
|
return undefined;
|
|
103
123
|
}
|
|
104
124
|
try {
|
|
105
|
-
var
|
|
106
|
-
var stats = (
|
|
125
|
+
var _config2, _config2$getReactHydr;
|
|
126
|
+
var stats = (_config2 = config) === null || _config2 === void 0 || (_config2$getReactHydr = _config2.getReactHydrationStats) === null || _config2$getReactHydr === void 0 ? void 0 : _config2$getReactHydr.call(_config2);
|
|
107
127
|
return stats !== null && stats !== void 0 ? stats : undefined;
|
|
108
128
|
} catch (e) {
|
|
109
129
|
// eslint-disable-next-line no-console
|
|
@@ -116,12 +136,12 @@ function getInteractionRate(name, interactionKind) {
|
|
|
116
136
|
if (!config) {
|
|
117
137
|
return 0;
|
|
118
138
|
}
|
|
119
|
-
var
|
|
120
|
-
killswitch =
|
|
121
|
-
rates =
|
|
122
|
-
rules =
|
|
123
|
-
kind =
|
|
124
|
-
autoGeneratedRate =
|
|
139
|
+
var _config3 = config,
|
|
140
|
+
killswitch = _config3.killswitch,
|
|
141
|
+
rates = _config3.rates,
|
|
142
|
+
rules = _config3.rules,
|
|
143
|
+
kind = _config3.kind,
|
|
144
|
+
autoGeneratedRate = _config3.autoGeneratedRate;
|
|
125
145
|
if (killswitch != null) {
|
|
126
146
|
// Specifically kill certain events
|
|
127
147
|
if (killswitch.includes(name)) {
|
|
@@ -179,8 +199,8 @@ function getExperimentalInteractionRate(name, interactionType) {
|
|
|
179
199
|
if (!config) {
|
|
180
200
|
return 0;
|
|
181
201
|
}
|
|
182
|
-
var
|
|
183
|
-
experimentalInteractionMetrics =
|
|
202
|
+
var _config4 = config,
|
|
203
|
+
experimentalInteractionMetrics = _config4.experimentalInteractionMetrics;
|
|
184
204
|
if (!(experimentalInteractionMetrics !== null && experimentalInteractionMetrics !== void 0 && experimentalInteractionMetrics.enabled)) {
|
|
185
205
|
return 0;
|
|
186
206
|
}
|
|
@@ -215,8 +235,8 @@ function getCapabilityRate(capability) {
|
|
|
215
235
|
if (!config) {
|
|
216
236
|
return 0;
|
|
217
237
|
}
|
|
218
|
-
var
|
|
219
|
-
capabilityRate =
|
|
238
|
+
var _config5 = config,
|
|
239
|
+
capabilityRate = _config5.capability;
|
|
220
240
|
if (capabilityRate != null) {
|
|
221
241
|
var rate = capabilityRate[capability];
|
|
222
242
|
if (rate != null) {
|
|
@@ -261,8 +281,8 @@ function getTypingPerformanceTracingMethod() {
|
|
|
261
281
|
if (!config) {
|
|
262
282
|
return defaultMethod;
|
|
263
283
|
}
|
|
264
|
-
var
|
|
265
|
-
typingMethod =
|
|
284
|
+
var _config6 = config,
|
|
285
|
+
typingMethod = _config6.typingMethod;
|
|
266
286
|
if (typingMethod != null && validTypingMethods.find(function (m) {
|
|
267
287
|
return m === typingMethod;
|
|
268
288
|
})) {
|
|
@@ -281,8 +301,8 @@ function getAwaitBM3TTIList() {
|
|
|
281
301
|
if (!config) {
|
|
282
302
|
return [];
|
|
283
303
|
}
|
|
284
|
-
var
|
|
285
|
-
awaitBM3TTI =
|
|
304
|
+
var _config7 = config,
|
|
305
|
+
awaitBM3TTI = _config7.awaitBM3TTI;
|
|
286
306
|
if (awaitBM3TTI != null) {
|
|
287
307
|
return awaitBM3TTI;
|
|
288
308
|
} else {
|
|
@@ -302,8 +322,8 @@ function getUfoNameOverrides() {
|
|
|
302
322
|
if (!config) {
|
|
303
323
|
return undefined;
|
|
304
324
|
}
|
|
305
|
-
var
|
|
306
|
-
ufoNameOverrides =
|
|
325
|
+
var _config8 = config,
|
|
326
|
+
ufoNameOverrides = _config8.ufoNameOverrides;
|
|
307
327
|
if (ufoNameOverrides != null) {
|
|
308
328
|
return ufoNameOverrides;
|
|
309
329
|
}
|
|
@@ -317,8 +337,8 @@ function getMinorInteractions() {
|
|
|
317
337
|
if (!config) {
|
|
318
338
|
return undefined;
|
|
319
339
|
}
|
|
320
|
-
var
|
|
321
|
-
minorInteractions =
|
|
340
|
+
var _config9 = config,
|
|
341
|
+
minorInteractions = _config9.minorInteractions;
|
|
322
342
|
return minorInteractions;
|
|
323
343
|
} catch (_unused9) {
|
|
324
344
|
return undefined;
|
|
@@ -331,8 +351,8 @@ function getDoNotAbortActivePressInteraction() {
|
|
|
331
351
|
if (!config) {
|
|
332
352
|
return undefined;
|
|
333
353
|
}
|
|
334
|
-
var
|
|
335
|
-
doNotAbortActivePressInteraction =
|
|
354
|
+
var _config0 = config,
|
|
355
|
+
doNotAbortActivePressInteraction = _config0.doNotAbortActivePressInteraction;
|
|
336
356
|
return doNotAbortActivePressInteraction;
|
|
337
357
|
} catch (_unused0) {
|
|
338
358
|
return undefined;
|
|
@@ -345,8 +365,8 @@ function getDoNotAbortActivePressInteractionOnTransition() {
|
|
|
345
365
|
if (!config) {
|
|
346
366
|
return undefined;
|
|
347
367
|
}
|
|
348
|
-
var
|
|
349
|
-
doNotAbortActivePressInteractionOnTransition =
|
|
368
|
+
var _config1 = config,
|
|
369
|
+
doNotAbortActivePressInteractionOnTransition = _config1.doNotAbortActivePressInteractionOnTransition;
|
|
350
370
|
return doNotAbortActivePressInteractionOnTransition;
|
|
351
371
|
} catch (_unused1) {
|
|
352
372
|
return undefined;
|
|
@@ -359,8 +379,8 @@ function getFinishInteractionOnTransition() {
|
|
|
359
379
|
if (!config) {
|
|
360
380
|
return undefined;
|
|
361
381
|
}
|
|
362
|
-
var
|
|
363
|
-
finishInteractionOnTransition =
|
|
382
|
+
var _config10 = config,
|
|
383
|
+
finishInteractionOnTransition = _config10.finishInteractionOnTransition;
|
|
364
384
|
return finishInteractionOnTransition;
|
|
365
385
|
} catch (_unused10) {
|
|
366
386
|
return undefined;
|
|
@@ -372,8 +392,8 @@ function getInteractionTimeout(ufoName) {
|
|
|
372
392
|
if (!config) {
|
|
373
393
|
return CLEANUP_TIMEOUT;
|
|
374
394
|
}
|
|
375
|
-
var
|
|
376
|
-
interactionTimeout =
|
|
395
|
+
var _config11 = config,
|
|
396
|
+
interactionTimeout = _config11.interactionTimeout;
|
|
377
397
|
if (interactionTimeout != null && interactionTimeout[ufoName] != null) {
|
|
378
398
|
return interactionTimeout[ufoName];
|
|
379
399
|
}
|
|
@@ -17,7 +17,7 @@ var _api = require("@opentelemetry/api");
|
|
|
17
17
|
* and we need to get it because we need to call a function that's not available in the OTel API:
|
|
18
18
|
* `setActive`. The OTel JS API design doesn't allow us to manually set the active context
|
|
19
19
|
* despite the spec allowing for the capability. Sigh.
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
21
|
* I imagine this situation might not be permanent if we can move to a system were we can rely
|
|
22
22
|
* solely on the API, but for the purposes of the first change being React UFO API compatible,
|
|
23
23
|
* we'll need to do this.
|
|
@@ -31,7 +31,7 @@ function getContextManager() {
|
|
|
31
31
|
return contextManager;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
35
|
* The below is shamelessly borrowed from StackContextManager from @opentelemetry/sdk-trace-web
|
|
36
36
|
* Using this rather than importing the entire package because this is all we need for now
|
|
37
37
|
*/
|
|
@@ -165,9 +165,9 @@ var UFOContextManager = exports.UFOContextManager = /*#__PURE__*/function () {
|
|
|
165
165
|
* This function is an extension of the OTel spec, in order to facilitate the current API of React UFO trace context handling.
|
|
166
166
|
* It doesn't keep track of any previously set active contexts, because it's assumed (for now) that only one trace context
|
|
167
167
|
* will ever exist at a time.
|
|
168
|
-
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
168
|
+
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
169
169
|
* hierarchy of contexts (likely using the `with()` function above).
|
|
170
|
-
* @param context The context to be made the globally active one
|
|
170
|
+
* @param context The context to be made the globally active one
|
|
171
171
|
*/
|
|
172
172
|
}, {
|
|
173
173
|
key: "setActive",
|
|
@@ -153,10 +153,19 @@ function init(analyticsWebClientAsync, config) {
|
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
// Always set config first so isUFOEnabled() can check config.enabled
|
|
157
|
+
(0, _config.setUFOConfig)(config);
|
|
158
|
+
|
|
159
|
+
// If UFO is disabled via config, skip all initialization
|
|
160
|
+
// This is gated behind platform_ufo_enable_killswitch_config feature flag
|
|
161
|
+
if (!(0, _config.isUFOEnabled)()) {
|
|
162
|
+
initialized = true;
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
156
166
|
// Initialize pressure observer for CPU usage monitoring
|
|
157
167
|
(0, _machineUtilisation.initialisePressureObserver)();
|
|
158
168
|
(0, _machineUtilisation.initialiseMemoryObserver)();
|
|
159
|
-
(0, _config.setUFOConfig)(config);
|
|
160
169
|
if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_otel_context_manager')) {
|
|
161
170
|
// Configure global OTel context manager
|
|
162
171
|
var contextManager = new _contextManager.UFOContextManager();
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = UFOLoadHold;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _config = require("../config");
|
|
11
12
|
var _interactionContext = _interopRequireDefault(require("../interaction-context"));
|
|
12
13
|
var _interactionIdContext = _interopRequireWildcard(require("../interaction-id-context"));
|
|
13
14
|
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); }
|
|
@@ -85,18 +86,25 @@ function UFOLoadHold(_ref) {
|
|
|
85
86
|
hold = _ref$hold === void 0 ? true : _ref$hold,
|
|
86
87
|
_ref$experimental = _ref.experimental,
|
|
87
88
|
experimental = _ref$experimental === void 0 ? false : _ref$experimental;
|
|
89
|
+
// Check if UFO is enabled (gated behind platform_ufo_enable_killswitch_config feature flag)
|
|
90
|
+
// Note: isUFOEnabled() returns a stable value based on config, so it's safe to call before hooks
|
|
91
|
+
var ufoEnabled = (0, _config.isUFOEnabled)();
|
|
88
92
|
var currentInteractionId = useInteractionIdValue();
|
|
89
93
|
|
|
90
94
|
// react-18: useId instead
|
|
91
95
|
var context = (0, _react.useContext)(_interactionContext.default);
|
|
92
96
|
useLayoutEffectSAFE(function () {
|
|
97
|
+
// Skip hold registration if UFO is disabled
|
|
98
|
+
if (!ufoEnabled) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
93
101
|
if (hold && context != null) {
|
|
94
102
|
if (experimental && context.holdExperimental) {
|
|
95
103
|
return context.holdExperimental(name);
|
|
96
104
|
}
|
|
97
105
|
return context.hold(name);
|
|
98
106
|
}
|
|
99
|
-
}, [hold, context, name, currentInteractionId]);
|
|
107
|
+
}, [hold, context, name, currentInteractionId, ufoEnabled]);
|
|
100
108
|
|
|
101
109
|
// react-18: can return children directly
|
|
102
110
|
return children != null ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children) : null;
|
|
@@ -36,6 +36,10 @@ function UFOSegment(_ref) {
|
|
|
36
36
|
mode = _ref$mode === void 0 ? 'single' : _ref$mode,
|
|
37
37
|
_ref$type = _ref.type,
|
|
38
38
|
type = _ref$type === void 0 ? 'first-party' : _ref$type;
|
|
39
|
+
// If UFO is disabled, render children without any tracking overhead
|
|
40
|
+
// This is gated behind platform_ufo_enable_killswitch_config feature flag
|
|
41
|
+
// Note: isUFOEnabled() returns a stable value based on config, so it's safe to call before hooks
|
|
42
|
+
var ufoEnabled = (0, _config.isUFOEnabled)();
|
|
39
43
|
var parentContext = (0, _react.useContext)(_interactionContext.default);
|
|
40
44
|
var segmentIdMap = (0, _react.useMemo)(function () {
|
|
41
45
|
if (!(parentContext !== null && parentContext !== void 0 && parentContext.segmentIdMap)) {
|
|
@@ -279,6 +283,11 @@ function UFOSegment(_ref) {
|
|
|
279
283
|
return l.name;
|
|
280
284
|
}).join('/');
|
|
281
285
|
}, [labelStack]);
|
|
286
|
+
|
|
287
|
+
// If UFO is disabled, just render children without tracking overhead
|
|
288
|
+
if (!ufoEnabled) {
|
|
289
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
|
|
290
|
+
}
|
|
282
291
|
var ufoSegment = /*#__PURE__*/_react.default.createElement(_interactionContext.default.Provider, {
|
|
283
292
|
value: interactionContext
|
|
284
293
|
}, /*#__PURE__*/_react.default.createElement(_react.Profiler, {
|
|
@@ -292,5 +301,4 @@ function UFOSegment(_ref) {
|
|
|
292
301
|
}, ufoSegment);
|
|
293
302
|
}
|
|
294
303
|
return ufoSegment;
|
|
295
|
-
}
|
|
296
|
-
UFOSegment.displayName = 'UFOSegment';
|
|
304
|
+
}
|
|
@@ -16,6 +16,10 @@ var _routeNameContext = _interopRequireDefault(require("../../route-name-context
|
|
|
16
16
|
|
|
17
17
|
function traceUFOInteraction(name, interactionType, startTime) {
|
|
18
18
|
var _getMinorInteractions;
|
|
19
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
20
|
+
if (!(0, _config.isUFOEnabled)()) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
19
23
|
var rate = (0, _config.getInteractionRate)(name, interactionType);
|
|
20
24
|
var pressInteractionsList = (0, _config.getDoNotAbortActivePressInteraction)();
|
|
21
25
|
var minorInteractions = (pressInteractionsList !== null && pressInteractionsList !== void 0 ? pressInteractionsList : []).concat((_getMinorInteractions = (0, _config.getMinorInteractions)()) !== null && _getMinorInteractions !== void 0 ? _getMinorInteractions : []);
|
|
@@ -18,6 +18,10 @@ var _routeNameContext = _interopRequireDefault(require("../route-name-context"))
|
|
|
18
18
|
var AWAITING_PAGELOAD_NAME = 'awaiting_pageload_name';
|
|
19
19
|
function traceUFOPageLoad(ufoName) {
|
|
20
20
|
var routeName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ufoName;
|
|
21
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
22
|
+
if (!(0, _config.isUFOEnabled)()) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
21
25
|
var activeInteraction = (0, _interactionMetrics.getActiveInteraction)();
|
|
22
26
|
if (activeInteraction && !ufoName) {
|
|
23
27
|
return;
|
|
@@ -45,6 +49,10 @@ function traceUFOPageLoad(ufoName) {
|
|
|
45
49
|
var _default = exports.default = traceUFOPageLoad;
|
|
46
50
|
function updatePageloadName(ufoName) {
|
|
47
51
|
var routeName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ufoName;
|
|
52
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
53
|
+
if (!(0, _config.isUFOEnabled)()) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
48
56
|
var interaction = (0, _interactionMetrics.getActiveInteraction)();
|
|
49
57
|
if (!interaction || interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
50
58
|
return;
|
|
@@ -21,6 +21,10 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
21
21
|
|
|
22
22
|
function traceUFOTransition(ufoName) {
|
|
23
23
|
var routeName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ufoName;
|
|
24
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
25
|
+
if (!(0, _config.isUFOEnabled)()) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
24
28
|
var pressInteractionsList = (0, _config.getDoNotAbortActivePressInteractionOnTransition)();
|
|
25
29
|
var interaction = (0, _interactionMetrics.getActiveInteraction)();
|
|
26
30
|
if (pressInteractionsList && interaction) {
|
|
@@ -33,6 +33,25 @@ export function setUFOConfig(newConfig) {
|
|
|
33
33
|
export function getConfig() {
|
|
34
34
|
return config;
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Check if UFO is enabled based on the config.enabled field.
|
|
39
|
+
*
|
|
40
|
+
* This function is gated behind the platform_ufo_enable_killswitch_config feature flag.
|
|
41
|
+
* When the feature flag is disabled, UFO is always considered enabled (default behavior).
|
|
42
|
+
* When the feature flag is enabled, the config.enabled field is respected.
|
|
43
|
+
*
|
|
44
|
+
* @returns true if UFO is enabled, false if disabled
|
|
45
|
+
*/
|
|
46
|
+
export function isUFOEnabled() {
|
|
47
|
+
var _config;
|
|
48
|
+
// Only respect the config.enabled field when the killswitch feature flag is enabled
|
|
49
|
+
if (!fg('platform_ufo_enable_killswitch_config')) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
// Default to enabled if config is not set or enabled is not explicitly false
|
|
53
|
+
return ((_config = config) === null || _config === void 0 ? void 0 : _config.enabled) !== false;
|
|
54
|
+
}
|
|
36
55
|
const isValidConfigArray = array => {
|
|
37
56
|
return Array.isArray(array) && array.length > 0;
|
|
38
57
|
};
|
|
@@ -73,8 +92,8 @@ export function getReactHydrationStats() {
|
|
|
73
92
|
return undefined;
|
|
74
93
|
}
|
|
75
94
|
try {
|
|
76
|
-
var
|
|
77
|
-
const stats = (
|
|
95
|
+
var _config2, _config2$getReactHydr;
|
|
96
|
+
const stats = (_config2 = config) === null || _config2 === void 0 ? void 0 : (_config2$getReactHydr = _config2.getReactHydrationStats) === null || _config2$getReactHydr === void 0 ? void 0 : _config2$getReactHydr.call(_config2);
|
|
78
97
|
return stats !== null && stats !== void 0 ? stats : undefined;
|
|
79
98
|
} catch (e) {
|
|
80
99
|
// eslint-disable-next-line no-console
|
|
@@ -7,7 +7,7 @@ import { ROOT_CONTEXT } from '@opentelemetry/api';
|
|
|
7
7
|
* and we need to get it because we need to call a function that's not available in the OTel API:
|
|
8
8
|
* `setActive`. The OTel JS API design doesn't allow us to manually set the active context
|
|
9
9
|
* despite the spec allowing for the capability. Sigh.
|
|
10
|
-
*
|
|
10
|
+
*
|
|
11
11
|
* I imagine this situation might not be permanent if we can move to a system were we can rely
|
|
12
12
|
* solely on the API, but for the purposes of the first change being React UFO API compatible,
|
|
13
13
|
* we'll need to do this.
|
|
@@ -21,7 +21,7 @@ export function getContextManager() {
|
|
|
21
21
|
return contextManager;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
/**
|
|
24
|
+
/**
|
|
25
25
|
* The below is shamelessly borrowed from StackContextManager from @opentelemetry/sdk-trace-web
|
|
26
26
|
* Using this rather than importing the entire package because this is all we need for now
|
|
27
27
|
*/
|
|
@@ -130,9 +130,9 @@ export class UFOContextManager {
|
|
|
130
130
|
* This function is an extension of the OTel spec, in order to facilitate the current API of React UFO trace context handling.
|
|
131
131
|
* It doesn't keep track of any previously set active contexts, because it's assumed (for now) that only one trace context
|
|
132
132
|
* will ever exist at a time.
|
|
133
|
-
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
133
|
+
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
134
134
|
* hierarchy of contexts (likely using the `with()` function above).
|
|
135
|
-
* @param context The context to be made the globally active one
|
|
135
|
+
* @param context The context to be made the globally active one
|
|
136
136
|
*/
|
|
137
137
|
setActive(context) {
|
|
138
138
|
if (this._enabled) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { context } from '@opentelemetry/api';
|
|
2
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
3
|
import { startLighthouseObserver } from '../additional-payload';
|
|
4
|
-
import { setUFOConfig } from '../config';
|
|
4
|
+
import { isUFOEnabled, setUFOConfig } from '../config';
|
|
5
5
|
import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-interaction-metrics-payload';
|
|
6
6
|
import { sinkExtraSearchPageInteractionHandler } from '../create-extra-search-page-interaction-payload';
|
|
7
7
|
import { setContextManager, UFOContextManager } from '../experience-trace-id-context/context-manager';
|
|
@@ -129,10 +129,19 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
// Always set config first so isUFOEnabled() can check config.enabled
|
|
133
|
+
setUFOConfig(config);
|
|
134
|
+
|
|
135
|
+
// If UFO is disabled via config, skip all initialization
|
|
136
|
+
// This is gated behind platform_ufo_enable_killswitch_config feature flag
|
|
137
|
+
if (!isUFOEnabled()) {
|
|
138
|
+
initialized = true;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
132
142
|
// Initialize pressure observer for CPU usage monitoring
|
|
133
143
|
initialisePressureObserver();
|
|
134
144
|
initialiseMemoryObserver();
|
|
135
|
-
setUFOConfig(config);
|
|
136
145
|
if (fg('platform_ufo_enable_otel_context_manager')) {
|
|
137
146
|
// Configure global OTel context manager
|
|
138
147
|
const contextManager = new UFOContextManager();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { isUFOEnabled } from '../config';
|
|
2
3
|
import UFOInteractionContext from '../interaction-context';
|
|
3
4
|
import UFOInteractionIDContext, { subscribeToInteractionIdChanges } from '../interaction-id-context';
|
|
4
5
|
const useLayoutEffectSAFE = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
@@ -71,18 +72,25 @@ export default function UFOLoadHold({
|
|
|
71
72
|
hold = true,
|
|
72
73
|
experimental = false
|
|
73
74
|
}) {
|
|
75
|
+
// Check if UFO is enabled (gated behind platform_ufo_enable_killswitch_config feature flag)
|
|
76
|
+
// Note: isUFOEnabled() returns a stable value based on config, so it's safe to call before hooks
|
|
77
|
+
const ufoEnabled = isUFOEnabled();
|
|
74
78
|
const currentInteractionId = useInteractionIdValue();
|
|
75
79
|
|
|
76
80
|
// react-18: useId instead
|
|
77
81
|
const context = useContext(UFOInteractionContext);
|
|
78
82
|
useLayoutEffectSAFE(() => {
|
|
83
|
+
// Skip hold registration if UFO is disabled
|
|
84
|
+
if (!ufoEnabled) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
79
87
|
if (hold && context != null) {
|
|
80
88
|
if (experimental && context.holdExperimental) {
|
|
81
89
|
return context.holdExperimental(name);
|
|
82
90
|
}
|
|
83
91
|
return context.hold(name);
|
|
84
92
|
}
|
|
85
|
-
}, [hold, context, name, currentInteractionId]);
|
|
93
|
+
}, [hold, context, name, currentInteractionId, ufoEnabled]);
|
|
86
94
|
|
|
87
95
|
// react-18: can return children directly
|
|
88
96
|
return children != null ? /*#__PURE__*/React.createElement(React.Fragment, null, children) : null;
|
|
@@ -4,7 +4,7 @@ import { unstable_NormalPriority as NormalPriority, unstable_scheduleCallback as
|
|
|
4
4
|
import { v4 as createUUID } from 'uuid';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import coinflip from '../coinflip';
|
|
7
|
-
import { getConfig, getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions } from '../config';
|
|
7
|
+
import { getConfig, getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions, isUFOEnabled } from '../config';
|
|
8
8
|
import { getActiveTrace, setInteractionActiveTrace } from '../experience-trace-id-context';
|
|
9
9
|
import UFOInteractionContext from '../interaction-context';
|
|
10
10
|
import UFOInteractionIDContext from '../interaction-id-context';
|
|
@@ -23,6 +23,10 @@ export default function UFOSegment({
|
|
|
23
23
|
mode = 'single',
|
|
24
24
|
type = 'first-party'
|
|
25
25
|
}) {
|
|
26
|
+
// If UFO is disabled, render children without any tracking overhead
|
|
27
|
+
// This is gated behind platform_ufo_enable_killswitch_config feature flag
|
|
28
|
+
// Note: isUFOEnabled() returns a stable value based on config, so it's safe to call before hooks
|
|
29
|
+
const ufoEnabled = isUFOEnabled();
|
|
26
30
|
const parentContext = useContext(UFOInteractionContext);
|
|
27
31
|
const segmentIdMap = useMemo(() => {
|
|
28
32
|
if (!(parentContext !== null && parentContext !== void 0 && parentContext.segmentIdMap)) {
|
|
@@ -257,6 +261,11 @@ export default function UFOSegment({
|
|
|
257
261
|
};
|
|
258
262
|
}, [interactionId, parentContext, interactionContext, labelStack]);
|
|
259
263
|
const reactProfilerId = useMemo(() => labelStack.map(l => l.name).join('/'), [labelStack]);
|
|
264
|
+
|
|
265
|
+
// If UFO is disabled, just render children without tracking overhead
|
|
266
|
+
if (!ufoEnabled) {
|
|
267
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
268
|
+
}
|
|
260
269
|
const ufoSegment = /*#__PURE__*/React.createElement(UFOInteractionContext.Provider, {
|
|
261
270
|
value: interactionContext
|
|
262
271
|
}, /*#__PURE__*/React.createElement(Profiler, {
|
|
@@ -270,5 +279,4 @@ export default function UFOSegment({
|
|
|
270
279
|
}, ufoSegment);
|
|
271
280
|
}
|
|
272
281
|
return ufoSegment;
|
|
273
|
-
}
|
|
274
|
-
UFOSegment.displayName = 'UFOSegment';
|
|
282
|
+
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
2
|
import { v4 as createUUID } from 'uuid';
|
|
3
3
|
import coinflip from '../../coinflip';
|
|
4
|
-
import { getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions } from '../../config';
|
|
4
|
+
import { getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions, isUFOEnabled } from '../../config';
|
|
5
5
|
import { getActiveTrace, setInteractionActiveTrace } from '../../experience-trace-id-context';
|
|
6
6
|
import { DefaultInteractionID } from '../../interaction-id-context';
|
|
7
7
|
import { abortAll, addNewInteraction, getActiveInteraction } from '../../interaction-metrics';
|
|
8
8
|
import UFORouteName from '../../route-name-context';
|
|
9
9
|
function traceUFOInteraction(name, interactionType, startTime) {
|
|
10
10
|
var _getMinorInteractions;
|
|
11
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
12
|
+
if (!isUFOEnabled()) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
11
15
|
const rate = getInteractionRate(name, interactionType);
|
|
12
16
|
const pressInteractionsList = getDoNotAbortActivePressInteraction();
|
|
13
17
|
const minorInteractions = (pressInteractionsList !== null && pressInteractionsList !== void 0 ? pressInteractionsList : []).concat((_getMinorInteractions = getMinorInteractions()) !== null && _getMinorInteractions !== void 0 ? _getMinorInteractions : []);
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
2
|
import { v4 as createUUID } from 'uuid';
|
|
3
3
|
import coinflip from '../coinflip';
|
|
4
|
-
import { getInteractionRate } from '../config';
|
|
4
|
+
import { getInteractionRate, isUFOEnabled } from '../config';
|
|
5
5
|
import { getActiveTrace } from '../experience-trace-id-context';
|
|
6
6
|
import { DefaultInteractionID } from '../interaction-id-context';
|
|
7
7
|
import { abort, addHoldByID, addNewInteraction, getActiveInteraction, removeHoldByID, updatePageLoadInteractionName } from '../interaction-metrics';
|
|
8
8
|
import UFORouteName from '../route-name-context';
|
|
9
9
|
const AWAITING_PAGELOAD_NAME = 'awaiting_pageload_name';
|
|
10
10
|
function traceUFOPageLoad(ufoName, routeName = ufoName) {
|
|
11
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
12
|
+
if (!isUFOEnabled()) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
11
15
|
const activeInteraction = getActiveInteraction();
|
|
12
16
|
if (activeInteraction && !ufoName) {
|
|
13
17
|
return;
|
|
@@ -34,6 +38,10 @@ function traceUFOPageLoad(ufoName, routeName = ufoName) {
|
|
|
34
38
|
}
|
|
35
39
|
export default traceUFOPageLoad;
|
|
36
40
|
export function updatePageloadName(ufoName, routeName = ufoName) {
|
|
41
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
42
|
+
if (!isUFOEnabled()) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
37
45
|
const interaction = getActiveInteraction();
|
|
38
46
|
if (!interaction || interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
39
47
|
return;
|
|
@@ -3,13 +3,17 @@ import { useContext, useEffect } from 'react';
|
|
|
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
5
|
import coinflip from '../coinflip';
|
|
6
|
-
import { getDoNotAbortActivePressInteractionOnTransition, getInteractionRate } from '../config';
|
|
6
|
+
import { getDoNotAbortActivePressInteractionOnTransition, getInteractionRate, isUFOEnabled } from '../config';
|
|
7
7
|
import { getActiveTrace } from '../experience-trace-id-context';
|
|
8
8
|
import UFOInteractionIDContext, { DefaultInteractionID } from '../interaction-id-context';
|
|
9
9
|
import { abortAll, addNewInteraction, addOnCancelCallback, getActiveInteraction, tryComplete } from '../interaction-metrics';
|
|
10
10
|
import UFORouteName from '../route-name-context';
|
|
11
11
|
import { setInteractionActiveTrace } from './utils/set-interaction-active-trace';
|
|
12
12
|
function traceUFOTransition(ufoName, routeName = ufoName) {
|
|
13
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
14
|
+
if (!isUFOEnabled()) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
13
17
|
const pressInteractionsList = getDoNotAbortActivePressInteractionOnTransition();
|
|
14
18
|
const interaction = getActiveInteraction();
|
|
15
19
|
if (pressInteractionsList && interaction) {
|
package/dist/esm/config/index.js
CHANGED
|
@@ -33,6 +33,25 @@ export function setUFOConfig(newConfig) {
|
|
|
33
33
|
export function getConfig() {
|
|
34
34
|
return config;
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Check if UFO is enabled based on the config.enabled field.
|
|
39
|
+
*
|
|
40
|
+
* This function is gated behind the platform_ufo_enable_killswitch_config feature flag.
|
|
41
|
+
* When the feature flag is disabled, UFO is always considered enabled (default behavior).
|
|
42
|
+
* When the feature flag is enabled, the config.enabled field is respected.
|
|
43
|
+
*
|
|
44
|
+
* @returns true if UFO is enabled, false if disabled
|
|
45
|
+
*/
|
|
46
|
+
export function isUFOEnabled() {
|
|
47
|
+
var _config;
|
|
48
|
+
// Only respect the config.enabled field when the killswitch feature flag is enabled
|
|
49
|
+
if (!fg('platform_ufo_enable_killswitch_config')) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
// Default to enabled if config is not set or enabled is not explicitly false
|
|
53
|
+
return ((_config = config) === null || _config === void 0 ? void 0 : _config.enabled) !== false;
|
|
54
|
+
}
|
|
36
55
|
var isValidConfigArray = function isValidConfigArray(array) {
|
|
37
56
|
return Array.isArray(array) && array.length > 0;
|
|
38
57
|
};
|
|
@@ -74,8 +93,8 @@ export function getReactHydrationStats() {
|
|
|
74
93
|
return undefined;
|
|
75
94
|
}
|
|
76
95
|
try {
|
|
77
|
-
var
|
|
78
|
-
var stats = (
|
|
96
|
+
var _config2, _config2$getReactHydr;
|
|
97
|
+
var stats = (_config2 = config) === null || _config2 === void 0 || (_config2$getReactHydr = _config2.getReactHydrationStats) === null || _config2$getReactHydr === void 0 ? void 0 : _config2$getReactHydr.call(_config2);
|
|
79
98
|
return stats !== null && stats !== void 0 ? stats : undefined;
|
|
80
99
|
} catch (e) {
|
|
81
100
|
// eslint-disable-next-line no-console
|
|
@@ -88,12 +107,12 @@ export function getInteractionRate(name, interactionKind) {
|
|
|
88
107
|
if (!config) {
|
|
89
108
|
return 0;
|
|
90
109
|
}
|
|
91
|
-
var
|
|
92
|
-
killswitch =
|
|
93
|
-
rates =
|
|
94
|
-
rules =
|
|
95
|
-
kind =
|
|
96
|
-
autoGeneratedRate =
|
|
110
|
+
var _config3 = config,
|
|
111
|
+
killswitch = _config3.killswitch,
|
|
112
|
+
rates = _config3.rates,
|
|
113
|
+
rules = _config3.rules,
|
|
114
|
+
kind = _config3.kind,
|
|
115
|
+
autoGeneratedRate = _config3.autoGeneratedRate;
|
|
97
116
|
if (killswitch != null) {
|
|
98
117
|
// Specifically kill certain events
|
|
99
118
|
if (killswitch.includes(name)) {
|
|
@@ -151,8 +170,8 @@ export function getExperimentalInteractionRate(name, interactionType) {
|
|
|
151
170
|
if (!config) {
|
|
152
171
|
return 0;
|
|
153
172
|
}
|
|
154
|
-
var
|
|
155
|
-
experimentalInteractionMetrics =
|
|
173
|
+
var _config4 = config,
|
|
174
|
+
experimentalInteractionMetrics = _config4.experimentalInteractionMetrics;
|
|
156
175
|
if (!(experimentalInteractionMetrics !== null && experimentalInteractionMetrics !== void 0 && experimentalInteractionMetrics.enabled)) {
|
|
157
176
|
return 0;
|
|
158
177
|
}
|
|
@@ -187,8 +206,8 @@ export function getCapabilityRate(capability) {
|
|
|
187
206
|
if (!config) {
|
|
188
207
|
return 0;
|
|
189
208
|
}
|
|
190
|
-
var
|
|
191
|
-
capabilityRate =
|
|
209
|
+
var _config5 = config,
|
|
210
|
+
capabilityRate = _config5.capability;
|
|
192
211
|
if (capabilityRate != null) {
|
|
193
212
|
var rate = capabilityRate[capability];
|
|
194
213
|
if (rate != null) {
|
|
@@ -233,8 +252,8 @@ export function getTypingPerformanceTracingMethod() {
|
|
|
233
252
|
if (!config) {
|
|
234
253
|
return defaultMethod;
|
|
235
254
|
}
|
|
236
|
-
var
|
|
237
|
-
typingMethod =
|
|
255
|
+
var _config6 = config,
|
|
256
|
+
typingMethod = _config6.typingMethod;
|
|
238
257
|
if (typingMethod != null && validTypingMethods.find(function (m) {
|
|
239
258
|
return m === typingMethod;
|
|
240
259
|
})) {
|
|
@@ -253,8 +272,8 @@ export function getAwaitBM3TTIList() {
|
|
|
253
272
|
if (!config) {
|
|
254
273
|
return [];
|
|
255
274
|
}
|
|
256
|
-
var
|
|
257
|
-
awaitBM3TTI =
|
|
275
|
+
var _config7 = config,
|
|
276
|
+
awaitBM3TTI = _config7.awaitBM3TTI;
|
|
258
277
|
if (awaitBM3TTI != null) {
|
|
259
278
|
return awaitBM3TTI;
|
|
260
279
|
} else {
|
|
@@ -274,8 +293,8 @@ export function getUfoNameOverrides() {
|
|
|
274
293
|
if (!config) {
|
|
275
294
|
return undefined;
|
|
276
295
|
}
|
|
277
|
-
var
|
|
278
|
-
ufoNameOverrides =
|
|
296
|
+
var _config8 = config,
|
|
297
|
+
ufoNameOverrides = _config8.ufoNameOverrides;
|
|
279
298
|
if (ufoNameOverrides != null) {
|
|
280
299
|
return ufoNameOverrides;
|
|
281
300
|
}
|
|
@@ -289,8 +308,8 @@ export function getMinorInteractions() {
|
|
|
289
308
|
if (!config) {
|
|
290
309
|
return undefined;
|
|
291
310
|
}
|
|
292
|
-
var
|
|
293
|
-
minorInteractions =
|
|
311
|
+
var _config9 = config,
|
|
312
|
+
minorInteractions = _config9.minorInteractions;
|
|
294
313
|
return minorInteractions;
|
|
295
314
|
} catch (_unused9) {
|
|
296
315
|
return undefined;
|
|
@@ -303,8 +322,8 @@ export function getDoNotAbortActivePressInteraction() {
|
|
|
303
322
|
if (!config) {
|
|
304
323
|
return undefined;
|
|
305
324
|
}
|
|
306
|
-
var
|
|
307
|
-
doNotAbortActivePressInteraction =
|
|
325
|
+
var _config0 = config,
|
|
326
|
+
doNotAbortActivePressInteraction = _config0.doNotAbortActivePressInteraction;
|
|
308
327
|
return doNotAbortActivePressInteraction;
|
|
309
328
|
} catch (_unused0) {
|
|
310
329
|
return undefined;
|
|
@@ -317,8 +336,8 @@ export function getDoNotAbortActivePressInteractionOnTransition() {
|
|
|
317
336
|
if (!config) {
|
|
318
337
|
return undefined;
|
|
319
338
|
}
|
|
320
|
-
var
|
|
321
|
-
doNotAbortActivePressInteractionOnTransition =
|
|
339
|
+
var _config1 = config,
|
|
340
|
+
doNotAbortActivePressInteractionOnTransition = _config1.doNotAbortActivePressInteractionOnTransition;
|
|
322
341
|
return doNotAbortActivePressInteractionOnTransition;
|
|
323
342
|
} catch (_unused1) {
|
|
324
343
|
return undefined;
|
|
@@ -331,8 +350,8 @@ export function getFinishInteractionOnTransition() {
|
|
|
331
350
|
if (!config) {
|
|
332
351
|
return undefined;
|
|
333
352
|
}
|
|
334
|
-
var
|
|
335
|
-
finishInteractionOnTransition =
|
|
353
|
+
var _config10 = config,
|
|
354
|
+
finishInteractionOnTransition = _config10.finishInteractionOnTransition;
|
|
336
355
|
return finishInteractionOnTransition;
|
|
337
356
|
} catch (_unused10) {
|
|
338
357
|
return undefined;
|
|
@@ -344,8 +363,8 @@ export function getInteractionTimeout(ufoName) {
|
|
|
344
363
|
if (!config) {
|
|
345
364
|
return CLEANUP_TIMEOUT;
|
|
346
365
|
}
|
|
347
|
-
var
|
|
348
|
-
interactionTimeout =
|
|
366
|
+
var _config11 = config,
|
|
367
|
+
interactionTimeout = _config11.interactionTimeout;
|
|
349
368
|
if (interactionTimeout != null && interactionTimeout[ufoName] != null) {
|
|
350
369
|
return interactionTimeout[ufoName];
|
|
351
370
|
}
|
|
@@ -9,7 +9,7 @@ import { ROOT_CONTEXT } from '@opentelemetry/api';
|
|
|
9
9
|
* and we need to get it because we need to call a function that's not available in the OTel API:
|
|
10
10
|
* `setActive`. The OTel JS API design doesn't allow us to manually set the active context
|
|
11
11
|
* despite the spec allowing for the capability. Sigh.
|
|
12
|
-
*
|
|
12
|
+
*
|
|
13
13
|
* I imagine this situation might not be permanent if we can move to a system were we can rely
|
|
14
14
|
* solely on the API, but for the purposes of the first change being React UFO API compatible,
|
|
15
15
|
* we'll need to do this.
|
|
@@ -23,7 +23,7 @@ export function getContextManager() {
|
|
|
23
23
|
return contextManager;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
/**
|
|
26
|
+
/**
|
|
27
27
|
* The below is shamelessly borrowed from StackContextManager from @opentelemetry/sdk-trace-web
|
|
28
28
|
* Using this rather than importing the entire package because this is all we need for now
|
|
29
29
|
*/
|
|
@@ -157,9 +157,9 @@ export var UFOContextManager = /*#__PURE__*/function () {
|
|
|
157
157
|
* This function is an extension of the OTel spec, in order to facilitate the current API of React UFO trace context handling.
|
|
158
158
|
* It doesn't keep track of any previously set active contexts, because it's assumed (for now) that only one trace context
|
|
159
159
|
* will ever exist at a time.
|
|
160
|
-
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
160
|
+
* The next step in the work to improve tracing in the FE will likely remove this function as we need to track the
|
|
161
161
|
* hierarchy of contexts (likely using the `with()` function above).
|
|
162
|
-
* @param context The context to be made the globally active one
|
|
162
|
+
* @param context The context to be made the globally active one
|
|
163
163
|
*/
|
|
164
164
|
}, {
|
|
165
165
|
key: "setActive",
|
|
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
4
4
|
import { context } from '@opentelemetry/api';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { startLighthouseObserver } from '../additional-payload';
|
|
7
|
-
import { setUFOConfig } from '../config';
|
|
7
|
+
import { isUFOEnabled, setUFOConfig } from '../config';
|
|
8
8
|
import { experimentalVC, sinkExperimentalHandler } from '../create-experimental-interaction-metrics-payload';
|
|
9
9
|
import { sinkExtraSearchPageInteractionHandler } from '../create-extra-search-page-interaction-payload';
|
|
10
10
|
import { setContextManager, UFOContextManager } from '../experience-trace-id-context/context-manager';
|
|
@@ -144,10 +144,19 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
// Always set config first so isUFOEnabled() can check config.enabled
|
|
148
|
+
setUFOConfig(config);
|
|
149
|
+
|
|
150
|
+
// If UFO is disabled via config, skip all initialization
|
|
151
|
+
// This is gated behind platform_ufo_enable_killswitch_config feature flag
|
|
152
|
+
if (!isUFOEnabled()) {
|
|
153
|
+
initialized = true;
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
147
157
|
// Initialize pressure observer for CPU usage monitoring
|
|
148
158
|
initialisePressureObserver();
|
|
149
159
|
initialiseMemoryObserver();
|
|
150
|
-
setUFOConfig(config);
|
|
151
160
|
if (fg('platform_ufo_enable_otel_context_manager')) {
|
|
152
161
|
// Configure global OTel context manager
|
|
153
162
|
var contextManager = new UFOContextManager();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { useContext, useEffect, useLayoutEffect, useState } from 'react';
|
|
3
|
+
import { isUFOEnabled } from '../config';
|
|
3
4
|
import UFOInteractionContext from '../interaction-context';
|
|
4
5
|
import UFOInteractionIDContext, { subscribeToInteractionIdChanges } from '../interaction-id-context';
|
|
5
6
|
var useLayoutEffectSAFE = typeof window === 'undefined' ? useEffect : useLayoutEffect;
|
|
@@ -76,18 +77,25 @@ export default function UFOLoadHold(_ref) {
|
|
|
76
77
|
hold = _ref$hold === void 0 ? true : _ref$hold,
|
|
77
78
|
_ref$experimental = _ref.experimental,
|
|
78
79
|
experimental = _ref$experimental === void 0 ? false : _ref$experimental;
|
|
80
|
+
// Check if UFO is enabled (gated behind platform_ufo_enable_killswitch_config feature flag)
|
|
81
|
+
// Note: isUFOEnabled() returns a stable value based on config, so it's safe to call before hooks
|
|
82
|
+
var ufoEnabled = isUFOEnabled();
|
|
79
83
|
var currentInteractionId = useInteractionIdValue();
|
|
80
84
|
|
|
81
85
|
// react-18: useId instead
|
|
82
86
|
var context = useContext(UFOInteractionContext);
|
|
83
87
|
useLayoutEffectSAFE(function () {
|
|
88
|
+
// Skip hold registration if UFO is disabled
|
|
89
|
+
if (!ufoEnabled) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
84
92
|
if (hold && context != null) {
|
|
85
93
|
if (experimental && context.holdExperimental) {
|
|
86
94
|
return context.holdExperimental(name);
|
|
87
95
|
}
|
|
88
96
|
return context.hold(name);
|
|
89
97
|
}
|
|
90
|
-
}, [hold, context, name, currentInteractionId]);
|
|
98
|
+
}, [hold, context, name, currentInteractionId, ufoEnabled]);
|
|
91
99
|
|
|
92
100
|
// react-18: can return children directly
|
|
93
101
|
return children != null ? /*#__PURE__*/React.createElement(React.Fragment, null, children) : null;
|
|
@@ -8,7 +8,7 @@ import { unstable_NormalPriority as NormalPriority, unstable_scheduleCallback as
|
|
|
8
8
|
import { v4 as createUUID } from 'uuid';
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import coinflip from '../coinflip';
|
|
11
|
-
import { getConfig, getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions } from '../config';
|
|
11
|
+
import { getConfig, getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions, isUFOEnabled } from '../config';
|
|
12
12
|
import { getActiveTrace, setInteractionActiveTrace } from '../experience-trace-id-context';
|
|
13
13
|
import UFOInteractionContext from '../interaction-context';
|
|
14
14
|
import UFOInteractionIDContext from '../interaction-id-context';
|
|
@@ -28,6 +28,10 @@ export default function UFOSegment(_ref) {
|
|
|
28
28
|
mode = _ref$mode === void 0 ? 'single' : _ref$mode,
|
|
29
29
|
_ref$type = _ref.type,
|
|
30
30
|
type = _ref$type === void 0 ? 'first-party' : _ref$type;
|
|
31
|
+
// If UFO is disabled, render children without any tracking overhead
|
|
32
|
+
// This is gated behind platform_ufo_enable_killswitch_config feature flag
|
|
33
|
+
// Note: isUFOEnabled() returns a stable value based on config, so it's safe to call before hooks
|
|
34
|
+
var ufoEnabled = isUFOEnabled();
|
|
31
35
|
var parentContext = useContext(UFOInteractionContext);
|
|
32
36
|
var segmentIdMap = useMemo(function () {
|
|
33
37
|
if (!(parentContext !== null && parentContext !== void 0 && parentContext.segmentIdMap)) {
|
|
@@ -271,6 +275,11 @@ export default function UFOSegment(_ref) {
|
|
|
271
275
|
return l.name;
|
|
272
276
|
}).join('/');
|
|
273
277
|
}, [labelStack]);
|
|
278
|
+
|
|
279
|
+
// If UFO is disabled, just render children without tracking overhead
|
|
280
|
+
if (!ufoEnabled) {
|
|
281
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
282
|
+
}
|
|
274
283
|
var ufoSegment = /*#__PURE__*/React.createElement(UFOInteractionContext.Provider, {
|
|
275
284
|
value: interactionContext
|
|
276
285
|
}, /*#__PURE__*/React.createElement(Profiler, {
|
|
@@ -284,5 +293,4 @@ export default function UFOSegment(_ref) {
|
|
|
284
293
|
}, ufoSegment);
|
|
285
294
|
}
|
|
286
295
|
return ufoSegment;
|
|
287
|
-
}
|
|
288
|
-
UFOSegment.displayName = 'UFOSegment';
|
|
296
|
+
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
2
|
import { v4 as createUUID } from 'uuid';
|
|
3
3
|
import coinflip from '../../coinflip';
|
|
4
|
-
import { getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions } from '../../config';
|
|
4
|
+
import { getDoNotAbortActivePressInteraction, getInteractionRate, getMinorInteractions, isUFOEnabled } from '../../config';
|
|
5
5
|
import { getActiveTrace, setInteractionActiveTrace } from '../../experience-trace-id-context';
|
|
6
6
|
import { DefaultInteractionID } from '../../interaction-id-context';
|
|
7
7
|
import { abortAll, addNewInteraction, getActiveInteraction } from '../../interaction-metrics';
|
|
8
8
|
import UFORouteName from '../../route-name-context';
|
|
9
9
|
function traceUFOInteraction(name, interactionType, startTime) {
|
|
10
10
|
var _getMinorInteractions;
|
|
11
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
12
|
+
if (!isUFOEnabled()) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
11
15
|
var rate = getInteractionRate(name, interactionType);
|
|
12
16
|
var pressInteractionsList = getDoNotAbortActivePressInteraction();
|
|
13
17
|
var minorInteractions = (pressInteractionsList !== null && pressInteractionsList !== void 0 ? pressInteractionsList : []).concat((_getMinorInteractions = getMinorInteractions()) !== null && _getMinorInteractions !== void 0 ? _getMinorInteractions : []);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
2
2
|
import { v4 as createUUID } from 'uuid';
|
|
3
3
|
import coinflip from '../coinflip';
|
|
4
|
-
import { getInteractionRate } from '../config';
|
|
4
|
+
import { getInteractionRate, isUFOEnabled } from '../config';
|
|
5
5
|
import { getActiveTrace } from '../experience-trace-id-context';
|
|
6
6
|
import { DefaultInteractionID } from '../interaction-id-context';
|
|
7
7
|
import { abort, addHoldByID, addNewInteraction, getActiveInteraction, removeHoldByID, updatePageLoadInteractionName } from '../interaction-metrics';
|
|
@@ -9,6 +9,10 @@ import UFORouteName from '../route-name-context';
|
|
|
9
9
|
var AWAITING_PAGELOAD_NAME = 'awaiting_pageload_name';
|
|
10
10
|
function traceUFOPageLoad(ufoName) {
|
|
11
11
|
var routeName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ufoName;
|
|
12
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
13
|
+
if (!isUFOEnabled()) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
12
16
|
var activeInteraction = getActiveInteraction();
|
|
13
17
|
if (activeInteraction && !ufoName) {
|
|
14
18
|
return;
|
|
@@ -36,6 +40,10 @@ function traceUFOPageLoad(ufoName) {
|
|
|
36
40
|
export default traceUFOPageLoad;
|
|
37
41
|
export function updatePageloadName(ufoName) {
|
|
38
42
|
var routeName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ufoName;
|
|
43
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
44
|
+
if (!isUFOEnabled()) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
39
47
|
var interaction = getActiveInteraction();
|
|
40
48
|
if (!interaction || interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
41
49
|
return;
|
|
@@ -3,7 +3,7 @@ import { useContext, useEffect } from 'react';
|
|
|
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
5
|
import coinflip from '../coinflip';
|
|
6
|
-
import { getDoNotAbortActivePressInteractionOnTransition, getInteractionRate } from '../config';
|
|
6
|
+
import { getDoNotAbortActivePressInteractionOnTransition, getInteractionRate, isUFOEnabled } from '../config';
|
|
7
7
|
import { getActiveTrace } from '../experience-trace-id-context';
|
|
8
8
|
import UFOInteractionIDContext, { DefaultInteractionID } from '../interaction-id-context';
|
|
9
9
|
import { abortAll, addNewInteraction, addOnCancelCallback, getActiveInteraction, tryComplete } from '../interaction-metrics';
|
|
@@ -11,6 +11,10 @@ import UFORouteName from '../route-name-context';
|
|
|
11
11
|
import { setInteractionActiveTrace } from './utils/set-interaction-active-trace';
|
|
12
12
|
function traceUFOTransition(ufoName) {
|
|
13
13
|
var routeName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ufoName;
|
|
14
|
+
// Skip if UFO is disabled (gated behind platform_ufo_enable_killswitch_config)
|
|
15
|
+
if (!isUFOEnabled()) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
14
18
|
var pressInteractionsList = getDoNotAbortActivePressInteractionOnTransition();
|
|
15
19
|
var interaction = getActiveInteraction();
|
|
16
20
|
if (pressInteractionsList && interaction) {
|
|
@@ -190,6 +190,16 @@ export type Config = {
|
|
|
190
190
|
};
|
|
191
191
|
export declare function setUFOConfig(newConfig: Config): void;
|
|
192
192
|
export declare function getConfig(): Config | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Check if UFO is enabled based on the config.enabled field.
|
|
195
|
+
*
|
|
196
|
+
* This function is gated behind the platform_ufo_enable_killswitch_config feature flag.
|
|
197
|
+
* When the feature flag is disabled, UFO is always considered enabled (default behavior).
|
|
198
|
+
* When the feature flag is enabled, the config.enabled field is respected.
|
|
199
|
+
*
|
|
200
|
+
* @returns true if UFO is enabled, false if disabled
|
|
201
|
+
*/
|
|
202
|
+
export declare function isUFOEnabled(): boolean;
|
|
193
203
|
export declare function getEnabledVCRevisions(experienceKey?: string): readonly TTVCRevision[];
|
|
194
204
|
export declare function isVCRevisionEnabled(revision: TTVCRevision, experienceKey?: string): boolean;
|
|
195
205
|
export declare function getMostRecentVCRevision(experienceKey?: string): TTVCRevision;
|
|
@@ -24,8 +24,4 @@ export type UFOIgnoreHoldsProps = {
|
|
|
24
24
|
* Has an `ignore` prop, to allow you to use it conditionally
|
|
25
25
|
* Has a `reason` prop, to specify why the hold is being ignored
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
declare namespace UFOIgnoreHolds {
|
|
29
|
-
var displayName: string;
|
|
30
|
-
}
|
|
31
|
-
export default UFOIgnoreHolds;
|
|
27
|
+
export default function UFOIgnoreHolds({ children, ignore, }: UFOIgnoreHoldsProps): React.JSX.Element;
|
|
@@ -7,8 +7,4 @@ export type Props = {
|
|
|
7
7
|
type?: UFOSegmentType;
|
|
8
8
|
};
|
|
9
9
|
/** A portion of the page we apply measurement to */
|
|
10
|
-
|
|
11
|
-
declare namespace UFOSegment {
|
|
12
|
-
var displayName: string;
|
|
13
|
-
}
|
|
14
|
-
export default UFOSegment;
|
|
10
|
+
export default function UFOSegment({ name: segmentName, children, mode, type, }: Props): React.JSX.Element;
|
|
@@ -190,6 +190,16 @@ export type Config = {
|
|
|
190
190
|
};
|
|
191
191
|
export declare function setUFOConfig(newConfig: Config): void;
|
|
192
192
|
export declare function getConfig(): Config | undefined;
|
|
193
|
+
/**
|
|
194
|
+
* Check if UFO is enabled based on the config.enabled field.
|
|
195
|
+
*
|
|
196
|
+
* This function is gated behind the platform_ufo_enable_killswitch_config feature flag.
|
|
197
|
+
* When the feature flag is disabled, UFO is always considered enabled (default behavior).
|
|
198
|
+
* When the feature flag is enabled, the config.enabled field is respected.
|
|
199
|
+
*
|
|
200
|
+
* @returns true if UFO is enabled, false if disabled
|
|
201
|
+
*/
|
|
202
|
+
export declare function isUFOEnabled(): boolean;
|
|
193
203
|
export declare function getEnabledVCRevisions(experienceKey?: string): readonly TTVCRevision[];
|
|
194
204
|
export declare function isVCRevisionEnabled(revision: TTVCRevision, experienceKey?: string): boolean;
|
|
195
205
|
export declare function getMostRecentVCRevision(experienceKey?: string): TTVCRevision;
|
|
@@ -24,8 +24,4 @@ export type UFOIgnoreHoldsProps = {
|
|
|
24
24
|
* Has an `ignore` prop, to allow you to use it conditionally
|
|
25
25
|
* Has a `reason` prop, to specify why the hold is being ignored
|
|
26
26
|
*/
|
|
27
|
-
|
|
28
|
-
declare namespace UFOIgnoreHolds {
|
|
29
|
-
var displayName: string;
|
|
30
|
-
}
|
|
31
|
-
export default UFOIgnoreHolds;
|
|
27
|
+
export default function UFOIgnoreHolds({ children, ignore, }: UFOIgnoreHoldsProps): React.JSX.Element;
|
|
@@ -7,8 +7,4 @@ export type Props = {
|
|
|
7
7
|
type?: UFOSegmentType;
|
|
8
8
|
};
|
|
9
9
|
/** A portion of the page we apply measurement to */
|
|
10
|
-
|
|
11
|
-
declare namespace UFOSegment {
|
|
12
|
-
var displayName: string;
|
|
13
|
-
}
|
|
14
|
-
export default UFOSegment;
|
|
10
|
+
export default function UFOSegment({ name: segmentName, children, mode, type, }: Props): React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.7",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -208,6 +208,9 @@
|
|
|
208
208
|
},
|
|
209
209
|
"ufo_vc_revision_trim_enabled": {
|
|
210
210
|
"type": "boolean"
|
|
211
|
+
},
|
|
212
|
+
"platform_ufo_enable_killswitch_config": {
|
|
213
|
+
"type": "boolean"
|
|
211
214
|
}
|
|
212
215
|
}
|
|
213
216
|
}
|