@atlaskit/react-ufo 2.3.3 → 2.4.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.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/common/constants.js +2 -1
- package/dist/cjs/create-payload/common/utils/index.js +61 -2
- package/dist/cjs/create-payload/index.js +68 -50
- package/dist/cjs/global-error-handler/index.js +7 -1
- package/dist/cjs/interaction-metrics-init/index.js +0 -7
- package/dist/es2019/common/constants.js +2 -1
- package/dist/es2019/create-payload/common/utils/index.js +53 -2
- package/dist/es2019/create-payload/index.js +49 -31
- package/dist/es2019/global-error-handler/index.js +4 -0
- package/dist/es2019/interaction-metrics-init/index.js +0 -7
- package/dist/esm/common/constants.js +2 -1
- package/dist/esm/create-payload/common/utils/index.js +57 -2
- package/dist/esm/create-payload/index.js +53 -35
- package/dist/esm/global-error-handler/index.js +6 -0
- package/dist/esm/interaction-metrics-init/index.js +0 -7
- package/dist/types/common/constants.d.ts +1 -1
- package/dist/types/create-payload/common/types.d.ts +1 -1
- package/dist/types/create-payload/common/utils/index.d.ts +15 -1
- package/dist/types/create-payload/index.d.ts +3217 -145
- package/dist/types/global-error-handler/index.d.ts +1 -0
- package/dist/types/interaction-context/index.d.ts +1 -1
- package/dist/types-ts4.5/common/constants.d.ts +1 -1
- package/dist/types-ts4.5/create-payload/common/types.d.ts +1 -1
- package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +15 -1
- package/dist/types-ts4.5/create-payload/index.d.ts +3217 -145
- package/dist/types-ts4.5/global-error-handler/index.d.ts +1 -0
- package/dist/types-ts4.5/interaction-context/index.d.ts +1 -1
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 2.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#170689](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/170689)
|
|
8
|
+
[`960d36f94739d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/960d36f94739d) -
|
|
9
|
+
[React UFO] Fix sessionStorage no access error
|
|
10
|
+
|
|
11
|
+
## 2.4.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#169410](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169410)
|
|
16
|
+
[`70969d8e13353`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/70969d8e13353) -
|
|
17
|
+
Optimising React UFO payload size by referncing segments tree
|
|
18
|
+
|
|
3
19
|
## 2.3.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -4,4 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.REACT_UFO_VERSION = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
var REACT_UFO_VERSION = exports.REACT_UFO_VERSION = (0, _platformFeatureFlags.fg)('react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
|
|
@@ -1,15 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
7
|
+
exports.buildSegmentTree = buildSegmentTree;
|
|
6
8
|
exports.isSegmentLabel = isSegmentLabel;
|
|
9
|
+
exports.labelStackStartWith = labelStackStartWith;
|
|
10
|
+
exports.optimizeLabelStack = optimizeLabelStack;
|
|
7
11
|
exports.sanitizeUfoName = void 0;
|
|
12
|
+
exports.stringifyLabelStackFully = stringifyLabelStackFully;
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
|
+
var _constants = require("../../../common/constants");
|
|
15
|
+
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; }
|
|
16
|
+
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; } /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
|
8
17
|
var sanitizeUfoName = exports.sanitizeUfoName = function sanitizeUfoName(name) {
|
|
9
18
|
return name.replace(/_/g, '-');
|
|
10
19
|
};
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
20
|
function isSegmentLabel(obj) {
|
|
14
21
|
return obj && typeof obj.name === 'string' && typeof obj.segmentId === 'string';
|
|
22
|
+
}
|
|
23
|
+
function buildSegmentTree(labelStacks) {
|
|
24
|
+
var r = {
|
|
25
|
+
n: 'segment-tree-root',
|
|
26
|
+
c: {}
|
|
27
|
+
};
|
|
28
|
+
labelStacks.forEach(function (labelStack) {
|
|
29
|
+
var currentNode = r;
|
|
30
|
+
labelStack.forEach(function (label, index) {
|
|
31
|
+
var _currentNode$c;
|
|
32
|
+
var name = label.name;
|
|
33
|
+
var id = isSegmentLabel(label) ? label.segmentId : undefined;
|
|
34
|
+
var key = id !== undefined ? id.toString() : name;
|
|
35
|
+
if (currentNode.c && !currentNode.c[key]) {
|
|
36
|
+
currentNode.c[key] = {
|
|
37
|
+
n: name
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
currentNode = (_currentNode$c = currentNode.c) === null || _currentNode$c === void 0 ? void 0 : _currentNode$c[key];
|
|
41
|
+
if (index < labelStack.length - 1) {
|
|
42
|
+
currentNode.c = _objectSpread({}, currentNode.c || {});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return {
|
|
47
|
+
r: r
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function stringifyLabelStackFully(labelStack) {
|
|
51
|
+
return labelStack.map(function (l) {
|
|
52
|
+
if (isSegmentLabel(l)) {
|
|
53
|
+
return "".concat(l.name, ":").concat(l.segmentId);
|
|
54
|
+
}
|
|
55
|
+
return l.name;
|
|
56
|
+
}).join('/');
|
|
57
|
+
}
|
|
58
|
+
function getLabelStackReference(labelStack) {
|
|
59
|
+
return labelStack.map(function (l) {
|
|
60
|
+
return isSegmentLabel(l) ? l.segmentId : l.name;
|
|
61
|
+
}).join('/');
|
|
62
|
+
}
|
|
63
|
+
function labelStackStartWith(labelStack, startWith) {
|
|
64
|
+
return stringifyLabelStackFully(labelStack).startsWith(stringifyLabelStackFully(startWith));
|
|
65
|
+
}
|
|
66
|
+
function optimizeLabelStack(labelStack) {
|
|
67
|
+
return _constants.REACT_UFO_VERSION === '2.0.0' ? getLabelStackReference(labelStack) : labelStack.map(function (ls) {
|
|
68
|
+
return _objectSpread({
|
|
69
|
+
n: ls.name
|
|
70
|
+
}, ls.segmentId ? {
|
|
71
|
+
s: ls.segmentId
|
|
72
|
+
} : {});
|
|
73
|
+
});
|
|
15
74
|
}
|
|
@@ -11,11 +11,13 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
13
|
var _bowserUltralight = _interopRequireDefault(require("bowser-ultralight"));
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _additionalPayload = require("../additional-payload");
|
|
15
16
|
var bundleEvalTiming = _interopRequireWildcard(require("../bundle-eval-timing"));
|
|
16
17
|
var _constants = require("../common/constants");
|
|
17
18
|
var _config = require("../config");
|
|
18
19
|
var _customTimings = require("../custom-timings");
|
|
20
|
+
var _globalErrorHandler = require("../global-error-handler");
|
|
19
21
|
var _hiddenTiming = require("../hidden-timing");
|
|
20
22
|
var initialPageLoadExtraTiming = _interopRequireWildcard(require("../initial-page-load-extra-timing"));
|
|
21
23
|
var _interactionMetrics = require("../interaction-metrics");
|
|
@@ -49,17 +51,6 @@ function getUfoNameOverride(interaction) {
|
|
|
49
51
|
return ufoName;
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
|
-
function stringifyLabelStackFully(labelStack) {
|
|
53
|
-
return labelStack.map(function (l) {
|
|
54
|
-
if ((0, _utils.isSegmentLabel)(l)) {
|
|
55
|
-
return "".concat(l.name, ":").concat(l.segmentId);
|
|
56
|
-
}
|
|
57
|
-
return l.name;
|
|
58
|
-
}).join('/');
|
|
59
|
-
}
|
|
60
|
-
function labelStackStartWith(labelStack, startWith) {
|
|
61
|
-
return stringifyLabelStackFully(labelStack).startsWith(stringifyLabelStackFully(startWith));
|
|
62
|
-
}
|
|
63
54
|
function getEarliestLegacyStopTime(interaction, labelStack) {
|
|
64
55
|
var earliestLegacyStopTime = null;
|
|
65
56
|
interaction.apdex.forEach(function (a) {
|
|
@@ -67,7 +58,7 @@ function getEarliestLegacyStopTime(interaction, labelStack) {
|
|
|
67
58
|
if (!(a !== null && a !== void 0 && a.stopTime)) {
|
|
68
59
|
return;
|
|
69
60
|
}
|
|
70
|
-
if (!labelStackStartWith((_a$labelStack = a.labelStack) !== null && _a$labelStack !== void 0 ? _a$labelStack : [], labelStack)) {
|
|
61
|
+
if (!(0, _utils.labelStackStartWith)((_a$labelStack = a.labelStack) !== null && _a$labelStack !== void 0 ? _a$labelStack : [], labelStack)) {
|
|
71
62
|
return;
|
|
72
63
|
}
|
|
73
64
|
if (a.stopTime > interaction.start && ((_earliestLegacyStopTi = earliestLegacyStopTime) !== null && _earliestLegacyStopTi !== void 0 ? _earliestLegacyStopTi : a.stopTime) >= a.stopTime) {
|
|
@@ -345,18 +336,6 @@ var getTracingContextData = function getTracingContextData(interaction) {
|
|
|
345
336
|
}
|
|
346
337
|
return tracingContextData;
|
|
347
338
|
};
|
|
348
|
-
|
|
349
|
-
// interaction metric
|
|
350
|
-
|
|
351
|
-
function optimizeLabelStack(labelStack) {
|
|
352
|
-
return labelStack.map(function (ls) {
|
|
353
|
-
return _objectSpread({
|
|
354
|
-
n: ls.name
|
|
355
|
-
}, ls.segmentId ? {
|
|
356
|
-
s: ls.segmentId
|
|
357
|
-
} : {});
|
|
358
|
-
});
|
|
359
|
-
}
|
|
360
339
|
function optimizeCustomData(interaction) {
|
|
361
340
|
var customData = interaction.customData,
|
|
362
341
|
legacyMetrics = interaction.legacyMetrics;
|
|
@@ -364,10 +343,10 @@ function optimizeCustomData(interaction) {
|
|
|
364
343
|
var _result$get$data, _result$get;
|
|
365
344
|
var labelStack = _ref2.labelStack,
|
|
366
345
|
data = _ref2.data;
|
|
367
|
-
var label = stringifyLabelStackFully(labelStack);
|
|
346
|
+
var label = (0, _utils.stringifyLabelStackFully)(labelStack);
|
|
368
347
|
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 : {};
|
|
369
348
|
result.set(label, {
|
|
370
|
-
labelStack: optimizeLabelStack(labelStack),
|
|
349
|
+
labelStack: (0, _utils.optimizeLabelStack)(labelStack),
|
|
371
350
|
data: Object.assign(value, data)
|
|
372
351
|
});
|
|
373
352
|
return result;
|
|
@@ -381,10 +360,10 @@ function optimizeCustomData(interaction) {
|
|
|
381
360
|
var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
|
|
382
361
|
_key = _Object$entries$_i[0],
|
|
383
362
|
value = _Object$entries$_i[1];
|
|
384
|
-
var label = stringifyLabelStackFully([]);
|
|
363
|
+
var label = (0, _utils.stringifyLabelStackFully)([]);
|
|
385
364
|
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 : {};
|
|
386
365
|
result.set(label, {
|
|
387
|
-
labelStack: optimizeLabelStack([]),
|
|
366
|
+
labelStack: (0, _utils.optimizeLabelStack)([]),
|
|
388
367
|
data: Object.assign(labelValue, (0, _defineProperty2.default)({}, _key, value))
|
|
389
368
|
});
|
|
390
369
|
}
|
|
@@ -402,11 +381,11 @@ function optimizeReactProfilerTimings(reactProfilerTimings, interactionStart) {
|
|
|
402
381
|
actualDuration = _ref3.actualDuration,
|
|
403
382
|
type = _ref3.type;
|
|
404
383
|
if (labelStack && startTime >= interactionStart) {
|
|
405
|
-
var label = stringifyLabelStackFully(labelStack);
|
|
384
|
+
var label = (0, _utils.stringifyLabelStackFully)(labelStack);
|
|
406
385
|
var start = Math.round(startTime);
|
|
407
386
|
var end = Math.round(commitTime);
|
|
408
387
|
var timing = result.get(label) || {
|
|
409
|
-
labelStack: optimizeLabelStack(labelStack),
|
|
388
|
+
labelStack: (0, _utils.optimizeLabelStack)(labelStack),
|
|
410
389
|
startTime: start,
|
|
411
390
|
endTime: end,
|
|
412
391
|
mountCount: 0,
|
|
@@ -461,13 +440,13 @@ function optimizeHoldInfo(holdInfo, interactionStart) {
|
|
|
461
440
|
end = hold.end,
|
|
462
441
|
ignoreOnSubmit = hold.ignoreOnSubmit;
|
|
463
442
|
if (labelStack && !ignoreOnSubmit && start >= interactionStart) {
|
|
464
|
-
var label = stringifyLabelStackFully([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
443
|
+
var label = (0, _utils.stringifyLabelStackFully)([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
465
444
|
name: name
|
|
466
445
|
}]));
|
|
467
446
|
var startTime = Math.round(start);
|
|
468
447
|
var endTime = Math.round(end);
|
|
469
448
|
var timing = result.get(label) || {
|
|
470
|
-
labelStack: optimizeLabelStack([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
449
|
+
labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
471
450
|
name: name
|
|
472
451
|
}])),
|
|
473
452
|
startTime: startTime,
|
|
@@ -494,7 +473,7 @@ function optimizeSpans(spans, interactionStart) {
|
|
|
494
473
|
end = span.end;
|
|
495
474
|
if (labelStack && start >= interactionStart) {
|
|
496
475
|
result.push({
|
|
497
|
-
labelStack: optimizeLabelStack([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
476
|
+
labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
498
477
|
name: name
|
|
499
478
|
}])),
|
|
500
479
|
startTime: Math.round(start),
|
|
@@ -518,7 +497,7 @@ function optimizeRequestInfo(requestInfo, interactionStart) {
|
|
|
518
497
|
var endTime = networkComplete !== null && networkComplete !== void 0 ? networkComplete : end;
|
|
519
498
|
if (labelStack && start >= interactionStart && endTime) {
|
|
520
499
|
result.push({
|
|
521
|
-
labelStack: optimizeLabelStack([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
500
|
+
labelStack: (0, _utils.optimizeLabelStack)([].concat((0, _toConsumableArray2.default)(labelStack), [{
|
|
522
501
|
name: name
|
|
523
502
|
}])),
|
|
524
503
|
startTime: Math.round(startTime),
|
|
@@ -530,7 +509,7 @@ function optimizeRequestInfo(requestInfo, interactionStart) {
|
|
|
530
509
|
return updatedRequestInfo;
|
|
531
510
|
}
|
|
532
511
|
function optimizeCustomTimings(customTimings, interactionStart) {
|
|
533
|
-
|
|
512
|
+
return customTimings.reduce(function (result, item) {
|
|
534
513
|
Object.keys(item.data).forEach(function (key) {
|
|
535
514
|
if (item.data[key].startTime >= interactionStart) {
|
|
536
515
|
result.push({
|
|
@@ -544,7 +523,6 @@ function optimizeCustomTimings(customTimings, interactionStart) {
|
|
|
544
523
|
});
|
|
545
524
|
return result;
|
|
546
525
|
}, []);
|
|
547
|
-
return updatedCustomTimings;
|
|
548
526
|
}
|
|
549
527
|
function optimizeMarks(marks) {
|
|
550
528
|
return marks.map(function (_ref4) {
|
|
@@ -552,7 +530,7 @@ function optimizeMarks(marks) {
|
|
|
552
530
|
time = _ref4.time,
|
|
553
531
|
others = (0, _objectWithoutProperties2.default)(_ref4, _excluded);
|
|
554
532
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
555
|
-
labelStack: labelStack && optimizeLabelStack(labelStack),
|
|
533
|
+
labelStack: labelStack && (0, _utils.optimizeLabelStack)(labelStack),
|
|
556
534
|
time: Math.round(time)
|
|
557
535
|
});
|
|
558
536
|
});
|
|
@@ -565,12 +543,10 @@ function optimizeApdex(apdex) {
|
|
|
565
543
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
566
544
|
stopTime: Math.round(stopTime)
|
|
567
545
|
}, labelStack ? {
|
|
568
|
-
labelStack: optimizeLabelStack(labelStack)
|
|
546
|
+
labelStack: (0, _utils.optimizeLabelStack)(labelStack)
|
|
569
547
|
} : {});
|
|
570
548
|
});
|
|
571
549
|
}
|
|
572
|
-
|
|
573
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
574
550
|
function objectToArray() {
|
|
575
551
|
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
576
552
|
return Object.keys(obj).reduce(function (result, key) {
|
|
@@ -579,9 +555,7 @@ function objectToArray() {
|
|
|
579
555
|
data: obj[key]
|
|
580
556
|
});
|
|
581
557
|
return result;
|
|
582
|
-
},
|
|
583
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
584
|
-
[]);
|
|
558
|
+
}, []);
|
|
585
559
|
}
|
|
586
560
|
function getBM3SubmetricsTimings(submetrics) {
|
|
587
561
|
if (!submetrics) {
|
|
@@ -635,6 +609,45 @@ function getSSRDoneTimeValue(config) {
|
|
|
635
609
|
function getPayloadSize(payload) {
|
|
636
610
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
637
611
|
}
|
|
612
|
+
function getStylesheetMetrics() {
|
|
613
|
+
if (!(0, _platformFeatureFlags.fg)('ufo_capture_stylesheet_metrics')) {
|
|
614
|
+
return {};
|
|
615
|
+
}
|
|
616
|
+
try {
|
|
617
|
+
var stylesheets = Array.from(document.styleSheets);
|
|
618
|
+
var stylesheetCount = stylesheets.length;
|
|
619
|
+
var cssrules = Array.from(document.styleSheets).reduce(function (acc, item) {
|
|
620
|
+
// Other domain stylesheets throw a SecurityError
|
|
621
|
+
try {
|
|
622
|
+
return acc + item.cssRules.length;
|
|
623
|
+
} catch (e) {
|
|
624
|
+
return acc;
|
|
625
|
+
}
|
|
626
|
+
}, 0);
|
|
627
|
+
var styleElements = document.querySelectorAll('style').length;
|
|
628
|
+
var styleProps = document.querySelectorAll('[style]');
|
|
629
|
+
var styleDeclarations = Array.from(document.querySelectorAll('[style]')).reduce(function (acc, item) {
|
|
630
|
+
try {
|
|
631
|
+
if ('style' in item) {
|
|
632
|
+
return acc + item.style.length;
|
|
633
|
+
} else {
|
|
634
|
+
return acc;
|
|
635
|
+
}
|
|
636
|
+
} catch (e) {
|
|
637
|
+
return acc;
|
|
638
|
+
}
|
|
639
|
+
}, 0);
|
|
640
|
+
return {
|
|
641
|
+
stylesheets: stylesheetCount,
|
|
642
|
+
styleElements: styleElements,
|
|
643
|
+
styleProps: styleProps.length,
|
|
644
|
+
styleDeclarations: styleDeclarations,
|
|
645
|
+
cssrules: cssrules
|
|
646
|
+
};
|
|
647
|
+
} catch (e) {
|
|
648
|
+
return {};
|
|
649
|
+
}
|
|
650
|
+
}
|
|
638
651
|
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
639
652
|
var _window$location, _config$additionalPay;
|
|
640
653
|
var interactionPayloadStart = performance.now();
|
|
@@ -657,13 +670,16 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
657
670
|
var pageVisibilityAtTTI = getPageVisibilityUpToTTI(interaction);
|
|
658
671
|
var pageVisibilityAtTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
659
672
|
var segments = config.killswitchNestedSegments ? [] : knownSegments;
|
|
673
|
+
var segmentTree = (0, _utils.buildSegmentTree)(segments.map(function (segment) {
|
|
674
|
+
return segment.labelStack;
|
|
675
|
+
}));
|
|
660
676
|
var isDetailedPayload = pageVisibilityAtTTAI === 'visible';
|
|
661
677
|
var isPageLoad = type === 'page_load';
|
|
662
678
|
var calculatePageVisibilityFromTheStartOfPageLoad = config.enableBetterPageVisibilityApi && isPageLoad;
|
|
663
679
|
var moreAccuratePageVisibilityAtTTI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTI(interaction) : null;
|
|
664
680
|
var moreAccuratePageVisibilityAtTTAI = calculatePageVisibilityFromTheStartOfPageLoad ? getMoreAccuratePageVisibilityUpToTTAI(interaction) : null;
|
|
665
681
|
var labelStack = interaction.labelStack ? {
|
|
666
|
-
labelStack: optimizeLabelStack(interaction.labelStack)
|
|
682
|
+
labelStack: (0, _utils.optimizeLabelStack)(interaction.labelStack)
|
|
667
683
|
} : {};
|
|
668
684
|
// Page Load
|
|
669
685
|
var getPageLoadInteractionMetrics = function getPageLoadInteractionMetrics() {
|
|
@@ -693,7 +709,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
693
709
|
var labelStack = _ref6.labelStack,
|
|
694
710
|
others = (0, _objectWithoutProperties2.default)(_ref6, _excluded3);
|
|
695
711
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
696
|
-
labelStack: labelStack && optimizeLabelStack(labelStack)
|
|
712
|
+
labelStack: labelStack && (0, _utils.optimizeLabelStack)(labelStack)
|
|
697
713
|
});
|
|
698
714
|
}),
|
|
699
715
|
holdActive: (0, _toConsumableArray2.default)(interaction.holdActive.values()),
|
|
@@ -726,7 +742,7 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
726
742
|
source: 'measured',
|
|
727
743
|
tags: ['observability'],
|
|
728
744
|
attributes: {
|
|
729
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
745
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
730
746
|
// basic
|
|
731
747
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
732
748
|
'event:product': config.product,
|
|
@@ -740,7 +756,8 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
740
756
|
'event:region': config.region || 'unknown',
|
|
741
757
|
'experience:key': 'custom.interaction-metrics',
|
|
742
758
|
'experience:name': newUFOName
|
|
743
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), {}, {
|
|
759
|
+
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), {}, {
|
|
760
|
+
errorCount: (0, _globalErrorHandler.getGlobalErrorCount)(),
|
|
744
761
|
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
745
762
|
namePrefix: config.namePrefix || '',
|
|
746
763
|
segmentPrefix: config.segmentPrefix || '',
|
|
@@ -762,16 +779,17 @@ function createInteractionMetricsPayload(interaction, interactionId) {
|
|
|
762
779
|
apdex: optimizeApdex(interaction.apdex),
|
|
763
780
|
end: Math.round(end),
|
|
764
781
|
start: Math.round(start),
|
|
765
|
-
segments: segments.map(function (_ref7) {
|
|
782
|
+
segments: _constants.REACT_UFO_VERSION === '2.0.0' ? segmentTree : segments.map(function (_ref7) {
|
|
766
783
|
var labelStack = _ref7.labelStack,
|
|
767
784
|
others = (0, _objectWithoutProperties2.default)(_ref7, _excluded4);
|
|
768
785
|
return _objectSpread(_objectSpread({}, others), {}, {
|
|
769
|
-
labelStack: optimizeLabelStack(labelStack)
|
|
786
|
+
labelStack: (0, _utils.optimizeLabelStack)(labelStack)
|
|
770
787
|
});
|
|
771
788
|
}),
|
|
772
789
|
marks: optimizeMarks(interaction.marks),
|
|
773
790
|
customData: optimizeCustomData(interaction),
|
|
774
|
-
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
|
|
791
|
+
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start),
|
|
792
|
+
errorCount: interaction.errors.length
|
|
775
793
|
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
776
794
|
'ufo:payloadTime': (0, _roundNumber.roundEpsilon)(performance.now() - interactionPayloadStart)
|
|
777
795
|
})
|
|
@@ -4,10 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.sinkErrorHandler = exports.default = void 0;
|
|
7
|
+
exports.sinkErrorHandler = exports.getGlobalErrorCount = exports.default = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _bindEventListener = require("bind-event-listener");
|
|
10
10
|
var shouldInitilizeGlobalErrorHandler = true;
|
|
11
|
+
var globalCount = 0;
|
|
11
12
|
var errors = [];
|
|
12
13
|
var push = function push(name, labelStack, errorType, errorMessage, errorStack) {
|
|
13
14
|
errors.push({
|
|
@@ -25,8 +26,12 @@ var sinkErrorHandler = exports.sinkErrorHandler = function sinkErrorHandler(sink
|
|
|
25
26
|
});
|
|
26
27
|
errors.length = 0;
|
|
27
28
|
};
|
|
29
|
+
var getGlobalErrorCount = exports.getGlobalErrorCount = function getGlobalErrorCount() {
|
|
30
|
+
return globalCount;
|
|
31
|
+
};
|
|
28
32
|
var handleError = function handleError(e) {
|
|
29
33
|
var _e$error;
|
|
34
|
+
globalCount++;
|
|
30
35
|
if (((_e$error = e.error) === null || _e$error === void 0 ? void 0 : _e$error.UFOhasCaught) === undefined) {
|
|
31
36
|
try {
|
|
32
37
|
if (e.error instanceof Error) {
|
|
@@ -46,6 +51,7 @@ var handleError = function handleError(e) {
|
|
|
46
51
|
}
|
|
47
52
|
};
|
|
48
53
|
var handlePromiseRejection = function handlePromiseRejection(e) {
|
|
54
|
+
globalCount++;
|
|
49
55
|
if (e.reason instanceof Error) {
|
|
50
56
|
push('GlobalErrorHandler', null, e.reason.name, e.reason.message, e.reason.stack);
|
|
51
57
|
} else if (e.reason) {
|
|
@@ -41,13 +41,6 @@ var init = exports.init = function init(analyticsWebClientAsync, config) {
|
|
|
41
41
|
if (initialized) {
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
|
-
try {
|
|
45
|
-
if (window !== undefined) {
|
|
46
|
-
window.__REACT_UFO_ENABLE_PERF_TRACING = Boolean(sessionStorage.getItem('additionalPerfMarks') === 'true');
|
|
47
|
-
}
|
|
48
|
-
} catch (err) {
|
|
49
|
-
/* do nothing */
|
|
50
|
-
}
|
|
51
44
|
(0, _config.setUFOConfig)(config);
|
|
52
45
|
if ((_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled) {
|
|
53
46
|
var vcOptions = {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
export const REACT_UFO_VERSION = fg('react-ufo-payload-segment-compressed') ? '2.0.0' : '1.0.1';
|
|
@@ -1,8 +1,59 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
|
2
|
+
import { REACT_UFO_VERSION } from '../../../common/constants';
|
|
1
3
|
export const sanitizeUfoName = name => {
|
|
2
4
|
return name.replace(/_/g, '-');
|
|
3
5
|
};
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
6
|
export function isSegmentLabel(obj) {
|
|
7
7
|
return obj && typeof obj.name === 'string' && typeof obj.segmentId === 'string';
|
|
8
|
+
}
|
|
9
|
+
export function buildSegmentTree(labelStacks) {
|
|
10
|
+
const r = {
|
|
11
|
+
n: 'segment-tree-root',
|
|
12
|
+
c: {}
|
|
13
|
+
};
|
|
14
|
+
labelStacks.forEach(labelStack => {
|
|
15
|
+
let currentNode = r;
|
|
16
|
+
labelStack.forEach((label, index) => {
|
|
17
|
+
var _currentNode$c;
|
|
18
|
+
const name = label.name;
|
|
19
|
+
const id = isSegmentLabel(label) ? label.segmentId : undefined;
|
|
20
|
+
const key = id !== undefined ? id.toString() : name;
|
|
21
|
+
if (currentNode.c && !currentNode.c[key]) {
|
|
22
|
+
currentNode.c[key] = {
|
|
23
|
+
n: name
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
currentNode = (_currentNode$c = currentNode.c) === null || _currentNode$c === void 0 ? void 0 : _currentNode$c[key];
|
|
27
|
+
if (index < labelStack.length - 1) {
|
|
28
|
+
currentNode.c = {
|
|
29
|
+
...(currentNode.c || {})
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
r
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export function stringifyLabelStackFully(labelStack) {
|
|
39
|
+
return labelStack.map(l => {
|
|
40
|
+
if (isSegmentLabel(l)) {
|
|
41
|
+
return `${l.name}:${l.segmentId}`;
|
|
42
|
+
}
|
|
43
|
+
return l.name;
|
|
44
|
+
}).join('/');
|
|
45
|
+
}
|
|
46
|
+
function getLabelStackReference(labelStack) {
|
|
47
|
+
return labelStack.map(l => isSegmentLabel(l) ? l.segmentId : l.name).join('/');
|
|
48
|
+
}
|
|
49
|
+
export function labelStackStartWith(labelStack, startWith) {
|
|
50
|
+
return stringifyLabelStackFully(labelStack).startsWith(stringifyLabelStackFully(startWith));
|
|
51
|
+
}
|
|
52
|
+
export function optimizeLabelStack(labelStack) {
|
|
53
|
+
return REACT_UFO_VERSION === '2.0.0' ? getLabelStackReference(labelStack) : labelStack.map(ls => ({
|
|
54
|
+
n: ls.name,
|
|
55
|
+
...(ls.segmentId ? {
|
|
56
|
+
s: ls.segmentId
|
|
57
|
+
} : {})
|
|
58
|
+
}));
|
|
8
59
|
}
|