@atlaskit/react-ufo 3.3.0 → 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.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +1 -0
- package/dist/cjs/create-payload/index.js +63 -156
- package/dist/cjs/create-payload/utils/get-interaction-status.js +37 -0
- package/dist/cjs/create-payload/utils/get-page-visibility-up-to-ttai.js +12 -0
- package/dist/cjs/create-payload/utils/get-ssr-done-time-value.js +14 -0
- package/dist/cjs/create-payload/utils/get-vc-metrics.js +96 -0
- package/dist/cjs/interaction-metrics/post-interaction-log.js +1 -0
- package/dist/cjs/vc/vc-observer/heatmap/heatmap.js +4 -1
- package/dist/cjs/vc/vc-observer/index.js +27 -30
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +1 -0
- package/dist/es2019/create-payload/index.js +11 -80
- package/dist/es2019/create-payload/utils/get-interaction-status.js +31 -0
- package/dist/es2019/create-payload/utils/get-page-visibility-up-to-ttai.js +8 -0
- package/dist/es2019/create-payload/utils/get-ssr-done-time-value.js +5 -0
- package/dist/es2019/create-payload/utils/get-vc-metrics.js +53 -0
- package/dist/es2019/interaction-metrics/post-interaction-log.js +1 -0
- package/dist/es2019/vc/vc-observer/heatmap/heatmap.js +4 -1
- package/dist/es2019/vc/vc-observer/index.js +29 -29
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +1 -0
- package/dist/esm/create-payload/index.js +56 -149
- package/dist/esm/create-payload/utils/get-interaction-status.js +31 -0
- package/dist/esm/create-payload/utils/get-page-visibility-up-to-ttai.js +6 -0
- package/dist/esm/create-payload/utils/get-ssr-done-time-value.js +5 -0
- package/dist/esm/create-payload/utils/get-vc-metrics.js +89 -0
- package/dist/esm/interaction-metrics/post-interaction-log.js +1 -0
- package/dist/esm/vc/vc-observer/heatmap/heatmap.js +4 -1
- package/dist/esm/vc/vc-observer/index.js +27 -30
- package/dist/types/create-payload/utils/get-interaction-status.d.ts +27 -0
- package/dist/types/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -0
- package/dist/types/create-payload/utils/get-ssr-done-time-value.d.ts +2 -0
- package/dist/types/create-payload/utils/get-vc-metrics.d.ts +5 -0
- package/dist/types/vc/types.d.ts +1 -0
- package/dist/types/vc/vc-observer/heatmap/heatmap.d.ts +2 -0
- package/dist/types/vc/vc-observer/index.d.ts +1 -1
- package/dist/types-ts4.5/create-payload/utils/get-interaction-status.d.ts +27 -0
- package/dist/types-ts4.5/create-payload/utils/get-page-visibility-up-to-ttai.d.ts +2 -0
- package/dist/types-ts4.5/create-payload/utils/get-ssr-done-time-value.d.ts +2 -0
- package/dist/types-ts4.5/create-payload/utils/get-vc-metrics.d.ts +5 -0
- package/dist/types-ts4.5/vc/types.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer/heatmap/heatmap.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/index.d.ts +1 -1
- package/package.json +7 -4
|
@@ -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
|
|
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,84 +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, result, VC, interactionStatus, pageVisibilityUpToTTAI, _result;
|
|
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
|
-
_context.next = 12;
|
|
209
|
-
return getVCObserver().getVCResult(_objectSpread({
|
|
210
|
-
start: interaction.start,
|
|
211
|
-
stop: interaction.end,
|
|
212
|
-
tti: tti,
|
|
213
|
-
prefix: prefix,
|
|
214
|
-
vc: interaction.vc
|
|
215
|
-
}, ssr));
|
|
216
|
-
case 12:
|
|
217
|
-
result = _context.sent;
|
|
218
|
-
if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
219
|
-
getVCObserver().stop();
|
|
220
|
-
}
|
|
221
|
-
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
222
|
-
VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
223
|
-
if (!(!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")]))) {
|
|
224
|
-
_context.next = 18;
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
return _context.abrupt("return", result);
|
|
228
|
-
case 18:
|
|
229
|
-
interactionStatus = getInteractionStatus(interaction);
|
|
230
|
-
pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
231
|
-
if (!(interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible')) {
|
|
232
|
-
_context.next = 22;
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
return _context.abrupt("return", result);
|
|
236
|
-
case 22:
|
|
237
|
-
if (fg('ufo_vc_multiheatmap')) {
|
|
238
|
-
(_result = result["".concat(prefix, ":vc:rev")]) === null || _result === void 0 || _result.forEach(function (element) {
|
|
239
|
-
var _element$vcDetails;
|
|
240
|
-
if ((_element$vcDetails = element.vcDetails) !== null && _element$vcDetails !== void 0 && (_element$vcDetails = _element$vcDetails['90']) !== null && _element$vcDetails !== void 0 && _element$vcDetails.t) {
|
|
241
|
-
var _element$vcDetails$;
|
|
242
|
-
element['metric:vc90'] = (_element$vcDetails$ = element.vcDetails['90']) === null || _element$vcDetails$ === void 0 ? void 0 : _element$vcDetails$.t;
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
247
|
-
'metric:vc90': VC['90']
|
|
248
|
-
}));
|
|
249
|
-
case 24:
|
|
250
|
-
case "end":
|
|
251
|
-
return _context.stop();
|
|
252
|
-
}
|
|
253
|
-
}, _callee);
|
|
254
|
-
}));
|
|
255
|
-
return function getVCMetrics(_x) {
|
|
256
|
-
return _ref2.apply(this, arguments);
|
|
257
|
-
};
|
|
258
|
-
}();
|
|
259
170
|
var getNavigationMetrics = function getNavigationMetrics(type) {
|
|
260
171
|
if (type !== 'page_load') {
|
|
261
172
|
return {};
|
|
@@ -303,13 +214,13 @@ var getNavigationMetrics = function getNavigationMetrics(type) {
|
|
|
303
214
|
};
|
|
304
215
|
};
|
|
305
216
|
var getPPSMetrics = function getPPSMetrics(interaction) {
|
|
306
|
-
var _interaction$
|
|
217
|
+
var _interaction$apdex;
|
|
307
218
|
var start = interaction.start,
|
|
308
219
|
end = interaction.end;
|
|
309
220
|
var config = getConfig();
|
|
310
221
|
var interactionStatus = getInteractionStatus(interaction);
|
|
311
222
|
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
312
|
-
var tti = (_interaction$
|
|
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;
|
|
313
224
|
var ttai = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
|
|
314
225
|
var PPSMetricsAtTTI = tti !== undefined ? getLighthouseMetrics({
|
|
315
226
|
start: start,
|
|
@@ -405,10 +316,10 @@ var getTracingContextData = function getTracingContextData(interaction) {
|
|
|
405
316
|
function optimizeCustomData(interaction) {
|
|
406
317
|
var customData = interaction.customData,
|
|
407
318
|
legacyMetrics = interaction.legacyMetrics;
|
|
408
|
-
var customDataMap = customData.reduce(function (result,
|
|
319
|
+
var customDataMap = customData.reduce(function (result, _ref2) {
|
|
409
320
|
var _result$get$data, _result$get;
|
|
410
|
-
var labelStack =
|
|
411
|
-
data =
|
|
321
|
+
var labelStack = _ref2.labelStack,
|
|
322
|
+
data = _ref2.data;
|
|
412
323
|
var label = stringifyLabelStackFully(labelStack);
|
|
413
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 : {};
|
|
414
325
|
result.set(label, {
|
|
@@ -424,13 +335,13 @@ function optimizeCustomData(interaction) {
|
|
|
424
335
|
for (var _i = 0, _Object$entries = Object.entries(currentValue.custom || {}); _i < _Object$entries.length; _i++) {
|
|
425
336
|
var _result$get$data2, _result$get2;
|
|
426
337
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
427
|
-
|
|
338
|
+
key = _Object$entries$_i[0],
|
|
428
339
|
value = _Object$entries$_i[1];
|
|
429
340
|
var label = stringifyLabelStackFully([]);
|
|
430
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 : {};
|
|
431
342
|
result.set(label, {
|
|
432
343
|
labelStack: optimizeLabelStack([], getReactUFOVersion(interaction.type)),
|
|
433
|
-
data: Object.assign(labelValue, _defineProperty({},
|
|
344
|
+
data: Object.assign(labelValue, _defineProperty({}, key, value))
|
|
434
345
|
});
|
|
435
346
|
}
|
|
436
347
|
return result;
|
|
@@ -440,12 +351,12 @@ function optimizeCustomData(interaction) {
|
|
|
440
351
|
return _toConsumableArray(customDataMap.values());
|
|
441
352
|
}
|
|
442
353
|
function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart, reactUFOVersion) {
|
|
443
|
-
var reactProfilerTimingsMap = reactProfilerTimings.reduce(function (result,
|
|
444
|
-
var labelStack =
|
|
445
|
-
startTime =
|
|
446
|
-
commitTime =
|
|
447
|
-
actualDuration =
|
|
448
|
-
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;
|
|
449
360
|
if (labelStack && startTime >= interactionStart) {
|
|
450
361
|
var label = stringifyLabelStackFully(labelStack);
|
|
451
362
|
var start = Math.round(startTime);
|
|
@@ -591,10 +502,10 @@ function optimizeCustomTimings(customTimings, interactionStart) {
|
|
|
591
502
|
}, []);
|
|
592
503
|
}
|
|
593
504
|
function optimizeMarks(marks, reactUFOVersion) {
|
|
594
|
-
return marks.map(function (
|
|
595
|
-
var labelStack =
|
|
596
|
-
time =
|
|
597
|
-
others = _objectWithoutProperties(
|
|
505
|
+
return marks.map(function (_ref4) {
|
|
506
|
+
var labelStack = _ref4.labelStack,
|
|
507
|
+
time = _ref4.time,
|
|
508
|
+
others = _objectWithoutProperties(_ref4, _excluded);
|
|
598
509
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
599
510
|
labelStack: labelStack && optimizeLabelStack(labelStack, reactUFOVersion),
|
|
600
511
|
time: Math.round(time)
|
|
@@ -602,10 +513,10 @@ function optimizeMarks(marks, reactUFOVersion) {
|
|
|
602
513
|
});
|
|
603
514
|
}
|
|
604
515
|
function optimizeApdex(apdex, reactUFOVersion) {
|
|
605
|
-
return apdex.map(function (
|
|
606
|
-
var stopTime =
|
|
607
|
-
labelStack =
|
|
608
|
-
others = _objectWithoutProperties(
|
|
516
|
+
return apdex.map(function (_ref5) {
|
|
517
|
+
var stopTime = _ref5.stopTime,
|
|
518
|
+
labelStack = _ref5.labelStack,
|
|
519
|
+
others = _objectWithoutProperties(_ref5, _excluded2);
|
|
609
520
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
610
521
|
stopTime: Math.round(stopTime)
|
|
611
522
|
}, labelStack ? {
|
|
@@ -668,10 +579,6 @@ function getBm3TrackerTimings(interaction) {
|
|
|
668
579
|
legacyMetrics: legacyMetrics
|
|
669
580
|
};
|
|
670
581
|
}
|
|
671
|
-
function getSSRDoneTimeValue(config) {
|
|
672
|
-
var _config$ssr, _config$ssr2;
|
|
673
|
-
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();
|
|
674
|
-
}
|
|
675
582
|
function getPayloadSize(payload) {
|
|
676
583
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
677
584
|
}
|
|
@@ -723,20 +630,20 @@ function getErrorCounts(interaction) {
|
|
|
723
630
|
'ufo:errors:count': interaction.errors.length
|
|
724
631
|
};
|
|
725
632
|
}
|
|
726
|
-
function createInteractionMetricsPayload(_x2, _x3
|
|
633
|
+
function createInteractionMetricsPayload(_x, _x2, _x3) {
|
|
727
634
|
return _createInteractionMetricsPayload.apply(this, arguments);
|
|
728
635
|
}
|
|
729
636
|
function _createInteractionMetricsPayload() {
|
|
730
|
-
_createInteractionMetricsPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
637
|
+
_createInteractionMetricsPayload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction, interactionId, experimental) {
|
|
731
638
|
var _window$location, _config$additionalPay;
|
|
732
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;
|
|
733
|
-
return _regeneratorRuntime.wrap(function
|
|
734
|
-
while (1) switch (
|
|
640
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
641
|
+
while (1) switch (_context.prev = _context.next) {
|
|
735
642
|
case 0:
|
|
736
643
|
interactionPayloadStart = performance.now();
|
|
737
644
|
config = getConfig();
|
|
738
645
|
if (config) {
|
|
739
|
-
|
|
646
|
+
_context.next = 4;
|
|
740
647
|
break;
|
|
741
648
|
}
|
|
742
649
|
throw Error('UFO Configuration not provided');
|
|
@@ -757,7 +664,7 @@ function _createInteractionMetricsPayload() {
|
|
|
757
664
|
labelStack: optimizeLabelStack(interaction.labelStack, getReactUFOVersion(interaction.type))
|
|
758
665
|
} : {}; // Page Load
|
|
759
666
|
getPageLoadInteractionMetrics = function getPageLoadInteractionMetrics() {
|
|
760
|
-
var _config$
|
|
667
|
+
var _config$ssr;
|
|
761
668
|
if (!isPageLoad) {
|
|
762
669
|
return {};
|
|
763
670
|
}
|
|
@@ -768,7 +675,7 @@ function _createInteractionMetricsPayload() {
|
|
|
768
675
|
} : {};
|
|
769
676
|
return _objectSpread(_objectSpread({}, SSRDoneTime), {}, {
|
|
770
677
|
isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
|
|
771
|
-
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$
|
|
678
|
+
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime)
|
|
772
679
|
});
|
|
773
680
|
}; // Detailed payload. Page visibility = visible
|
|
774
681
|
getDetailedInteractionMetrics = function getDetailedInteractionMetrics(resourceTimings) {
|
|
@@ -778,9 +685,9 @@ function _createInteractionMetricsPayload() {
|
|
|
778
685
|
var spans = [].concat(_toConsumableArray(interaction.spans), _toConsumableArray(atlaskitInteractionSpans));
|
|
779
686
|
atlaskitInteractionSpans.length = 0;
|
|
780
687
|
return {
|
|
781
|
-
errors: interaction.errors.map(function (
|
|
782
|
-
var labelStack =
|
|
783
|
-
others = _objectWithoutProperties(
|
|
688
|
+
errors: interaction.errors.map(function (_ref6) {
|
|
689
|
+
var labelStack = _ref6.labelStack,
|
|
690
|
+
others = _objectWithoutProperties(_ref6, _excluded3);
|
|
784
691
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
785
692
|
labelStack: labelStack && optimizeLabelStack(labelStack, getReactUFOVersion(interaction.type))
|
|
786
693
|
});
|
|
@@ -796,14 +703,14 @@ function _createInteractionMetricsPayload() {
|
|
|
796
703
|
};
|
|
797
704
|
}; // Page load & detailed payload
|
|
798
705
|
getPageLoadDetailedInteractionMetrics = function getPageLoadDetailedInteractionMetrics() {
|
|
799
|
-
var _config$
|
|
706
|
+
var _config$ssr2;
|
|
800
707
|
if (!isPageLoad || !isDetailedPayload) {
|
|
801
708
|
return {};
|
|
802
709
|
}
|
|
803
710
|
var config = getConfig();
|
|
804
711
|
return {
|
|
805
712
|
initialPageLoadExtraTimings: objectToArray(initialPageLoadExtraTiming.getTimings()),
|
|
806
|
-
SSRTimings: config !== null && config !== void 0 && (_config$
|
|
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())
|
|
807
714
|
};
|
|
808
715
|
};
|
|
809
716
|
if (experimental) {
|
|
@@ -813,10 +720,10 @@ function _createInteractionMetricsPayload() {
|
|
|
813
720
|
}
|
|
814
721
|
newUFOName = sanitizeUfoName(ufoName);
|
|
815
722
|
resourceTimings = getResourceTimings(start, end);
|
|
816
|
-
|
|
723
|
+
_context.next = 23;
|
|
817
724
|
return Promise.all([getVCMetrics(interaction), experimental ? getExperimentalVCMetrics(interaction) : Promise.resolve(undefined)]);
|
|
818
725
|
case 23:
|
|
819
|
-
_yield$Promise$all =
|
|
726
|
+
_yield$Promise$all = _context.sent;
|
|
820
727
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
821
728
|
vcMetrics = _yield$Promise$all2[0];
|
|
822
729
|
experimentalMetrics = _yield$Promise$all2[1];
|
|
@@ -862,9 +769,9 @@ function _createInteractionMetricsPayload() {
|
|
|
862
769
|
apdex: optimizeApdex(interaction.apdex, getReactUFOVersion(interaction.type)),
|
|
863
770
|
end: Math.round(end),
|
|
864
771
|
start: Math.round(start),
|
|
865
|
-
segments: getReactUFOVersion(interaction.type) === '2.0.0' ? segmentTree : segments.map(function (
|
|
866
|
-
var labelStack =
|
|
867
|
-
others = _objectWithoutProperties(
|
|
772
|
+
segments: getReactUFOVersion(interaction.type) === '2.0.0' ? segmentTree : segments.map(function (_ref7) {
|
|
773
|
+
var labelStack = _ref7.labelStack,
|
|
774
|
+
others = _objectWithoutProperties(_ref7, _excluded4);
|
|
868
775
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
869
776
|
labelStack: optimizeLabelStack(labelStack, getReactUFOVersion(interaction.type))
|
|
870
777
|
});
|
|
@@ -885,38 +792,38 @@ function _createInteractionMetricsPayload() {
|
|
|
885
792
|
expTTAI = undefined;
|
|
886
793
|
}
|
|
887
794
|
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
888
|
-
return
|
|
795
|
+
return _context.abrupt("return", payload);
|
|
889
796
|
case 31:
|
|
890
797
|
case "end":
|
|
891
|
-
return
|
|
798
|
+
return _context.stop();
|
|
892
799
|
}
|
|
893
|
-
},
|
|
800
|
+
}, _callee);
|
|
894
801
|
}));
|
|
895
802
|
return _createInteractionMetricsPayload.apply(this, arguments);
|
|
896
803
|
}
|
|
897
|
-
export function createPayloads(
|
|
804
|
+
export function createPayloads(_x4, _x5) {
|
|
898
805
|
return _createPayloads.apply(this, arguments);
|
|
899
806
|
}
|
|
900
807
|
function _createPayloads() {
|
|
901
|
-
_createPayloads = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
808
|
+
_createPayloads = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(interactionId, interaction) {
|
|
902
809
|
var ufoNameOverride, modifiedInteraction, interactionMetricsPayload;
|
|
903
|
-
return _regeneratorRuntime.wrap(function
|
|
904
|
-
while (1) switch (
|
|
810
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
811
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
905
812
|
case 0:
|
|
906
813
|
ufoNameOverride = getUfoNameOverride(interaction);
|
|
907
814
|
modifiedInteraction = _objectSpread(_objectSpread({}, interaction), {}, {
|
|
908
815
|
ufoName: ufoNameOverride
|
|
909
816
|
});
|
|
910
|
-
|
|
817
|
+
_context2.next = 4;
|
|
911
818
|
return createInteractionMetricsPayload(modifiedInteraction, interactionId);
|
|
912
819
|
case 4:
|
|
913
|
-
interactionMetricsPayload =
|
|
914
|
-
return
|
|
820
|
+
interactionMetricsPayload = _context2.sent;
|
|
821
|
+
return _context2.abrupt("return", [interactionMetricsPayload]);
|
|
915
822
|
case 6:
|
|
916
823
|
case "end":
|
|
917
|
-
return
|
|
824
|
+
return _context2.stop();
|
|
918
825
|
}
|
|
919
|
-
},
|
|
826
|
+
}, _callee2);
|
|
920
827
|
}));
|
|
921
828
|
return _createPayloads.apply(this, arguments);
|
|
922
829
|
}
|
|
@@ -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
|
+
var originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
|
|
25
|
+
var hasBm3TTI = interaction.apdex.length > 0;
|
|
26
|
+
var overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
|
|
27
|
+
return {
|
|
28
|
+
originalInteractionStatus: originalInteractionStatus,
|
|
29
|
+
overrideStatus: overrideStatus
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -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 || (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
|
|
5
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
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';
|
|
7
|
+
import { getConfig } from '../../config';
|
|
8
|
+
import { postInteractionLog } from '../../interaction-metrics';
|
|
9
|
+
import { getVCObserver } from '../../vc';
|
|
10
|
+
import getInteractionStatus from './get-interaction-status';
|
|
11
|
+
import getPageVisibilityUpToTTAI from './get-page-visibility-up-to-ttai';
|
|
12
|
+
import getSSRDoneTimeValue from './get-ssr-done-time-value';
|
|
13
|
+
export default function getVCMetrics(_x) {
|
|
14
|
+
return _getVCMetrics.apply(this, arguments);
|
|
15
|
+
}
|
|
16
|
+
function _getVCMetrics() {
|
|
17
|
+
_getVCMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction) {
|
|
18
|
+
var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$experimentalI;
|
|
19
|
+
var config, interactionStatus, pageVisibilityUpToTTAI, isSSREnabled, ssr, tti, prefix, result, VC;
|
|
20
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
21
|
+
while (1) switch (_context.prev = _context.next) {
|
|
22
|
+
case 0:
|
|
23
|
+
config = getConfig();
|
|
24
|
+
if (config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
25
|
+
_context.next = 3;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
return _context.abrupt("return", {});
|
|
29
|
+
case 3:
|
|
30
|
+
if (!(interaction.type !== 'page_load' && interaction.type !== 'transition')) {
|
|
31
|
+
_context.next = 5;
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
return _context.abrupt("return", {});
|
|
35
|
+
case 5:
|
|
36
|
+
interactionStatus = getInteractionStatus(interaction);
|
|
37
|
+
pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
38
|
+
if (!((interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') && fg('platform_ufo_no_vc_on_aborted'))) {
|
|
39
|
+
_context.next = 9;
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
return _context.abrupt("return", {});
|
|
43
|
+
case 9:
|
|
44
|
+
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));
|
|
45
|
+
ssr = interaction.type === 'page_load' && isSSREnabled ? {
|
|
46
|
+
ssr: getSSRDoneTimeValue(config)
|
|
47
|
+
} : null;
|
|
48
|
+
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
49
|
+
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;
|
|
50
|
+
prefix = 'ufo';
|
|
51
|
+
_context.next = 16;
|
|
52
|
+
return getVCObserver().getVCResult(_objectSpread({
|
|
53
|
+
start: interaction.start,
|
|
54
|
+
stop: interaction.end,
|
|
55
|
+
tti: tti,
|
|
56
|
+
prefix: prefix,
|
|
57
|
+
vc: interaction.vc,
|
|
58
|
+
isEventAborted: interactionStatus.originalInteractionStatus !== 'SUCCEEDED'
|
|
59
|
+
}, ssr));
|
|
60
|
+
case 16:
|
|
61
|
+
result = _context.sent;
|
|
62
|
+
if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
63
|
+
getVCObserver().stop();
|
|
64
|
+
}
|
|
65
|
+
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
66
|
+
VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
67
|
+
if (!(!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")]))) {
|
|
68
|
+
_context.next = 22;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
return _context.abrupt("return", result);
|
|
72
|
+
case 22:
|
|
73
|
+
if (!(interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible')) {
|
|
74
|
+
_context.next = 24;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
return _context.abrupt("return", result);
|
|
78
|
+
case 24:
|
|
79
|
+
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
80
|
+
'metric:vc90': VC['90']
|
|
81
|
+
}));
|
|
82
|
+
case 25:
|
|
83
|
+
case "end":
|
|
84
|
+
return _context.stop();
|
|
85
|
+
}
|
|
86
|
+
}, _callee);
|
|
87
|
+
}));
|
|
88
|
+
return _getVCMetrics.apply(this, arguments);
|
|
89
|
+
}
|
|
@@ -130,6 +130,7 @@ var PostInteractionLog = /*#__PURE__*/function () {
|
|
|
130
130
|
stop: performance.now(),
|
|
131
131
|
tti: -1,
|
|
132
132
|
// no need for TTI value here
|
|
133
|
+
isEventAborted: !!this.lastInteractionFinish.abortReason,
|
|
133
134
|
prefix: 'ufo'
|
|
134
135
|
}, this.vcObserverSSRConfig));
|
|
135
136
|
case 6:
|
|
@@ -3,6 +3,7 @@ import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructurin
|
|
|
3
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
+
import { getPageVisibilityState } from '../../../hidden-timing';
|
|
6
7
|
var UNUSED_SECTOR = 0;
|
|
7
8
|
export var MultiRevisionHeatmap = /*#__PURE__*/function () {
|
|
8
9
|
function MultiRevisionHeatmap(_ref) {
|
|
@@ -100,8 +101,10 @@ export var MultiRevisionHeatmap = /*#__PURE__*/function () {
|
|
|
100
101
|
}, {
|
|
101
102
|
key: "getPayloadShapedData",
|
|
102
103
|
value: function getPayloadShapedData(args) {
|
|
104
|
+
var pageVisibilityUpToTTAI = getPageVisibilityState(args.interactionStart, args.ttai);
|
|
103
105
|
var result = this.processData(args);
|
|
104
106
|
var payload = this.revisions.map(function (rev, i) {
|
|
107
|
+
var _vcDetails$;
|
|
105
108
|
var vcDetails = {};
|
|
106
109
|
args.VCParts.forEach(function (VCPart) {
|
|
107
110
|
vcDetails[VCPart] = {
|
|
@@ -113,7 +116,7 @@ export var MultiRevisionHeatmap = /*#__PURE__*/function () {
|
|
|
113
116
|
revision: rev.name,
|
|
114
117
|
vcDetails: vcDetails,
|
|
115
118
|
clean: args.clean,
|
|
116
|
-
'metric:vc90': null
|
|
119
|
+
'metric:vc90': args.clean && !args.isEventAborted && pageVisibilityUpToTTAI === 'visible' ? vcDetails === null || vcDetails === void 0 || (_vcDetails$ = vcDetails['90']) === null || _vcDetails$ === void 0 ? void 0 : _vcDetails$.t : null
|
|
117
120
|
};
|
|
118
121
|
});
|
|
119
122
|
return payload;
|