@atlaskit/react-ufo 4.5.0 → 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 (26) hide show
  1. package/CHANGELOG.md +7 -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/es2019/create-interaction-extra-metrics-payload/index.js +14 -15
  9. package/dist/es2019/create-payload/index.js +1 -1
  10. package/dist/es2019/create-payload/utils/get-vc-metrics.js +4 -1
  11. package/dist/es2019/interaction-metrics/index.js +30 -36
  12. package/dist/es2019/interaction-metrics/interaction-extra-metrics.js +5 -0
  13. package/dist/es2019/interaction-metrics-init/index.js +7 -10
  14. package/dist/esm/create-interaction-extra-metrics-payload/index.js +32 -27
  15. package/dist/esm/create-payload/index.js +1 -1
  16. package/dist/esm/create-payload/utils/get-vc-metrics.js +4 -1
  17. package/dist/esm/interaction-metrics/index.js +29 -35
  18. package/dist/esm/interaction-metrics/interaction-extra-metrics.js +7 -0
  19. package/dist/esm/interaction-metrics-init/index.js +7 -10
  20. package/dist/types/create-interaction-extra-metrics-payload/index.d.ts +3 -4
  21. package/dist/types/create-payload/index.d.ts +2 -0
  22. package/dist/types/interaction-metrics/interaction-extra-metrics.d.ts +1 -0
  23. package/dist/types-ts4.5/create-interaction-extra-metrics-payload/index.d.ts +3 -4
  24. package/dist/types-ts4.5/create-payload/index.d.ts +2 -0
  25. package/dist/types-ts4.5/interaction-metrics/interaction-extra-metrics.d.ts +1 -0
  26. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/ufo-interaction-ignore
2
2
 
3
+ ## 4.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`b0a4a5983f4e8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b0a4a5983f4e8) -
8
+ Update extra metrics onComplete logic and modify its payload
9
+
3
10
  ## 4.5.0
4
11
 
5
12
  ### Minor Changes
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
10
12
  var _coinflip = _interopRequireDefault(require("../coinflip"));
11
13
  var _config = require("../config");
12
14
  var _createPayload = require("../create-payload");
@@ -16,13 +18,15 @@ var _getPayloadSize = _interopRequireDefault(require("../create-payload/utils/ge
16
18
  var _getReactUfoPayloadVersion = require("../create-payload/utils/get-react-ufo-payload-version");
17
19
  var _getTtai = _interopRequireDefault(require("../create-payload/utils/get-ttai"));
18
20
  var _getVcMetrics = _interopRequireDefault(require("../create-payload/utils/get-vc-metrics"));
21
+ 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; }
22
+ 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; }
19
23
  function createInteractionExtraLogPayload(_x, _x2) {
20
24
  return _createInteractionExtraLogPayload.apply(this, arguments);
21
25
  }
22
26
  function _createInteractionExtraLogPayload() {
23
27
  _createInteractionExtraLogPayload = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interactionId, interaction) {
24
- var _getTTAI, _finalVCMetrics$ufoV, _window$location;
25
- var config, end, start, ufoName, rate, type, abortReason, routeName, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, configRate, pageVisibilityAtTTAI, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTAI, extraTTAI, newUFOName, finalVCMetrics, ttvc, payload;
28
+ var _getTTAI, _interaction$hold3pIn, _window$location;
29
+ 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;
26
30
  return _regenerator.default.wrap(function _callee$(_context) {
27
31
  while (1) switch (_context.prev = _context.next) {
28
32
  case 0:
@@ -33,41 +37,40 @@ function _createInteractionExtraLogPayload() {
33
37
  }
34
38
  throw Error('UFO Configuration not provided');
35
39
  case 3:
36
- 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;
37
- configRate = (0, _config.getExtraInteractionRate)(ufoName, type);
40
+ 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;
41
+ sanitisedUfoName = (0, _utils.sanitizeUfoName)(ufoName);
42
+ configRate = (0, _config.getExtraInteractionRate)(sanitisedUfoName, type);
38
43
  if ((0, _coinflip.default)(configRate)) {
39
- _context.next = 7;
44
+ _context.next = 8;
40
45
  break;
41
46
  }
42
47
  return _context.abrupt("return", null);
43
- case 7:
48
+ case 8:
44
49
  pageVisibilityAtTTAI = (0, _getPageVisibilityUpToTtai.default)(interaction);
45
50
  isPageLoad = type === 'page_load' || type === 'transition';
46
51
  if (isPageLoad) {
47
- _context.next = 11;
52
+ _context.next = 12;
48
53
  break;
49
54
  }
50
55
  return _context.abrupt("return", null);
51
- case 11:
56
+ case 12:
52
57
  calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
53
58
  moreAccuratePageVisibilityAtTTAI = calculatePageVisibilityFromTheStartOfPageLoad ? (0, _createPayload.getMoreAccuratePageVisibilityUpToTTAI)(interaction) : null;
54
59
  extraTTAI = (_getTTAI = (0, _getTtai.default)(interaction)) !== null && _getTTAI !== void 0 ? _getTTAI : undefined;
55
60
  newUFOName = (0, _utils.sanitizeUfoName)(ufoName);
56
- _context.next = 17;
61
+ _context.next = 18;
57
62
  return (0, _getVcMetrics.default)(interaction, true);
58
- case 17:
63
+ case 18:
59
64
  finalVCMetrics = _context.sent;
60
- ttvc = (_finalVCMetrics$ufoV = finalVCMetrics['ufo:vc:rev']) === null || _finalVCMetrics$ufoV === void 0 ? void 0 : _finalVCMetrics$ufoV.map(function (revision) {
61
- if (revision['metric:vc90'] === null || revision.clean !== true) {
62
- return null;
63
- }
64
- return {
65
- revision: revision.revision,
66
- vc90: revision['metric:vc90']
67
- };
68
- }).filter(function (revision) {
69
- return revision != null;
65
+ holdInfo = (0, _createPayload.optimizeHoldInfo)((_interaction$hold3pIn = interaction.hold3pInfo) !== null && _interaction$hold3pIn !== void 0 ? _interaction$hold3pIn : [], start, (0, _getReactUfoPayloadVersion.getReactUFOPayloadVersion)(interaction.type));
66
+ segments3p = !(0, _platformFeatureFlags.fg)('platform_ufo_remove_deprecated_config_fields') && config.killswitchNestedSegments ? [] : knownSegments.filter(function (knownSegment) {
67
+ return knownSegment.labelStack.some(function (entry) {
68
+ return 'type' in entry && entry.type === 'third-party';
69
+ });
70
70
  });
71
+ segmentTree = (0, _getReactUfoPayloadVersion.getReactUFOPayloadVersion)(interaction.type) === '2.0.0' ? (0, _utils.buildSegmentTree)(segments3p.map(function (segment) {
72
+ return segment.labelStack;
73
+ })) : {};
71
74
  payload = {
72
75
  actionSubject: 'experience',
73
76
  action: 'measured',
@@ -88,7 +91,7 @@ function _createInteractionExtraLogPayload() {
88
91
  'event:region': config.region || 'unknown',
89
92
  'experience:key': 'custom.interaction-extra-metrics',
90
93
  'experience:name': newUFOName,
91
- interactionMetrics: {
94
+ interactionMetrics: _objectSpread(_objectSpread({
92
95
  namePrefix: config.namePrefix || '',
93
96
  segmentPrefix: config.segmentPrefix || '',
94
97
  interactionId: interactionId,
@@ -105,15 +108,17 @@ function _createInteractionExtraLogPayload() {
105
108
  // performance
106
109
  end: Math.round(end),
107
110
  start: Math.round(start),
108
- 'metric:ttai:3p': extraTTAI,
109
- ttvc: ttvc !== null && ttvc !== void 0 ? ttvc : undefined
110
- }
111
+ 'metric:ttai:3p': extraTTAI
112
+ }, finalVCMetrics), {}, {
113
+ holdInfo: holdInfo,
114
+ segments: (0, _getReactUfoPayloadVersion.getReactUFOPayloadVersion)(interaction.type) === '2.0.0' ? segmentTree : (0, _utils.getOldSegmentsLabelStack)(segments3p, interaction.type)
115
+ })
111
116
  }
112
117
  }
113
118
  };
114
119
  payload.attributes.properties['event:sizeInKb'] = (0, _getPayloadSize.default)(payload.attributes.properties);
115
120
  return _context.abrupt("return", payload);
116
- case 22:
121
+ case 25:
117
122
  case "end":
118
123
  return _context.stop();
119
124
  }
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.createExperimentalMetricsPayload = createExperimentalMetricsPayload;
9
9
  exports.createPayloads = createPayloads;
10
10
  exports.getMoreAccuratePageVisibilityUpToTTAI = getMoreAccuratePageVisibilityUpToTTAI;
11
+ exports.optimizeHoldInfo = optimizeHoldInfo;
11
12
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
13
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
14
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
@@ -108,7 +108,10 @@ function _getVCMetrics() {
108
108
  case 27:
109
109
  result = _context.sent;
110
110
  observer.stop(interaction.ufoName);
111
- _interactionMetrics.postInteractionLog.setLastInteractionFinishVCResult(result);
111
+ if (!include3p) {
112
+ // For Post Interaction, last interaction should be without 3p
113
+ _interactionMetrics.postInteractionLog.setLastInteractionFinishVCResult(result);
114
+ }
112
115
  mostRecentVCRevision = (0, _config.getMostRecentVCRevision)(interaction.ufoName);
113
116
  mostRecentVCRevisionPayload = result === null || result === void 0 || (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(function (_ref) {
114
117
  var revision = _ref.revision;
@@ -704,15 +704,14 @@ function finishInteraction(id, data) {
704
704
  postInteractionLog.stopVCObserver();
705
705
  }
706
706
  if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
707
- if (!data.hold3pActive || data.hold3pActive.size === 0) {
707
+ var _sanitisedUfoName = (0, _utils.sanitizeUfoName)(data.ufoName);
708
+ if (!(0, _coinflip.default)((0, _config.getExtraInteractionRate)(_sanitisedUfoName, data.type))) {
709
+ interactionExtraMetrics.stopAll(id);
710
+ } else if (!data.hold3pActive || data.hold3pActive.size === 0) {
708
711
  var _getConfig5;
709
712
  if (!((_getConfig5 = (0, _config.getConfig)()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
710
713
  remove(id);
711
714
  }
712
- var _sanitisedUfoName = (0, _utils.sanitizeUfoName)(data.ufoName);
713
- if (!(0, _coinflip.default)((0, _config.getExtraInteractionRate)(_sanitisedUfoName, data.type))) {
714
- interactionExtraMetrics.stopVCObserver();
715
- }
716
715
  }
717
716
  } else {
718
717
  var _getConfig6;
@@ -877,25 +876,29 @@ function tryComplete(interactionId, endTime) {
877
876
  if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
878
877
  var _interaction$hold3pAc;
879
878
  var noMoreActive3pHolds = ((_interaction$hold3pAc = interaction.hold3pActive) === null || _interaction$hold3pAc === void 0 ? void 0 : _interaction$hold3pAc.size) === 0 || interaction.hold3pActive === undefined;
880
- if (noMoreActiveHolds) {
879
+ if (noMoreActiveHolds && interactionExtraMetrics.finishedInteractionId !== interactionId) {
880
+ // If it's not waiting for extra metrics to complete, finish the interaction as normal
881
881
  if (!activeSubmitted) {
882
+ var _getConfig1;
882
883
  finishInteraction(interactionId, interaction, endTime);
883
- interactionExtraMetrics.updateFinishedInteractionId(interactionId);
884
+ if ((_getConfig1 = (0, _config.getConfig)()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.extraInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
885
+ interactionExtraMetrics.updateFinishedInteractionId(interactionId);
886
+ }
884
887
  activeSubmitted = true;
885
888
  }
886
889
  if (noMoreExpHolds) {
887
- var _getConfig1;
888
- if ((_getConfig1 = (0, _config.getConfig)()) !== null && _getConfig1 !== void 0 && (_getConfig1 = _getConfig1.experimentalInteractionMetrics) !== null && _getConfig1 !== void 0 && _getConfig1.enabled) {
890
+ var _getConfig10;
891
+ if ((_getConfig10 = (0, _config.getConfig)()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
889
892
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction, endTime);
890
893
  }
891
894
  postInteraction();
892
895
  }
893
- if (noMoreActive3pHolds) {
894
- var data = _objectSpread(_objectSpread({}, interaction), {}, {
895
- end: endTime
896
- });
897
- interactionExtraMetrics.onInteractionComplete(interactionId, data);
898
- }
896
+ }
897
+ if (noMoreActiveHolds && noMoreActive3pHolds) {
898
+ var data = _objectSpread(_objectSpread({}, interaction), {}, {
899
+ end: endTime
900
+ });
901
+ interactionExtraMetrics.onInteractionComplete(interactionId, data);
899
902
  }
900
903
  } else {
901
904
  if (noMoreActiveHolds) {
@@ -904,8 +907,8 @@ function tryComplete(interactionId, endTime) {
904
907
  activeSubmitted = true;
905
908
  }
906
909
  if (noMoreExpHolds) {
907
- var _getConfig10;
908
- if ((_getConfig10 = (0, _config.getConfig)()) !== null && _getConfig10 !== void 0 && (_getConfig10 = _getConfig10.experimentalInteractionMetrics) !== null && _getConfig10 !== void 0 && _getConfig10.enabled) {
910
+ var _getConfig11;
911
+ if ((_getConfig11 = (0, _config.getConfig)()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.experimentalInteractionMetrics) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
909
912
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction, endTime);
910
913
  }
911
914
  postInteraction();
@@ -938,9 +941,7 @@ function abort(interactionId, abortReason) {
938
941
  postInteractionLog.reset();
939
942
  postInteractionLog.stopVCObserver();
940
943
  if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
941
- interactionExtraMetrics.stopVCObserver();
942
- interactionExtraMetrics.reset();
943
- remove(interactionId);
944
+ interactionExtraMetrics.stopAll(interactionId);
944
945
  }
945
946
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
946
947
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
@@ -968,9 +969,7 @@ function abortByNewInteraction(interactionId, interactionName) {
968
969
  postInteractionLog.reset();
969
970
  postInteractionLog.stopVCObserver();
970
971
  if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
971
- interactionExtraMetrics.stopVCObserver();
972
- interactionExtraMetrics.reset();
973
- remove(interactionId);
972
+ interactionExtraMetrics.stopAll(interactionId);
974
973
  }
975
974
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
976
975
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
@@ -1002,9 +1001,7 @@ function abortAll(abortReason, abortedByInteractionName) {
1002
1001
  postInteractionLog.reset();
1003
1002
  postInteractionLog.stopVCObserver();
1004
1003
  if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
1005
- interactionExtraMetrics.stopVCObserver();
1006
- interactionExtraMetrics.reset();
1007
- remove(interactionId);
1004
+ interactionExtraMetrics.stopAll(interactionId);
1008
1005
  }
1009
1006
  if ((0, _coinflip.default)((0, _config.getExperimentalInteractionRate)(interaction.ufoName, interaction.type))) {
1010
1007
  (0, _createExperimentalInteractionMetricsPayload.onExperimentalInteractionComplete)(interactionId, interaction);
@@ -1129,7 +1126,7 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
1129
1126
  addHoldByID(interactionId, [], ufoName, ufoName, true);
1130
1127
  }
1131
1128
  if (type === 'transition' || type === 'page_load') {
1132
- var _getConfig11;
1129
+ var _getConfig12, _config$extraInteract;
1133
1130
  // Use per-interaction VC observer if available, otherwise fall back to global
1134
1131
  var observer = vcObserver;
1135
1132
  if (observer) {
@@ -1140,7 +1137,7 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
1140
1137
  }
1141
1138
  // Start post interaction observer for all if config is enabled
1142
1139
  // in case ufoName is updated at later time
1143
- if ((_getConfig11 = (0, _config.getConfig)()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
1140
+ if ((_getConfig12 = (0, _config.getConfig)()) !== null && _getConfig12 !== void 0 && (_getConfig12 = _getConfig12.postInteractionLog) !== null && _getConfig12 !== void 0 && _getConfig12.enabled) {
1144
1141
  postInteractionLog.startVCObserver({
1145
1142
  startTime: startTime
1146
1143
  });
@@ -1150,13 +1147,10 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
1150
1147
  startTime: startTime
1151
1148
  });
1152
1149
  }
1153
- if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
1154
- var _config$extraInteract;
1155
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
1156
- interactionExtraMetrics.startVCObserver({
1157
- startTime: startTime
1158
- }, interactionId);
1159
- }
1150
+ 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')) {
1151
+ interactionExtraMetrics.startVCObserver({
1152
+ startTime: startTime
1153
+ }, interactionId);
1160
1154
  }
1161
1155
  }
1162
1156
  if (type === 'press' && (0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_press_interactions')) {
@@ -85,5 +85,12 @@ var InteractionExtraMetrics = exports.default = /*#__PURE__*/function () {
85
85
  value: function reset() {
86
86
  this.finishedInteractionId = null;
87
87
  }
88
+ }, {
89
+ key: "stopAll",
90
+ value: function stopAll(id) {
91
+ this.stopVCObserver();
92
+ (0, _index.remove)(id);
93
+ this.reset();
94
+ }
88
95
  }]);
89
96
  }();
@@ -121,7 +121,7 @@ function init(analyticsWebClientAsync, config) {
121
121
  (0, _machineUtilisation.initialiseMemoryObserver)();
122
122
  (0, _config.setUFOConfig)(config);
123
123
  if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
124
- var _config$experimentalI;
124
+ var _config$experimentalI, _config$extraInteract;
125
125
  var vcOptions = {
126
126
  heatmapSize: config.vc.heatmapSize,
127
127
  oldDomUpdates: config.vc.oldDomUpdates,
@@ -135,11 +135,8 @@ function init(analyticsWebClientAsync, config) {
135
135
  startTime: 0
136
136
  });
137
137
  }
138
- if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
139
- var _config$extraInteract;
140
- if (config !== null && config !== void 0 && (_config$extraInteract = config.extraInteractionMetrics) !== null && _config$extraInteract !== void 0 && _config$extraInteract.enabled) {
141
- _interactionMetrics.interactionExtraMetrics.initializeVCObserver(vcOptions);
142
- }
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')) {
139
+ _interactionMetrics.interactionExtraMetrics.initializeVCObserver(vcOptions);
143
140
  }
144
141
  }
145
142
  (0, _hiddenTiming.setupHiddenTimingCapture)();
@@ -167,7 +164,7 @@ function init(analyticsWebClientAsync, config) {
167
164
  createInteractionExtraMetricsPayloadPackage = _ref3[3];
168
165
  if (awc.getAnalyticsWebClientPromise) {
169
166
  awc.getAnalyticsWebClientPromise().then(function (client) {
170
- var _config$experimentalI2, _config$postInteracti;
167
+ var _config$experimentalI2, _config$postInteracti, _config$extraInteract2;
171
168
  var instance = client.getInstance();
172
169
  sinkInteraction(instance, payloadPackage);
173
170
  if (config !== null && config !== void 0 && (_config$experimentalI2 = config.experimentalInteractionMetrics) !== null && _config$experimentalI2 !== void 0 && _config$experimentalI2.enabled) {
@@ -176,12 +173,12 @@ function init(analyticsWebClientAsync, config) {
176
173
  if ((_config$postInteracti = config.postInteractionLog) !== null && _config$postInteracti !== void 0 && _config$postInteracti.enabled) {
177
174
  sinkPostInteractionLog(instance, createPostInteractionLogPayloadPackage.default);
178
175
  }
179
- if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
176
+ if (config !== null && config !== void 0 && (_config$extraInteract2 = config.extraInteractionMetrics) !== null && _config$extraInteract2 !== void 0 && _config$extraInteract2.enabled && (0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
180
177
  sinkInteractionExtraMetrics(instance, createInteractionExtraMetricsPayloadPackage.default);
181
178
  }
182
179
  });
183
180
  } else if (awc.sendOperationalEvent) {
184
- var _config$experimentalI3, _config$postInteracti2;
181
+ var _config$experimentalI3, _config$postInteracti2, _config$extraInteract3;
185
182
  sinkInteraction(awc, payloadPackage);
186
183
  if (config !== null && config !== void 0 && (_config$experimentalI3 = config.experimentalInteractionMetrics) !== null && _config$experimentalI3 !== void 0 && _config$experimentalI3.enabled) {
187
184
  sinkExperimentalInteractionMetrics(awc, payloadPackage);
@@ -189,7 +186,7 @@ function init(analyticsWebClientAsync, config) {
189
186
  if ((_config$postInteracti2 = config.postInteractionLog) !== null && _config$postInteracti2 !== void 0 && _config$postInteracti2.enabled) {
190
187
  sinkPostInteractionLog(awc, createPostInteractionLogPayloadPackage.default);
191
188
  }
192
- if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
189
+ if (config !== null && config !== void 0 && (_config$extraInteract3 = config.extraInteractionMetrics) !== null && _config$extraInteract3 !== void 0 && _config$extraInteract3.enabled && (0, _platformFeatureFlags.fg)('platform_ufo_enable_ttai_with_3p')) {
193
190
  sinkInteractionExtraMetrics(awc, createInteractionExtraMetricsPayloadPackage.default);
194
191
  }
195
192
  }
@@ -1,14 +1,15 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
1
2
  import coinflip from '../coinflip';
2
3
  import { getConfig, getExtraInteractionRate } from '../config';
3
- import { getMoreAccuratePageVisibilityUpToTTAI } from '../create-payload';
4
- import { sanitizeUfoName } from '../create-payload/common/utils';
4
+ import { getMoreAccuratePageVisibilityUpToTTAI, optimizeHoldInfo } from '../create-payload';
5
+ import { buildSegmentTree, getOldSegmentsLabelStack, sanitizeUfoName } from '../create-payload/common/utils';
5
6
  import getPageVisibilityUpToTTAI from '../create-payload/utils/get-page-visibility-up-to-ttai';
6
7
  import getPayloadSize from '../create-payload/utils/get-payload-size';
7
8
  import { getReactUFOPayloadVersion } from '../create-payload/utils/get-react-ufo-payload-version';
8
9
  import getTTAI from '../create-payload/utils/get-ttai';
9
10
  import getVCMetrics from '../create-payload/utils/get-vc-metrics';
10
11
  async function createInteractionExtraLogPayload(interactionId, interaction) {
11
- var _getTTAI, _finalVCMetrics$ufoV, _window$location;
12
+ var _getTTAI, _interaction$hold3pIn, _window$location;
12
13
  const config = getConfig();
13
14
  if (!config) {
14
15
  throw Error('UFO Configuration not provided');
@@ -23,9 +24,11 @@ async function createInteractionExtraLogPayload(interactionId, interaction) {
23
24
  routeName,
24
25
  previousInteractionName,
25
26
  isPreviousInteractionAborted,
26
- abortedByInteractionName
27
+ abortedByInteractionName,
28
+ knownSegments
27
29
  } = interaction;
28
- const configRate = getExtraInteractionRate(ufoName, type);
30
+ const sanitisedUfoName = sanitizeUfoName(ufoName);
31
+ const configRate = getExtraInteractionRate(sanitisedUfoName, type);
29
32
  if (!coinflip(configRate)) {
30
33
  return null;
31
34
  }
@@ -40,15 +43,9 @@ async function createInteractionExtraLogPayload(interactionId, interaction) {
40
43
  const extraTTAI = (_getTTAI = getTTAI(interaction)) !== null && _getTTAI !== void 0 ? _getTTAI : undefined;
41
44
  const newUFOName = sanitizeUfoName(ufoName);
42
45
  const finalVCMetrics = await getVCMetrics(interaction, true);
43
- const ttvc = (_finalVCMetrics$ufoV = finalVCMetrics['ufo:vc:rev']) === null || _finalVCMetrics$ufoV === void 0 ? void 0 : _finalVCMetrics$ufoV.map(revision => {
44
- if (revision['metric:vc90'] === null || revision.clean !== true) {
45
- return null;
46
- }
47
- return {
48
- revision: revision.revision,
49
- vc90: revision['metric:vc90']
50
- };
51
- }).filter(revision => revision != null);
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'));
48
+ const segmentTree = getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? buildSegmentTree(segments3p.map(segment => segment.labelStack)) : {};
52
49
  const payload = {
53
50
  actionSubject: 'experience',
54
51
  action: 'measured',
@@ -87,7 +84,9 @@ async function createInteractionExtraLogPayload(interactionId, interaction) {
87
84
  end: Math.round(end),
88
85
  start: Math.round(start),
89
86
  'metric:ttai:3p': extraTTAI,
90
- ttvc: ttvc !== null && ttvc !== void 0 ? ttvc : undefined
87
+ ...finalVCMetrics,
88
+ holdInfo,
89
+ segments: getReactUFOPayloadVersion(interaction.type) === '2.0.0' ? segmentTree : getOldSegmentsLabelStack(segments3p, interaction.type)
91
90
  }
92
91
  }
93
92
  }
@@ -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
  const holdInfoMap = holdInfo.reduce((result, hold) => {
360
360
  const {
361
361
  labelStack,
@@ -54,7 +54,10 @@ async function getVCMetrics(interaction, include3p = false) {
54
54
  include3p
55
55
  });
56
56
  observer.stop(interaction.ufoName);
57
- postInteractionLog.setLastInteractionFinishVCResult(result);
57
+ if (!include3p) {
58
+ // For Post Interaction, last interaction should be without 3p
59
+ postInteractionLog.setLastInteractionFinishVCResult(result);
60
+ }
58
61
  const mostRecentVCRevision = getMostRecentVCRevision(interaction.ufoName);
59
62
  const mostRecentVCRevisionPayload = result === null || result === void 0 ? void 0 : (_result$ufoVcRev = result['ufo:vc:rev']) === null || _result$ufoVcRev === void 0 ? void 0 : _result$ufoVcRev.find(({
60
63
  revision
@@ -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
  }
@@ -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
  }
@@ -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
  };
@@ -3,7 +3,9 @@ import { type ResourceTiming } from '../common/react-ufo-payload-schema';
3
3
  import * as ssr from '../ssr';
4
4
  import type { OptimizedLabelStack } from './common/types';
5
5
  import type { CriticalMetricsPayload } from './critical-metrics-payload/types';
6
+ import { getReactUFOPayloadVersion } from './utils/get-react-ufo-payload-version';
6
7
  export declare function getMoreAccuratePageVisibilityUpToTTAI(interaction: InteractionMetrics): import("../common/react-ufo-payload-schema").PageVisibility;
8
+ export declare function optimizeHoldInfo(holdInfo: InteractionMetrics['holdInfo'], interactionStart: number, reactUFOVersion: ReturnType<typeof getReactUFOPayloadVersion>): any[];
7
9
  export declare function createPayloads(interactionId: string, interaction: InteractionMetrics): Promise<(CriticalMetricsPayload | {
8
10
  actionSubject: string;
9
11
  action: string;
@@ -14,4 +14,5 @@ export default class InteractionExtraMetrics {
14
14
  sinkHandler(fn: (interactionId: string, interaction: InteractionMetrics) => void | Promise<void>): void;
15
15
  onInteractionComplete(id: string, data: InteractionMetrics): void;
16
16
  reset(): void;
17
+ stopAll(id: string): void;
17
18
  }
@@ -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
  };
@@ -3,7 +3,9 @@ import { type ResourceTiming } from '../common/react-ufo-payload-schema';
3
3
  import * as ssr from '../ssr';
4
4
  import type { OptimizedLabelStack } from './common/types';
5
5
  import type { CriticalMetricsPayload } from './critical-metrics-payload/types';
6
+ import { getReactUFOPayloadVersion } from './utils/get-react-ufo-payload-version';
6
7
  export declare function getMoreAccuratePageVisibilityUpToTTAI(interaction: InteractionMetrics): import("../common/react-ufo-payload-schema").PageVisibility;
8
+ export declare function optimizeHoldInfo(holdInfo: InteractionMetrics['holdInfo'], interactionStart: number, reactUFOVersion: ReturnType<typeof getReactUFOPayloadVersion>): any[];
7
9
  export declare function createPayloads(interactionId: string, interaction: InteractionMetrics): Promise<(CriticalMetricsPayload | {
8
10
  actionSubject: string;
9
11
  action: string;
@@ -14,4 +14,5 @@ export default class InteractionExtraMetrics {
14
14
  sinkHandler(fn: (interactionId: string, interaction: InteractionMetrics) => void | Promise<void>): void;
15
15
  onInteractionComplete(id: string, data: InteractionMetrics): void;
16
16
  reset(): void;
17
+ stopAll(id: string): void;
17
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/react-ufo",
3
- "version": "4.5.0",
3
+ "version": "4.5.1",
4
4
  "description": "Parts of React UFO that are publicly available",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",