@atlaskit/react-ufo 4.4.3 → 4.4.5

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/create-interaction-extra-metrics-payload/index.js +116 -0
  3. package/dist/cjs/create-payload/index.js +3 -2
  4. package/dist/cjs/create-payload/utils/get-vc-metrics.js +37 -21
  5. package/dist/cjs/interaction-metrics/index.js +313 -259
  6. package/dist/cjs/interaction-metrics/interaction-extra-metrics.js +89 -0
  7. package/dist/cjs/interaction-metrics-init/index.js +51 -7
  8. package/dist/cjs/segment/third-party-segment.js +3 -1
  9. package/dist/cjs/ssr/index.js +3 -2
  10. package/dist/cjs/vc/index.js +4 -3
  11. package/dist/cjs/vc/vc-observer/index.js +31 -51
  12. package/dist/cjs/vc/vc-observer-new/index.js +4 -3
  13. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +7 -5
  14. package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +15 -6
  15. package/dist/es2019/create-interaction-extra-metrics-payload/index.js +93 -0
  16. package/dist/es2019/create-payload/index.js +3 -3
  17. package/dist/es2019/create-payload/utils/get-vc-metrics.js +3 -2
  18. package/dist/es2019/interaction-metrics/index.js +317 -260
  19. package/dist/es2019/interaction-metrics/interaction-extra-metrics.js +63 -0
  20. package/dist/es2019/interaction-metrics-init/index.js +29 -2
  21. package/dist/es2019/segment/third-party-segment.js +3 -1
  22. package/dist/es2019/ssr/index.js +3 -2
  23. package/dist/es2019/vc/index.js +4 -2
  24. package/dist/es2019/vc/vc-observer/index.js +41 -61
  25. package/dist/es2019/vc/vc-observer-new/index.js +4 -2
  26. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +7 -3
  27. package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +12 -5
  28. package/dist/esm/create-interaction-extra-metrics-payload/index.js +109 -0
  29. package/dist/esm/create-payload/index.js +3 -3
  30. package/dist/esm/create-payload/utils/get-vc-metrics.js +37 -21
  31. package/dist/esm/interaction-metrics/index.js +312 -258
  32. package/dist/esm/interaction-metrics/interaction-extra-metrics.js +83 -0
  33. package/dist/esm/interaction-metrics-init/index.js +48 -6
  34. package/dist/esm/segment/third-party-segment.js +3 -1
  35. package/dist/esm/ssr/index.js +3 -2
  36. package/dist/esm/vc/index.js +4 -3
  37. package/dist/esm/vc/vc-observer/index.js +31 -51
  38. package/dist/esm/vc/vc-observer-new/index.js +4 -3
  39. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +7 -5
  40. package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +15 -6
  41. package/dist/types/common/common/types.d.ts +2 -0
  42. package/dist/types/common/vc/types.d.ts +1 -0
  43. package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +45 -0
  44. package/dist/types/create-payload/index.d.ts +1 -0
  45. package/dist/types/create-payload/utils/get-vc-metrics.d.ts +1 -1
  46. package/dist/types/interaction-metrics/index.d.ts +2 -0
  47. package/dist/types/interaction-metrics/interaction-extra-metrics.d.ts +17 -0
  48. package/dist/types/vc/types.d.ts +1 -0
  49. package/dist/types/vc/vc-observer/getVCRevisionDebugDetails.d.ts +1 -0
  50. package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +3 -2
  51. package/dist/types/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +2 -2
  52. package/dist/types/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
  53. package/dist/types/vc/vc-observer-new/types.d.ts +1 -0
  54. package/dist/types-ts4.5/common/common/types.d.ts +2 -0
  55. package/dist/types-ts4.5/common/vc/types.d.ts +1 -0
  56. package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +45 -0
  57. package/dist/types-ts4.5/create-payload/index.d.ts +1 -0
  58. package/dist/types-ts4.5/create-payload/utils/get-vc-metrics.d.ts +1 -1
  59. package/dist/types-ts4.5/interaction-metrics/index.d.ts +2 -0
  60. package/dist/types-ts4.5/interaction-metrics/interaction-extra-metrics.d.ts +17 -0
  61. package/dist/types-ts4.5/vc/types.d.ts +1 -0
  62. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionDebugDetails.d.ts +1 -0
  63. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +3 -2
  64. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +2 -2
  65. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/types.d.ts +1 -0
  66. package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +1 -0
  67. package/package.json +7 -10
@@ -35,7 +35,7 @@ exports.addSpanToAll = addSpanToAll;
35
35
  exports.extractModuleName = extractModuleName;
36
36
  exports.getActiveInteraction = getActiveInteraction;
37
37
  exports.getCurrentInteractionType = getCurrentInteractionType;
38
- exports.postInteractionLog = exports.interactionSpans = exports.getPerformanceObserver = void 0;
38
+ exports.postInteractionLog = exports.interactionSpans = exports.interactionExtraMetrics = exports.getPerformanceObserver = void 0;
39
39
  exports.remove = remove;
40
40
  exports.removeHoldByID = removeHoldByID;
41
41
  exports.removeSegment = removeSegment;
@@ -61,6 +61,7 @@ var _featureFlagsAccessed = require("../feature-flags-accessed");
61
61
  var _interactionIdContext = require("../interaction-id-context");
62
62
  var _vc = require("../vc");
63
63
  var _constants = require("./common/constants");
64
+ var _interactionExtraMetrics = _interopRequireDefault(require("./interaction-extra-metrics"));
64
65
  var _postInteractionLog = _interopRequireDefault(require("./post-interaction-log"));
65
66
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
66
67
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -72,6 +73,7 @@ var PreviousInteractionLog = {
72
73
  isAborted: undefined
73
74
  };
74
75
  var postInteractionLog = exports.postInteractionLog = new _postInteractionLog.default();
76
+ var interactionExtraMetrics = exports.interactionExtraMetrics = new _interactionExtraMetrics.default();
75
77
  var interactionQueue = [];
76
78
  var segmentCache = new Map();
77
79
  var segmentUnmountCache = exports.segmentUnmountCache = new Map(); // Temporarily store segment unmount counts
@@ -238,23 +240,16 @@ function addCustomTiming(interactionId, labelStack, data) {
238
240
  endTime = timingData.endTime;
239
241
  try {
240
242
  // for Firefox 102 and older
241
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
242
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, key), " [custom_timing]"), {
243
- start: startTime,
244
- end: endTime,
245
- detail: {
246
- devtools: {
247
- track: '🛸 reactUFO detailed timings',
248
- color: 'tertiary-light'
249
- }
243
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, key), " [custom_timing]"), {
244
+ start: startTime,
245
+ end: endTime,
246
+ detail: {
247
+ devtools: {
248
+ track: '🛸 reactUFO detailed timings',
249
+ color: 'tertiary-light'
250
250
  }
251
- });
252
- } else {
253
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, key), " [custom_timing]"), {
254
- start: startTime,
255
- end: endTime
256
- });
257
- }
251
+ }
252
+ });
258
253
  } catch (e) {
259
254
  // do nothing
260
255
  }
@@ -311,23 +306,16 @@ function addSpan(interactionId, type, name, labelStack, start) {
311
306
  if (isPerformanceTracingEnabled()) {
312
307
  try {
313
308
  // for Firefox 102 and older
314
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
315
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
316
- start: start,
317
- end: end,
318
- detail: {
319
- devtools: {
320
- track: '🛸 reactUFO detailed timings',
321
- color: 'secondary'
322
- }
309
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
310
+ start: start,
311
+ end: end,
312
+ detail: {
313
+ devtools: {
314
+ track: '🛸 reactUFO detailed timings',
315
+ color: 'secondary'
323
316
  }
324
- });
325
- } else {
326
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
327
- start: start,
328
- end: end
329
- });
330
- }
317
+ }
318
+ });
331
319
  } catch (e) {
332
320
  // do nothing
333
321
  }
@@ -350,23 +338,16 @@ function addSpanToAll(type, name, labelStack, start) {
350
338
  if (isPerformanceTracingEnabled()) {
351
339
  try {
352
340
  // for Firefox 102 and older
353
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
354
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
355
- start: start,
356
- end: end,
357
- detail: {
358
- devtools: {
359
- track: '🛸 reactUFO detailed timings',
360
- color: 'secondary'
361
- }
341
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
342
+ start: start,
343
+ end: end,
344
+ detail: {
345
+ devtools: {
346
+ track: '🛸 reactUFO detailed timings',
347
+ color: 'secondary'
362
348
  }
363
- });
364
- } else {
365
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [").concat(type, "]"), {
366
- start: start,
367
- end: end
368
- });
369
- }
349
+ }
350
+ });
370
351
  } catch (e) {
371
352
  // do nothing
372
353
  }
@@ -404,46 +385,58 @@ function addHold(interactionId, labelStack, name, experimental) {
404
385
  var interaction = _constants.interactions.get(interactionId);
405
386
  var id = (0, _uuid.v4)();
406
387
  if (interaction != null) {
407
- var _getConfig2;
408
388
  var start = performance.now();
409
389
  var holdActive = {
410
390
  labelStack: labelStack,
411
391
  name: name,
412
392
  start: start
413
393
  };
414
- if ((_getConfig2 = (0, _config.getConfig)()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled && experimental) {
415
- interaction.holdExpActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
416
- start: start
417
- }));
418
- }
419
- if (!experimental) {
420
- interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
421
- start: start
422
- }));
394
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
395
+ var is3pHold = labelStack.some(function (l) {
396
+ return 'type' in l && l.type === 'third-party';
397
+ });
398
+ if (is3pHold) {
399
+ if (!interaction.hold3pActive) {
400
+ interaction.hold3pActive = new Map();
401
+ }
402
+ interaction.hold3pActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
403
+ start: start
404
+ }));
405
+ } else {
406
+ interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
407
+ start: start
408
+ }));
409
+ addHoldCriterion(id, labelStack, name, start);
410
+ }
411
+ } else {
412
+ var _getConfig2;
413
+ if ((_getConfig2 = (0, _config.getConfig)()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled && experimental) {
414
+ interaction.holdExpActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
415
+ start: start
416
+ }));
417
+ }
418
+ if (!experimental) {
419
+ interaction.holdActive.set(id, _objectSpread(_objectSpread({}, holdActive), {}, {
420
+ start: start
421
+ }));
422
+ }
423
+ addHoldCriterion(id, labelStack, name, start);
423
424
  }
424
- addHoldCriterion(id, labelStack, name, start);
425
425
  return function () {
426
426
  var end = performance.now();
427
427
  if (isPerformanceTracingEnabled()) {
428
428
  try {
429
429
  // for Firefox 102 and older
430
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
431
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
432
- start: start,
433
- end: end,
434
- detail: {
435
- devtools: {
436
- track: '🛸 reactUFO detailed timings',
437
- color: 'secondary-light'
438
- }
430
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
431
+ start: start,
432
+ end: end,
433
+ detail: {
434
+ devtools: {
435
+ track: '🛸 reactUFO detailed timings',
436
+ color: 'secondary-light'
439
437
  }
440
- });
441
- } else {
442
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack, name), " [hold]"), {
443
- start: start,
444
- end: end
445
- });
446
- }
438
+ }
439
+ });
447
440
  } catch (e) {
448
441
  // do nothing
449
442
  }
@@ -465,6 +458,20 @@ function addHold(interactionId, labelStack, name, experimental) {
465
458
  }));
466
459
  interaction.holdExpActive.delete(id);
467
460
  }
461
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
462
+ if (interaction.hold3pActive) {
463
+ var current3pHold = interaction.hold3pActive.get(id);
464
+ if (current3pHold != null) {
465
+ if (!currentInteraction.hold3pInfo) {
466
+ currentInteraction.hold3pInfo = [];
467
+ }
468
+ currentInteraction.hold3pInfo.push(_objectSpread(_objectSpread({}, current3pHold), {}, {
469
+ end: end
470
+ }));
471
+ interaction.hold3pActive.delete(id);
472
+ }
473
+ }
474
+ }
468
475
  }
469
476
  };
470
477
  }
@@ -474,13 +481,38 @@ function addHoldByID(interactionId, labelStack, name, id, ignoreOnSubmit) {
474
481
  var interaction = _constants.interactions.get(interactionId);
475
482
  if (interaction != null) {
476
483
  var start = performance.now();
477
- interaction.holdActive.set(id, {
478
- labelStack: labelStack,
479
- name: name,
480
- start: start,
481
- ignoreOnSubmit: ignoreOnSubmit
482
- });
483
- addHoldCriterion(id, labelStack, name, start);
484
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
485
+ var is3pHold = labelStack.some(function (l) {
486
+ return 'type' in l && l.type === 'third-party';
487
+ });
488
+ if (is3pHold) {
489
+ if (!interaction.hold3pActive) {
490
+ interaction.hold3pActive = new Map();
491
+ }
492
+ interaction.hold3pActive.set(id, {
493
+ labelStack: labelStack,
494
+ name: name,
495
+ start: start,
496
+ ignoreOnSubmit: ignoreOnSubmit
497
+ });
498
+ } else {
499
+ interaction.holdActive.set(id, {
500
+ labelStack: labelStack,
501
+ name: name,
502
+ start: start,
503
+ ignoreOnSubmit: ignoreOnSubmit
504
+ });
505
+ addHoldCriterion(id, labelStack, name, start);
506
+ }
507
+ } else {
508
+ interaction.holdActive.set(id, {
509
+ labelStack: labelStack,
510
+ name: name,
511
+ start: start,
512
+ ignoreOnSubmit: ignoreOnSubmit
513
+ });
514
+ addHoldCriterion(id, labelStack, name, start);
515
+ }
484
516
  }
485
517
  return function () {};
486
518
  }
@@ -497,6 +529,20 @@ function removeHoldByID(interactionId, id) {
497
529
  interaction.holdActive.delete(id);
498
530
  removeHoldCriterion(id);
499
531
  }
532
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
533
+ if (interaction.hold3pActive) {
534
+ var current3pHold = interaction.hold3pActive.get(id);
535
+ if (currentInteraction != null && current3pHold != null) {
536
+ if (!currentInteraction.hold3pInfo) {
537
+ currentInteraction.hold3pInfo = [];
538
+ }
539
+ currentInteraction.hold3pInfo.push(_objectSpread(_objectSpread({}, current3pHold), {}, {
540
+ end: end
541
+ }));
542
+ interaction.hold3pActive.delete(id);
543
+ }
544
+ }
545
+ }
500
546
  }
501
547
  }
502
548
  function getCurrentInteractionType(interactionId) {
@@ -570,23 +616,16 @@ function addProfilerTimings(interactionId, labelStack, type, actualDuration, bas
570
616
  if (isPerformanceTracingEnabled()) {
571
617
  try {
572
618
  // for Firefox 102 and older
573
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
574
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
575
- start: startTime,
576
- duration: actualDuration,
577
- detail: {
578
- devtools: {
579
- track: '🛸 reactUFO detailed timings',
580
- color: 'secondary-dark'
581
- }
619
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
620
+ start: startTime,
621
+ duration: actualDuration,
622
+ detail: {
623
+ devtools: {
624
+ track: '🛸 reactUFO detailed timings',
625
+ color: 'secondary-dark'
582
626
  }
583
- });
584
- } else {
585
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [react-profiler] ").concat(type), {
586
- start: startTime,
587
- duration: actualDuration
588
- });
589
- }
627
+ }
628
+ });
590
629
  } catch (e) {
591
630
  // do nothing
592
631
  }
@@ -618,38 +657,30 @@ function callCleanUpCallbacks(interaction) {
618
657
  });
619
658
  }
620
659
  function finishInteraction(id, data) {
621
- var _getConfig4, _getConfig5;
660
+ var _getConfig4;
622
661
  var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : performance.now();
623
662
  data.end = endTime;
624
663
  try {
625
664
  // for Firefox 102 and older
626
-
627
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
628
- performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
629
- start: data.start,
630
- end: data.end,
631
- detail: {
632
- devtools: {
633
- track: 'main metrics',
634
- trackGroup: '🛸 reactUFO metrics',
635
- color: 'tertiary'
636
- }
665
+ performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
666
+ start: data.start,
667
+ end: data.end,
668
+ detail: {
669
+ devtools: {
670
+ track: 'main metrics',
671
+ trackGroup: '🛸 reactUFO metrics',
672
+ color: 'tertiary'
637
673
  }
638
- });
639
- performance.mark("TTAI", {
640
- startTime: data.end,
641
- detail: {
642
- devtools: {
643
- dataType: 'marker'
644
- }
674
+ }
675
+ });
676
+ performance.mark("TTAI", {
677
+ startTime: data.end,
678
+ detail: {
679
+ devtools: {
680
+ dataType: 'marker'
645
681
  }
646
- });
647
- } else {
648
- performance.measure("\uD83D\uDEF8 [".concat(data.type, "] ").concat(data.ufoName, " [ttai]"), {
649
- start: data.start,
650
- end: data.end
651
- });
652
- }
682
+ }
683
+ });
653
684
  } catch (e) {
654
685
  // do nothing
655
686
  }
@@ -668,23 +699,35 @@ function finishInteraction(id, data) {
668
699
  data.hydration = (0, _config.getReactHydrationStats)();
669
700
 
670
701
  // By this time, stop the post interaction log observer if coinflip rate is 0
671
- if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_check_name')) {
672
- var sanitisedUfoName = (0, _utils.sanitizeUfoName)(data.ufoName);
673
- if (!(0, _coinflip.default)((0, _config.getPostInteractionRate)(sanitisedUfoName, data.type))) {
674
- postInteractionLog.stopVCObserver();
702
+ var sanitisedUfoName = (0, _utils.sanitizeUfoName)(data.ufoName);
703
+ if (!(0, _coinflip.default)((0, _config.getPostInteractionRate)(sanitisedUfoName, data.type))) {
704
+ postInteractionLog.stopVCObserver();
705
+ }
706
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
707
+ if (!data.hold3pActive || data.hold3pActive.size === 0) {
708
+ var _getConfig5;
709
+ if (!((_getConfig5 = (0, _config.getConfig)()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
710
+ remove(id);
711
+ }
712
+ interactionExtraMetrics.stopVCObserver();
675
713
  }
676
714
  } else {
677
- if (!(0, _coinflip.default)((0, _config.getPostInteractionRate)(data.routeName || data.ufoName, data.type))) {
678
- postInteractionLog.stopVCObserver();
715
+ var _getConfig6;
716
+ if (!((_getConfig6 = (0, _config.getConfig)()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.experimentalInteractionMetrics) !== null && _getConfig6 !== void 0 && _getConfig6.enabled)) {
717
+ remove(id);
679
718
  }
680
719
  }
681
- if (!((_getConfig5 = (0, _config.getConfig)()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
682
- remove(id);
683
- }
684
720
  PreviousInteractionLog.name = data.ufoName || 'unknown';
685
721
  PreviousInteractionLog.isAborted = data.abortReason != null;
686
722
  if (data.ufoName) {
687
- handleInteraction(id, data);
723
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
724
+ if (interactionExtraMetrics.finishedInteractionId !== id) {
725
+ // If this same interaction was not already handled, handle it
726
+ handleInteraction(id, data);
727
+ }
728
+ } else {
729
+ handleInteraction(id, data);
730
+ }
688
731
  }
689
732
  if (isPerformanceTracingEnabled()) {
690
733
  var profilerTimingMap = new Map();
@@ -711,23 +754,16 @@ function finishInteraction(id, data) {
711
754
  labelStack = _step3$value$.labelStack,
712
755
  start = _step3$value$.start,
713
756
  end = _step3$value$.end;
714
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
715
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [segment_ttai]"), {
716
- start: start,
717
- end: end,
718
- detail: {
719
- devtools: {
720
- track: '🛸 reactUFO detailed timings',
721
- color: 'secondary-dark'
722
- }
757
+ performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [segment_ttai]"), {
758
+ start: start,
759
+ end: end,
760
+ detail: {
761
+ devtools: {
762
+ track: '🛸 reactUFO detailed timings',
763
+ color: 'secondary-dark'
723
764
  }
724
- });
725
- } else {
726
- performance.measure("\uD83D\uDEF8 ".concat(labelStackToString(labelStack), " [segment_ttai]"), {
727
- start: start,
728
- end: end
729
- });
730
- }
765
+ }
766
+ });
731
767
  }
732
768
  } catch (err) {
733
769
  _iterator3.e(err);
@@ -769,16 +805,16 @@ function tryComplete(interactionId, endTime) {
769
805
  var noMoreExpHolds = interaction.holdExpActive.size === 0;
770
806
  var postInteraction = /*#__PURE__*/function () {
771
807
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
772
- var _getConfig6, _getConfig8;
773
- var _getConfig7, experimentalVC90, experimentalTTAI, _yield$getExperimenta, start, end;
808
+ var _getConfig7;
809
+ var _getConfig8, experimentalVC90, experimentalTTAI, _yield$getExperimenta, start, end, _getConfig9, _getConfig0;
774
810
  return _regenerator.default.wrap(function _callee$(_context) {
775
811
  while (1) switch (_context.prev = _context.next) {
776
812
  case 0:
777
- if (!((_getConfig6 = (0, _config.getConfig)()) !== null && _getConfig6 !== void 0 && (_getConfig6 = _getConfig6.postInteractionLog) !== null && _getConfig6 !== void 0 && _getConfig6.enabled)) {
813
+ if (!((_getConfig7 = (0, _config.getConfig)()) !== null && _getConfig7 !== void 0 && (_getConfig7 = _getConfig7.postInteractionLog) !== null && _getConfig7 !== void 0 && _getConfig7.enabled)) {
778
814
  _context.next = 17;
779
815
  break;
780
816
  }
781
- if (!((_getConfig7 = (0, _config.getConfig)()) !== null && _getConfig7 !== void 0 && (_getConfig7 = _getConfig7.experimentalInteractionMetrics) !== null && _getConfig7 !== void 0 && _getConfig7.enabled)) {
817
+ if (!((_getConfig8 = (0, _config.getConfig)()) !== null && _getConfig8 !== void 0 && (_getConfig8 = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8 !== void 0 && _getConfig8.enabled)) {
782
818
  _context.next = 16;
783
819
  break;
784
820
  }
@@ -812,8 +848,17 @@ function tryComplete(interactionId, endTime) {
812
848
  experimentalVC90: experimentalVC90
813
849
  }));
814
850
  case 17:
815
- if ((_getConfig8 = (0, _config.getConfig)()) !== null && _getConfig8 !== void 0 && (_getConfig8 = _getConfig8.experimentalInteractionMetrics) !== null && _getConfig8 !== void 0 && _getConfig8.enabled) {
816
- remove(interactionId);
851
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
852
+ if (interactionExtraMetrics.finishedInteractionId !== interactionId) {
853
+ // If interactionExtraMetrics is not waiting for measuring this interaction
854
+ if ((_getConfig9 = (0, _config.getConfig)()) !== null && _getConfig9 !== void 0 && (_getConfig9 = _getConfig9.experimentalInteractionMetrics) !== null && _getConfig9 !== void 0 && _getConfig9.enabled) {
855
+ remove(interactionId);
856
+ }
857
+ }
858
+ } else {
859
+ if ((_getConfig0 = (0, _config.getConfig)()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.experimentalInteractionMetrics) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
860
+ remove(interactionId);
861
+ }
817
862
  }
818
863
  activeSubmitted = false;
819
864
  case 19:
@@ -826,17 +871,42 @@ function tryComplete(interactionId, endTime) {
826
871
  return _ref.apply(this, arguments);
827
872
  };
828
873
  }();
829
- if (noMoreActiveHolds) {
830
- if (!activeSubmitted) {
831
- finishInteraction(interactionId, interaction, endTime);
832
- activeSubmitted = true;
874
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
875
+ var _interaction$hold3pAc;
876
+ var noMoreActive3pHolds = ((_interaction$hold3pAc = interaction.hold3pActive) === null || _interaction$hold3pAc === void 0 ? void 0 : _interaction$hold3pAc.size) === 0 || interaction.hold3pActive === undefined;
877
+ if (noMoreActiveHolds) {
878
+ if (!activeSubmitted) {
879
+ finishInteraction(interactionId, interaction, endTime);
880
+ interactionExtraMetrics.updateFinishedInteractionId(interactionId);
881
+ activeSubmitted = true;
882
+ }
883
+ if (noMoreExpHolds) {
884
+ var _getConfig1;
885
+ if ((_getConfig1 = (0, _config.getConfig)()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
886
+ (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction, endTime);
887
+ }
888
+ postInteraction();
889
+ }
890
+ if (noMoreActive3pHolds) {
891
+ var data = _objectSpread(_objectSpread({}, interaction), {}, {
892
+ end: endTime
893
+ });
894
+ interactionExtraMetrics.onInteractionComplete(interactionId, data);
895
+ }
833
896
  }
834
- if (noMoreExpHolds) {
835
- var _getConfig9;
836
- if ((_getConfig9 = (0, _config.getConfig)()) !== null && _getConfig9 !== void 0 && (_getConfig9 = _getConfig9.experimentalInteractionMetrics) !== null && _getConfig9 !== void 0 && _getConfig9.enabled) {
837
- (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction, endTime);
897
+ } else {
898
+ if (noMoreActiveHolds) {
899
+ if (!activeSubmitted) {
900
+ finishInteraction(interactionId, interaction, endTime);
901
+ activeSubmitted = true;
902
+ }
903
+ if (noMoreExpHolds) {
904
+ var _getConfig10;
905
+ if ((_getConfig10 = (0, _config.getConfig)()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
906
+ (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction, endTime);
907
+ }
908
+ postInteraction();
838
909
  }
839
- postInteraction();
840
910
  }
841
911
  }
842
912
  }
@@ -864,6 +934,11 @@ function abort(interactionId, abortReason) {
864
934
  finishInteraction(interactionId, interaction);
865
935
  postInteractionLog.reset();
866
936
  postInteractionLog.stopVCObserver();
937
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
938
+ interactionExtraMetrics.stopVCObserver();
939
+ interactionExtraMetrics.reset();
940
+ remove(interactionId);
941
+ }
867
942
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
868
943
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
869
944
  remove(interactionId);
@@ -889,6 +964,11 @@ function abortByNewInteraction(interactionId, interactionName) {
889
964
  finishInteraction(interactionId, interaction);
890
965
  postInteractionLog.reset();
891
966
  postInteractionLog.stopVCObserver();
967
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
968
+ interactionExtraMetrics.stopVCObserver();
969
+ interactionExtraMetrics.reset();
970
+ remove(interactionId);
971
+ }
892
972
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
893
973
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
894
974
  remove(interactionId);
@@ -918,6 +998,11 @@ function abortAll(abortReason, abortedByInteractionName) {
918
998
  finishInteraction(interactionId, interaction);
919
999
  postInteractionLog.reset();
920
1000
  postInteractionLog.stopVCObserver();
1001
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
1002
+ interactionExtraMetrics.stopVCObserver();
1003
+ interactionExtraMetrics.reset();
1004
+ remove(interactionId);
1005
+ }
921
1006
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
922
1007
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
923
1008
  remove(interactionId);
@@ -930,13 +1015,7 @@ function addOnCancelCallback(id, cancelCallback) {
930
1015
  }
931
1016
  function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelStack, routeName) {
932
1017
  var trace = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
933
- if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_check_name')) {
934
- postInteractionLog.reset();
935
- } else {
936
- if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
937
- postInteractionLog.reset();
938
- }
939
- }
1018
+ postInteractionLog.reset();
940
1019
  var vcObserver;
941
1020
  var previousTime = startTime;
942
1021
  var timeoutTime = (0, _platformFeatureFlags.fg)('platform_ufo_enable_timeout_config') ? (0, _config.getInteractionTimeout)(ufoName) : CLEANUP_TIMEOUT;
@@ -1015,7 +1094,9 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
1015
1094
  timerID: timerID,
1016
1095
  changeTimeout: changeTimeout,
1017
1096
  trace: trace,
1018
- vcObserver: vcObserver
1097
+ vcObserver: vcObserver,
1098
+ hold3pActive: new Map(),
1099
+ hold3pInfo: []
1019
1100
  };
1020
1101
  if (addFeatureFlagsToInteraction) {
1021
1102
  _featureFlagsAccessed.currentFeatureFlagsAccessed.clear();
@@ -1045,6 +1126,7 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
1045
1126
  addHoldByID(interactionId, [], ufoName, ufoName, true);
1046
1127
  }
1047
1128
  if (type === 'transition' || type === 'page_load') {
1129
+ var _getConfig11;
1048
1130
  // Use per-interaction VC observer if available, otherwise fall back to global
1049
1131
  var observer = vcObserver;
1050
1132
  if (observer) {
@@ -1053,27 +1135,23 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
1053
1135
  experienceKey: ufoName
1054
1136
  });
1055
1137
  }
1056
- if ((0, _platformFeatureFlags.fg)('platform_ufo_post_interaction_check_name')) {
1057
- var _getConfig0;
1058
- // Start post interaction observer for all if config is enabled
1059
- // in case ufoName is updated at later time
1060
- if ((_getConfig0 = (0, _config.getConfig)()) !== null && _getConfig0 !== void 0 && (_getConfig0 = _getConfig0.postInteractionLog) !== null && _getConfig0 !== void 0 && _getConfig0.enabled) {
1061
- postInteractionLog.startVCObserver({
1062
- startTime: startTime
1063
- });
1064
- }
1065
- } else {
1066
- if ((0, _coinflip.default)((0, _config.getPostInteractionRate)(routeName || ufoName, type))) {
1067
- postInteractionLog.startVCObserver({
1068
- startTime: startTime
1069
- });
1070
- }
1138
+ // Start post interaction observer for all if config is enabled
1139
+ // in case ufoName is updated at later time
1140
+ if ((_getConfig11 = (0, _config.getConfig)()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
1141
+ postInteractionLog.startVCObserver({
1142
+ startTime: startTime
1143
+ });
1071
1144
  }
1072
1145
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(ufoName, type))) {
1073
1146
  _createExperimentalInteractionMetricsPayload.experimentalVC.start({
1074
1147
  startTime: startTime
1075
1148
  });
1076
1149
  }
1150
+ if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
1151
+ interactionExtraMetrics.startVCObserver({
1152
+ startTime: startTime
1153
+ }, interactionId);
1154
+ }
1077
1155
  }
1078
1156
  if (type === 'press' && (0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_press_interactions')) {
1079
1157
  // Use per-interaction VC observer if available, otherwise fall back to global
@@ -1101,35 +1179,27 @@ function addApdexToAll(apdex) {
1101
1179
  _constants.interactions.forEach(function (interaction, key) {
1102
1180
  interaction.apdex.push(apdex);
1103
1181
  try {
1182
+ var _apdex$startTime;
1104
1183
  // for Firefox 102 and older
1105
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
1106
- var _apdex$startTime;
1107
- performance.measure("\uD83D\uDEF8 ".concat(apdex.key, " [bm3_tti]"), {
1108
- start: (_apdex$startTime = apdex.startTime) !== null && _apdex$startTime !== void 0 ? _apdex$startTime : interaction.start,
1109
- end: apdex.stopTime,
1110
- detail: {
1111
- devtools: {
1112
- track: 'main metrics',
1113
- trackGroup: '🛸 reactUFO metrics',
1114
- color: 'primary-dark'
1115
- }
1184
+ performance.measure("\uD83D\uDEF8 ".concat(apdex.key, " [bm3_tti]"), {
1185
+ start: (_apdex$startTime = apdex.startTime) !== null && _apdex$startTime !== void 0 ? _apdex$startTime : interaction.start,
1186
+ end: apdex.stopTime,
1187
+ detail: {
1188
+ devtools: {
1189
+ track: 'main metrics',
1190
+ trackGroup: '🛸 reactUFO metrics',
1191
+ color: 'primary-dark'
1116
1192
  }
1117
- });
1118
- performance.mark("[bm3] TTI", {
1119
- startTime: apdex.stopTime,
1120
- detail: {
1121
- devtools: {
1122
- dataType: 'marker'
1123
- }
1193
+ }
1194
+ });
1195
+ performance.mark("[bm3] TTI", {
1196
+ startTime: apdex.stopTime,
1197
+ detail: {
1198
+ devtools: {
1199
+ dataType: 'marker'
1124
1200
  }
1125
- });
1126
- } else {
1127
- var _apdex$startTime2;
1128
- performance.measure("\uD83D\uDEF8 ".concat(apdex.key, " [bm3_tti]"), {
1129
- start: (_apdex$startTime2 = apdex.startTime) !== null && _apdex$startTime2 !== void 0 ? _apdex$startTime2 : interaction.start,
1130
- end: apdex.stopTime
1131
- });
1132
- }
1201
+ }
1202
+ });
1133
1203
  } catch (e) {
1134
1204
  // do nothing
1135
1205
  }
@@ -1143,35 +1213,27 @@ function addApdex(interactionId, apdexInfo) {
1143
1213
  if (interaction != null) {
1144
1214
  interaction.apdex.push(apdexInfo);
1145
1215
  try {
1216
+ var _apdexInfo$startTime;
1146
1217
  // for Firefox 102 and older
1147
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
1148
- var _apdexInfo$startTime;
1149
- performance.measure("\uD83D\uDEF8 ".concat(apdexInfo.key, " [bm3_tti]"), {
1150
- start: (_apdexInfo$startTime = apdexInfo.startTime) !== null && _apdexInfo$startTime !== void 0 ? _apdexInfo$startTime : interaction.start,
1151
- end: apdexInfo.stopTime,
1152
- detail: {
1153
- devtools: {
1154
- track: 'main metrics',
1155
- trackGroup: '🛸 reactUFO metrics',
1156
- color: 'primary-dark'
1157
- }
1218
+ performance.measure("\uD83D\uDEF8 ".concat(apdexInfo.key, " [bm3_tti]"), {
1219
+ start: (_apdexInfo$startTime = apdexInfo.startTime) !== null && _apdexInfo$startTime !== void 0 ? _apdexInfo$startTime : interaction.start,
1220
+ end: apdexInfo.stopTime,
1221
+ detail: {
1222
+ devtools: {
1223
+ track: 'main metrics',
1224
+ trackGroup: '🛸 reactUFO metrics',
1225
+ color: 'primary-dark'
1158
1226
  }
1159
- });
1160
- performance.mark("[bm3] TTI", {
1161
- startTime: apdexInfo.stopTime,
1162
- detail: {
1163
- devtools: {
1164
- dataType: 'marker'
1165
- }
1227
+ }
1228
+ });
1229
+ performance.mark("[bm3] TTI", {
1230
+ startTime: apdexInfo.stopTime,
1231
+ detail: {
1232
+ devtools: {
1233
+ dataType: 'marker'
1166
1234
  }
1167
- });
1168
- } else {
1169
- var _apdexInfo$startTime2;
1170
- performance.measure("\uD83D\uDEF8 ".concat(apdexInfo.key, " [bm3_tti]"), {
1171
- start: (_apdexInfo$startTime2 = apdexInfo.startTime) !== null && _apdexInfo$startTime2 !== void 0 ? _apdexInfo$startTime2 : interaction.start,
1172
- end: apdexInfo.stopTime
1173
- });
1174
- }
1235
+ }
1236
+ });
1175
1237
  } catch (e) {
1176
1238
  // do nothing
1177
1239
  }
@@ -1238,26 +1300,18 @@ function addRedirect(interactionId, fromUfoName, nextUfoName, nextRouteName, tim
1238
1300
  if (isPerformanceTracingEnabled()) {
1239
1301
  var prevRedirect = interaction.redirects.at(-2);
1240
1302
  try {
1303
+ var _prevRedirect$time;
1241
1304
  // for Firefox 102 and older
1242
- if ((0, _platformFeatureFlags.fg)('ufo_chrome_devtools_uplift')) {
1243
- var _prevRedirect$time;
1244
- performance.measure("\uD83D\uDEF8 ".concat(nextUfoName, " [redirect]"), {
1245
- start: (_prevRedirect$time = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time !== void 0 ? _prevRedirect$time : interaction.start,
1246
- end: time,
1247
- detail: {
1248
- devtools: {
1249
- track: '🛸 reactUFO detailed timings',
1250
- color: 'tertiary'
1251
- }
1305
+ performance.measure("\uD83D\uDEF8 ".concat(nextUfoName, " [redirect]"), {
1306
+ start: (_prevRedirect$time = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time !== void 0 ? _prevRedirect$time : interaction.start,
1307
+ end: time,
1308
+ detail: {
1309
+ devtools: {
1310
+ track: '🛸 reactUFO detailed timings',
1311
+ color: 'tertiary'
1252
1312
  }
1253
- });
1254
- } else {
1255
- var _prevRedirect$time2;
1256
- performance.measure("\uD83D\uDEF8 ".concat(nextUfoName, " [redirect]"), {
1257
- start: (_prevRedirect$time2 = prevRedirect === null || prevRedirect === void 0 ? void 0 : prevRedirect.time) !== null && _prevRedirect$time2 !== void 0 ? _prevRedirect$time2 : interaction.start,
1258
- end: time
1259
- });
1260
- }
1313
+ }
1314
+ });
1261
1315
  } catch (e) {
1262
1316
  // do nothing
1263
1317
  }