@atlaskit/react-ufo 3.3.1 → 3.3.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 (25) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cjs/create-payload/index.js +63 -148
  3. package/dist/cjs/create-payload/utils/get-interaction-status.js +37 -0
  4. package/dist/cjs/create-payload/utils/get-page-visibility-up-to-ttai.js +12 -0
  5. package/dist/cjs/create-payload/utils/get-ssr-done-time-value.js +14 -0
  6. package/dist/cjs/create-payload/utils/get-vc-metrics.js +96 -0
  7. package/dist/es2019/create-payload/index.js +11 -71
  8. package/dist/es2019/create-payload/utils/get-interaction-status.js +31 -0
  9. package/dist/es2019/create-payload/utils/get-page-visibility-up-to-ttai.js +8 -0
  10. package/dist/es2019/create-payload/utils/get-ssr-done-time-value.js +5 -0
  11. package/dist/es2019/create-payload/utils/get-vc-metrics.js +53 -0
  12. package/dist/esm/create-payload/index.js +56 -141
  13. package/dist/esm/create-payload/utils/get-interaction-status.js +31 -0
  14. package/dist/esm/create-payload/utils/get-page-visibility-up-to-ttai.js +6 -0
  15. package/dist/esm/create-payload/utils/get-ssr-done-time-value.js +5 -0
  16. package/dist/esm/create-payload/utils/get-vc-metrics.js +89 -0
  17. package/dist/types/create-payload/utils/get-interaction-status.d.ts +27 -0
  18. package/dist/types/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -0
  19. package/dist/types/create-payload/utils/get-ssr-done-time-value.d.ts +2 -0
  20. package/dist/types/create-payload/utils/get-vc-metrics.d.ts +5 -0
  21. package/dist/types-ts4.5/create-payload/utils/get-interaction-status.d.ts +27 -0
  22. package/dist/types-ts4.5/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -0
  23. package/dist/types-ts4.5/create-payload/utils/get-ssr-done-time-value.d.ts +2 -0
  24. package/dist/types-ts4.5/create-payload/utils/get-vc-metrics.d.ts +5 -0
  25. package/package.json +4 -1
@@ -11,12 +11,15 @@ import { getBm3Timings } from '../custom-timings';
11
11
  import { getGlobalErrorCount } from '../global-error-handler';
12
12
  import { getPageVisibilityState } from '../hidden-timing';
13
13
  import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
14
- import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
14
+ import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
15
15
  import * as resourceTiming from '../resource-timing';
16
16
  import { roundEpsilon } from '../round-number';
17
17
  import * as ssr from '../ssr';
18
- import { getVCObserver } from '../vc';
19
18
  import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
19
+ import getInteractionStatus from './utils/get-interaction-status';
20
+ import getPageVisibilityUpToTTAI from './utils/get-page-visibility-up-to-ttai';
21
+ import getSSRDoneTimeValue from './utils/get-ssr-done-time-value';
22
+ import getVCMetrics from './utils/get-vc-metrics';
20
23
  function getUfoNameOverride(interaction) {
21
24
  const {
22
25
  ufoName,
@@ -65,13 +68,6 @@ const getPageVisibilityUpToTTI = interaction => {
65
68
  const bm3EndTimeOrInteractionEndTime = getBm3EndTimeOrFallbackValue(interaction);
66
69
  return getPageVisibilityState(start, bm3EndTimeOrInteractionEndTime);
67
70
  };
68
- const getPageVisibilityUpToTTAI = interaction => {
69
- const {
70
- start,
71
- end
72
- } = interaction;
73
- return getPageVisibilityState(start, end);
74
- };
75
71
  const getVisibilityStateFromPerformance = stop => {
76
72
  try {
77
73
  const results = performance.getEntriesByType('visibility-state');
@@ -126,15 +122,6 @@ const getMoreAccuratePageVisibilityUpToTTAI = interaction => {
126
122
  }
127
123
  return old;
128
124
  };
129
- const getInteractionStatus = interaction => {
130
- const originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
131
- const hasBm3TTI = interaction.apdex.length > 0;
132
- const overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
133
- return {
134
- originalInteractionStatus,
135
- overrideStatus
136
- };
137
- };
138
125
  const getResourceTimings = (start, end) => {
139
126
  var _resourceTiming$getRe;
140
127
  return (_resourceTiming$getRe = resourceTiming.getResourceTimings(start, end)) !== null && _resourceTiming$getRe !== void 0 ? _resourceTiming$getRe : undefined;
@@ -165,49 +152,6 @@ const getTTAI = interaction => {
165
152
  const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
166
153
  return !interaction.abortReason && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
167
154
  };
168
- const getVCMetrics = async interaction => {
169
- var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _interaction$apdex$, _config$experimentalI;
170
- const config = getConfig();
171
- if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
172
- return {};
173
- }
174
- if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
175
- return {};
176
- }
177
- const isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 ? void 0 : (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
178
- const ssr = interaction.type === 'page_load' && isSSREnabled ? {
179
- ssr: getSSRDoneTimeValue(config)
180
- } : null;
181
- postInteractionLog.setVCObserverSSRConfig(ssr);
182
- const tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime;
183
- const prefix = 'ufo';
184
- const interactionStatus = getInteractionStatus(interaction);
185
- const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
186
- const result = await getVCObserver().getVCResult({
187
- start: interaction.start,
188
- stop: interaction.end,
189
- tti,
190
- prefix,
191
- vc: interaction.vc,
192
- isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED',
193
- ...ssr
194
- });
195
- if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
196
- getVCObserver().stop();
197
- }
198
- postInteractionLog.setLastInteractionFinishVCResult(result);
199
- const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
200
- if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
201
- return result;
202
- }
203
- if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
204
- return result;
205
- }
206
- return {
207
- ...result,
208
- 'metric:vc90': VC['90']
209
- };
210
- };
211
155
  const getNavigationMetrics = type => {
212
156
  if (type !== 'page_load') {
213
157
  return {};
@@ -255,7 +199,7 @@ const getNavigationMetrics = type => {
255
199
  };
256
200
  };
257
201
  const getPPSMetrics = interaction => {
258
- var _interaction$apdex2, _interaction$apdex2$;
202
+ var _interaction$apdex, _interaction$apdex$;
259
203
  const {
260
204
  start,
261
205
  end
@@ -263,7 +207,7 @@ const getPPSMetrics = interaction => {
263
207
  const config = getConfig();
264
208
  const interactionStatus = getInteractionStatus(interaction);
265
209
  const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
266
- const tti = (_interaction$apdex2 = interaction.apdex) === null || _interaction$apdex2 === void 0 ? void 0 : (_interaction$apdex2$ = _interaction$apdex2[0]) === null || _interaction$apdex2$ === void 0 ? void 0 : _interaction$apdex2$.stopTime;
210
+ const tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime;
267
211
  const ttai = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
268
212
  const PPSMetricsAtTTI = tti !== undefined ? getLighthouseMetrics({
269
213
  start,
@@ -635,10 +579,6 @@ function getBm3TrackerTimings(interaction) {
635
579
  legacyMetrics
636
580
  };
637
581
  }
638
- function getSSRDoneTimeValue(config) {
639
- var _config$ssr, _config$ssr2;
640
- return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 ? void 0 : (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
641
- }
642
582
  function getPayloadSize(payload) {
643
583
  return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
644
584
  }
@@ -725,7 +665,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
725
665
  } : {};
726
666
  // Page Load
727
667
  const getPageLoadInteractionMetrics = () => {
728
- var _config$ssr3;
668
+ var _config$ssr;
729
669
  if (!isPageLoad) {
730
670
  return {};
731
671
  }
@@ -737,7 +677,7 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
737
677
  return {
738
678
  ...SSRDoneTime,
739
679
  isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
740
- isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr3 = config.ssr) !== null && _config$ssr3 !== void 0 && _config$ssr3.getSSRDoneTime)
680
+ isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
741
681
  };
742
682
  };
743
683
  // Detailed payload. Page visibility = visible
@@ -767,14 +707,14 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
767
707
  };
768
708
  // Page load & detailed payload
769
709
  const getPageLoadDetailedInteractionMetrics = () => {
770
- var _config$ssr4;
710
+ var _config$ssr2;
771
711
  if (!isPageLoad || !isDetailedPayload) {
772
712
  return {};
773
713
  }
774
714
  const config = getConfig();
775
715
  return {
776
716
  initialPageLoadExtraTimings: objectToArray(initialPageLoadExtraTiming.getTimings()),
777
- SSRTimings: config !== null && config !== void 0 && (_config$ssr4 = config.ssr) !== null && _config$ssr4 !== void 0 && _config$ssr4.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
717
+ SSRTimings: config !== null && config !== void 0 && (_config$ssr2 = config.ssr) !== null && _config$ssr2 !== void 0 && _config$ssr2.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
778
718
  };
779
719
  };
780
720
  if (experimental) {
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Determines the interaction status based on abort reason and BM3 TTI presence.
3
+ *
4
+ * @param {InteractionMetrics} interaction - The interaction metrics object containing abort reason and apdex data
5
+ * @returns {{
6
+ * originalInteractionStatus: 'ABORTED' | 'SUCCEEDED',
7
+ * overrideStatus: 'ABORTED' | 'SUCCEEDED'
8
+ * }} An object containing both the original and override status
9
+ *
10
+ * @description
11
+ * This function evaluates the interaction status in two ways:
12
+ * 1. originalInteractionStatus: Based on whether there's an abort reason
13
+ * 2. overrideStatus: Based on the presence of BM3 TTI (apdex data)
14
+ *
15
+ * @example
16
+ * const interaction = {
17
+ * abortReason: null,
18
+ * apdex: [1, 2, 3]
19
+ * };
20
+ * const result = getInteractionStatus(interaction);
21
+ * // Returns: { originalInteractionStatus: 'SUCCEEDED', overrideStatus: 'SUCCEEDED' }
22
+ */
23
+ export default function getInteractionStatus(interaction) {
24
+ const originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
25
+ const hasBm3TTI = interaction.apdex.length > 0;
26
+ const overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
27
+ return {
28
+ originalInteractionStatus,
29
+ overrideStatus
30
+ };
31
+ }
@@ -0,0 +1,8 @@
1
+ import { getPageVisibilityState } from '../../hidden-timing';
2
+ export default function getPageVisibilityUpToTTAI(interaction) {
3
+ const {
4
+ start,
5
+ end
6
+ } = interaction;
7
+ return getPageVisibilityState(start, end);
8
+ }
@@ -0,0 +1,5 @@
1
+ import * as ssr from '../../ssr';
2
+ export default function getSSRDoneTimeValue(config) {
3
+ var _config$ssr, _config$ssr2;
4
+ return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 ? void 0 : (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
5
+ }
@@ -0,0 +1,53 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { getConfig } from '../../config';
3
+ import { postInteractionLog } from '../../interaction-metrics';
4
+ import { getVCObserver } from '../../vc';
5
+ import getInteractionStatus from './get-interaction-status';
6
+ import getPageVisibilityUpToTTAI from './get-page-visibility-up-to-ttai';
7
+ import getSSRDoneTimeValue from './get-ssr-done-time-value';
8
+ export default async function getVCMetrics(interaction) {
9
+ var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _interaction$apdex$, _config$experimentalI;
10
+ const config = getConfig();
11
+ if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
12
+ return {};
13
+ }
14
+ if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
15
+ return {};
16
+ }
17
+ const interactionStatus = getInteractionStatus(interaction);
18
+ const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
19
+ if ((interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') && fg('platform_ufo_no_vc_on_aborted')) {
20
+ return {};
21
+ }
22
+ const isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 ? void 0 : (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
23
+ const ssr = interaction.type === 'page_load' && isSSREnabled ? {
24
+ ssr: getSSRDoneTimeValue(config)
25
+ } : null;
26
+ postInteractionLog.setVCObserverSSRConfig(ssr);
27
+ const tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime;
28
+ const prefix = 'ufo';
29
+ const result = await getVCObserver().getVCResult({
30
+ start: interaction.start,
31
+ stop: interaction.end,
32
+ tti,
33
+ prefix,
34
+ vc: interaction.vc,
35
+ isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED',
36
+ ...ssr
37
+ });
38
+ if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
39
+ getVCObserver().stop();
40
+ }
41
+ postInteractionLog.setLastInteractionFinishVCResult(result);
42
+ const VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
43
+ if (!VC || !(result !== null && result !== void 0 && result[`${prefix}:vc:clean`])) {
44
+ return result;
45
+ }
46
+ if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
47
+ return result;
48
+ }
49
+ return {
50
+ ...result,
51
+ 'metric:vc90': VC['90']
52
+ };
53
+ }
@@ -1,8 +1,8 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
1
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
3
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
6
6
  var _excluded = ["labelStack", "time"],
7
7
  _excluded2 = ["stopTime", "labelStack"],
8
8
  _excluded3 = ["labelStack"],
@@ -23,12 +23,15 @@ import { getBm3Timings } from '../custom-timings';
23
23
  import { getGlobalErrorCount } from '../global-error-handler';
24
24
  import { getPageVisibilityState } from '../hidden-timing';
25
25
  import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
26
- import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
26
+ import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
27
27
  import * as resourceTiming from '../resource-timing';
28
28
  import { roundEpsilon } from '../round-number';
29
29
  import * as ssr from '../ssr';
30
- import { getVCObserver } from '../vc';
31
30
  import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
31
+ import getInteractionStatus from './utils/get-interaction-status';
32
+ import getPageVisibilityUpToTTAI from './utils/get-page-visibility-up-to-ttai';
33
+ import getSSRDoneTimeValue from './utils/get-ssr-done-time-value';
34
+ import getVCMetrics from './utils/get-vc-metrics';
32
35
  function getUfoNameOverride(interaction) {
33
36
  var ufoName = interaction.ufoName,
34
37
  apdex = interaction.apdex;
@@ -75,11 +78,6 @@ var getPageVisibilityUpToTTI = function getPageVisibilityUpToTTI(interaction) {
75
78
  var bm3EndTimeOrInteractionEndTime = getBm3EndTimeOrFallbackValue(interaction);
76
79
  return getPageVisibilityState(start, bm3EndTimeOrInteractionEndTime);
77
80
  };
78
- var getPageVisibilityUpToTTAI = function getPageVisibilityUpToTTAI(interaction) {
79
- var start = interaction.start,
80
- end = interaction.end;
81
- return getPageVisibilityState(start, end);
82
- };
83
81
  var getVisibilityStateFromPerformance = function getVisibilityStateFromPerformance(stop) {
84
82
  try {
85
83
  var results = performance.getEntriesByType('visibility-state');
@@ -135,15 +133,6 @@ var getMoreAccuratePageVisibilityUpToTTAI = function getMoreAccuratePageVisibili
135
133
  }
136
134
  return old;
137
135
  };
138
- var getInteractionStatus = function getInteractionStatus(interaction) {
139
- var originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
140
- var hasBm3TTI = interaction.apdex.length > 0;
141
- var overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
142
- return {
143
- originalInteractionStatus: originalInteractionStatus,
144
- overrideStatus: overrideStatus
145
- };
146
- };
147
136
  var getResourceTimings = function getResourceTimings(start, end) {
148
137
  var _resourceTiming$getRe;
149
138
  return (_resourceTiming$getRe = resourceTiming.getResourceTimings(start, end)) !== null && _resourceTiming$getRe !== void 0 ? _resourceTiming$getRe : undefined;
@@ -178,76 +167,6 @@ var getTTAI = function getTTAI(interaction) {
178
167
  var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
179
168
  return !interaction.abortReason && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
180
169
  };
181
- var getVCMetrics = /*#__PURE__*/function () {
182
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction) {
183
- var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI;
184
- var config, isSSREnabled, ssr, tti, prefix, interactionStatus, pageVisibilityUpToTTAI, result, VC;
185
- return _regeneratorRuntime.wrap(function _callee$(_context) {
186
- while (1) switch (_context.prev = _context.next) {
187
- case 0:
188
- config = getConfig();
189
- if (config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
190
- _context.next = 3;
191
- break;
192
- }
193
- return _context.abrupt("return", {});
194
- case 3:
195
- if (!(interaction.type !== 'page_load' && interaction.type !== 'transition')) {
196
- _context.next = 5;
197
- break;
198
- }
199
- return _context.abrupt("return", {});
200
- case 5:
201
- isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
202
- ssr = interaction.type === 'page_load' && isSSREnabled ? {
203
- ssr: getSSRDoneTimeValue(config)
204
- } : null;
205
- postInteractionLog.setVCObserverSSRConfig(ssr);
206
- tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime;
207
- prefix = 'ufo';
208
- interactionStatus = getInteractionStatus(interaction);
209
- pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
210
- _context.next = 14;
211
- return getVCObserver().getVCResult(_objectSpread({
212
- start: interaction.start,
213
- stop: interaction.end,
214
- tti: tti,
215
- prefix: prefix,
216
- vc: interaction.vc,
217
- isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED'
218
- }, ssr));
219
- case 14:
220
- result = _context.sent;
221
- if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
222
- getVCObserver().stop();
223
- }
224
- postInteractionLog.setLastInteractionFinishVCResult(result);
225
- VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
226
- if (!(!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")]))) {
227
- _context.next = 20;
228
- break;
229
- }
230
- return _context.abrupt("return", result);
231
- case 20:
232
- if (!(interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible')) {
233
- _context.next = 22;
234
- break;
235
- }
236
- return _context.abrupt("return", result);
237
- case 22:
238
- return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
239
- 'metric:vc90': VC['90']
240
- }));
241
- case 23:
242
- case "end":
243
- return _context.stop();
244
- }
245
- }, _callee);
246
- }));
247
- return function getVCMetrics(_x) {
248
- return _ref2.apply(this, arguments);
249
- };
250
- }();
251
170
  var getNavigationMetrics = function getNavigationMetrics(type) {
252
171
  if (type !== 'page_load') {
253
172
  return {};
@@ -295,13 +214,13 @@ var getNavigationMetrics = function getNavigationMetrics(type) {
295
214
  };
296
215
  };
297
216
  var getPPSMetrics = function getPPSMetrics(interaction) {
298
- var _interaction$apdex2;
217
+ var _interaction$apdex;
299
218
  var start = interaction.start,
300
219
  end = interaction.end;
301
220
  var config = getConfig();
302
221
  var interactionStatus = getInteractionStatus(interaction);
303
222
  var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
304
- var tti = (_interaction$apdex2 = interaction.apdex) === null || _interaction$apdex2 === void 0 || (_interaction$apdex2 = _interaction$apdex2[0]) === null || _interaction$apdex2 === void 0 ? void 0 : _interaction$apdex2.stopTime;
223
+ var tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime;
305
224
  var ttai = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
306
225
  var PPSMetricsAtTTI = tti !== undefined ? getLighthouseMetrics({
307
226
  start: start,
@@ -397,10 +316,10 @@ var getTracingContextData = function getTracingContextData(interaction) {
397
316
  function optimizeCustomData(interaction) {
398
317
  var customData = interaction.customData,
399
318
  legacyMetrics = interaction.legacyMetrics;
400
- var customDataMap = customData.reduce(function (result, _ref3) {
319
+ var customDataMap = customData.reduce(function (result, _ref2) {
401
320
  var _result$get$data, _result$get;
402
- var labelStack = _ref3.labelStack,
403
- data = _ref3.data;
321
+ var labelStack = _ref2.labelStack,
322
+ data = _ref2.data;
404
323
  var label = stringifyLabelStackFully(labelStack);
405
324
  var value = (_result$get$data = (_result$get = result.get(label)) === null || _result$get === void 0 ? void 0 : _result$get.data) !== null && _result$get$data !== void 0 ? _result$get$data : {};
406
325
  result.set(label, {
@@ -416,13 +335,13 @@ function optimizeCustomData(interaction) {
416
335
  for (var _i = 0, _Object$entries = Object.entries(currentValue.custom || {}); _i < _Object$entries.length; _i++) {
417
336
  var _result$get$data2, _result$get2;
418
337
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
419
- _key = _Object$entries$_i[0],
338
+ key = _Object$entries$_i[0],
420
339
  value = _Object$entries$_i[1];
421
340
  var label = stringifyLabelStackFully([]);
422
341
  var labelValue = (_result$get$data2 = (_result$get2 = result.get(label)) === null || _result$get2 === void 0 ? void 0 : _result$get2.data) !== null && _result$get$data2 !== void 0 ? _result$get$data2 : {};
423
342
  result.set(label, {
424
343
  labelStack: optimizeLabelStack([], getReactUFOVersion(interaction.type)),
425
- data: Object.assign(labelValue, _defineProperty({}, _key, value))
344
+ data: Object.assign(labelValue, _defineProperty({}, key, value))
426
345
  });
427
346
  }
428
347
  return result;
@@ -432,12 +351,12 @@ function optimizeCustomData(interaction) {
432
351
  return _toConsumableArray(customDataMap.values());
433
352
  }
434
353
  function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart, reactUFOVersion) {
435
- var reactProfilerTimingsMap = reactProfilerTimings.reduce(function (result, _ref4) {
436
- var labelStack = _ref4.labelStack,
437
- startTime = _ref4.startTime,
438
- commitTime = _ref4.commitTime,
439
- actualDuration = _ref4.actualDuration,
440
- type = _ref4.type;
354
+ var reactProfilerTimingsMap = reactProfilerTimings.reduce(function (result, _ref3) {
355
+ var labelStack = _ref3.labelStack,
356
+ startTime = _ref3.startTime,
357
+ commitTime = _ref3.commitTime,
358
+ actualDuration = _ref3.actualDuration,
359
+ type = _ref3.type;
441
360
  if (labelStack && startTime >= interactionStart) {
442
361
  var label = stringifyLabelStackFully(labelStack);
443
362
  var start = Math.round(startTime);
@@ -583,10 +502,10 @@ function optimizeCustomTimings(customTimings, interactionStart) {
583
502
  }, []);
584
503
  }
585
504
  function optimizeMarks(marks, reactUFOVersion) {
586
- return marks.map(function (_ref5) {
587
- var labelStack = _ref5.labelStack,
588
- time = _ref5.time,
589
- others = _objectWithoutProperties(_ref5, _excluded);
505
+ return marks.map(function (_ref4) {
506
+ var labelStack = _ref4.labelStack,
507
+ time = _ref4.time,
508
+ others = _objectWithoutProperties(_ref4, _excluded);
590
509
  return _objectSpread(_objectSpread({}, others), {}, {
591
510
  labelStack: labelStack && optimizeLabelStack(labelStack, reactUFOVersion),
592
511
  time: Math.round(time)
@@ -594,10 +513,10 @@ function optimizeMarks(marks, reactUFOVersion) {
594
513
  });
595
514
  }
596
515
  function optimizeApdex(apdex, reactUFOVersion) {
597
- return apdex.map(function (_ref6) {
598
- var stopTime = _ref6.stopTime,
599
- labelStack = _ref6.labelStack,
600
- others = _objectWithoutProperties(_ref6, _excluded2);
516
+ return apdex.map(function (_ref5) {
517
+ var stopTime = _ref5.stopTime,
518
+ labelStack = _ref5.labelStack,
519
+ others = _objectWithoutProperties(_ref5, _excluded2);
601
520
  return _objectSpread(_objectSpread({}, others), {}, {
602
521
  stopTime: Math.round(stopTime)
603
522
  }, labelStack ? {
@@ -660,10 +579,6 @@ function getBm3TrackerTimings(interaction) {
660
579
  legacyMetrics: legacyMetrics
661
580
  };
662
581
  }
663
- function getSSRDoneTimeValue(config) {
664
- var _config$ssr, _config$ssr2;
665
- return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 || (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
666
- }
667
582
  function getPayloadSize(payload) {
668
583
  return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
669
584
  }
@@ -715,20 +630,20 @@ function getErrorCounts(interaction) {
715
630
  'ufo:errors:count': interaction.errors.length
716
631
  };
717
632
  }
718
- function createInteractionMetricsPayload(_x2, _x3, _x4) {
633
+ function createInteractionMetricsPayload(_x, _x2, _x3) {
719
634
  return _createInteractionMetricsPayload.apply(this, arguments);
720
635
  }
721
636
  function _createInteractionMetricsPayload() {
722
- _createInteractionMetricsPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(interaction, interactionId, experimental) {
637
+ _createInteractionMetricsPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction, interactionId, experimental) {
723
638
  var _window$location, _config$additionalPay;
724
639
  var interactionPayloadStart, config, end, start, ufoName, knownSegments, rate, type, abortReason, routeName, featureFlags, previousInteractionName, isPreviousInteractionAborted, abortedByInteractionName, pageVisibilityAtTTI, pageVisibilityAtTTAI, segments, segmentTree, isDetailedPayload, isPageLoad, calculatePageVisibilityFromTheStartOfPageLoad, moreAccuratePageVisibilityAtTTI, moreAccuratePageVisibilityAtTTAI, labelStack, getPageLoadInteractionMetrics, getDetailedInteractionMetrics, getPageLoadDetailedInteractionMetrics, newUFOName, resourceTimings, _yield$Promise$all, _yield$Promise$all2, vcMetrics, experimentalMetrics, payload;
725
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
726
- while (1) switch (_context2.prev = _context2.next) {
640
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
641
+ while (1) switch (_context.prev = _context.next) {
727
642
  case 0:
728
643
  interactionPayloadStart = performance.now();
729
644
  config = getConfig();
730
645
  if (config) {
731
- _context2.next = 4;
646
+ _context.next = 4;
732
647
  break;
733
648
  }
734
649
  throw Error('UFO Configuration not provided');
@@ -749,7 +664,7 @@ function _createInteractionMetricsPayload() {
749
664
  labelStack: optimizeLabelStack(interaction.labelStack, getReactUFOVersion(interaction.type))
750
665
  } : {}; // Page Load
751
666
  getPageLoadInteractionMetrics = function getPageLoadInteractionMetrics() {
752
- var _config$ssr3;
667
+ var _config$ssr;
753
668
  if (!isPageLoad) {
754
669
  return {};
755
670
  }
@@ -760,7 +675,7 @@ function _createInteractionMetricsPayload() {
760
675
  } : {};
761
676
  return _objectSpread(_objectSpread({}, SSRDoneTime), {}, {
762
677
  isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
763
- isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr3 = config.ssr) !== null && _config$ssr3 !== void 0 && _config$ssr3.getSSRDoneTime)
678
+ isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
764
679
  });
765
680
  }; // Detailed payload. Page visibility = visible
766
681
  getDetailedInteractionMetrics = function getDetailedInteractionMetrics(resourceTimings) {
@@ -770,9 +685,9 @@ function _createInteractionMetricsPayload() {
770
685
  var spans = [].concat(_toConsumableArray(interaction.spans), _toConsumableArray(atlaskitInteractionSpans));
771
686
  atlaskitInteractionSpans.length = 0;
772
687
  return {
773
- errors: interaction.errors.map(function (_ref7) {
774
- var labelStack = _ref7.labelStack,
775
- others = _objectWithoutProperties(_ref7, _excluded3);
688
+ errors: interaction.errors.map(function (_ref6) {
689
+ var labelStack = _ref6.labelStack,
690
+ others = _objectWithoutProperties(_ref6, _excluded3);
776
691
  return _objectSpread(_objectSpread({}, others), {}, {
777
692
  labelStack: labelStack && optimizeLabelStack(labelStack, getReactUFOVersion(interaction.type))
778
693
  });
@@ -788,14 +703,14 @@ function _createInteractionMetricsPayload() {
788
703
  };
789
704
  }; // Page load & detailed payload
790
705
  getPageLoadDetailedInteractionMetrics = function getPageLoadDetailedInteractionMetrics() {
791
- var _config$ssr4;
706
+ var _config$ssr2;
792
707
  if (!isPageLoad || !isDetailedPayload) {
793
708
  return {};
794
709
  }
795
710
  var config = getConfig();
796
711
  return {
797
712
  initialPageLoadExtraTimings: objectToArray(initialPageLoadExtraTiming.getTimings()),
798
- SSRTimings: config !== null && config !== void 0 && (_config$ssr4 = config.ssr) !== null && _config$ssr4 !== void 0 && _config$ssr4.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
713
+ SSRTimings: config !== null && config !== void 0 && (_config$ssr2 = config.ssr) !== null && _config$ssr2 !== void 0 && _config$ssr2.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
799
714
  };
800
715
  };
801
716
  if (experimental) {
@@ -805,10 +720,10 @@ function _createInteractionMetricsPayload() {
805
720
  }
806
721
  newUFOName = sanitizeUfoName(ufoName);
807
722
  resourceTimings = getResourceTimings(start, end);
808
- _context2.next = 23;
723
+ _context.next = 23;
809
724
  return Promise.all([getVCMetrics(interaction), experimental ? getExperimentalVCMetrics(interaction) : Promise.resolve(undefined)]);
810
725
  case 23:
811
- _yield$Promise$all = _context2.sent;
726
+ _yield$Promise$all = _context.sent;
812
727
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
813
728
  vcMetrics = _yield$Promise$all2[0];
814
729
  experimentalMetrics = _yield$Promise$all2[1];
@@ -854,9 +769,9 @@ function _createInteractionMetricsPayload() {
854
769
  apdex: optimizeApdex(interaction.apdex, getReactUFOVersion(interaction.type)),
855
770
  end: Math.round(end),
856
771
  start: Math.round(start),
857
- segments: getReactUFOVersion(interaction.type) === '2.0.0' ? segmentTree : segments.map(function (_ref8) {
858
- var labelStack = _ref8.labelStack,
859
- others = _objectWithoutProperties(_ref8, _excluded4);
772
+ segments: getReactUFOVersion(interaction.type) === '2.0.0' ? segmentTree : segments.map(function (_ref7) {
773
+ var labelStack = _ref7.labelStack,
774
+ others = _objectWithoutProperties(_ref7, _excluded4);
860
775
  return _objectSpread(_objectSpread({}, others), {}, {
861
776
  labelStack: optimizeLabelStack(labelStack, getReactUFOVersion(interaction.type))
862
777
  });
@@ -877,38 +792,38 @@ function _createInteractionMetricsPayload() {
877
792
  expTTAI = undefined;
878
793
  }
879
794
  payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
880
- return _context2.abrupt("return", payload);
795
+ return _context.abrupt("return", payload);
881
796
  case 31:
882
797
  case "end":
883
- return _context2.stop();
798
+ return _context.stop();
884
799
  }
885
- }, _callee2);
800
+ }, _callee);
886
801
  }));
887
802
  return _createInteractionMetricsPayload.apply(this, arguments);
888
803
  }
889
- export function createPayloads(_x5, _x6) {
804
+ export function createPayloads(_x4, _x5) {
890
805
  return _createPayloads.apply(this, arguments);
891
806
  }
892
807
  function _createPayloads() {
893
- _createPayloads = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(interactionId, interaction) {
808
+ _createPayloads = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(interactionId, interaction) {
894
809
  var ufoNameOverride, modifiedInteraction, interactionMetricsPayload;
895
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
896
- while (1) switch (_context3.prev = _context3.next) {
810
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
811
+ while (1) switch (_context2.prev = _context2.next) {
897
812
  case 0:
898
813
  ufoNameOverride = getUfoNameOverride(interaction);
899
814
  modifiedInteraction = _objectSpread(_objectSpread({}, interaction), {}, {
900
815
  ufoName: ufoNameOverride
901
816
  });
902
- _context3.next = 4;
817
+ _context2.next = 4;
903
818
  return createInteractionMetricsPayload(modifiedInteraction, interactionId);
904
819
  case 4:
905
- interactionMetricsPayload = _context3.sent;
906
- return _context3.abrupt("return", [interactionMetricsPayload]);
820
+ interactionMetricsPayload = _context2.sent;
821
+ return _context2.abrupt("return", [interactionMetricsPayload]);
907
822
  case 6:
908
823
  case "end":
909
- return _context3.stop();
824
+ return _context2.stop();
910
825
  }
911
- }, _callee3);
826
+ }, _callee2);
912
827
  }));
913
828
  return _createPayloads.apply(this, arguments);
914
829
  }