@atlaskit/react-ufo 4.4.6 → 4.5.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/create-interaction-extra-metrics-payload/index.js +30 -25
  3. package/dist/cjs/create-payload/index.js +1 -0
  4. package/dist/cjs/create-payload/utils/get-vc-metrics.js +4 -1
  5. package/dist/cjs/interaction-metrics/index.js +29 -35
  6. package/dist/cjs/interaction-metrics/interaction-extra-metrics.js +7 -0
  7. package/dist/cjs/interaction-metrics-init/index.js +7 -10
  8. package/dist/cjs/vc/vc-observer-new/metric-calculator/fy25_03/index.js +7 -2
  9. package/dist/es2019/create-interaction-extra-metrics-payload/index.js +14 -15
  10. package/dist/es2019/create-payload/index.js +1 -1
  11. package/dist/es2019/create-payload/utils/get-vc-metrics.js +4 -1
  12. package/dist/es2019/interaction-metrics/index.js +30 -36
  13. package/dist/es2019/interaction-metrics/interaction-extra-metrics.js +5 -0
  14. package/dist/es2019/interaction-metrics-init/index.js +7 -10
  15. package/dist/es2019/vc/vc-observer-new/metric-calculator/fy25_03/index.js +6 -1
  16. package/dist/esm/create-interaction-extra-metrics-payload/index.js +32 -27
  17. package/dist/esm/create-payload/index.js +1 -1
  18. package/dist/esm/create-payload/utils/get-vc-metrics.js +4 -1
  19. package/dist/esm/interaction-metrics/index.js +29 -35
  20. package/dist/esm/interaction-metrics/interaction-extra-metrics.js +7 -0
  21. package/dist/esm/interaction-metrics-init/index.js +7 -10
  22. package/dist/esm/vc/vc-observer-new/metric-calculator/fy25_03/index.js +6 -1
  23. package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +3 -4
  24. package/dist/types/create-payload/index.d.ts +2 -0
  25. package/dist/types/interaction-metrics/interaction-extra-metrics.d.ts +1 -0
  26. package/dist/types/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -0
  27. package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +3 -4
  28. package/dist/types-ts4.5/create-payload/index.d.ts +2 -0
  29. package/dist/types-ts4.5/interaction-metrics/interaction-extra-metrics.d.ts +1 -0
  30. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/fy25_03/index.d.ts +1 -0
  31. package/package.json +4 -1
@@ -622,15 +622,14 @@ function finishInteraction(id, data, endTime = performance.now()) {
622
622
  postInteractionLog.stopVCObserver();
623
623
  }
624
624
  if (fg('platform_ufo_enable_ttai_with_3p')) {
625
- if (!data.hold3pActive || data.hold3pActive.size === 0) {
625
+ const sanitisedUfoName = sanitizeUfoName(data.ufoName);
626
+ if (!coinflip(getExtraInteractionRate(sanitisedUfoName, data.type))) {
627
+ interactionExtraMetrics.stopAll(id);
628
+ } else if (!data.hold3pActive || data.hold3pActive.size === 0) {
626
629
  var _getConfig5, _getConfig5$experimen;
627
630
  if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$experimen = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5$experimen !== void 0 && _getConfig5$experimen.enabled)) {
628
631
  remove(id);
629
632
  }
630
- const sanitisedUfoName = sanitizeUfoName(data.ufoName);
631
- if (!coinflip(getExtraInteractionRate(sanitisedUfoName, data.type))) {
632
- interactionExtraMetrics.stopVCObserver();
633
- }
634
633
  }
635
634
  } else {
636
635
  var _getConfig6, _getConfig6$experimen;
@@ -755,26 +754,30 @@ export function tryComplete(interactionId, endTime) {
755
754
  if (fg('platform_ufo_enable_ttai_with_3p')) {
756
755
  var _interaction$hold3pAc;
757
756
  const noMoreActive3pHolds = ((_interaction$hold3pAc = interaction.hold3pActive) === null || _interaction$hold3pAc === void 0 ? void 0 : _interaction$hold3pAc.size) === 0 || interaction.hold3pActive === undefined;
758
- if (noMoreActiveHolds) {
757
+ if (noMoreActiveHolds && interactionExtraMetrics.finishedInteractionId !== interactionId) {
758
+ // If it's not waiting for extra metrics to complete, finish the interaction as normal
759
759
  if (!activeSubmitted) {
760
+ var _getConfig1, _getConfig1$extraInte;
760
761
  finishInteraction(interactionId, interaction, endTime);
761
- interactionExtraMetrics.updateFinishedInteractionId(interactionId);
762
+ if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1$extraInte = _getConfig1.extraInteractionMetrics) !== null && _getConfig1$extraInte !== void 0 && _getConfig1$extraInte.enabled) {
763
+ interactionExtraMetrics.updateFinishedInteractionId(interactionId);
764
+ }
762
765
  activeSubmitted = true;
763
766
  }
764
767
  if (noMoreExpHolds) {
765
- var _getConfig1, _getConfig1$experimen;
766
- if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1$experimen = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1$experimen !== void 0 && _getConfig1$experimen.enabled) {
768
+ var _getConfig10, _getConfig10$experime;
769
+ if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10$experime = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10$experime !== void 0 && _getConfig10$experime.enabled) {
767
770
  onExperimentalInteractionComplete(interactionId, interaction, endTime);
768
771
  }
769
772
  postInteraction();
770
773
  }
771
- if (noMoreActive3pHolds) {
772
- const data = {
773
- ...interaction,
774
- end: endTime
775
- };
776
- interactionExtraMetrics.onInteractionComplete(interactionId, data);
777
- }
774
+ }
775
+ if (noMoreActiveHolds && noMoreActive3pHolds) {
776
+ const data = {
777
+ ...interaction,
778
+ end: endTime
779
+ };
780
+ interactionExtraMetrics.onInteractionComplete(interactionId, data);
778
781
  }
779
782
  } else {
780
783
  if (noMoreActiveHolds) {
@@ -783,8 +786,8 @@ export function tryComplete(interactionId, endTime) {
783
786
  activeSubmitted = true;
784
787
  }
785
788
  if (noMoreExpHolds) {
786
- var _getConfig10, _getConfig10$experime;
787
- if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10$experime = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10$experime !== void 0 && _getConfig10$experime.enabled) {
789
+ var _getConfig11, _getConfig11$experime;
790
+ if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11$experime = _getConfig11.experimentalInteractionMetrics) !== null && _getConfig11$experime !== void 0 && _getConfig11$experime.enabled) {
788
791
  onExperimentalInteractionComplete(interactionId, interaction, endTime);
789
792
  }
790
793
  postInteraction();
@@ -817,9 +820,7 @@ export function abort(interactionId, abortReason) {
817
820
  postInteractionLog.reset();
818
821
  postInteractionLog.stopVCObserver();
819
822
  if (fg('platform_ufo_enable_ttai_with_3p')) {
820
- interactionExtraMetrics.stopVCObserver();
821
- interactionExtraMetrics.reset();
822
- remove(interactionId);
823
+ interactionExtraMetrics.stopAll(interactionId);
823
824
  }
824
825
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
825
826
  onExperimentalInteractionComplete(interactionId, interaction);
@@ -847,9 +848,7 @@ export function abortByNewInteraction(interactionId, interactionName) {
847
848
  postInteractionLog.reset();
848
849
  postInteractionLog.stopVCObserver();
849
850
  if (fg('platform_ufo_enable_ttai_with_3p')) {
850
- interactionExtraMetrics.stopVCObserver();
851
- interactionExtraMetrics.reset();
852
- remove(interactionId);
851
+ interactionExtraMetrics.stopAll(interactionId);
853
852
  }
854
853
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
855
854
  onExperimentalInteractionComplete(interactionId, interaction);
@@ -881,9 +880,7 @@ export function abortAll(abortReason, abortedByInteractionName) {
881
880
  postInteractionLog.reset();
882
881
  postInteractionLog.stopVCObserver();
883
882
  if (fg('platform_ufo_enable_ttai_with_3p')) {
884
- interactionExtraMetrics.stopVCObserver();
885
- interactionExtraMetrics.reset();
886
- remove(interactionId);
883
+ interactionExtraMetrics.stopAll(interactionId);
887
884
  }
888
885
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
889
886
  onExperimentalInteractionComplete(interactionId, interaction);
@@ -1007,7 +1004,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1007
1004
  addHoldByID(interactionId, [], ufoName, ufoName, true);
1008
1005
  }
1009
1006
  if (type === 'transition' || type === 'page_load') {
1010
- var _getConfig11, _getConfig11$postInte;
1007
+ var _getConfig12, _getConfig12$postInte, _config$extraInteract;
1011
1008
  // Use per-interaction VC observer if available, otherwise fall back to global
1012
1009
  const observer = vcObserver;
1013
1010
  if (observer) {
@@ -1018,7 +1015,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1018
1015
  }
1019
1016
  // Start post interaction observer for all if config is enabled
1020
1017
  // in case ufoName is updated at later time
1021
- if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11$postInte = _getConfig11.postInteractionLog) !== null && _getConfig11$postInte !== void 0 && _getConfig11$postInte.enabled) {
1018
+ if ((_getConfig12 = getConfig()) !== null && _getConfig12 !== void 0 && (_getConfig12$postInte = _getConfig12.postInteractionLog) !== null && _getConfig12$postInte !== void 0 && _getConfig12$postInte.enabled) {
1022
1019
  postInteractionLog.startVCObserver({
1023
1020
  startTime
1024
1021
  });
@@ -1028,13 +1025,10 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1028
1025
  startTime
1029
1026
  });
1030
1027
  }
1031
- if (fg('platform_ufo_enable_ttai_with_3p')) {
1032
- var _config$extraInteract;
1033
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
1034
- interactionExtraMetrics.startVCObserver({
1035
- startTime
1036
- }, interactionId);
1037
- }
1028
+ if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
1029
+ interactionExtraMetrics.startVCObserver({
1030
+ startTime
1031
+ }, interactionId);
1038
1032
  }
1039
1033
  }
1040
1034
  if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
@@ -60,4 +60,9 @@ export default class InteractionExtraMetrics {
60
60
  reset() {
61
61
  this.finishedInteractionId = null;
62
62
  }
63
+ stopAll(id) {
64
+ this.stopVCObserver();
65
+ remove(id);
66
+ this.reset();
67
+ }
63
68
  }
@@ -97,7 +97,7 @@ export function init(analyticsWebClientAsync, config) {
97
97
  initialiseMemoryObserver();
98
98
  setUFOConfig(config);
99
99
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
100
- var _config$experimentalI;
100
+ var _config$experimentalI, _config$extraInteract;
101
101
  const vcOptions = {
102
102
  heatmapSize: config.vc.heatmapSize,
103
103
  oldDomUpdates: config.vc.oldDomUpdates,
@@ -111,11 +111,8 @@ export function init(analyticsWebClientAsync, config) {
111
111
  startTime: 0
112
112
  });
113
113
  }
114
- if (fg('platform_ufo_enable_ttai_with_3p')) {
115
- var _config$extraInteract;
116
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
117
- interactionExtraMetrics.initializeVCObserver(vcOptions);
118
- }
114
+ if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
115
+ interactionExtraMetrics.initializeVCObserver(vcOptions);
119
116
  }
120
117
  }
121
118
  setupHiddenTimingCapture();
@@ -132,7 +129,7 @@ export function init(analyticsWebClientAsync, config) {
132
129
  Promise.all([analyticsWebClientAsync, import( /* webpackChunkName: "create-payloads" */'../create-payload'), import( /* webpackChunkName: "create-post-interaction-log-payload" */'../create-post-interaction-log-payload'), import( /* webpackChunkName: "create-interaction-extra-metrics-payload" */'../create-interaction-extra-metrics-payload')]).then(([awc, payloadPackage, createPostInteractionLogPayloadPackage, createInteractionExtraMetricsPayloadPackage]) => {
133
130
  if (awc.getAnalyticsWebClientPromise) {
134
131
  awc.getAnalyticsWebClientPromise().then(client => {
135
- var _config$experimentalI2, _config$postInteracti;
132
+ var _config$experimentalI2, _config$postInteracti, _config$extraInteract2;
136
133
  const instance = client.getInstance();
137
134
  sinkInteraction(instance, payloadPackage);
138
135
  if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
@@ -141,12 +138,12 @@ export function init(analyticsWebClientAsync, config) {
141
138
  if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
142
139
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
143
140
  }
144
- if (fg('platform_ufo_enable_ttai_with_3p')) {
141
+ if (config !== null && config !== void 0 && (_config$extraInteract2 = config.extraInteractionMetrics) !== null && _config$extraInteract2 !== void 0 && _config$extraInteract2.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
145
142
  sinkInteractionExtraMetrics(instance, createInteractionExtraMetricsPayloadPackage.default);
146
143
  }
147
144
  });
148
145
  } else if (awc.sendOperationalEvent) {
149
- var _config$experimentalI3, _config$postInteracti2;
146
+ var _config$experimentalI3, _config$postInteracti2, _config$extraInteract3;
150
147
  sinkInteraction(awc, payloadPackage);
151
148
  if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
152
149
  sinkExperimentalInteractionMetrics(awc, payloadPackage);
@@ -154,7 +151,7 @@ export function init(analyticsWebClientAsync, config) {
154
151
  if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
155
152
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
156
153
  }
157
- if (fg('platform_ufo_enable_ttai_with_3p')) {
154
+ if (config !== null && config !== void 0 && (_config$extraInteract3 = config.extraInteractionMetrics) !== null && _config$extraInteract3 !== void 0 && _config$extraInteract3.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
158
155
  sinkInteractionExtraMetrics(awc, createInteractionExtraMetricsPayloadPackage.default);
159
156
  }
160
157
  }
@@ -24,6 +24,11 @@ export const KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS = ['data-drop-ta
24
24
 
25
25
  // Common aria attributes that don't cause visual layout shifts
26
26
  export const NON_VISUAL_ARIA_ATTRIBUTES = ['aria-label', 'aria-labelledby', 'aria-describedby', 'aria-hidden', 'aria-expanded', 'aria-controls', 'aria-selected', 'aria-checked', 'aria-disabled', 'aria-required', 'aria-current', 'aria-haspopup', 'aria-pressed', 'aria-atomic', 'aria-live'];
27
+
28
+ // Common third party browser extension attributes
29
+ export const THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES = ['bis_skin_checked', 'cz-shortcut-listen', 'monica-version', 'data-gr-ext-installed', 'data-dashlane-rid', 'sapling-installed', 'data-gptw',
30
+ // grammarly extensions
31
+ 'data-new-gr-c-s-loaded', 'data-gr-aaa-notch-connection-id', 'data-gr-aaa-loaded'];
27
32
  export default class VCCalculator_FY25_03 extends AbstractVCCalculatorBase {
28
33
  constructor() {
29
34
  super(REVISION_NO);
@@ -38,7 +43,7 @@ export default class VCCalculator_FY25_03 extends AbstractVCCalculatorBase {
38
43
  if (!attributeName || KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS.includes(attributeName)) {
39
44
  return false;
40
45
  }
41
- if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || attributeName === 'data-new-gr-c-c-s-loaded' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName)) {
46
+ if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && fg('platform_ufo_exclude_3p_extensions_from_ttvc')) {
42
47
  return false;
43
48
  }
44
49
  return true;
@@ -1,9 +1,13 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
+ 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; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import { fg } from '@atlaskit/platform-feature-flags';
3
7
  import coinflip from '../coinflip';
4
8
  import { getConfig, getExtraInteractionRate } from '../config';
5
- import { getMoreAccuratePageVisibilityUpToTTAI } from '../create-payload';
6
- import { sanitizeUfoName } from '../create-payload/common/utils';
9
+ import { getMoreAccuratePageVisibilityUpToTTAI, optimizeHoldInfo } from '../create-payload';
10
+ import { buildSegmentTree, getOldSegmentsLabelStack, sanitizeUfoName } from '../create-payload/common/utils';
7
11
  import getPageVisibilityUpToTTAI from '../create-payload/utils/get-page-visibility-up-to-ttai';
8
12
  import getPayloadSize from '../create-payload/utils/get-payload-size';
9
13
  import { getReactUFOPayloadVersion } from '../create-payload/utils/get-react-ufo-payload-version';
@@ -14,8 +18,8 @@ function createInteractionExtraLogPayload(_x, _x2) {
14
18
  }
15
19
  function _createInteractionExtraLogPayload() {
16
20
  _createInteractionExtraLogPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interactionId, interaction) {
17
- var _getTTAI, _finalVCMetrics$ufoV, _window$location;
18
- var config, end, start, ufoName, rate, type, abortReason, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, configRate, pageVisibilityAtTTAI, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTAI, extraTTAI, newUFOName, finalVCMetrics, ttvc, payload;
21
+ var _getTTAI, _interaction$hold3pIn, _window$location;
22
+ var config, end, start, ufoName, rate, type, abortReason, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, knownSegments, sanitisedUfoName, configRate, pageVisibilityAtTTAI, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTAI, extraTTAI, newUFOName, finalVCMetrics, holdInfo, segments3p, segmentTree, payload;
19
23
  return _regeneratorRuntime.wrap(function _callee$(_context) {
20
24
  while (1) switch (_context.prev = _context.next) {
21
25
  case 0:
@@ -26,41 +30,40 @@ function _createInteractionExtraLogPayload() {
26
30
  }
27
31
  throw Error('UFO Configuration not provided');
28
32
  case 3:
29
- end = interaction.end, start = interaction.start, ufoName = interaction.ufoName, rate = interaction.rate, type = interaction.type, abortReason = interaction.abortReason, routeName = interaction.routeName, previousInteractionName = interaction.previousInteractionName, isPreviousInteractionAborted = interaction.isPreviousInteractionAborted, abortedByInteractionName = interaction.abortedByInteractionName;
30
- configRate = getExtraInteractionRate(ufoName, type);
33
+ end = interaction.end, start = interaction.start, ufoName = interaction.ufoName, rate = interaction.rate, type = interaction.type, abortReason = interaction.abortReason, routeName = interaction.routeName, previousInteractionName = interaction.previousInteractionName, isPreviousInteractionAborted = interaction.isPreviousInteractionAborted, abortedByInteractionName = interaction.abortedByInteractionName, knownSegments = interaction.knownSegments;
34
+ sanitisedUfoName = sanitizeUfoName(ufoName);
35
+ configRate = getExtraInteractionRate(sanitisedUfoName, type);
31
36
  if (coinflip(configRate)) {
32
- _context.next = 7;
37
+ _context.next = 8;
33
38
  break;
34
39
  }
35
40
  return _context.abrupt("return", null);
36
- case 7:
41
+ case 8:
37
42
  pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
38
43
  isPageLoad = type === 'page_load' || type === 'transition';
39
44
  if (isPageLoad) {
40
- _context.next = 11;
45
+ _context.next = 12;
41
46
  break;
42
47
  }
43
48
  return _context.abrupt("return", null);
44
- case 11:
49
+ case 12:
45
50
  calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
46
51
  moreAccuratePageVisibilityAtTTAI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTAI(interaction) : null;
47
52
  extraTTAI = (_getTTAI = getTTAI(interaction)) !== null && _getTTAI !== void 0 ? _getTTAI : undefined;
48
53
  newUFOName = sanitizeUfoName(ufoName);
49
- _context.next = 17;
54
+ _context.next = 18;
50
55
  return getVCMetrics(interaction, true);
51
- case 17:
56
+ case 18:
52
57
  finalVCMetrics = _context.sent;
53
- ttvc = (_finalVCMetrics$ufoV = finalVCMetrics['ufo:vc:rev']) === null || _finalVCMetrics$ufoV === void 0 ? void 0 : _finalVCMetrics$ufoV.map(function (revision) {
54
- if (revision['metric:vc90'] === null || revision.clean !== true) {
55
- return null;
56
- }
57
- return {
58
- revision: revision.revision,
59
- vc90: revision['metric:vc90']
60
- };
61
- }).filter(function (revision) {
62
- return revision != null;
58
+ holdInfo = optimizeHoldInfo((_interaction$hold3pIn = interaction.hold3pInfo) !== null && _interaction$hold3pIn !== void 0 ? _interaction$hold3pIn : [], start, getReactUFOPayloadVersion(interaction.type));
59
+ segments3p = !fg('platform_ufo_remove_deprecated_config_fields') && config.killswitchNestedSegments ? [] : knownSegments.filter(function (knownSegment) {
60
+ return knownSegment.labelStack.some(function (entry) {
61
+ return 'type' in entry && entry.type === 'third-party';
62
+ });
63
63
  });
64
+ segmentTree = getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? buildSegmentTree(segments3p.map(function (segment) {
65
+ return segment.labelStack;
66
+ })) : {};
64
67
  payload = {
65
68
  actionSubject: 'experience',
66
69
  action: 'measured',
@@ -81,7 +84,7 @@ function _createInteractionExtraLogPayload() {
81
84
  'event:region': config.region || 'unknown',
82
85
  'experience:key': 'custom.interaction-extra-metrics',
83
86
  'experience:name': newUFOName,
84
- interactionMetrics: {
87
+ interactionMetrics: _objectSpread(_objectSpread({
85
88
  namePrefix: config.namePrefix || '',
86
89
  segmentPrefix: config.segmentPrefix || '',
87
90
  interactionId: interactionId,
@@ -98,15 +101,17 @@ function _createInteractionExtraLogPayload() {
98
101
  // performance
99
102
  end: Math.round(end),
100
103
  start: Math.round(start),
101
- 'metric:ttai:3p': extraTTAI,
102
- ttvc: ttvc !== null && ttvc !== void 0 ? ttvc : undefined
103
- }
104
+ 'metric:ttai:3p': extraTTAI
105
+ }, finalVCMetrics), {}, {
106
+ holdInfo: holdInfo,
107
+ segments: getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? segmentTree : getOldSegmentsLabelStack(segments3p, interaction.type)
108
+ })
104
109
  }
105
110
  }
106
111
  };
107
112
  payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
108
113
  return _context.abrupt("return", payload);
109
- case 22:
114
+ case 25:
110
115
  case "end":
111
116
  return _context.stop();
112
117
  }
@@ -355,7 +355,7 @@ function optimizeRedirects(redirects, interactionStart) {
355
355
  }, []);
356
356
  return updatedRedirects;
357
357
  }
358
- function optimizeHoldInfo(holdInfo, interactionStart, reactUFOVersion) {
358
+ export function optimizeHoldInfo(holdInfo, interactionStart, reactUFOVersion) {
359
359
  var holdInfoMap = holdInfo.reduce(function (result, hold) {
360
360
  var labelStack = hold.labelStack,
361
361
  name = hold.name,
@@ -101,7 +101,10 @@ function _getVCMetrics() {
101
101
  case 27:
102
102
  result = _context.sent;
103
103
  observer.stop(interaction.ufoName);
104
- postInteractionLog.setLastInteractionFinishVCResult(result);
104
+ if (!include3p) {
105
+ // For Post Interaction, last interaction should be without 3p
106
+ postInteractionLog.setLastInteractionFinishVCResult(result);
107
+ }
105
108
  mostRecentVCRevision = getMostRecentVCRevision(interaction.ufoName);
106
109
  mostRecentVCRevisionPayload = result === null || result === void 0 || (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(function (_ref) {
107
110
  var revision = _ref.revision;
@@ -658,15 +658,14 @@ function finishInteraction(id, data) {
658
658
  postInteractionLog.stopVCObserver();
659
659
  }
660
660
  if (fg('platform_ufo_enable_ttai_with_3p')) {
661
- if (!data.hold3pActive || data.hold3pActive.size === 0) {
661
+ var _sanitisedUfoName = sanitizeUfoName(data.ufoName);
662
+ if (!coinflip(getExtraInteractionRate(_sanitisedUfoName, data.type))) {
663
+ interactionExtraMetrics.stopAll(id);
664
+ } else if (!data.hold3pActive || data.hold3pActive.size === 0) {
662
665
  var _getConfig5;
663
666
  if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
664
667
  remove(id);
665
668
  }
666
- var _sanitisedUfoName = sanitizeUfoName(data.ufoName);
667
- if (!coinflip(getExtraInteractionRate(_sanitisedUfoName, data.type))) {
668
- interactionExtraMetrics.stopVCObserver();
669
- }
670
669
  }
671
670
  } else {
672
671
  var _getConfig6;
@@ -831,25 +830,29 @@ export function tryComplete(interactionId, endTime) {
831
830
  if (fg('platform_ufo_enable_ttai_with_3p')) {
832
831
  var _interaction$hold3pAc;
833
832
  var noMoreActive3pHolds = ((_interaction$hold3pAc = interaction.hold3pActive) === null || _interaction$hold3pAc === void 0 ? void 0 : _interaction$hold3pAc.size) === 0 || interaction.hold3pActive === undefined;
834
- if (noMoreActiveHolds) {
833
+ if (noMoreActiveHolds && interactionExtraMetrics.finishedInteractionId !== interactionId) {
834
+ // If it's not waiting for extra metrics to complete, finish the interaction as normal
835
835
  if (!activeSubmitted) {
836
+ var _getConfig1;
836
837
  finishInteraction(interactionId, interaction, endTime);
837
- interactionExtraMetrics.updateFinishedInteractionId(interactionId);
838
+ if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.extraInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
839
+ interactionExtraMetrics.updateFinishedInteractionId(interactionId);
840
+ }
838
841
  activeSubmitted = true;
839
842
  }
840
843
  if (noMoreExpHolds) {
841
- var _getConfig1;
842
- if ((_getConfig1 = getConfig()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
844
+ var _getConfig10;
845
+ if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
843
846
  onExperimentalInteractionComplete(interactionId, interaction, endTime);
844
847
  }
845
848
  postInteraction();
846
849
  }
847
- if (noMoreActive3pHolds) {
848
- var data = _objectSpread(_objectSpread({}, interaction), {}, {
849
- end: endTime
850
- });
851
- interactionExtraMetrics.onInteractionComplete(interactionId, data);
852
- }
850
+ }
851
+ if (noMoreActiveHolds && noMoreActive3pHolds) {
852
+ var data = _objectSpread(_objectSpread({}, interaction), {}, {
853
+ end: endTime
854
+ });
855
+ interactionExtraMetrics.onInteractionComplete(interactionId, data);
853
856
  }
854
857
  } else {
855
858
  if (noMoreActiveHolds) {
@@ -858,8 +861,8 @@ export function tryComplete(interactionId, endTime) {
858
861
  activeSubmitted = true;
859
862
  }
860
863
  if (noMoreExpHolds) {
861
- var _getConfig10;
862
- if ((_getConfig10 = getConfig()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
864
+ var _getConfig11;
865
+ if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.experimentalInteractionMetrics) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
863
866
  onExperimentalInteractionComplete(interactionId, interaction, endTime);
864
867
  }
865
868
  postInteraction();
@@ -892,9 +895,7 @@ export function abort(interactionId, abortReason) {
892
895
  postInteractionLog.reset();
893
896
  postInteractionLog.stopVCObserver();
894
897
  if (fg('platform_ufo_enable_ttai_with_3p')) {
895
- interactionExtraMetrics.stopVCObserver();
896
- interactionExtraMetrics.reset();
897
- remove(interactionId);
898
+ interactionExtraMetrics.stopAll(interactionId);
898
899
  }
899
900
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
900
901
  onExperimentalInteractionComplete(interactionId, interaction);
@@ -922,9 +923,7 @@ export function abortByNewInteraction(interactionId, interactionName) {
922
923
  postInteractionLog.reset();
923
924
  postInteractionLog.stopVCObserver();
924
925
  if (fg('platform_ufo_enable_ttai_with_3p')) {
925
- interactionExtraMetrics.stopVCObserver();
926
- interactionExtraMetrics.reset();
927
- remove(interactionId);
926
+ interactionExtraMetrics.stopAll(interactionId);
928
927
  }
929
928
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
930
929
  onExperimentalInteractionComplete(interactionId, interaction);
@@ -956,9 +955,7 @@ export function abortAll(abortReason, abortedByInteractionName) {
956
955
  postInteractionLog.reset();
957
956
  postInteractionLog.stopVCObserver();
958
957
  if (fg('platform_ufo_enable_ttai_with_3p')) {
959
- interactionExtraMetrics.stopVCObserver();
960
- interactionExtraMetrics.reset();
961
- remove(interactionId);
958
+ interactionExtraMetrics.stopAll(interactionId);
962
959
  }
963
960
  if (coinflip(getExperimentalInteractionRate(interaction.ufoName, interaction.type))) {
964
961
  onExperimentalInteractionComplete(interactionId, interaction);
@@ -1083,7 +1080,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1083
1080
  addHoldByID(interactionId, [], ufoName, ufoName, true);
1084
1081
  }
1085
1082
  if (type === 'transition' || type === 'page_load') {
1086
- var _getConfig11;
1083
+ var _getConfig12, _config$extraInteract;
1087
1084
  // Use per-interaction VC observer if available, otherwise fall back to global
1088
1085
  var observer = vcObserver;
1089
1086
  if (observer) {
@@ -1094,7 +1091,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1094
1091
  }
1095
1092
  // Start post interaction observer for all if config is enabled
1096
1093
  // in case ufoName is updated at later time
1097
- if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
1094
+ if ((_getConfig12 = getConfig()) !== null && _getConfig12 !== void 0 && (_getConfig12 = _getConfig12.postInteractionLog) !== null && _getConfig12 !== void 0 && _getConfig12.enabled) {
1098
1095
  postInteractionLog.startVCObserver({
1099
1096
  startTime: startTime
1100
1097
  });
@@ -1104,13 +1101,10 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
1104
1101
  startTime: startTime
1105
1102
  });
1106
1103
  }
1107
- if (fg('platform_ufo_enable_ttai_with_3p')) {
1108
- var _config$extraInteract;
1109
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
1110
- interactionExtraMetrics.startVCObserver({
1111
- startTime: startTime
1112
- }, interactionId);
1113
- }
1104
+ if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
1105
+ interactionExtraMetrics.startVCObserver({
1106
+ startTime: startTime
1107
+ }, interactionId);
1114
1108
  }
1115
1109
  }
1116
1110
  if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
@@ -78,6 +78,13 @@ var InteractionExtraMetrics = /*#__PURE__*/function () {
78
78
  value: function reset() {
79
79
  this.finishedInteractionId = null;
80
80
  }
81
+ }, {
82
+ key: "stopAll",
83
+ value: function stopAll(id) {
84
+ this.stopVCObserver();
85
+ remove(id);
86
+ this.reset();
87
+ }
81
88
  }]);
82
89
  }();
83
90
  export { InteractionExtraMetrics as default };
@@ -112,7 +112,7 @@ export function init(analyticsWebClientAsync, config) {
112
112
  initialiseMemoryObserver();
113
113
  setUFOConfig(config);
114
114
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
115
- var _config$experimentalI;
115
+ var _config$experimentalI, _config$extraInteract;
116
116
  var vcOptions = {
117
117
  heatmapSize: config.vc.heatmapSize,
118
118
  oldDomUpdates: config.vc.oldDomUpdates,
@@ -126,11 +126,8 @@ export function init(analyticsWebClientAsync, config) {
126
126
  startTime: 0
127
127
  });
128
128
  }
129
- if (fg('platform_ufo_enable_ttai_with_3p')) {
130
- var _config$extraInteract;
131
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
132
- interactionExtraMetrics.initializeVCObserver(vcOptions);
133
- }
129
+ if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
130
+ interactionExtraMetrics.initializeVCObserver(vcOptions);
134
131
  }
135
132
  }
136
133
  setupHiddenTimingCapture();
@@ -152,7 +149,7 @@ export function init(analyticsWebClientAsync, config) {
152
149
  createInteractionExtraMetricsPayloadPackage = _ref3[3];
153
150
  if (awc.getAnalyticsWebClientPromise) {
154
151
  awc.getAnalyticsWebClientPromise().then(function (client) {
155
- var _config$experimentalI2, _config$postInteracti;
152
+ var _config$experimentalI2, _config$postInteracti, _config$extraInteract2;
156
153
  var instance = client.getInstance();
157
154
  sinkInteraction(instance, payloadPackage);
158
155
  if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
@@ -161,12 +158,12 @@ export function init(analyticsWebClientAsync, config) {
161
158
  if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
162
159
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
163
160
  }
164
- if (fg('platform_ufo_enable_ttai_with_3p')) {
161
+ if (config !== null && config !== void 0 && (_config$extraInteract2 = config.extraInteractionMetrics) !== null && _config$extraInteract2 !== void 0 && _config$extraInteract2.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
165
162
  sinkInteractionExtraMetrics(instance, createInteractionExtraMetricsPayloadPackage.default);
166
163
  }
167
164
  });
168
165
  } else if (awc.sendOperationalEvent) {
169
- var _config$experimentalI3, _config$postInteracti2;
166
+ var _config$experimentalI3, _config$postInteracti2, _config$extraInteract3;
170
167
  sinkInteraction(awc, payloadPackage);
171
168
  if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
172
169
  sinkExperimentalInteractionMetrics(awc, payloadPackage);
@@ -174,7 +171,7 @@ export function init(analyticsWebClientAsync, config) {
174
171
  if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
175
172
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
176
173
  }
177
- if (fg('platform_ufo_enable_ttai_with_3p')) {
174
+ if (config !== null && config !== void 0 && (_config$extraInteract3 = config.extraInteractionMetrics) !== null && _config$extraInteract3 !== void 0 && _config$extraInteract3.enabled && fg('platform_ufo_enable_ttai_with_3p')) {
178
175
  sinkInteractionExtraMetrics(awc, createInteractionExtraMetricsPayloadPackage.default);
179
176
  }
180
177
  }
@@ -34,6 +34,11 @@ export var KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS = ['data-drop-targ
34
34
 
35
35
  // Common aria attributes that don't cause visual layout shifts
36
36
  export var NON_VISUAL_ARIA_ATTRIBUTES = ['aria-label', 'aria-labelledby', 'aria-describedby', 'aria-hidden', 'aria-expanded', 'aria-controls', 'aria-selected', 'aria-checked', 'aria-disabled', 'aria-required', 'aria-current', 'aria-haspopup', 'aria-pressed', 'aria-atomic', 'aria-live'];
37
+
38
+ // Common third party browser extension attributes
39
+ export var THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES = ['bis_skin_checked', 'cz-shortcut-listen', 'monica-version', 'data-gr-ext-installed', 'data-dashlane-rid', 'sapling-installed', 'data-gptw',
40
+ // grammarly extensions
41
+ 'data-new-gr-c-s-loaded', 'data-gr-aaa-notch-connection-id', 'data-gr-aaa-loaded'];
37
42
  var VCCalculator_FY25_03 = /*#__PURE__*/function (_AbstractVCCalculator) {
38
43
  function VCCalculator_FY25_03() {
39
44
  _classCallCheck(this, VCCalculator_FY25_03);
@@ -52,7 +57,7 @@ var VCCalculator_FY25_03 = /*#__PURE__*/function (_AbstractVCCalculator) {
52
57
  if (!attributeName || KNOWN_ATTRIBUTES_THAT_DOES_NOT_CAUSE_LAYOUT_SHIFTS.includes(attributeName)) {
53
58
  return false;
54
59
  }
55
- if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || attributeName === 'data-new-gr-c-c-s-loaded' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName)) {
60
+ if (attributeName.startsWith('data-test') || attributeName === 'data-aui-version' || attributeName === 'data-testid' || attributeName === 'data-vc' || attributeName === 'data-ssr-placeholder' || attributeName === 'data-ssr-placeholder-replace' || attributeName === 'data-vc-nvs' || attributeName === 'data-media-vc-wrapper' || attributeName === 'data-renderer-start-pos' || attributeName === 'data-table-local-id' || attributeName === 'spellcheck' || attributeName === 'data-auto-scrollable' || attributeName === 'id' || attributeName === 'tabindex' || attributeName === 'data-is-ttvc-ready' || NON_VISUAL_ARIA_ATTRIBUTES.includes(attributeName) || THIRD_PARTY_BROWSER_EXTENSION_ATTRIBUTES.includes(attributeName) && fg('platform_ufo_exclude_3p_extensions_from_ttvc')) {
56
61
  return false;
57
62
  }
58
63
  return true;
@@ -19,6 +19,9 @@ declare function createInteractionExtraLogPayload(interactionId: string, interac
19
19
  'experience:key': string;
20
20
  'experience:name': string;
21
21
  interactionMetrics: {
22
+ holdInfo: any[];
23
+ segments: {};
24
+ 'metric:vc90'?: number | null;
22
25
  namePrefix: string;
23
26
  segmentPrefix: string;
24
27
  interactionId: string;
@@ -34,10 +37,6 @@ declare function createInteractionExtraLogPayload(interactionId: string, interac
34
37
  end: number;
35
38
  start: number;
36
39
  'metric:ttai:3p': number | undefined;
37
- ttvc: {
38
- revision: string;
39
- vc90: number;
40
- }[];
41
40
  };
42
41
  };
43
42
  };