@atlaskit/react-ufo 4.7.0 → 4.7.2

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 (69) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/create-interaction-extra-metrics-payload/index.js +82 -15
  3. package/dist/cjs/create-payload/index.js +26 -218
  4. package/dist/cjs/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.js +20 -0
  5. package/dist/cjs/create-payload/utils/get-visibility-state-from-performance.js +35 -0
  6. package/dist/cjs/create-payload/utils/optimize-apdex.js +25 -0
  7. package/dist/cjs/create-payload/utils/optimize-custom-timings.js +22 -0
  8. package/dist/cjs/create-payload/utils/optimize-hold-info.js +41 -0
  9. package/dist/cjs/create-payload/utils/optimize-marks.js +24 -0
  10. package/dist/cjs/create-payload/utils/optimize-react-profiler-timings.js +53 -0
  11. package/dist/cjs/create-payload/utils/optimize-request-info.js +32 -0
  12. package/dist/cjs/create-payload/utils/optimize-spans.js +30 -0
  13. package/dist/cjs/interaction-metrics-init/index.js +1 -1
  14. package/dist/cjs/vc/vc-observer/observers/ssr-placeholders/index.js +2 -2
  15. package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +4 -6
  16. package/dist/cjs/vc/vc-observer-new/viewport-observer/index.js +30 -48
  17. package/dist/es2019/create-interaction-extra-metrics-payload/index.js +62 -9
  18. package/dist/es2019/create-payload/index.js +10 -205
  19. package/dist/es2019/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.js +13 -0
  20. package/dist/es2019/create-payload/utils/get-visibility-state-from-performance.js +28 -0
  21. package/dist/es2019/create-payload/utils/optimize-apdex.js +14 -0
  22. package/dist/es2019/create-payload/utils/optimize-custom-timings.js +16 -0
  23. package/dist/es2019/create-payload/utils/optimize-hold-info.js +35 -0
  24. package/dist/es2019/create-payload/utils/optimize-marks.js +12 -0
  25. package/dist/es2019/create-payload/utils/optimize-react-profiler-timings.js +46 -0
  26. package/dist/es2019/create-payload/utils/optimize-request-info.js +26 -0
  27. package/dist/es2019/create-payload/utils/optimize-spans.js +24 -0
  28. package/dist/es2019/interaction-metrics-init/index.js +1 -1
  29. package/dist/es2019/vc/vc-observer/observers/ssr-placeholders/index.js +2 -2
  30. package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +9 -13
  31. package/dist/es2019/vc/vc-observer-new/viewport-observer/index.js +20 -29
  32. package/dist/esm/create-interaction-extra-metrics-payload/index.js +83 -16
  33. package/dist/esm/create-payload/index.js +18 -208
  34. package/dist/esm/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.js +13 -0
  35. package/dist/esm/create-payload/utils/get-visibility-state-from-performance.js +29 -0
  36. package/dist/esm/create-payload/utils/optimize-apdex.js +18 -0
  37. package/dist/esm/create-payload/utils/optimize-custom-timings.js +16 -0
  38. package/dist/esm/create-payload/utils/optimize-hold-info.js +34 -0
  39. package/dist/esm/create-payload/utils/optimize-marks.js +17 -0
  40. package/dist/esm/create-payload/utils/optimize-react-profiler-timings.js +46 -0
  41. package/dist/esm/create-payload/utils/optimize-request-info.js +25 -0
  42. package/dist/esm/create-payload/utils/optimize-spans.js +23 -0
  43. package/dist/esm/interaction-metrics-init/index.js +1 -1
  44. package/dist/esm/vc/vc-observer/observers/ssr-placeholders/index.js +2 -2
  45. package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +4 -6
  46. package/dist/esm/vc/vc-observer-new/viewport-observer/index.js +30 -48
  47. package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +56 -0
  48. package/dist/types/create-payload/index.d.ts +0 -3
  49. package/dist/types/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.d.ts +2 -0
  50. package/dist/types/create-payload/utils/get-visibility-state-from-performance.d.ts +1 -0
  51. package/dist/types/create-payload/utils/optimize-apdex.d.ts +12 -0
  52. package/dist/types/create-payload/utils/optimize-custom-timings.d.ts +7 -0
  53. package/dist/types/create-payload/utils/optimize-hold-info.d.ts +3 -0
  54. package/dist/types/create-payload/utils/optimize-marks.d.ts +12 -0
  55. package/dist/types/create-payload/utils/optimize-react-profiler-timings.d.ts +3 -0
  56. package/dist/types/create-payload/utils/optimize-request-info.d.ts +8 -0
  57. package/dist/types/create-payload/utils/optimize-spans.d.ts +9 -0
  58. package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +56 -0
  59. package/dist/types-ts4.5/create-payload/index.d.ts +0 -3
  60. package/dist/types-ts4.5/create-payload/utils/get-more-accurate-page-visibility-up-to-ttai.d.ts +2 -0
  61. package/dist/types-ts4.5/create-payload/utils/get-visibility-state-from-performance.d.ts +1 -0
  62. package/dist/types-ts4.5/create-payload/utils/optimize-apdex.d.ts +12 -0
  63. package/dist/types-ts4.5/create-payload/utils/optimize-custom-timings.d.ts +7 -0
  64. package/dist/types-ts4.5/create-payload/utils/optimize-hold-info.d.ts +3 -0
  65. package/dist/types-ts4.5/create-payload/utils/optimize-marks.d.ts +12 -0
  66. package/dist/types-ts4.5/create-payload/utils/optimize-react-profiler-timings.d.ts +3 -0
  67. package/dist/types-ts4.5/create-payload/utils/optimize-request-info.d.ts +8 -0
  68. package/dist/types-ts4.5/create-payload/utils/optimize-spans.d.ts +9 -0
  69. package/package.json +1 -7
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.optimizeMarks = optimizeMarks;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
+ var _utils = require("../common/utils");
11
+ var _excluded = ["labelStack", "time"];
12
+ 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; }
13
+ 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; }
14
+ function optimizeMarks(marks, reactUFOVersion) {
15
+ return marks.map(function (_ref) {
16
+ var labelStack = _ref.labelStack,
17
+ time = _ref.time,
18
+ others = (0, _objectWithoutProperties2.default)(_ref, _excluded);
19
+ return _objectSpread(_objectSpread({}, others), {}, {
20
+ labelStack: labelStack && (0, _utils.optimizeLabelStack)(labelStack, reactUFOVersion),
21
+ time: Math.round(time)
22
+ });
23
+ });
24
+ }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.optimizeReactProfilerTimings = optimizeReactProfilerTimings;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
+ var _interactionMetrics = require("../../interaction-metrics");
11
+ var _utils = require("../common/utils");
12
+ function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart, reactUFOVersion) {
13
+ var reactProfilerTimingsMap = reactProfilerTimings.reduce(function (result, _ref) {
14
+ var labelStack = _ref.labelStack,
15
+ startTime = _ref.startTime,
16
+ commitTime = _ref.commitTime,
17
+ actualDuration = _ref.actualDuration,
18
+ type = _ref.type;
19
+ if (labelStack && startTime >= interactionStart) {
20
+ var label = (0, _utils.stringifyLabelStackFully)(labelStack);
21
+ var start = Math.round(startTime);
22
+ var end = Math.round(commitTime);
23
+ var timing = result.get(label) || {
24
+ labelStack: (0, _utils.optimizeLabelStack)(labelStack, reactUFOVersion),
25
+ startTime: start,
26
+ endTime: end,
27
+ mountCount: 0,
28
+ rerenderCount: 0,
29
+ renderDuration: 0
30
+ };
31
+ if (start < timing.startTime) {
32
+ timing.startTime = start;
33
+ }
34
+ if (end > timing.endTime) {
35
+ timing.endTime = end;
36
+ }
37
+ if (type === 'mount') {
38
+ timing.mountCount += 1;
39
+ }
40
+ if (type === 'update') {
41
+ timing.rerenderCount += 1;
42
+ }
43
+ if (_interactionMetrics.segmentUnmountCache.has(label) && (0, _platformFeatureFlags.fg)('platform_ufo_segment_unmount_count')) {
44
+ timing.unmountCount = _interactionMetrics.segmentUnmountCache.get(label) || 0;
45
+ _interactionMetrics.segmentUnmountCache.delete(label);
46
+ }
47
+ timing.renderDuration += Math.round(actualDuration);
48
+ result.set(label, timing);
49
+ }
50
+ return result;
51
+ }, new Map());
52
+ return (0, _toConsumableArray2.default)(reactProfilerTimingsMap.values());
53
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.optimizeRequestInfo = optimizeRequestInfo;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _utils = require("../common/utils");
10
+ function optimizeRequestInfo(requestInfo, interactionStart, reactUFOVersion) {
11
+ var updatedRequestInfo = requestInfo.reduce(function (result, reqInfo) {
12
+ var labelStack = reqInfo.labelStack,
13
+ name = reqInfo.name,
14
+ start = reqInfo.start,
15
+ end = reqInfo.end,
16
+ networkStart = reqInfo.networkStart,
17
+ networkComplete = reqInfo.networkComplete;
18
+ var startTime = networkStart !== null && networkStart !== void 0 ? networkStart : start;
19
+ var endTime = networkComplete !== null && networkComplete !== void 0 ? networkComplete : end;
20
+ if (labelStack && start >= interactionStart && endTime) {
21
+ result.push({
22
+ labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
23
+ name: name
24
+ }]), reactUFOVersion),
25
+ startTime: Math.round(startTime),
26
+ endTime: Math.round(endTime)
27
+ });
28
+ }
29
+ return result;
30
+ }, []);
31
+ return updatedRequestInfo;
32
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.optimizeSpans = optimizeSpans;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _utils = require("../common/utils");
10
+ function optimizeSpans(spans, interactionStart, reactUFOVersion) {
11
+ var updatedSpans = spans.reduce(function (result, span) {
12
+ var labelStack = span.labelStack,
13
+ type = span.type,
14
+ name = span.name,
15
+ start = span.start,
16
+ end = span.end;
17
+ if (labelStack && start >= interactionStart) {
18
+ result.push({
19
+ labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
20
+ name: name
21
+ }]), reactUFOVersion),
22
+ startTime: Math.round(start),
23
+ endTime: Math.round(end),
24
+ type: type
25
+ });
26
+ }
27
+ return result;
28
+ }, []);
29
+ return updatedSpans;
30
+ }
@@ -135,7 +135,7 @@ function init(analyticsWebClientAsync, config) {
135
135
  startTime: 0
136
136
  });
137
137
  }
138
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled && (0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
138
+ if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
139
139
  _interactionMetrics.interactionExtraMetrics.initializeVCObserver(vcOptions);
140
140
  }
141
141
  }
@@ -214,7 +214,7 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
214
214
  return element;
215
215
  }
216
216
 
217
- // NOTE - for use when the FG `platform_ufo_ssr_placeholder_resolution_ttvc_v3` is disabled
217
+ // Validates placeholder match using asynchronous observation and resolves with the result
218
218
  }, {
219
219
  key: "checkIfExistedAndSizeMatching",
220
220
  value: function checkIfExistedAndSizeMatching(el) {
@@ -233,7 +233,7 @@ var SSRPlaceholderHandlers = exports.SSRPlaceholderHandlers = /*#__PURE__*/funct
233
233
  });
234
234
  }
235
235
 
236
- // NOTE - for use when the FG `platform_ufo_ssr_placeholder_resolution_ttvc_v3` is enabled
236
+ // Validates placeholder match synchronously using stored SSR dimensions and current bounds
237
237
  }, {
238
238
  key: "checkIfExistedAndSizeMatchingV3",
239
239
  value: function checkIfExistedAndSizeMatchingV3(el) {
@@ -204,15 +204,14 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
204
204
  }
205
205
  }
206
206
  enhancedVcLogs = vcLogs ? vcLogs.map(function (log) {
207
- return _objectSpread(_objectSpread(_objectSpread({}, log), (0, _platformFeatureFlags.fg)('platform_ufo_serialise_ttvc_v3_debug_data') && {
207
+ return _objectSpread(_objectSpread({}, log), {}, {
208
208
  entries: log.entries.map(function (entry) {
209
209
  var _entry$rect, _entry$previousRect;
210
210
  return _objectSpread(_objectSpread({}, entry), {}, {
211
211
  rect: (_entry$rect = entry.rect) === null || _entry$rect === void 0 ? void 0 : _entry$rect.toJSON(),
212
212
  previousRect: (_entry$previousRect = entry.previousRect) === null || _entry$previousRect === void 0 ? void 0 : _entry$previousRect.toJSON()
213
213
  });
214
- })
215
- }), {}, {
214
+ }),
216
215
  viewportPercentage: log.viewportPercentage
217
216
  });
218
217
  }) : []; // If 3p metric enabled - calculate the debug details
@@ -268,10 +267,9 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
268
267
  if (!ignoredEntriesByTime.has(timestamp)) {
269
268
  ignoredEntriesByTime.set(timestamp, []);
270
269
  }
271
- (_ignoredEntriesByTime = ignoredEntriesByTime.get(timestamp)) === null || _ignoredEntriesByTime === void 0 || _ignoredEntriesByTime.push(_objectSpread(_objectSpread(_objectSpread({}, viewportData), (0, _platformFeatureFlags.fg)('platform_ufo_serialise_ttvc_v3_debug_data') && {
270
+ (_ignoredEntriesByTime = ignoredEntriesByTime.get(timestamp)) === null || _ignoredEntriesByTime === void 0 || _ignoredEntriesByTime.push(_objectSpread(_objectSpread({}, viewportData), {}, {
272
271
  rect: (_viewportData$rect = viewportData.rect) === null || _viewportData$rect === void 0 ? void 0 : _viewportData$rect.toJSON(),
273
- previousRect: (_viewportData$previou = viewportData.previousRect) === null || _viewportData$previou === void 0 ? void 0 : _viewportData$previou.toJSON()
274
- }), {}, {
272
+ previousRect: (_viewportData$previou = viewportData.previousRect) === null || _viewportData$previou === void 0 ? void 0 : _viewportData$previou.toJSON(),
275
273
  ignoreReason: viewportData.visible ? viewportData.type : 'not-visible'
276
274
  }));
277
275
  }
@@ -125,7 +125,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
125
125
  _iterator = _createForOfIteratorHelper(addedNodes);
126
126
  _context2.prev = 4;
127
127
  _loop = /*#__PURE__*/_regenerator.default.mark(function _loop() {
128
- var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, _result, _this$intersectionObs5, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs6, _this$intersectionObs7, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs8, validTargets, _iterator2, _step2, _this$intersectionObs9, validTarget, _this$intersectionObs0;
128
+ var addedNodeRef, addedNode, ssrState, SSRStateEnum, _this$intersectionObs, _this$intersectionObs2, ssrPlaceholderHandler, _this$intersectionObs3, result, _this$intersectionObs4, sameDeletedNode, isInIgnoreLsMarker, _this$intersectionObs5, _this$intersectionObs6, _checkWithinComponent, isWithinThirdPartySegment, _this$intersectionObs7, validTargets, _iterator2, _step2, _this$intersectionObs8, validTarget, _this$intersectionObs9;
129
129
  return _regenerator.default.wrap(function _loop$(_context) {
130
130
  while (1) switch (_context.prev = _context.next) {
131
131
  case 0:
@@ -173,58 +173,40 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
173
173
  ssrState.state = SSRStateEnum.normal;
174
174
  case 19:
175
175
  if (!_this.getSSRPlaceholderHandler) {
176
- _context.next = 42;
176
+ _context.next = 33;
177
177
  break;
178
178
  }
179
179
  ssrPlaceholderHandler = _this.getSSRPlaceholderHandler();
180
180
  if (!ssrPlaceholderHandler) {
181
- _context.next = 42;
181
+ _context.next = 33;
182
182
  break;
183
183
  }
184
184
  if (!(ssrPlaceholderHandler.isPlaceholder(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode))) {
185
- _context.next = 35;
186
- break;
187
- }
188
- if (!(0, _platformFeatureFlags.fg)('platform_ufo_ssr_placeholder_resolution_ttvc_v3')) {
189
- _context.next = 29;
185
+ _context.next = 26;
190
186
  break;
191
187
  }
192
188
  if (!ssrPlaceholderHandler.checkIfExistedAndSizeMatchingV3(addedNode)) {
193
- _context.next = 27;
189
+ _context.next = 26;
194
190
  break;
195
191
  }
196
192
  (_this$intersectionObs3 = _this.intersectionObserver) === null || _this$intersectionObs3 === void 0 || _this$intersectionObs3.watchAndTag(addedNode, 'mutation:ssr-placeholder');
197
193
  return _context.abrupt("return", 0);
198
- case 27:
199
- _context.next = 35;
200
- break;
201
- case 29:
202
- _context.next = 31;
203
- return ssrPlaceholderHandler.checkIfExistedAndSizeMatching(addedNode);
204
- case 31:
205
- result = _context.sent;
206
- if (!(result !== false)) {
207
- _context.next = 35;
208
- break;
209
- }
210
- (_this$intersectionObs4 = _this.intersectionObserver) === null || _this$intersectionObs4 === void 0 || _this$intersectionObs4.watchAndTag(addedNode, 'mutation:ssr-placeholder');
211
- return _context.abrupt("return", 0);
212
- case 35:
194
+ case 26:
213
195
  if (!(ssrPlaceholderHandler.isPlaceholderReplacement(addedNode) || ssrPlaceholderHandler.isPlaceholderIgnored(addedNode))) {
214
- _context.next = 42;
196
+ _context.next = 33;
215
197
  break;
216
198
  }
217
- _context.next = 38;
199
+ _context.next = 29;
218
200
  return ssrPlaceholderHandler.validateReactComponentMatchToPlaceholder(addedNode);
219
- case 38:
220
- _result = _context.sent;
221
- if (!(_result !== false)) {
222
- _context.next = 42;
201
+ case 29:
202
+ result = _context.sent;
203
+ if (!(result !== false)) {
204
+ _context.next = 33;
223
205
  break;
224
206
  }
225
- (_this$intersectionObs5 = _this.intersectionObserver) === null || _this$intersectionObs5 === void 0 || _this$intersectionObs5.watchAndTag(addedNode, 'mutation:ssr-placeholder');
207
+ (_this$intersectionObs4 = _this.intersectionObserver) === null || _this$intersectionObs4 === void 0 || _this$intersectionObs4.watchAndTag(addedNode, 'mutation:ssr-placeholder');
226
208
  return _context.abrupt("return", 0);
227
- case 42:
209
+ case 33:
228
210
  sameDeletedNode = removedNodes.find(function (ref) {
229
211
  var n = ref.deref();
230
212
  if (!n || !addedNode) {
@@ -234,27 +216,27 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
234
216
  });
235
217
  isInIgnoreLsMarker = (0, _isInVcIgnoreIfNoLayoutShiftMarker.default)(addedNode);
236
218
  if (!(sameDeletedNode && isInIgnoreLsMarker)) {
237
- _context.next = 47;
219
+ _context.next = 38;
238
220
  break;
239
221
  }
240
- (_this$intersectionObs6 = _this.intersectionObserver) === null || _this$intersectionObs6 === void 0 || _this$intersectionObs6.watchAndTag(addedNode, 'mutation:remount');
222
+ (_this$intersectionObs5 = _this.intersectionObserver) === null || _this$intersectionObs5 === void 0 || _this$intersectionObs5.watchAndTag(addedNode, 'mutation:remount');
241
223
  return _context.abrupt("return", 0);
242
- case 47:
224
+ case 38:
243
225
  if (!(0, _vcUtils.isContainedWithinMediaWrapper)(addedNode)) {
244
- _context.next = 50;
226
+ _context.next = 41;
245
227
  break;
246
228
  }
247
- (_this$intersectionObs7 = _this.intersectionObserver) === null || _this$intersectionObs7 === void 0 || _this$intersectionObs7.watchAndTag(addedNode, 'mutation:media');
229
+ (_this$intersectionObs6 = _this.intersectionObserver) === null || _this$intersectionObs6 === void 0 || _this$intersectionObs6.watchAndTag(addedNode, 'mutation:media');
248
230
  return _context.abrupt("return", 0);
249
- case 50:
231
+ case 41:
250
232
  _checkWithinComponent = (0, _checkWithinComponent2.default)(addedNode, 'UFOThirdPartySegment', _this.mapIs3pResult), isWithinThirdPartySegment = _checkWithinComponent.isWithin;
251
233
  if (!isWithinThirdPartySegment) {
252
- _context.next = 54;
234
+ _context.next = 45;
253
235
  break;
254
236
  }
255
- (_this$intersectionObs8 = _this.intersectionObserver) === null || _this$intersectionObs8 === void 0 || _this$intersectionObs8.watchAndTag(addedNode, 'mutation:third-party-element');
237
+ (_this$intersectionObs7 = _this.intersectionObserver) === null || _this$intersectionObs7 === void 0 || _this$intersectionObs7.watchAndTag(addedNode, 'mutation:third-party-element');
256
238
  return _context.abrupt("return", 0);
257
- case 54:
239
+ case 45:
258
240
  if ((0, _platformFeatureFlags.fg)('platform_ufo_display_content_resolution_ttvc_v3')) {
259
241
  // Check if the target has display:content css property, return array of valid targets
260
242
  validTargets = (0, _checkDisplayContent.default)(addedNode);
@@ -262,7 +244,7 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
262
244
  try {
263
245
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
264
246
  validTarget = _step2.value;
265
- (_this$intersectionObs9 = _this.intersectionObserver) === null || _this$intersectionObs9 === void 0 || _this$intersectionObs9.watchAndTag(validTarget, createElementMutationsWatcher(removedNodeRects));
247
+ (_this$intersectionObs8 = _this.intersectionObserver) === null || _this$intersectionObs8 === void 0 || _this$intersectionObs8.watchAndTag(validTarget, createElementMutationsWatcher(removedNodeRects));
266
248
  }
267
249
  } catch (err) {
268
250
  _iterator2.e(err);
@@ -273,9 +255,9 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
273
255
  if ((0, _platformFeatureFlags.fg)('platform_ufo_display_content_track_occurrence')) {
274
256
  (0, _trackDisplayContentOccurrence.default)(addedNode);
275
257
  }
276
- (_this$intersectionObs0 = _this.intersectionObserver) === null || _this$intersectionObs0 === void 0 || _this$intersectionObs0.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
258
+ (_this$intersectionObs9 = _this.intersectionObserver) === null || _this$intersectionObs9 === void 0 || _this$intersectionObs9.watchAndTag(addedNode, createElementMutationsWatcher(removedNodeRects));
277
259
  }
278
- case 55:
260
+ case 46:
279
261
  case "end":
280
262
  return _context.stop();
281
263
  }
@@ -320,12 +302,12 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
320
302
  };
321
303
  }());
322
304
  (0, _defineProperty2.default)(this, "handleAttributeMutation", function (_ref6) {
323
- var _this$intersectionObs1;
305
+ var _this$intersectionObs0;
324
306
  var target = _ref6.target,
325
307
  attributeName = _ref6.attributeName,
326
308
  oldValue = _ref6.oldValue,
327
309
  newValue = _ref6.newValue;
328
- (_this$intersectionObs1 = _this.intersectionObserver) === null || _this$intersectionObs1 === void 0 || _this$intersectionObs1.watchAndTag(target, function (_ref7) {
310
+ (_this$intersectionObs0 = _this.intersectionObserver) === null || _this$intersectionObs0 === void 0 || _this$intersectionObs0.watchAndTag(target, function (_ref7) {
329
311
  var target = _ref7.target,
330
312
  rect = _ref7.rect;
331
313
  if ((0, _vcUtils.isContainedWithinMediaWrapper)(target)) {
@@ -465,12 +447,12 @@ var ViewportObserver = exports.default = /*#__PURE__*/function () {
465
447
  }, {
466
448
  key: "stop",
467
449
  value: function stop() {
468
- var _this$mutationObserve2, _this$intersectionObs10, _this$performanceObse2;
450
+ var _this$mutationObserve2, _this$intersectionObs1, _this$performanceObse2;
469
451
  if (!this.isStarted) {
470
452
  return;
471
453
  }
472
454
  (_this$mutationObserve2 = this.mutationObserver) === null || _this$mutationObserve2 === void 0 || _this$mutationObserve2.disconnect();
473
- (_this$intersectionObs10 = this.intersectionObserver) === null || _this$intersectionObs10 === void 0 || _this$intersectionObs10.disconnect();
455
+ (_this$intersectionObs1 = this.intersectionObserver) === null || _this$intersectionObs1 === void 0 || _this$intersectionObs1.disconnect();
474
456
  (_this$performanceObse2 = this.performanceObserver) === null || _this$performanceObse2 === void 0 || _this$performanceObse2.disconnect();
475
457
  this.isStarted = false;
476
458
  // Clean up caches when stopping
@@ -1,15 +1,23 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
2
  import coinflip from '../coinflip';
3
- import { getConfig, getExtraInteractionRate } from '../config';
4
- import { getMoreAccuratePageVisibilityUpToTTAI, optimizeHoldInfo } from '../create-payload';
5
- import { buildSegmentTree, getOldSegmentsLabelStack, sanitizeUfoName } from '../create-payload/common/utils';
3
+ import { DEFAULT_TTVC_REVISION, getConfig, getExtraInteractionRate, getMostRecentVCRevision } from '../config';
4
+ import { buildSegmentTree, getOldSegmentsLabelStack, optimizeLabelStack, sanitizeUfoName } from '../create-payload/common/utils';
5
+ import { getMoreAccuratePageVisibilityUpToTTAI } from '../create-payload/utils/get-more-accurate-page-visibility-up-to-ttai';
6
6
  import getPageVisibilityUpToTTAI from '../create-payload/utils/get-page-visibility-up-to-ttai';
7
7
  import getPayloadSize from '../create-payload/utils/get-payload-size';
8
8
  import { getReactUFOPayloadVersion } from '../create-payload/utils/get-react-ufo-payload-version';
9
9
  import getTTAI from '../create-payload/utils/get-ttai';
10
10
  import getVCMetrics from '../create-payload/utils/get-vc-metrics';
11
+ import { optimizeApdex } from '../create-payload/utils/optimize-apdex';
12
+ import { optimizeCustomTimings } from '../create-payload/utils/optimize-custom-timings';
13
+ import { optimizeHoldInfo } from '../create-payload/utils/optimize-hold-info';
14
+ import { optimizeMarks } from '../create-payload/utils/optimize-marks';
15
+ import { optimizeReactProfilerTimings } from '../create-payload/utils/optimize-react-profiler-timings';
16
+ import { optimizeRequestInfo } from '../create-payload/utils/optimize-request-info';
17
+ import { optimizeSpans } from '../create-payload/utils/optimize-spans';
18
+ import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
11
19
  async function createInteractionExtraLogPayload(interactionId, interaction) {
12
- var _getTTAI, _interaction$hold3pIn, _window$location;
20
+ var _getTTAI, _getMostRecentVCRevis, _window$location;
13
21
  const config = getConfig();
14
22
  if (!config) {
15
23
  throw Error('UFO Configuration not provided');
@@ -42,9 +50,49 @@ async function createInteractionExtraLogPayload(interactionId, interaction) {
42
50
  const moreAccuratePageVisibilityAtTTAI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTAI(interaction) : null;
43
51
  const extraTTAI = (_getTTAI = getTTAI(interaction)) !== null && _getTTAI !== void 0 ? _getTTAI : undefined;
44
52
  const newUFOName = sanitizeUfoName(ufoName);
53
+ const mostRecentVCRevision = (_getMostRecentVCRevis = getMostRecentVCRevision(newUFOName)) !== null && _getMostRecentVCRevis !== void 0 ? _getMostRecentVCRevis : DEFAULT_TTVC_REVISION;
45
54
  const finalVCMetrics = await getVCMetrics(interaction, true);
46
- const holdInfo = optimizeHoldInfo((_interaction$hold3pIn = interaction.hold3pInfo) !== null && _interaction$hold3pIn !== void 0 ? _interaction$hold3pIn : [], start, getReactUFOPayloadVersion(interaction.type));
47
- const segments3p = !fg('platform_ufo_remove_deprecated_config_fields') && config.killswitchNestedSegments ? [] : knownSegments.filter(knownSegment => knownSegment.labelStack.some(entry => 'type' in entry && entry.type === 'third-party'));
55
+
56
+ // Helper function to check if labelStack contains third-party type
57
+ const isThirdParty = labelStack => {
58
+ var _labelStack$some;
59
+ return (_labelStack$some = labelStack === null || labelStack === void 0 ? void 0 : labelStack.some(entry => 'type' in entry && entry.type === 'third-party')) !== null && _labelStack$some !== void 0 ? _labelStack$some : false;
60
+ };
61
+
62
+ // Pre-filter 3p data
63
+ const filteredData = {
64
+ errors: interaction.errors.filter(error => isThirdParty(error.labelStack)),
65
+ spans: [...interaction.spans, ...atlaskitInteractionSpans].filter(span => isThirdParty(span.labelStack)),
66
+ requestInfo: interaction.requestInfo.filter(req => isThirdParty(req.labelStack)),
67
+ customTimings: interaction.customTimings.filter(timing => isThirdParty(timing.labelStack)),
68
+ apdex: interaction.apdex.filter(apdex => isThirdParty(apdex.labelStack)),
69
+ reactProfilerTimings: interaction.reactProfilerTimings.filter(timing => isThirdParty(timing.labelStack)),
70
+ customData: interaction.customData.filter(data => isThirdParty(data.labelStack)),
71
+ segments: knownSegments.filter(segment => isThirdParty(segment.labelStack)),
72
+ marks: interaction.marks.filter(mark => isThirdParty(mark.labelStack))
73
+ };
74
+ // Clear atlaskit spans after filtering
75
+ atlaskitInteractionSpans.length = 0;
76
+
77
+ // Detailed payload
78
+ const getDetailedInteractionMetrics = () => {
79
+ var _interaction$hold3pIn;
80
+ return {
81
+ errors: filteredData.errors.map(({
82
+ labelStack,
83
+ ...others
84
+ }) => ({
85
+ ...others,
86
+ labelStack: labelStack && optimizeLabelStack(labelStack, getReactUFOPayloadVersion(interaction.type))
87
+ })),
88
+ holdActive: interaction.hold3pActive ? [...interaction.hold3pActive.values()] : [],
89
+ holdInfo: optimizeHoldInfo((_interaction$hold3pIn = interaction.hold3pInfo) !== null && _interaction$hold3pIn !== void 0 ? _interaction$hold3pIn : [], start, getReactUFOPayloadVersion(interaction.type)),
90
+ spans: optimizeSpans(filteredData.spans, start, getReactUFOPayloadVersion(interaction.type)),
91
+ requestInfo: optimizeRequestInfo(filteredData.requestInfo, start, getReactUFOPayloadVersion(interaction.type)),
92
+ customTimings: optimizeCustomTimings(filteredData.customTimings, start)
93
+ };
94
+ };
95
+ const segments3p = !fg('platform_ufo_remove_deprecated_config_fields') && config.killswitchNestedSegments ? [] : filteredData.segments;
48
96
  const segmentTree = getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? buildSegmentTree(segments3p.map(segment => segment.labelStack)) : {};
49
97
  const payload = {
50
98
  actionSubject: 'experience',
@@ -85,9 +133,14 @@ async function createInteractionExtraLogPayload(interactionId, interaction) {
85
133
  start: Math.round(start),
86
134
  'metric:ttai:3p': extraTTAI,
87
135
  ...finalVCMetrics,
88
- holdInfo,
89
- segments: getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? segmentTree : getOldSegmentsLabelStack(segments3p, interaction.type)
90
- }
136
+ segments: getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? segmentTree : getOldSegmentsLabelStack(segments3p, interaction.type),
137
+ marks: optimizeMarks(filteredData.marks, getReactUFOPayloadVersion(interaction.type)),
138
+ apdex: optimizeApdex(filteredData.apdex, getReactUFOPayloadVersion(interaction.type)),
139
+ reactProfilerTimings: optimizeReactProfilerTimings(filteredData.reactProfilerTimings, start, getReactUFOPayloadVersion(interaction.type)),
140
+ customData: filteredData.customData,
141
+ ...getDetailedInteractionMetrics()
142
+ },
143
+ 'vc:effective:revision': mostRecentVCRevision
91
144
  }
92
145
  }
93
146
  };