@atlaskit/react-ufo 2.2.0 → 2.2.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 2.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#162445](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/162445)
8
+ [`19a11c825b2fe`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/19a11c825b2fe) -
9
+ enable additional performance marks in performance tab
10
+
3
11
  ## 2.2.0
4
12
 
5
13
  ### Minor Changes
@@ -75,6 +75,10 @@ function getActiveInteraction() {
75
75
  }
76
76
  return _constants.default.get(interactionId.current);
77
77
  }
78
+ function isPerformanceTracingEnabled() {
79
+ var _getConfig;
80
+ return ((_getConfig = (0, _config.getConfig)()) === null || _getConfig === void 0 ? void 0 : _getConfig.enableAdditionalPerformanceMarks) || window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production';
81
+ }
78
82
  function labelStackToString(labelStack, name) {
79
83
  var _stack$map;
80
84
  var stack = (0, _toConsumableArray2.default)(labelStack !== null && labelStack !== void 0 ? labelStack : []);
@@ -154,7 +158,7 @@ function addCustomTiming(interactionId, labelStack, data) {
154
158
  labelStack: labelStack,
155
159
  data: data
156
160
  });
157
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
161
+ if (isPerformanceTracingEnabled()) {
158
162
  for (var _i = 0, _Object$entries = Object.entries(data); _i < _Object$entries.length; _i++) {
159
163
  var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
160
164
  key = _Object$entries$_i[0],
@@ -185,7 +189,7 @@ function addMark(interactionId, type, name, labelStack) {
185
189
  time: time
186
190
  });
187
191
  }
188
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
192
+ if (isPerformanceTracingEnabled()) {
189
193
  performance.mark("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
190
194
  startTime: time
191
195
  });
@@ -201,7 +205,7 @@ function addMarkToAll(type, name, labelStack) {
201
205
  time: time
202
206
  });
203
207
  });
204
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
208
+ if (isPerformanceTracingEnabled()) {
205
209
  performance.mark("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
206
210
  startTime: time
207
211
  });
@@ -220,7 +224,7 @@ function addSpan(interactionId, type, name, labelStack, start) {
220
224
  end: end,
221
225
  size: size
222
226
  });
223
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
227
+ if (isPerformanceTracingEnabled()) {
224
228
  try {
225
229
  // for Firefox 102 and older
226
230
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
@@ -246,7 +250,7 @@ function addSpanToAll(type, name, labelStack, start) {
246
250
  size: size
247
251
  });
248
252
  });
249
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
253
+ if (isPerformanceTracingEnabled()) {
250
254
  try {
251
255
  // for Firefox 102 and older
252
256
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
@@ -299,7 +303,7 @@ function addHold(interactionId, labelStack, name) {
299
303
  addHoldCriterion(id, labelStack, name, start);
300
304
  return function () {
301
305
  var end = performance.now();
302
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
306
+ if (isPerformanceTracingEnabled()) {
303
307
  try {
304
308
  // for Firefox 102 and older
305
309
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
@@ -419,8 +423,8 @@ function addErrorToAll(name, labelStack, errorType, errorMessage, errorStack) {
419
423
  });
420
424
  }
421
425
  var addProfilerTimings = exports.addProfilerTimings = function addProfilerTimings(interactionId, labelStack, type, actualDuration, baseDuration, startTime, commitTime) {
422
- var _getConfig;
423
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
426
+ var _getConfig2;
427
+ if (isPerformanceTracingEnabled()) {
424
428
  try {
425
429
  // for Firefox 102 and older
426
430
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
@@ -441,7 +445,7 @@ var addProfilerTimings = exports.addProfilerTimings = function addProfilerTiming
441
445
  startTime: startTime,
442
446
  commitTime: commitTime
443
447
  });
444
- } else if ((_getConfig = (0, _config.getConfig)()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.postInteractionLog) !== null && _getConfig !== void 0 && _getConfig.enabled) {
448
+ } else if ((_getConfig2 = (0, _config.getConfig)()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.postInteractionLog) !== null && _getConfig2 !== void 0 && _getConfig2.enabled) {
445
449
  postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
446
450
  }
447
451
  };
@@ -458,7 +462,7 @@ function callCleanUpCallbacks(interaction) {
458
462
  });
459
463
  }
460
464
  var finishInteraction = function finishInteraction(id, data) {
461
- var _getConfig2;
465
+ var _getConfig3;
462
466
  var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
463
467
  // eslint-disable-next-line no-param-reassign
464
468
  data.end = endTime;
@@ -477,7 +481,7 @@ var finishInteraction = function finishInteraction(id, data) {
477
481
  }
478
482
  (0, _experienceTraceIdContext.clearActiveTrace)();
479
483
  callCleanUpCallbacks(data);
480
- if ((_getConfig2 = (0, _config.getConfig)()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.vc) !== null && _getConfig2 !== void 0 && _getConfig2.stopVCAtInteractionFinish) {
484
+ if ((_getConfig3 = (0, _config.getConfig)()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.vc) !== null && _getConfig3 !== void 0 && _getConfig3.stopVCAtInteractionFinish) {
481
485
  data.vc = (0, _vc.getVCObserver)().getVCRawData();
482
486
  }
483
487
  remove(id);
@@ -486,7 +490,7 @@ var finishInteraction = function finishInteraction(id, data) {
486
490
  if (data.ufoName) {
487
491
  handleInteraction(id, data);
488
492
  }
489
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
493
+ if (isPerformanceTracingEnabled()) {
490
494
  var profilerTimingMap = new Map();
491
495
  data.reactProfilerTimings.forEach(function (profilerTiming) {
492
496
  var labelStackId = labelStackToIdString(profilerTiming.labelStack);
@@ -551,9 +555,9 @@ function tryComplete(interactionId, endTime) {
551
555
  if (interaction != null) {
552
556
  var noMoreHolds = interaction.holdActive.size === 0;
553
557
  if (noMoreHolds) {
554
- var _getConfig3;
558
+ var _getConfig4;
555
559
  finishInteraction(interactionId, interaction, endTime);
556
- if ((_getConfig3 = (0, _config.getConfig)()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.postInteractionLog) !== null && _getConfig3 !== void 0 && _getConfig3.enabled) {
560
+ if ((_getConfig4 = (0, _config.getConfig)()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.postInteractionLog) !== null && _getConfig4 !== void 0 && _getConfig4.enabled) {
557
561
  postInteractionLog.onInteractionComplete(interaction);
558
562
  }
559
563
  }
@@ -601,9 +605,9 @@ function addOnCancelCallback(id, cancelCallback) {
601
605
  interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
602
606
  }
603
607
  function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
604
- var _getConfig4;
608
+ var _getConfig5;
605
609
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
606
- if ((_getConfig4 = (0, _config.getConfig)()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.postInteractionLog) !== null && _getConfig4 !== void 0 && _getConfig4.enabled) {
610
+ if ((_getConfig5 = (0, _config.getConfig)()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.postInteractionLog) !== null && _getConfig5 !== void 0 && _getConfig5.enabled) {
607
611
  postInteractionLog.reset();
608
612
  }
609
613
  var previousTime = startTime;
@@ -799,7 +803,7 @@ function addRedirect(interactionId, fromUfoName, nextUfoName, nextRouteName, tim
799
803
  fromInteractionName: fromUfoName,
800
804
  time: time
801
805
  });
802
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
806
+ if (isPerformanceTracingEnabled()) {
803
807
  var prevRedirect = interaction.redirects.at(-2);
804
808
  try {
805
809
  var _prevRedirect$time;
@@ -41,6 +41,9 @@ var init = exports.init = function init(analyticsWebClientAsync, config) {
41
41
  if (initialized) {
42
42
  return;
43
43
  }
44
+ if (window !== undefined) {
45
+ window.__REACT_UFO_ENABLE_PERF_TRACING = Boolean(sessionStorage.getItem('additionalPerfMarks') === 'true');
46
+ }
44
47
  (0, _config.setUFOConfig)(config);
45
48
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
46
49
  var vcOptions = {
@@ -24,6 +24,10 @@ export function getActiveInteraction() {
24
24
  }
25
25
  return interactions.get(interactionId.current);
26
26
  }
27
+ function isPerformanceTracingEnabled() {
28
+ var _getConfig;
29
+ return ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.enableAdditionalPerformanceMarks) || window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production';
30
+ }
27
31
  function labelStackToString(labelStack, name) {
28
32
  var _stack$map;
29
33
  const stack = [...(labelStack !== null && labelStack !== void 0 ? labelStack : [])];
@@ -89,7 +93,7 @@ export function addCustomTiming(interactionId, labelStack, data) {
89
93
  labelStack,
90
94
  data
91
95
  });
92
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
96
+ if (isPerformanceTracingEnabled()) {
93
97
  for (const [key, timingData] of Object.entries(data)) {
94
98
  const {
95
99
  startTime,
@@ -118,7 +122,7 @@ export function addMark(interactionId, type, name, labelStack, time = performanc
118
122
  time
119
123
  });
120
124
  }
121
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
125
+ if (isPerformanceTracingEnabled()) {
122
126
  performance.mark(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
123
127
  startTime: time
124
128
  });
@@ -133,7 +137,7 @@ export function addMarkToAll(type, name, labelStack, time = performance.now()) {
133
137
  time
134
138
  });
135
139
  });
136
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
140
+ if (isPerformanceTracingEnabled()) {
137
141
  performance.mark(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
138
142
  startTime: time
139
143
  });
@@ -150,7 +154,7 @@ export function addSpan(interactionId, type, name, labelStack, start, end = perf
150
154
  end,
151
155
  size
152
156
  });
153
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
157
+ if (isPerformanceTracingEnabled()) {
154
158
  try {
155
159
  // for Firefox 102 and older
156
160
  performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
@@ -174,7 +178,7 @@ export function addSpanToAll(type, name, labelStack, start, end = performance.no
174
178
  size
175
179
  });
176
180
  });
177
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
181
+ if (isPerformanceTracingEnabled()) {
178
182
  try {
179
183
  // for Firefox 102 and older
180
184
  performance.measure(`🛸 ${labelStackToString(labelStack, name)} [${type}]`, {
@@ -227,7 +231,7 @@ export function addHold(interactionId, labelStack, name) {
227
231
  addHoldCriterion(id, labelStack, name, start);
228
232
  return () => {
229
233
  const end = performance.now();
230
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
234
+ if (isPerformanceTracingEnabled()) {
231
235
  try {
232
236
  // for Firefox 102 and older
233
237
  performance.measure(`🛸 ${labelStackToString(labelStack, name)} [hold]`, {
@@ -349,8 +353,8 @@ export function addErrorToAll(name, labelStack, errorType, errorMessage, errorSt
349
353
  });
350
354
  }
351
355
  export const addProfilerTimings = (interactionId, labelStack, type, actualDuration, baseDuration, startTime, commitTime) => {
352
- var _getConfig, _getConfig$postIntera;
353
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
356
+ var _getConfig2, _getConfig2$postInter;
357
+ if (isPerformanceTracingEnabled()) {
354
358
  try {
355
359
  // for Firefox 102 and older
356
360
  performance.measure(`🛸 ${labelStackToString(labelStack)} [react-profiler] ${type}`, {
@@ -371,7 +375,7 @@ export const addProfilerTimings = (interactionId, labelStack, type, actualDurati
371
375
  startTime,
372
376
  commitTime
373
377
  });
374
- } else if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig$postIntera = _getConfig.postInteractionLog) !== null && _getConfig$postIntera !== void 0 && _getConfig$postIntera.enabled) {
378
+ } else if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2$postInter = _getConfig2.postInteractionLog) !== null && _getConfig2$postInter !== void 0 && _getConfig2$postInter.enabled) {
375
379
  postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
376
380
  }
377
381
  };
@@ -388,7 +392,7 @@ function callCleanUpCallbacks(interaction) {
388
392
  });
389
393
  }
390
394
  const finishInteraction = (id, data, endTime = performance.now()) => {
391
- var _getConfig2, _getConfig2$vc;
395
+ var _getConfig3, _getConfig3$vc;
392
396
  // eslint-disable-next-line no-param-reassign
393
397
  data.end = endTime;
394
398
  try {
@@ -406,7 +410,7 @@ const finishInteraction = (id, data, endTime = performance.now()) => {
406
410
  }
407
411
  clearActiveTrace();
408
412
  callCleanUpCallbacks(data);
409
- if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2$vc = _getConfig2.vc) !== null && _getConfig2$vc !== void 0 && _getConfig2$vc.stopVCAtInteractionFinish) {
413
+ if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3$vc = _getConfig3.vc) !== null && _getConfig3$vc !== void 0 && _getConfig3$vc.stopVCAtInteractionFinish) {
410
414
  data.vc = getVCObserver().getVCRawData();
411
415
  }
412
416
  remove(id);
@@ -415,7 +419,7 @@ const finishInteraction = (id, data, endTime = performance.now()) => {
415
419
  if (data.ufoName) {
416
420
  handleInteraction(id, data);
417
421
  }
418
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
422
+ if (isPerformanceTracingEnabled()) {
419
423
  const profilerTimingMap = new Map();
420
424
  data.reactProfilerTimings.forEach(profilerTiming => {
421
425
  const labelStackId = labelStackToIdString(profilerTiming.labelStack);
@@ -471,9 +475,9 @@ export function tryComplete(interactionId, endTime) {
471
475
  if (interaction != null) {
472
476
  const noMoreHolds = interaction.holdActive.size === 0;
473
477
  if (noMoreHolds) {
474
- var _getConfig3, _getConfig3$postInter;
478
+ var _getConfig4, _getConfig4$postInter;
475
479
  finishInteraction(interactionId, interaction, endTime);
476
- if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3$postInter = _getConfig3.postInteractionLog) !== null && _getConfig3$postInter !== void 0 && _getConfig3$postInter.enabled) {
480
+ if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4$postInter = _getConfig4.postInteractionLog) !== null && _getConfig4$postInter !== void 0 && _getConfig4$postInter.enabled) {
477
481
  postInteractionLog.onInteractionComplete(interaction);
478
482
  }
479
483
  }
@@ -521,8 +525,8 @@ export function addOnCancelCallback(id, cancelCallback) {
521
525
  interaction === null || interaction === void 0 ? void 0 : interaction.cancelCallbacks.push(cancelCallback);
522
526
  }
523
527
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName, trace = null) {
524
- var _getConfig4, _getConfig4$postInter;
525
- if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4$postInter = _getConfig4.postInteractionLog) !== null && _getConfig4$postInter !== void 0 && _getConfig4$postInter.enabled) {
528
+ var _getConfig5, _getConfig5$postInter;
529
+ if ((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$postInter = _getConfig5.postInteractionLog) !== null && _getConfig5$postInter !== void 0 && _getConfig5$postInter.enabled) {
526
530
  postInteractionLog.reset();
527
531
  }
528
532
  let previousTime = startTime;
@@ -719,7 +723,7 @@ export function addRedirect(interactionId, fromUfoName, nextUfoName, nextRouteNa
719
723
  fromInteractionName: fromUfoName,
720
724
  time
721
725
  });
722
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
726
+ if (isPerformanceTracingEnabled()) {
723
727
  const prevRedirect = interaction.redirects.at(-2);
724
728
  try {
725
729
  var _prevRedirect$time;
@@ -30,6 +30,9 @@ export const init = (analyticsWebClientAsync, config) => {
30
30
  if (initialized) {
31
31
  return;
32
32
  }
33
+ if (window !== undefined) {
34
+ window.__REACT_UFO_ENABLE_PERF_TRACING = Boolean(sessionStorage.getItem('additionalPerfMarks') === 'true');
35
+ }
33
36
  setUFOConfig(config);
34
37
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
35
38
  const vcOptions = {
@@ -32,6 +32,10 @@ export function getActiveInteraction() {
32
32
  }
33
33
  return interactions.get(interactionId.current);
34
34
  }
35
+ function isPerformanceTracingEnabled() {
36
+ var _getConfig;
37
+ return ((_getConfig = getConfig()) === null || _getConfig === void 0 ? void 0 : _getConfig.enableAdditionalPerformanceMarks) || window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production';
38
+ }
35
39
  function labelStackToString(labelStack, name) {
36
40
  var _stack$map;
37
41
  var stack = _toConsumableArray(labelStack !== null && labelStack !== void 0 ? labelStack : []);
@@ -111,7 +115,7 @@ export function addCustomTiming(interactionId, labelStack, data) {
111
115
  labelStack: labelStack,
112
116
  data: data
113
117
  });
114
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
118
+ if (isPerformanceTracingEnabled()) {
115
119
  for (var _i = 0, _Object$entries = Object.entries(data); _i < _Object$entries.length; _i++) {
116
120
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
117
121
  key = _Object$entries$_i[0],
@@ -142,7 +146,7 @@ export function addMark(interactionId, type, name, labelStack) {
142
146
  time: time
143
147
  });
144
148
  }
145
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
149
+ if (isPerformanceTracingEnabled()) {
146
150
  performance.mark("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
147
151
  startTime: time
148
152
  });
@@ -158,7 +162,7 @@ export function addMarkToAll(type, name, labelStack) {
158
162
  time: time
159
163
  });
160
164
  });
161
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
165
+ if (isPerformanceTracingEnabled()) {
162
166
  performance.mark("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
163
167
  startTime: time
164
168
  });
@@ -177,7 +181,7 @@ export function addSpan(interactionId, type, name, labelStack, start) {
177
181
  end: end,
178
182
  size: size
179
183
  });
180
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
184
+ if (isPerformanceTracingEnabled()) {
181
185
  try {
182
186
  // for Firefox 102 and older
183
187
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
@@ -203,7 +207,7 @@ export function addSpanToAll(type, name, labelStack, start) {
203
207
  size: size
204
208
  });
205
209
  });
206
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
210
+ if (isPerformanceTracingEnabled()) {
207
211
  try {
208
212
  // for Firefox 102 and older
209
213
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
@@ -256,7 +260,7 @@ export function addHold(interactionId, labelStack, name) {
256
260
  addHoldCriterion(id, labelStack, name, start);
257
261
  return function () {
258
262
  var end = performance.now();
259
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
263
+ if (isPerformanceTracingEnabled()) {
260
264
  try {
261
265
  // for Firefox 102 and older
262
266
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
@@ -376,8 +380,8 @@ export function addErrorToAll(name, labelStack, errorType, errorMessage, errorSt
376
380
  });
377
381
  }
378
382
  export var addProfilerTimings = function addProfilerTimings(interactionId, labelStack, type, actualDuration, baseDuration, startTime, commitTime) {
379
- var _getConfig;
380
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
383
+ var _getConfig2;
384
+ if (isPerformanceTracingEnabled()) {
381
385
  try {
382
386
  // for Firefox 102 and older
383
387
  performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
@@ -398,7 +402,7 @@ export var addProfilerTimings = function addProfilerTimings(interactionId, label
398
402
  startTime: startTime,
399
403
  commitTime: commitTime
400
404
  });
401
- } else if ((_getConfig = getConfig()) !== null && _getConfig !== void 0 && (_getConfig = _getConfig.postInteractionLog) !== null && _getConfig !== void 0 && _getConfig.enabled) {
405
+ } else if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.postInteractionLog) !== null && _getConfig2 !== void 0 && _getConfig2.enabled) {
402
406
  postInteractionLog.addProfilerTimings(labelStack, type, actualDuration, baseDuration, startTime, commitTime);
403
407
  }
404
408
  };
@@ -415,7 +419,7 @@ function callCleanUpCallbacks(interaction) {
415
419
  });
416
420
  }
417
421
  var finishInteraction = function finishInteraction(id, data) {
418
- var _getConfig2;
422
+ var _getConfig3;
419
423
  var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
420
424
  // eslint-disable-next-line no-param-reassign
421
425
  data.end = endTime;
@@ -434,7 +438,7 @@ var finishInteraction = function finishInteraction(id, data) {
434
438
  }
435
439
  clearActiveTrace();
436
440
  callCleanUpCallbacks(data);
437
- if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.vc) !== null && _getConfig2 !== void 0 && _getConfig2.stopVCAtInteractionFinish) {
441
+ if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.vc) !== null && _getConfig3 !== void 0 && _getConfig3.stopVCAtInteractionFinish) {
438
442
  data.vc = getVCObserver().getVCRawData();
439
443
  }
440
444
  remove(id);
@@ -443,7 +447,7 @@ var finishInteraction = function finishInteraction(id, data) {
443
447
  if (data.ufoName) {
444
448
  handleInteraction(id, data);
445
449
  }
446
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
450
+ if (isPerformanceTracingEnabled()) {
447
451
  var profilerTimingMap = new Map();
448
452
  data.reactProfilerTimings.forEach(function (profilerTiming) {
449
453
  var labelStackId = labelStackToIdString(profilerTiming.labelStack);
@@ -508,9 +512,9 @@ export function tryComplete(interactionId, endTime) {
508
512
  if (interaction != null) {
509
513
  var noMoreHolds = interaction.holdActive.size === 0;
510
514
  if (noMoreHolds) {
511
- var _getConfig3;
515
+ var _getConfig4;
512
516
  finishInteraction(interactionId, interaction, endTime);
513
- if ((_getConfig3 = getConfig()) !== null && _getConfig3 !== void 0 && (_getConfig3 = _getConfig3.postInteractionLog) !== null && _getConfig3 !== void 0 && _getConfig3.enabled) {
517
+ if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.postInteractionLog) !== null && _getConfig4 !== void 0 && _getConfig4.enabled) {
514
518
  postInteractionLog.onInteractionComplete(interaction);
515
519
  }
516
520
  }
@@ -558,9 +562,9 @@ export function addOnCancelCallback(id, cancelCallback) {
558
562
  interaction === null || interaction === void 0 || interaction.cancelCallbacks.push(cancelCallback);
559
563
  }
560
564
  export function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
561
- var _getConfig4;
565
+ var _getConfig5;
562
566
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
563
- if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.postInteractionLog) !== null && _getConfig4 !== void 0 && _getConfig4.enabled) {
567
+ if ((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.postInteractionLog) !== null && _getConfig5 !== void 0 && _getConfig5.enabled) {
564
568
  postInteractionLog.reset();
565
569
  }
566
570
  var previousTime = startTime;
@@ -756,7 +760,7 @@ export function addRedirect(interactionId, fromUfoName, nextUfoName, nextRouteNa
756
760
  fromInteractionName: fromUfoName,
757
761
  time: time
758
762
  });
759
- if (window.__REACT_UFO_ENABLE_PERF_TRACING || process.env.NODE_ENV !== 'production') {
763
+ if (isPerformanceTracingEnabled()) {
760
764
  var prevRedirect = interaction.redirects.at(-2);
761
765
  try {
762
766
  var _prevRedirect$time;
@@ -31,6 +31,9 @@ export var init = function init(analyticsWebClientAsync, config) {
31
31
  if (initialized) {
32
32
  return;
33
33
  }
34
+ if (window !== undefined) {
35
+ window.__REACT_UFO_ENABLE_PERF_TRACING = Boolean(sessionStorage.getItem('additionalPerfMarks') === 'true');
36
+ }
34
37
  setUFOConfig(config);
35
38
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
36
39
  var vcOptions = {
@@ -1,6 +1,6 @@
1
1
  import type { InteractionMetrics, InteractionType } from '../common';
2
2
  export interface AdditionalData {
3
- [key: string]: null | undefined | string | number | boolean | undefined | AdditionalData | Record<string, AdditionalData> | Array<AdditionalData>;
3
+ [key: string]: null | string | number | boolean | undefined | AdditionalData | Record<string, AdditionalData> | Array<AdditionalData>;
4
4
  }
5
5
  export interface SSRTiming {
6
6
  label: string;
@@ -73,6 +73,7 @@ export type Config = {
73
73
  readonly kind?: Record<InteractionType, number>;
74
74
  };
75
75
  readonly enableSegmentHighlighting?: boolean;
76
+ readonly enableAdditionalPerformanceMarks?: boolean;
76
77
  readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
77
78
  readonly timeWindowForLateMutationsInMilliseconds?: number;
78
79
  readonly manuallyTrackReactProfilerMounts?: boolean;
@@ -1,6 +1,6 @@
1
1
  import type { InteractionMetrics, InteractionType } from '../common';
2
2
  export interface AdditionalData {
3
- [key: string]: null | undefined | string | number | boolean | undefined | AdditionalData | Record<string, AdditionalData> | Array<AdditionalData>;
3
+ [key: string]: null | string | number | boolean | undefined | AdditionalData | Record<string, AdditionalData> | Array<AdditionalData>;
4
4
  }
5
5
  export interface SSRTiming {
6
6
  label: string;
@@ -73,6 +73,7 @@ export type Config = {
73
73
  readonly kind?: Record<InteractionType, number>;
74
74
  };
75
75
  readonly enableSegmentHighlighting?: boolean;
76
+ readonly enableAdditionalPerformanceMarks?: boolean;
76
77
  readonly shouldCalculateLighthouseMetricsFromTTAI?: boolean;
77
78
  readonly timeWindowForLateMutationsInMilliseconds?: number;
78
79
  readonly manuallyTrackReactProfilerMounts?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",