@atlaskit/react-ufo 3.10.3 → 3.11.0

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 (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/config/index.js +51 -5
  3. package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +2 -1
  4. package/dist/cjs/create-payload/utils/get-vc-metrics.js +41 -20
  5. package/dist/cjs/interaction-metrics/index.js +2 -1
  6. package/dist/cjs/interaction-metrics/post-interaction-log.js +4 -2
  7. package/dist/cjs/vc/index.js +123 -35
  8. package/dist/cjs/vc/vc-observer/getVCRevisionsData.js +48 -23
  9. package/dist/cjs/vc/vc-observer/index.js +17 -6
  10. package/dist/cjs/vc/vc-observer-new/entries-timeline/index.js +1 -3
  11. package/dist/cjs/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +25 -7
  12. package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +136 -115
  13. package/dist/es2019/config/index.js +49 -6
  14. package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +2 -1
  15. package/dist/es2019/create-payload/utils/get-vc-metrics.js +36 -19
  16. package/dist/es2019/interaction-metrics/index.js +2 -1
  17. package/dist/es2019/interaction-metrics/post-interaction-log.js +2 -1
  18. package/dist/es2019/vc/index.js +98 -35
  19. package/dist/es2019/vc/vc-observer/getVCRevisionsData.js +52 -25
  20. package/dist/es2019/vc/vc-observer/index.js +18 -6
  21. package/dist/es2019/vc/vc-observer-new/entries-timeline/index.js +1 -3
  22. package/dist/es2019/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +23 -7
  23. package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +122 -103
  24. package/dist/esm/config/index.js +49 -5
  25. package/dist/esm/create-experimental-interaction-metrics-payload/index.js +2 -1
  26. package/dist/esm/create-payload/utils/get-vc-metrics.js +42 -21
  27. package/dist/esm/interaction-metrics/index.js +2 -1
  28. package/dist/esm/interaction-metrics/post-interaction-log.js +4 -2
  29. package/dist/esm/vc/index.js +123 -35
  30. package/dist/esm/vc/vc-observer/getVCRevisionsData.js +48 -23
  31. package/dist/esm/vc/vc-observer/index.js +17 -6
  32. package/dist/esm/vc/vc-observer-new/entries-timeline/index.js +1 -3
  33. package/dist/esm/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.js +25 -7
  34. package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +136 -115
  35. package/dist/types/config/index.d.ts +14 -3
  36. package/dist/types/create-post-interaction-log-payload/index.d.ts +2 -2
  37. package/dist/types/vc/types.d.ts +3 -1
  38. package/dist/types/vc/vc-observer/getVCRevisionsData.d.ts +5 -3
  39. package/dist/types/vc/vc-observer/index.d.ts +1 -1
  40. package/dist/types/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +8 -3
  41. package/dist/types/vc/vc-observer-new/viewport-observer/index.d.ts +8 -1
  42. package/dist/types-ts4.5/config/index.d.ts +14 -3
  43. package/dist/types-ts4.5/create-post-interaction-log-payload/index.d.ts +2 -2
  44. package/dist/types-ts4.5/vc/types.d.ts +3 -1
  45. package/dist/types-ts4.5/vc/vc-observer/getVCRevisionsData.d.ts +5 -3
  46. package/dist/types-ts4.5/vc/vc-observer/index.d.ts +1 -1
  47. package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/percentile-calc/canvas-heatmap/canvas-pixel.d.ts +8 -3
  48. package/dist/types-ts4.5/vc/vc-observer-new/viewport-observer/index.d.ts +8 -1
  49. package/package.json +7 -1
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import { isContainedWithinMediaWrapper } from '../../vc-observer/media-wrapper/vc-utils';
2
3
  import isNonVisualStyleMutation from '../../vc-observer/observers/non-visual-styles/is-non-visual-style-mutation';
3
4
  import { createIntersectionObserver } from './intersection-observer';
@@ -43,131 +44,144 @@ const createElementMutationsWatcher = removedNodeRects => ({
43
44
  };
44
45
  export default class ViewportObserver {
45
46
  constructor({
46
- onChange: onChange
47
+ onChange
47
48
  }) {
48
- this.mapVisibleNodeRects = new WeakMap();
49
- this.intersectionObserver = createIntersectionObserver({
50
- onEntry: ({
51
- target,
52
- rect,
49
+ _defineProperty(this, "handleIntersectionEntry", ({
50
+ target,
51
+ rect,
52
+ time,
53
+ type,
54
+ mutationData
55
+ }) => {
56
+ if (!target) {
57
+ return;
58
+ }
59
+ const visible = isElementVisible(target);
60
+ const lastElementRect = this.mapVisibleNodeRects.get(target);
61
+ this.mapVisibleNodeRects.set(target, rect);
62
+ this.onChange({
53
63
  time,
54
64
  type,
65
+ elementRef: new WeakRef(target),
66
+ visible,
67
+ rect,
68
+ previousRect: lastElementRect,
55
69
  mutationData
56
- }) => {
57
- if (!target) {
70
+ });
71
+ });
72
+ _defineProperty(this, "handleChildListMutation", ({
73
+ addedNodes,
74
+ removedNodes
75
+ }) => {
76
+ const removedNodeRects = removedNodes.map(n => this.mapVisibleNodeRects.get(n));
77
+ addedNodes.forEach(addedNode => {
78
+ var _this$intersectionObs3;
79
+ const sameDeletedNode = removedNodes.find(n => n.isEqualNode(addedNode));
80
+ if (sameDeletedNode) {
81
+ var _this$intersectionObs;
82
+ (_this$intersectionObs = this.intersectionObserver) === null || _this$intersectionObs === void 0 ? void 0 : _this$intersectionObs.watchAndTag(addedNode, 'mutation:remount');
58
83
  return;
59
84
  }
60
- const visible = isElementVisible(target);
61
- const lastElementRect = this.mapVisibleNodeRects.get(target);
62
- this.mapVisibleNodeRects.set(target, rect);
63
- onChange({
64
- time,
65
- type,
66
- elementRef: new WeakRef(target),
67
- visible,
68
- rect,
69
- previousRect: lastElementRect,
70
- mutationData
71
- });
72
- }
85
+ if (isContainedWithinMediaWrapper(addedNode)) {
86
+ var _this$intersectionObs2;
87
+ (_this$intersectionObs2 = this.intersectionObserver) === null || _this$intersectionObs2 === void 0 ? void 0 : _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
88
+ return;
89
+ }
90
+ (_this$intersectionObs3 = this.intersectionObserver) === null || _this$intersectionObs3 === void 0 ? void 0 : _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
91
+ });
73
92
  });
74
- this.mutationObserver = createMutationObserver({
75
- onChildListMutation: ({
76
- addedNodes,
77
- removedNodes
78
- }) => {
79
- var _removedNodes$map;
80
- const removedNodeRects = (_removedNodes$map = removedNodes === null || removedNodes === void 0 ? void 0 : removedNodes.map(n => this.mapVisibleNodeRects.get(n))) !== null && _removedNodes$map !== void 0 ? _removedNodes$map : [];
81
- addedNodes.forEach(addedNode => {
82
- var _this$intersectionObs3;
83
- // for (const elem of addedNode.querySelectorAll('*')) {
84
- // this.intersectionObserver?.watchAndTag(elem, 'mutation:child-element');
85
- // }
86
-
87
- const sameDeletedNode = removedNodes.find(n => n.isEqualNode(addedNode));
88
- if (sameDeletedNode) {
89
- var _this$intersectionObs;
90
- (_this$intersectionObs = this.intersectionObserver) === null || _this$intersectionObs === void 0 ? void 0 : _this$intersectionObs.watchAndTag(addedNode, 'mutation:remount');
91
- return;
92
- }
93
- if (isContainedWithinMediaWrapper(addedNode)) {
94
- var _this$intersectionObs2;
95
- (_this$intersectionObs2 = this.intersectionObserver) === null || _this$intersectionObs2 === void 0 ? void 0 : _this$intersectionObs2.watchAndTag(addedNode, 'mutation:media');
96
- return;
97
- }
98
- (_this$intersectionObs3 = this.intersectionObserver) === null || _this$intersectionObs3 === void 0 ? void 0 : _this$intersectionObs3.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
99
- });
100
- },
101
- onAttributeMutation: ({
93
+ _defineProperty(this, "handleAttributeMutation", ({
94
+ target,
95
+ attributeName
96
+ }) => {
97
+ var _this$intersectionObs4;
98
+ (_this$intersectionObs4 = this.intersectionObserver) === null || _this$intersectionObs4 === void 0 ? void 0 : _this$intersectionObs4.watchAndTag(target, ({
102
99
  target,
103
- attributeName
100
+ rect
104
101
  }) => {
105
- var _this$intersectionObs4;
106
- (_this$intersectionObs4 = this.intersectionObserver) === null || _this$intersectionObs4 === void 0 ? void 0 : _this$intersectionObs4.watchAndTag(target, ({
102
+ if (isContainedWithinMediaWrapper(target)) {
103
+ return {
104
+ type: 'mutation:media',
105
+ mutationData: {
106
+ attributeName
107
+ }
108
+ };
109
+ }
110
+ if (isNonVisualStyleMutation({
107
111
  target,
108
- rect
109
- }) => {
110
- if (isContainedWithinMediaWrapper(target)) {
111
- return {
112
- type: 'mutation:media',
113
- mutationData: {
114
- attributeName
115
- }
116
- };
117
- }
118
- if (isNonVisualStyleMutation({
119
- target,
120
- attributeName,
121
- type: 'attributes'
122
- })) {
123
- return {
124
- type: 'mutation:attribute:non-visual-style',
125
- mutationData: {
126
- attributeName
127
- }
128
- };
129
- }
130
- const lastElementRect = this.mapVisibleNodeRects.get(target);
131
- if (lastElementRect && sameRectSize(rect, lastElementRect)) {
132
- return {
133
- type: 'mutation:attribute:no-layout-shift',
134
- mutationData: {
135
- attributeName
136
- }
137
- };
138
- }
112
+ attributeName,
113
+ type: 'attributes'
114
+ })) {
139
115
  return {
140
- type: 'mutation:attribute',
116
+ type: 'mutation:attribute:non-visual-style',
141
117
  mutationData: {
142
118
  attributeName
143
119
  }
144
120
  };
145
- });
146
- }
147
- });
148
- this.performanceObserver = createPerformanceObserver({
149
- onLayoutShift: ({
150
- time,
151
- changedRects
152
- }) => {
153
- for (const changedRect of changedRects) {
154
- const target = changedRect.node;
155
- if (target) {
156
- onChange({
157
- time,
158
- elementRef: new WeakRef(target),
159
- visible: true,
160
- rect: changedRect.rect,
161
- previousRect: changedRect.previousRect,
162
- type: 'layout-shift'
163
- });
121
+ }
122
+ const lastElementRect = this.mapVisibleNodeRects.get(target);
123
+ if (lastElementRect && sameRectSize(rect, lastElementRect)) {
124
+ return {
125
+ type: 'mutation:attribute:no-layout-shift',
126
+ mutationData: {
127
+ attributeName
128
+ }
129
+ };
130
+ }
131
+ return {
132
+ type: 'mutation:attribute',
133
+ mutationData: {
134
+ attributeName
164
135
  }
136
+ };
137
+ });
138
+ });
139
+ _defineProperty(this, "handleLayoutShift", ({
140
+ time,
141
+ changedRects
142
+ }) => {
143
+ for (const changedRect of changedRects) {
144
+ const target = changedRect.node;
145
+ if (target) {
146
+ this.onChange({
147
+ time,
148
+ elementRef: new WeakRef(target),
149
+ visible: true,
150
+ rect: changedRect.rect,
151
+ previousRect: changedRect.previousRect,
152
+ type: 'layout-shift'
153
+ });
165
154
  }
166
155
  }
167
156
  });
157
+ this.mapVisibleNodeRects = new WeakMap();
158
+ this.onChange = onChange;
159
+ this.isStarted = false;
160
+ this.intersectionObserver = null;
161
+ this.mutationObserver = null;
162
+ this.performanceObserver = null;
163
+ }
164
+ initializeObservers() {
165
+ if (this.isStarted) {
166
+ return;
167
+ }
168
+ this.intersectionObserver = createIntersectionObserver({
169
+ onEntry: this.handleIntersectionEntry
170
+ });
171
+ this.mutationObserver = createMutationObserver({
172
+ onChildListMutation: this.handleChildListMutation,
173
+ onAttributeMutation: this.handleAttributeMutation
174
+ });
175
+ this.performanceObserver = createPerformanceObserver({
176
+ onLayoutShift: this.handleLayoutShift
177
+ });
168
178
  }
169
179
  start() {
170
180
  var _this$mutationObserve, _this$performanceObse;
181
+ if (this.isStarted) {
182
+ return;
183
+ }
184
+ this.initializeObservers();
171
185
  (_this$mutationObserve = this.mutationObserver) === null || _this$mutationObserve === void 0 ? void 0 : _this$mutationObserve.observe(document.body, {
172
186
  attributeOldValue: true,
173
187
  attributes: true,
@@ -180,11 +194,16 @@ export default class ViewportObserver {
180
194
  // @ts-ignore-error
181
195
  durationThreshold: 30
182
196
  });
197
+ this.isStarted = true;
183
198
  }
184
199
  stop() {
185
200
  var _this$mutationObserve2, _this$intersectionObs5, _this$performanceObse2;
201
+ if (!this.isStarted) {
202
+ return;
203
+ }
186
204
  (_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 ? void 0 : _this$mutationObserve2.disconnect();
187
205
  (_this$intersectionObs5 = this.intersectionObserver) === null || _this$intersectionObs5 === void 0 ? void 0 : _this$intersectionObs5.disconnect();
188
206
  (_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 ? void 0 : _this$performanceObse2.disconnect();
207
+ this.isStarted = false;
189
208
  }
190
209
  }
@@ -1,3 +1,9 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _typeof from "@babel/runtime/helpers/typeof";
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';
1
7
  var config;
2
8
  var DEFAULT_TTVC_REVISION = 'fy25.02';
3
9
 
@@ -5,28 +11,66 @@ var DEFAULT_TTVC_REVISION = 'fy25.02';
5
11
  // and they could delete empty members
6
12
 
7
13
  export function setUFOConfig(newConfig) {
8
- config = newConfig;
14
+ if (fg('platform_ufo_vc_enable_revisions_by_experience')) {
15
+ var _newConfig$vc;
16
+ // Handle edge cases with `enabledVCRevisions`
17
+ var _ref = (_newConfig$vc = newConfig === null || newConfig === void 0 ? void 0 : newConfig.vc) !== null && _newConfig$vc !== void 0 ? _newConfig$vc : {},
18
+ enabledVCRevisions = _ref.enabledVCRevisions;
19
+ if (_typeof(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.byExperience) === 'object') {
20
+ config = _objectSpread(_objectSpread({}, newConfig), {}, {
21
+ vc: _objectSpread(_objectSpread({}, newConfig.vc), {}, {
22
+ enabledVCRevisions: {
23
+ // enforce axiom about `enabledVCRevisions.all` config
24
+ all: Array.from(new Set([DEFAULT_TTVC_REVISION].concat(_toConsumableArray(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.all), _toConsumableArray(Object.values(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.byExperience).flat())))),
25
+ byExperience: _objectSpread({}, enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.byExperience)
26
+ }
27
+ })
28
+ });
29
+ } else {
30
+ config = newConfig;
31
+ }
32
+ } else {
33
+ config = newConfig;
34
+ }
9
35
  }
10
36
  export function getConfig() {
11
37
  return config;
12
38
  }
39
+ var isValidConfigArray = function isValidConfigArray(array) {
40
+ return Array.isArray(array) && array.length > 0;
41
+ };
13
42
  export function getEnabledVCRevisions() {
43
+ var experienceKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
14
44
  try {
15
45
  var _config$vc;
16
46
  if (!config) {
17
47
  return [];
18
48
  }
19
49
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
20
- var _config$vc2, _config$vc3;
21
- return Array.isArray((_config$vc2 = config.vc) === null || _config$vc2 === void 0 ? void 0 : _config$vc2.enabledVCRevisions) && ((_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.enabledVCRevisions.length) > 0 ? config.vc.enabledVCRevisions : [DEFAULT_TTVC_REVISION];
50
+ var _config$vc2, _enabledVCRevisions$b;
51
+ var _ref2 = (_config$vc2 = config.vc) !== null && _config$vc2 !== void 0 ? _config$vc2 : {},
52
+ enabledVCRevisions = _ref2.enabledVCRevisions;
53
+ if (isValidConfigArray(enabledVCRevisions === null || enabledVCRevisions === void 0 || (_enabledVCRevisions$b = enabledVCRevisions.byExperience) === null || _enabledVCRevisions$b === void 0 ? void 0 : _enabledVCRevisions$b[experienceKey]) && fg('platform_ufo_vc_enable_revisions_by_experience')) {
54
+ var _enabledVCRevisions$b2;
55
+ return (_enabledVCRevisions$b2 = enabledVCRevisions.byExperience) === null || _enabledVCRevisions$b2 === void 0 ? void 0 : _enabledVCRevisions$b2[experienceKey];
56
+ }
57
+ if (isValidConfigArray(enabledVCRevisions === null || enabledVCRevisions === void 0 ? void 0 : enabledVCRevisions.all)) {
58
+ return enabledVCRevisions.all;
59
+ }
60
+ return [DEFAULT_TTVC_REVISION];
22
61
  }
23
62
  return [];
24
63
  } catch (_unused) {
25
64
  return [];
26
65
  }
27
66
  }
28
- export function isVCRevisionEnabled(revision) {
29
- return getEnabledVCRevisions().includes(revision);
67
+ export function isVCRevisionEnabled(revision, experienceKey) {
68
+ return getEnabledVCRevisions(experienceKey).includes(revision);
69
+ }
70
+ export function getMostRecentVCRevision() {
71
+ var experienceKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
72
+ var enabledVCRevisions = getEnabledVCRevisions(experienceKey);
73
+ return enabledVCRevisions[enabledVCRevisions.length - 1];
30
74
  }
31
75
  export function getInteractionRate(name, interactionKind) {
32
76
  try {
@@ -100,7 +100,8 @@ function _getExperimentalVCMetrics() {
100
100
  tti: (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime,
101
101
  isEventAborted: !!interaction.abortReason,
102
102
  prefix: prefix,
103
- vc: interaction.vc
103
+ vc: interaction.vc,
104
+ experienceKey: interaction.ufoName
104
105
  });
105
106
  case 4:
106
107
  result = _context.sent;
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
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
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
6
  import { fg } from '@atlaskit/platform-feature-flags';
7
- import { getConfig, isVCRevisionEnabled } from '../../config';
7
+ import { getConfig, getMostRecentVCRevision, isVCRevisionEnabled } from '../../config';
8
8
  import { postInteractionLog } from '../../interaction-metrics';
9
9
  import { getVCObserver } from '../../vc';
10
10
  import getInteractionStatus from './get-interaction-status';
@@ -16,7 +16,7 @@ function getVCMetrics(_x) {
16
16
  function _getVCMetrics() {
17
17
  _getVCMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction) {
18
18
  var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI;
19
- var config, interactionStatus, pageVisibilityUpToTTAI, isSSREnabled, ssr, tti, prefix, result, _result$ufoVcRev, ttvcV2Revision, VC;
19
+ var config, interactionStatus, pageVisibilityUpToTTAI, shouldReportVCMetrics, isSSREnabled, ssr, tti, prefix, result, _result$ufoVcRev, mostRecentVCRevision, mostRecentVCRevisionPayload, _result$ufoVcRev2, ttvcV2Revision, VC;
20
20
  return _regeneratorRuntime.wrap(function _callee$(_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
22
22
  case 0:
@@ -35,13 +35,14 @@ function _getVCMetrics() {
35
35
  case 5:
36
36
  interactionStatus = getInteractionStatus(interaction);
37
37
  pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
38
- if (!((interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') && fg('platform_ufo_no_vc_on_aborted'))) {
39
- _context.next = 10;
38
+ shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible';
39
+ if (!(!shouldReportVCMetrics && fg('platform_ufo_no_vc_on_aborted'))) {
40
+ _context.next = 11;
40
41
  break;
41
42
  }
42
- getVCObserver().stop();
43
+ getVCObserver().stop(interaction.ufoName);
43
44
  return _context.abrupt("return", {});
44
- case 10:
45
+ case 11:
45
46
  isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
46
47
  ssr = interaction.type === 'page_load' && isSSREnabled ? {
47
48
  ssr: getSSRDoneTimeValue(config)
@@ -49,56 +50,76 @@ function _getVCMetrics() {
49
50
  postInteractionLog.setVCObserverSSRConfig(ssr);
50
51
  tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime;
51
52
  prefix = 'ufo';
52
- _context.next = 17;
53
+ _context.next = 18;
53
54
  return getVCObserver().getVCResult(_objectSpread({
54
55
  start: interaction.start,
55
56
  stop: interaction.end,
56
57
  tti: tti,
57
58
  prefix: prefix,
58
59
  vc: interaction.vc,
59
- isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED'
60
+ isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED',
61
+ experienceKey: interaction.ufoName
60
62
  }, ssr));
61
- case 17:
63
+ case 18:
62
64
  result = _context.sent;
63
65
  if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
64
- getVCObserver().stop();
66
+ getVCObserver().stop(interaction.ufoName);
65
67
  }
66
68
  postInteractionLog.setLastInteractionFinishVCResult(result);
67
- if (isVCRevisionEnabled('fy25.01')) {
68
- _context.next = 27;
69
+ if (!fg('platform_ufo_vc_enable_revisions_by_experience')) {
70
+ _context.next = 29;
69
71
  break;
70
72
  }
71
- ttvcV2Revision = result === null || result === void 0 || (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(function (_ref) {
73
+ mostRecentVCRevision = getMostRecentVCRevision(interaction.ufoName);
74
+ mostRecentVCRevisionPayload = result === null || result === void 0 || (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(function (_ref) {
72
75
  var revision = _ref.revision;
76
+ return revision === mostRecentVCRevision;
77
+ });
78
+ if (!(!shouldReportVCMetrics || !(mostRecentVCRevisionPayload !== null && mostRecentVCRevisionPayload !== void 0 && mostRecentVCRevisionPayload.clean))) {
79
+ _context.next = 26;
80
+ break;
81
+ }
82
+ return _context.abrupt("return", result);
83
+ case 26:
84
+ return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
85
+ 'metric:vc90': mostRecentVCRevisionPayload['metric:vc90']
86
+ }));
87
+ case 29:
88
+ if (isVCRevisionEnabled('fy25.01')) {
89
+ _context.next = 36;
90
+ break;
91
+ }
92
+ ttvcV2Revision = result === null || result === void 0 || (_result$ufoVcRev2 = result['ufo:vc:rev']) === null || _result$ufoVcRev2 === void 0 ? void 0 : _result$ufoVcRev2.find(function (_ref2) {
93
+ var revision = _ref2.revision;
73
94
  return revision === 'fy25.02';
74
95
  });
75
96
  if (ttvcV2Revision !== null && ttvcV2Revision !== void 0 && ttvcV2Revision.clean) {
76
- _context.next = 24;
97
+ _context.next = 33;
77
98
  break;
78
99
  }
79
100
  return _context.abrupt("return", result);
80
- case 24:
101
+ case 33:
81
102
  return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
82
103
  'metric:vc90': ttvcV2Revision['metric:vc90']
83
104
  }));
84
- case 27:
105
+ case 36:
85
106
  VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
86
107
  if (!(!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")]))) {
87
- _context.next = 30;
108
+ _context.next = 39;
88
109
  break;
89
110
  }
90
111
  return _context.abrupt("return", result);
91
- case 30:
112
+ case 39:
92
113
  if (!(interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible')) {
93
- _context.next = 32;
114
+ _context.next = 41;
94
115
  break;
95
116
  }
96
117
  return _context.abrupt("return", result);
97
- case 32:
118
+ case 41:
98
119
  return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
99
120
  'metric:vc90': VC['90']
100
121
  }));
101
- case 33:
122
+ case 42:
102
123
  case "end":
103
124
  return _context.stop();
104
125
  }
@@ -798,7 +798,8 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
798
798
  if (type === 'transition') {
799
799
  var _getConfig14;
800
800
  getVCObserver().start({
801
- startTime: startTime
801
+ startTime: startTime,
802
+ experienceKey: ufoName
802
803
  });
803
804
  postInteractionLog.startVCObserver({
804
805
  startTime: startTime
@@ -125,14 +125,16 @@ var PostInteractionLog = /*#__PURE__*/function () {
125
125
  return _context.abrupt("return");
126
126
  case 4:
127
127
  _context.next = 6;
128
- return (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.getVCResult(_objectSpread({
128
+ return (_this$vcObserver3 = this.vcObserver) === null || _this$vcObserver3 === void 0 ? void 0 : _this$vcObserver3.getVCResult(_objectSpread(_objectSpread({
129
129
  start: this.lastInteractionFinish.start,
130
130
  stop: performance.now(),
131
131
  tti: -1,
132
132
  // no need for TTI value here
133
133
  isEventAborted: !!this.lastInteractionFinish.abortReason,
134
134
  prefix: 'ufo'
135
- }, this.vcObserverSSRConfig));
135
+ }, this.vcObserverSSRConfig), {}, {
136
+ experienceKey: this.lastInteractionFinish.ufoName
137
+ }));
136
138
  case 6:
137
139
  postInteractionFinishVCResult = _context.sent;
138
140
  if ((_getConfig2 = getConfig()) !== null && _getConfig2 !== void 0 && (_getConfig2 = _getConfig2.experimentalInteractionMetrics) !== null && _getConfig2 !== void 0 && _getConfig2.enabled) {