@atlaskit/react-ufo 4.5.12 → 4.6.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 +19 -0
- package/dist/cjs/config/index.js +19 -6
- package/dist/cjs/create-payload/index.js +3 -1
- package/dist/cjs/create-post-interaction-log-payload/get-late-mutations.js +15 -3
- package/dist/cjs/create-post-interaction-log-payload/index.js +2 -1
- package/dist/cjs/interaction-metrics/index.js +2 -1
- package/dist/cjs/segment/segment.js +19 -2
- package/dist/cjs/trace-hover/index.js +12 -0
- package/dist/cjs/trace-interaction/internal/trace-ufo-interaction.js +23 -6
- package/dist/cjs/vc/vc-observer-new/index.js +74 -11
- package/dist/cjs/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +91 -36
- package/dist/es2019/config/index.js +13 -0
- package/dist/es2019/create-payload/index.js +3 -0
- package/dist/es2019/create-post-interaction-log-payload/get-late-mutations.js +12 -3
- package/dist/es2019/create-post-interaction-log-payload/index.js +2 -1
- package/dist/es2019/interaction-metrics/index.js +2 -1
- package/dist/es2019/segment/segment.js +21 -4
- package/dist/es2019/trace-hover/index.js +5 -0
- package/dist/es2019/trace-interaction/internal/trace-ufo-interaction.js +24 -7
- package/dist/es2019/vc/vc-observer-new/index.js +67 -10
- package/dist/es2019/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +56 -8
- package/dist/esm/config/index.js +18 -6
- package/dist/esm/create-payload/index.js +3 -1
- package/dist/esm/create-post-interaction-log-payload/get-late-mutations.js +15 -3
- package/dist/esm/create-post-interaction-log-payload/index.js +2 -1
- package/dist/esm/interaction-metrics/index.js +2 -1
- package/dist/esm/segment/segment.js +21 -4
- package/dist/esm/trace-hover/index.js +5 -0
- package/dist/esm/trace-interaction/internal/trace-ufo-interaction.js +24 -7
- package/dist/esm/vc/vc-observer-new/index.js +74 -11
- package/dist/esm/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.js +91 -36
- package/dist/types/common/common/types.d.ts +5 -0
- package/dist/types/common/react-ufo-payload-schema.d.ts +4 -1
- package/dist/types/common/vc/types.d.ts +7 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/create-payload/index.d.ts +512 -0
- package/dist/types/create-post-interaction-log-payload/get-late-mutations.d.ts +2 -2
- package/dist/types/trace-hover/index.d.ts +2 -0
- package/dist/types/vc/vc-observer/getVCRevisionDebugDetails.d.ts +1 -1
- package/dist/types/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +1 -0
- package/dist/types/vc/vc-observer-new/types.d.ts +5 -0
- package/dist/types-ts4.5/common/common/types.d.ts +5 -0
- package/dist/types-ts4.5/common/react-ufo-payload-schema.d.ts +4 -1
- package/dist/types-ts4.5/common/vc/types.d.ts +7 -0
- package/dist/types-ts4.5/config/index.d.ts +2 -0
- package/dist/types-ts4.5/create-payload/index.d.ts +512 -0
- package/dist/types-ts4.5/create-post-interaction-log-payload/get-late-mutations.d.ts +2 -2
- package/dist/types-ts4.5/trace-hover/index.d.ts +2 -0
- package/dist/types-ts4.5/vc/vc-observer/getVCRevisionDebugDetails.d.ts +1 -1
- package/dist/types-ts4.5/vc/vc-observer-new/metric-calculator/abstract-base-vc-calculator.d.ts +1 -0
- package/dist/types-ts4.5/vc/vc-observer-new/types.d.ts +5 -0
- package/package.json +13 -1
- package/trace-hover/package.json +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 4.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a308f1abf3cf2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a308f1abf3cf2) -
|
|
8
|
+
unify abort status within TTVC debug data
|
|
9
|
+
|
|
10
|
+
## 4.6.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`a5c2905c301d6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/a5c2905c301d6) -
|
|
15
|
+
add tracking of minor interactions
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`135fc7330f9f3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/135fc7330f9f3) -
|
|
20
|
+
serialise TTVC v3 debug data rectangles
|
|
21
|
+
|
|
3
22
|
## 4.5.12
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/cjs/config/index.js
CHANGED
|
@@ -15,6 +15,7 @@ exports.getExperimentalInteractionRate = getExperimentalInteractionRate;
|
|
|
15
15
|
exports.getExtraInteractionRate = getExtraInteractionRate;
|
|
16
16
|
exports.getInteractionRate = getInteractionRate;
|
|
17
17
|
exports.getInteractionTimeout = getInteractionTimeout;
|
|
18
|
+
exports.getMinorInteractions = getMinorInteractions;
|
|
18
19
|
exports.getMostRecentVCRevision = getMostRecentVCRevision;
|
|
19
20
|
exports.getPostInteractionRate = getPostInteractionRate;
|
|
20
21
|
exports.getReactHydrationStats = getReactHydrationStats;
|
|
@@ -299,6 +300,18 @@ function getUfoNameOverrides() {
|
|
|
299
300
|
return undefined;
|
|
300
301
|
}
|
|
301
302
|
}
|
|
303
|
+
function getMinorInteractions() {
|
|
304
|
+
try {
|
|
305
|
+
if (!config) {
|
|
306
|
+
return undefined;
|
|
307
|
+
}
|
|
308
|
+
var _config8 = config,
|
|
309
|
+
minorInteractions = _config8.minorInteractions;
|
|
310
|
+
return minorInteractions;
|
|
311
|
+
} catch (e) {
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
302
315
|
|
|
303
316
|
// Contains the list of interactions that do not abort existing known interactions
|
|
304
317
|
function getDoNotAbortActivePressInteraction() {
|
|
@@ -306,8 +319,8 @@ function getDoNotAbortActivePressInteraction() {
|
|
|
306
319
|
if (!config) {
|
|
307
320
|
return undefined;
|
|
308
321
|
}
|
|
309
|
-
var
|
|
310
|
-
doNotAbortActivePressInteraction =
|
|
322
|
+
var _config9 = config,
|
|
323
|
+
doNotAbortActivePressInteraction = _config9.doNotAbortActivePressInteraction;
|
|
311
324
|
return doNotAbortActivePressInteraction;
|
|
312
325
|
} catch (e) {
|
|
313
326
|
return undefined;
|
|
@@ -320,8 +333,8 @@ function getDoNotAbortActivePressInteractionOnTransition() {
|
|
|
320
333
|
if (!config) {
|
|
321
334
|
return undefined;
|
|
322
335
|
}
|
|
323
|
-
var
|
|
324
|
-
doNotAbortActivePressInteractionOnTransition =
|
|
336
|
+
var _config0 = config,
|
|
337
|
+
doNotAbortActivePressInteractionOnTransition = _config0.doNotAbortActivePressInteractionOnTransition;
|
|
325
338
|
return doNotAbortActivePressInteractionOnTransition;
|
|
326
339
|
} catch (e) {
|
|
327
340
|
return undefined;
|
|
@@ -333,8 +346,8 @@ function getInteractionTimeout(ufoName) {
|
|
|
333
346
|
if (!config) {
|
|
334
347
|
return CLEANUP_TIMEOUT;
|
|
335
348
|
}
|
|
336
|
-
var
|
|
337
|
-
interactionTimeout =
|
|
349
|
+
var _config1 = config,
|
|
350
|
+
interactionTimeout = _config1.interactionTimeout;
|
|
338
351
|
if (interactionTimeout != null && interactionTimeout[ufoName] != null) {
|
|
339
352
|
return interactionTimeout[ufoName];
|
|
340
353
|
}
|
|
@@ -748,7 +748,7 @@ function _createInteractionMetricsPayload() {
|
|
|
748
748
|
'ufo:multipayload': true,
|
|
749
749
|
'ufo:criticalPayloadCount': criticalPayloadCount
|
|
750
750
|
} : {}), (0, _getBrowserMetadata.getBrowserMetadataToLegacyFormat)()), getSSRProperties(type)), getAssetsMetrics(interaction, pageLoadInteractionMetrics === null || pageLoadInteractionMetrics === void 0 ? void 0 : pageLoadInteractionMetrics.SSRDoneTime)), getPPSMetrics(interaction)), paintMetrics), (0, _getNavigationMetrics.getNavigationMetricsToLegacyFormat)(type)), finalVCMetrics), experimentalMetrics), (_config$additionalPay = config.additionalPayloadData) === null || _config$additionalPay === void 0 ? void 0 : _config$additionalPay.call(config, interaction)), getTracingContextData(interaction)), getStylesheetMetrics()), getErrorCounts(interaction)), getReactHydrationStats()), {}, {
|
|
751
|
-
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
751
|
+
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
752
752
|
namePrefix: config.namePrefix || '',
|
|
753
753
|
segmentPrefix: config.segmentPrefix || '',
|
|
754
754
|
interactionId: interactionId,
|
|
@@ -782,6 +782,8 @@ function _createInteractionMetricsPayload() {
|
|
|
782
782
|
unknownElementName: unknownElementName
|
|
783
783
|
} : {}), unknownElementHierarchy ? {
|
|
784
784
|
unknownElementHierarchy: unknownElementHierarchy
|
|
785
|
+
} : {}), (0, _platformFeatureFlags.fg)('platform_ufo_enable_minor_interactions') ? {
|
|
786
|
+
minorInteractions: interaction.minorInteractions
|
|
785
787
|
} : {}),
|
|
786
788
|
'ufo:payloadTime': (0, _roundNumber.roundEpsilon)(performance.now() - interactionPayloadStart)
|
|
787
789
|
})
|
|
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
7
8
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
8
9
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
10
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
10
|
-
function getLateMutations(vcDetails
|
|
11
|
+
function getLateMutations(vcDetails) {
|
|
12
|
+
var labelStacks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
|
+
var lastInteractionFinish = arguments.length > 2 ? arguments[2] : undefined;
|
|
14
|
+
var postInteractionFinishVCRatios = arguments.length > 3 ? arguments[3] : undefined;
|
|
11
15
|
// Map to track which elements are already seen for each timestamp
|
|
12
16
|
var seen = new Map();
|
|
13
17
|
var result = [];
|
|
@@ -29,11 +33,19 @@ function getLateMutations(vcDetails, lastInteractionFinish, postInteractionFinis
|
|
|
29
33
|
continue;
|
|
30
34
|
}
|
|
31
35
|
seenElements.add(element);
|
|
32
|
-
|
|
36
|
+
var lateMutation = {
|
|
33
37
|
time: details.t,
|
|
34
38
|
element: element,
|
|
35
39
|
viewportHeatmapPercentage: (postInteractionFinishVCRatios === null || postInteractionFinishVCRatios === void 0 ? void 0 : postInteractionFinishVCRatios[element]) || 0
|
|
36
|
-
}
|
|
40
|
+
};
|
|
41
|
+
if (labelStacks && (0, _platformFeatureFlags.fg)('platform_ufo_enable_late_mutation_label_stacks')) {
|
|
42
|
+
var labels = labelStacks[element];
|
|
43
|
+
if (labels) {
|
|
44
|
+
lateMutation.segment = labels.segment;
|
|
45
|
+
lateMutation.labelStack = labels.labelStack;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
result.push(lateMutation);
|
|
37
49
|
}
|
|
38
50
|
} catch (err) {
|
|
39
51
|
_iterator.e(err);
|
|
@@ -190,8 +190,9 @@ function createPostInteractionLogPayload(_ref2) {
|
|
|
190
190
|
revisedVC90 = (_postInteractionFinis = postInteractionFinishRevision['metric:vc90']) !== null && _postInteractionFinis !== void 0 ? _postInteractionFinis : null;
|
|
191
191
|
}
|
|
192
192
|
var vcDetails = postInteractionFinishRevision.vcDetails;
|
|
193
|
+
var labelStacks = postInteractionFinishRevision.labelStacks;
|
|
193
194
|
if (vcDetails) {
|
|
194
|
-
lateMutations = (0, _getLateMutations.default)(vcDetails, lastInteractionFinish, postInteractionFinishVCRatios);
|
|
195
|
+
lateMutations = (0, _getLateMutations.default)(vcDetails, labelStacks, lastInteractionFinish, postInteractionFinishVCRatios);
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
return {
|
|
@@ -1101,7 +1101,8 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
|
|
|
1101
1101
|
trace: trace,
|
|
1102
1102
|
vcObserver: vcObserver,
|
|
1103
1103
|
hold3pActive: new Map(),
|
|
1104
|
-
hold3pInfo: []
|
|
1104
|
+
hold3pInfo: [],
|
|
1105
|
+
minorInteractions: []
|
|
1105
1106
|
};
|
|
1106
1107
|
if (addFeatureFlagsToInteraction) {
|
|
1107
1108
|
_featureFlagsAccessed.currentFeatureFlagsAccessed.clear();
|
|
@@ -11,6 +11,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _scheduler = require("scheduler");
|
|
13
13
|
var _uuid = require("uuid");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
15
|
var _coinflip = _interopRequireDefault(require("../coinflip"));
|
|
15
16
|
var _config = require("../config");
|
|
16
17
|
var _experienceTraceIdContext = require("../experience-trace-id-context");
|
|
@@ -172,8 +173,24 @@ function UFOSegment(_ref) {
|
|
|
172
173
|
tracePress: function tracePress() {
|
|
173
174
|
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'unknown';
|
|
174
175
|
var timestamp = arguments.length > 1 ? arguments[1] : undefined;
|
|
175
|
-
if (
|
|
176
|
-
|
|
176
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_minor_interactions')) {
|
|
177
|
+
var _getDoNotAbortActiveP, _getMinorInteractions;
|
|
178
|
+
var minorInteractions = [].concat((0, _toConsumableArray2.default)((_getDoNotAbortActiveP = (0, _config.getDoNotAbortActivePressInteraction)()) !== null && _getDoNotAbortActiveP !== void 0 ? _getDoNotAbortActiveP : []), (0, _toConsumableArray2.default)((_getMinorInteractions = (0, _config.getMinorInteractions)()) !== null && _getMinorInteractions !== void 0 ? _getMinorInteractions : []));
|
|
179
|
+
if (minorInteractions.includes(name)) {
|
|
180
|
+
var _activeInteraction$mi;
|
|
181
|
+
var activeInteraction = (0, _interactionMetrics.getActiveInteraction)();
|
|
182
|
+
activeInteraction === null || activeInteraction === void 0 || (_activeInteraction$mi = activeInteraction.minorInteractions) === null || _activeInteraction$mi === void 0 || _activeInteraction$mi.push({
|
|
183
|
+
name: name,
|
|
184
|
+
startTime: timestamp !== null && timestamp !== void 0 ? timestamp : performance.now()
|
|
185
|
+
});
|
|
186
|
+
return;
|
|
187
|
+
} else if (interactionId.current != null) {
|
|
188
|
+
(0, _interactionMetrics.abortByNewInteraction)(interactionId.current, name);
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
if (interactionId.current != null) {
|
|
192
|
+
(0, _interactionMetrics.abortByNewInteraction)(interactionId.current, name);
|
|
193
|
+
}
|
|
177
194
|
}
|
|
178
195
|
var rate = (0, _config.getInteractionRate)(name, 'press');
|
|
179
196
|
if ((0, _coinflip.default)(rate)) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _traceUfoInteraction = _interopRequireDefault(require("../trace-interaction/internal/trace-ufo-interaction"));
|
|
9
|
+
function traceUFOHover(name, timestamp) {
|
|
10
|
+
return (0, _traceUfoInteraction.default)(name, 'hover', timestamp);
|
|
11
|
+
}
|
|
12
|
+
var _default = exports.default = traceUFOHover;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _uuid = require("uuid");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
9
10
|
var _coinflip = _interopRequireDefault(require("../../coinflip"));
|
|
10
11
|
var _config = require("../../config");
|
|
11
12
|
var _experienceTraceIdContext = require("../../experience-trace-id-context");
|
|
@@ -15,15 +16,31 @@ var _routeNameContext = _interopRequireDefault(require("../../route-name-context
|
|
|
15
16
|
function traceUFOInteraction(name, interactionType, startTime) {
|
|
16
17
|
var rate = (0, _config.getInteractionRate)(name, interactionType);
|
|
17
18
|
var pressInteractionsList = (0, _config.getDoNotAbortActivePressInteraction)();
|
|
18
|
-
if (
|
|
19
|
-
var
|
|
20
|
-
|
|
19
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_minor_interactions')) {
|
|
20
|
+
var _getMinorInteractions;
|
|
21
|
+
var minorInteractions = (pressInteractionsList !== null && pressInteractionsList !== void 0 ? pressInteractionsList : []).concat((_getMinorInteractions = (0, _config.getMinorInteractions)()) !== null && _getMinorInteractions !== void 0 ? _getMinorInteractions : []);
|
|
22
|
+
if (minorInteractions.includes(name)) {
|
|
23
|
+
var _activeInteraction$mi;
|
|
24
|
+
var activeInteraction = (0, _interactionMetrics.getActiveInteraction)();
|
|
25
|
+
activeInteraction === null || activeInteraction === void 0 || (_activeInteraction$mi = activeInteraction.minorInteractions) === null || _activeInteraction$mi === void 0 || _activeInteraction$mi.push({
|
|
26
|
+
name: name,
|
|
27
|
+
startTime: startTime !== null && startTime !== void 0 ? startTime : performance.now()
|
|
28
|
+
});
|
|
21
29
|
return;
|
|
30
|
+
} else {
|
|
31
|
+
(0, _interactionMetrics.abortAll)('new_interaction', name);
|
|
22
32
|
}
|
|
23
33
|
} else {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
34
|
+
if (pressInteractionsList !== null && pressInteractionsList !== void 0 && pressInteractionsList.includes(name)) {
|
|
35
|
+
var interaction = (0, _interactionMetrics.getActiveInteraction)();
|
|
36
|
+
if ((interaction === null || interaction === void 0 ? void 0 : interaction.ufoName) !== 'unknown' && (interaction === null || interaction === void 0 ? void 0 : interaction.type) === 'press') {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
// Abort any existing interaction regardless of the coinflip outcome
|
|
41
|
+
// Ensures measurements are not carried over between distinct interactions
|
|
42
|
+
(0, _interactionMetrics.abortAll)('new_interaction', name);
|
|
43
|
+
}
|
|
27
44
|
}
|
|
28
45
|
if ((0, _coinflip.default)(rate)) {
|
|
29
46
|
var startTimestamp = startTime !== null && startTime !== void 0 ? startTime : performance.now();
|
|
@@ -12,6 +12,7 @@ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
15
16
|
var _ssrPlaceholders = require("../vc-observer/observers/ssr-placeholders");
|
|
16
17
|
var _entriesTimeline = _interopRequireDefault(require("./entries-timeline"));
|
|
17
18
|
var _getElementName2 = _interopRequireDefault(require("./get-element-name"));
|
|
@@ -75,18 +76,27 @@ var VCObserverNew = exports.default = /*#__PURE__*/function () {
|
|
|
75
76
|
if (element) {
|
|
76
77
|
elementName = _this.getElementName(element);
|
|
77
78
|
}
|
|
79
|
+
var data = {
|
|
80
|
+
type: type,
|
|
81
|
+
elementName: elementName,
|
|
82
|
+
rect: rect,
|
|
83
|
+
previousRect: previousRect,
|
|
84
|
+
visible: visible,
|
|
85
|
+
attributeName: mutationData === null || mutationData === void 0 ? void 0 : mutationData.attributeName,
|
|
86
|
+
oldValue: mutationData === null || mutationData === void 0 ? void 0 : mutationData.oldValue,
|
|
87
|
+
newValue: mutationData === null || mutationData === void 0 ? void 0 : mutationData.newValue
|
|
88
|
+
};
|
|
89
|
+
if (element && _this.isPostInteraction && (0, _platformFeatureFlags.fg)('platform_ufo_enable_late_mutation_label_stacks')) {
|
|
90
|
+
var labelStacks = getLabelStacks(element);
|
|
91
|
+
if (labelStacks) {
|
|
92
|
+
Object.assign(data, {
|
|
93
|
+
labelStacks: labelStacks
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
78
97
|
_this.entriesTimeline.push({
|
|
79
98
|
time: time,
|
|
80
|
-
data:
|
|
81
|
-
type: type,
|
|
82
|
-
elementName: elementName,
|
|
83
|
-
rect: rect,
|
|
84
|
-
previousRect: previousRect,
|
|
85
|
-
visible: visible,
|
|
86
|
-
attributeName: mutationData === null || mutationData === void 0 ? void 0 : mutationData.attributeName,
|
|
87
|
-
oldValue: mutationData === null || mutationData === void 0 ? void 0 : mutationData.oldValue,
|
|
88
|
-
newValue: mutationData === null || mutationData === void 0 ? void 0 : mutationData.newValue
|
|
89
|
-
}
|
|
99
|
+
data: data
|
|
90
100
|
});
|
|
91
101
|
},
|
|
92
102
|
// Pass SSR context to ViewportObserver
|
|
@@ -308,4 +318,57 @@ var VCObserverNew = exports.default = /*#__PURE__*/function () {
|
|
|
308
318
|
return (0, _getElementName2.default)(this.selectorConfig, element);
|
|
309
319
|
}
|
|
310
320
|
}]);
|
|
311
|
-
}();
|
|
321
|
+
}();
|
|
322
|
+
function labelStackFromFiber(fiber) {
|
|
323
|
+
var _fiber$child;
|
|
324
|
+
var value = fiber === null || fiber === void 0 || (_fiber$child = fiber.child) === null || _fiber$child === void 0 || (_fiber$child = _fiber$child.memoizedProps) === null || _fiber$child === void 0 ? void 0 : _fiber$child.value;
|
|
325
|
+
return Array.isArray(value === null || value === void 0 ? void 0 : value.labelStack) ? value.labelStack : [];
|
|
326
|
+
}
|
|
327
|
+
function labelStackToString(labelStack) {
|
|
328
|
+
return labelStack.map(function (label) {
|
|
329
|
+
return label.name;
|
|
330
|
+
}).join('/');
|
|
331
|
+
}
|
|
332
|
+
function labelStackToSegment(labelStack) {
|
|
333
|
+
var segmentIndex = -1;
|
|
334
|
+
for (var i = labelStack.length - 1; i >= 0; i--) {
|
|
335
|
+
if (labelStack[i].segmentId) {
|
|
336
|
+
segmentIndex = i;
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return labelStack.slice(0, segmentIndex + 1).map(function (label) {
|
|
341
|
+
return label.name;
|
|
342
|
+
}).join('/');
|
|
343
|
+
}
|
|
344
|
+
function traverseFiber(fiber) {
|
|
345
|
+
var segment = 'unknown';
|
|
346
|
+
var labelStackString = 'unknown';
|
|
347
|
+
var currentFiber = fiber;
|
|
348
|
+
while (currentFiber) {
|
|
349
|
+
if (currentFiber.type) {
|
|
350
|
+
var componentName = currentFiber.type.displayName || currentFiber.type.name;
|
|
351
|
+
if (componentName === 'UFOSegment' || componentName === 'UFOLabel') {
|
|
352
|
+
var labelStack = labelStackFromFiber(currentFiber);
|
|
353
|
+
labelStackString = labelStackToString(labelStack) || 'unknown';
|
|
354
|
+
segment = labelStackToSegment(labelStack) || 'unknown';
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
currentFiber = currentFiber.return;
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
segment: segment,
|
|
362
|
+
labelStack: labelStackString
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function getLabelStacks(element) {
|
|
366
|
+
var reactFiberKey = Object.keys(element).find(function (key) {
|
|
367
|
+
return key.startsWith('__reactFiber$');
|
|
368
|
+
});
|
|
369
|
+
if (!reactFiberKey) {
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
372
|
+
var fiber = element[reactFiberKey];
|
|
373
|
+
return fiber ? traverseFiber(fiber) : null;
|
|
374
|
+
}
|
|
@@ -13,6 +13,9 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
13
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
15
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
|
+
var _getPageVisibilityUpToTtai = _interopRequireDefault(require("../../../create-payload/utils/get-page-visibility-up-to-ttai"));
|
|
17
|
+
var _interactionIdContext = require("../../../interaction-id-context");
|
|
18
|
+
var _constants = require("../../../interaction-metrics/common/constants");
|
|
16
19
|
var _trackDisplayContentOccurrence = require("../viewport-observer/utils/track-display-content-occurrence");
|
|
17
20
|
var _percentileCalc = require("./percentile-calc");
|
|
18
21
|
var _getViewportHeight = _interopRequireDefault(require("./utils/get-viewport-height"));
|
|
@@ -82,12 +85,35 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
82
85
|
}
|
|
83
86
|
return ratios;
|
|
84
87
|
}
|
|
88
|
+
}, {
|
|
89
|
+
key: "getLabelStacks",
|
|
90
|
+
value: function getLabelStacks(filteredEntries) {
|
|
91
|
+
var labelStacks = {};
|
|
92
|
+
var _iterator3 = _createForOfIteratorHelper(filteredEntries),
|
|
93
|
+
_step3;
|
|
94
|
+
try {
|
|
95
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
96
|
+
var _entry2 = _step3.value;
|
|
97
|
+
if ('elementName' in _entry2.data && _entry2.data.labelStacks) {
|
|
98
|
+
labelStacks[_entry2.data.elementName] = {
|
|
99
|
+
segment: _entry2.data.labelStacks.segment,
|
|
100
|
+
labelStack: _entry2.data.labelStacks.labelStack
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
} catch (err) {
|
|
105
|
+
_iterator3.e(err);
|
|
106
|
+
} finally {
|
|
107
|
+
_iterator3.f();
|
|
108
|
+
}
|
|
109
|
+
return labelStacks;
|
|
110
|
+
}
|
|
85
111
|
}, {
|
|
86
112
|
key: "calculateWithDebugInfo",
|
|
87
113
|
value: function () {
|
|
88
114
|
var _calculateWithDebugInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(filteredEntries, startTime, stopTime, isPostInteraction, isVCClean, interactionId, dirtyReason, allEntries, include3p) {
|
|
89
115
|
var _window, _window2, _window3, _window5;
|
|
90
|
-
var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer,
|
|
116
|
+
var percentiles, viewportEntries, vcLogs, vcDetails, percentileIndex, entryDataBuffer, _iterator4, _step4, _entry3, time, viewportPercentage, entries, elementNames, previousResult, i, percentile, enhancedVcLogs, shouldCalculate3p, shouldCalculateDebugDetails, sortedVcLogs, maxViewportPercentageAtTime, maxSoFar, _iterator5, _step5, log, getBiggestPreviousViewportPercentage, ignoredEntriesByTime, _iterator6, _step6, _entry4, _ignoredEntriesByTime, _viewportData$rect, _viewportData$previou, viewportData, timestamp, additionalVcLogs, _iterator7, _step7, _step7$value, _timestamp, ignoredEntries, _viewportPercentage, v3RevisionDebugDetails, _activeInteractionId$, activeInteractionId, activeInteraction, pageVisibilityUpToTTAI, isBackgrounded, _window4, _window4$__ufo_devtoo, _window6, _window6$__on_ufo_vc_;
|
|
91
117
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
92
118
|
while (1) switch (_context.prev = _context.next) {
|
|
93
119
|
case 0:
|
|
@@ -115,16 +141,16 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
115
141
|
_context.next = 29;
|
|
116
142
|
break;
|
|
117
143
|
}
|
|
118
|
-
|
|
144
|
+
_iterator4 = _createForOfIteratorHelper(vcLogs);
|
|
119
145
|
_context.prev = 11;
|
|
120
|
-
|
|
146
|
+
_iterator4.s();
|
|
121
147
|
case 13:
|
|
122
|
-
if ((
|
|
148
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
123
149
|
_context.next = 21;
|
|
124
150
|
break;
|
|
125
151
|
}
|
|
126
|
-
|
|
127
|
-
time =
|
|
152
|
+
_entry3 = _step4.value;
|
|
153
|
+
time = _entry3.time, viewportPercentage = _entry3.viewportPercentage, entries = _entry3.entries; // Only process entries if we haven't reached all percentiles
|
|
128
154
|
if (!(percentileIndex >= percentiles.length)) {
|
|
129
155
|
_context.next = 18;
|
|
130
156
|
break;
|
|
@@ -161,10 +187,10 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
161
187
|
case 23:
|
|
162
188
|
_context.prev = 23;
|
|
163
189
|
_context.t0 = _context["catch"](11);
|
|
164
|
-
|
|
190
|
+
_iterator4.e(_context.t0);
|
|
165
191
|
case 26:
|
|
166
192
|
_context.prev = 26;
|
|
167
|
-
|
|
193
|
+
_iterator4.f();
|
|
168
194
|
return _context.finish(26);
|
|
169
195
|
case 29:
|
|
170
196
|
// Fill in any missing percentiles with the last known values
|
|
@@ -181,7 +207,15 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
181
207
|
}
|
|
182
208
|
}
|
|
183
209
|
enhancedVcLogs = vcLogs ? vcLogs.map(function (log) {
|
|
184
|
-
return _objectSpread(_objectSpread({}, log),
|
|
210
|
+
return _objectSpread(_objectSpread(_objectSpread({}, log), (0, _platformFeatureFlags.fg)('platform_ufo_serialise_ttvc_v3_debug_data') && {
|
|
211
|
+
entries: log.entries.map(function (entry) {
|
|
212
|
+
var _entry$rect, _entry$previousRect;
|
|
213
|
+
return _objectSpread(_objectSpread({}, entry), {}, {
|
|
214
|
+
rect: (_entry$rect = entry.rect) === null || _entry$rect === void 0 ? void 0 : _entry$rect.toJSON(),
|
|
215
|
+
previousRect: (_entry$previousRect = entry.previousRect) === null || _entry$previousRect === void 0 ? void 0 : _entry$previousRect.toJSON()
|
|
216
|
+
});
|
|
217
|
+
})
|
|
218
|
+
}), {}, {
|
|
185
219
|
viewportPercentage: log.viewportPercentage
|
|
186
220
|
});
|
|
187
221
|
}) : []; // If 3p metric enabled - calculate the debug details
|
|
@@ -194,10 +228,10 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
194
228
|
}); // Pre-calculate max viewport percentage up to each time for efficient lookups
|
|
195
229
|
maxViewportPercentageAtTime = new Map();
|
|
196
230
|
maxSoFar = 0;
|
|
197
|
-
|
|
231
|
+
_iterator5 = _createForOfIteratorHelper(sortedVcLogs);
|
|
198
232
|
try {
|
|
199
|
-
for (
|
|
200
|
-
log =
|
|
233
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
234
|
+
log = _step5.value;
|
|
201
235
|
if (log.viewportPercentage !== null) {
|
|
202
236
|
maxSoFar = Math.max(maxSoFar, log.viewportPercentage);
|
|
203
237
|
maxViewportPercentageAtTime.set(log.time, maxSoFar);
|
|
@@ -206,9 +240,9 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
206
240
|
|
|
207
241
|
// Helper function to find the biggest previous viewport percentage
|
|
208
242
|
} catch (err) {
|
|
209
|
-
|
|
243
|
+
_iterator5.e(err);
|
|
210
244
|
} finally {
|
|
211
|
-
|
|
245
|
+
_iterator5.f();
|
|
212
246
|
}
|
|
213
247
|
getBiggestPreviousViewportPercentage = function getBiggestPreviousViewportPercentage(targetTime) {
|
|
214
248
|
// Binary search for the largest time <= targetTime
|
|
@@ -227,17 +261,20 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
227
261
|
return result >= 0 ? maxViewportPercentageAtTime.get(sortedVcLogs[result].time) || null : null;
|
|
228
262
|
}; // Group ignored entries by timestamp
|
|
229
263
|
ignoredEntriesByTime = new Map();
|
|
230
|
-
|
|
264
|
+
_iterator6 = _createForOfIteratorHelper(allEntries);
|
|
231
265
|
try {
|
|
232
|
-
for (
|
|
233
|
-
|
|
234
|
-
if ('rect' in
|
|
235
|
-
viewportData =
|
|
236
|
-
timestamp = Math.round(
|
|
266
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
267
|
+
_entry4 = _step6.value;
|
|
268
|
+
if ('rect' in _entry4.data && !this.isEntryIncluded(_entry4, include3p)) {
|
|
269
|
+
viewportData = _entry4.data;
|
|
270
|
+
timestamp = Math.round(_entry4.time);
|
|
237
271
|
if (!ignoredEntriesByTime.has(timestamp)) {
|
|
238
272
|
ignoredEntriesByTime.set(timestamp, []);
|
|
239
273
|
}
|
|
240
|
-
(_ignoredEntriesByTime = ignoredEntriesByTime.get(timestamp)) === null || _ignoredEntriesByTime === void 0 || _ignoredEntriesByTime.push(_objectSpread(_objectSpread({}, viewportData),
|
|
274
|
+
(_ignoredEntriesByTime = ignoredEntriesByTime.get(timestamp)) === null || _ignoredEntriesByTime === void 0 || _ignoredEntriesByTime.push(_objectSpread(_objectSpread(_objectSpread({}, viewportData), (0, _platformFeatureFlags.fg)('platform_ufo_serialise_ttvc_v3_debug_data') && {
|
|
275
|
+
rect: (_viewportData$rect = viewportData.rect) === null || _viewportData$rect === void 0 ? void 0 : _viewportData$rect.toJSON(),
|
|
276
|
+
previousRect: (_viewportData$previou = viewportData.previousRect) === null || _viewportData$previou === void 0 ? void 0 : _viewportData$previou.toJSON()
|
|
277
|
+
}), {}, {
|
|
241
278
|
ignoreReason: viewportData.visible ? viewportData.type : 'not-visible'
|
|
242
279
|
}));
|
|
243
280
|
}
|
|
@@ -245,15 +282,15 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
245
282
|
|
|
246
283
|
// Add ignored entries to vcLogs
|
|
247
284
|
} catch (err) {
|
|
248
|
-
|
|
285
|
+
_iterator6.e(err);
|
|
249
286
|
} finally {
|
|
250
|
-
|
|
287
|
+
_iterator6.f();
|
|
251
288
|
}
|
|
252
289
|
additionalVcLogs = [];
|
|
253
|
-
|
|
290
|
+
_iterator7 = _createForOfIteratorHelper(ignoredEntriesByTime);
|
|
254
291
|
try {
|
|
255
|
-
for (
|
|
256
|
-
|
|
292
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
293
|
+
_step7$value = (0, _slicedToArray2.default)(_step7.value, 2), _timestamp = _step7$value[0], ignoredEntries = _step7$value[1];
|
|
257
294
|
if (ignoredEntries.length > 0) {
|
|
258
295
|
_viewportPercentage = getBiggestPreviousViewportPercentage(_timestamp);
|
|
259
296
|
additionalVcLogs.push({
|
|
@@ -266,9 +303,9 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
266
303
|
|
|
267
304
|
// Combine and sort all vcLogs
|
|
268
305
|
} catch (err) {
|
|
269
|
-
|
|
306
|
+
_iterator7.e(err);
|
|
270
307
|
} finally {
|
|
271
|
-
|
|
308
|
+
_iterator7.f();
|
|
272
309
|
}
|
|
273
310
|
enhancedVcLogs = [].concat((0, _toConsumableArray2.default)(enhancedVcLogs), additionalVcLogs).sort(function (a, b) {
|
|
274
311
|
return a.time - b.time;
|
|
@@ -278,13 +315,28 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
278
315
|
// Only create debug details if callbacks exist
|
|
279
316
|
v3RevisionDebugDetails = null;
|
|
280
317
|
if (shouldCalculateDebugDetails) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
318
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_unify_abort_status_in_ttvc_debug_data')) {
|
|
319
|
+
// NOTE: using this instead of directly calling `getActiveInteraction()` to get around circular dependencies
|
|
320
|
+
activeInteractionId = (0, _interactionIdContext.getInteractionId)();
|
|
321
|
+
activeInteraction = _constants.interactions.get((_activeInteractionId$ = activeInteractionId.current) !== null && _activeInteractionId$ !== void 0 ? _activeInteractionId$ : '');
|
|
322
|
+
pageVisibilityUpToTTAI = activeInteraction ? (0, _getPageVisibilityUpToTtai.default)(activeInteraction) : null;
|
|
323
|
+
isBackgrounded = pageVisibilityUpToTTAI !== 'visible';
|
|
324
|
+
v3RevisionDebugDetails = {
|
|
325
|
+
revision: this.revisionNo,
|
|
326
|
+
isClean: isVCClean && !(activeInteraction !== null && activeInteraction !== void 0 && activeInteraction.abortReason) && !isBackgrounded,
|
|
327
|
+
abortReason: isBackgrounded ? 'browser_backgrounded' : dirtyReason !== null && dirtyReason !== void 0 ? dirtyReason : activeInteraction === null || activeInteraction === void 0 ? void 0 : activeInteraction.abortReason,
|
|
328
|
+
vcLogs: enhancedVcLogs,
|
|
329
|
+
interactionId: interactionId
|
|
330
|
+
};
|
|
331
|
+
} else {
|
|
332
|
+
v3RevisionDebugDetails = {
|
|
333
|
+
revision: this.revisionNo,
|
|
334
|
+
isClean: isVCClean,
|
|
335
|
+
abortReason: dirtyReason,
|
|
336
|
+
vcLogs: enhancedVcLogs,
|
|
337
|
+
interactionId: interactionId
|
|
338
|
+
};
|
|
339
|
+
}
|
|
288
340
|
}
|
|
289
341
|
|
|
290
342
|
// Handle devtool callback
|
|
@@ -368,11 +420,14 @@ var AbstractVCCalculatorBase = exports.default = /*#__PURE__*/function () {
|
|
|
368
420
|
vcDetails: vcDetails !== null && vcDetails !== void 0 ? vcDetails : undefined
|
|
369
421
|
};
|
|
370
422
|
result.ratios = this.calculateRatios(filteredEntries);
|
|
423
|
+
if (isPostInteraction) {
|
|
424
|
+
result.labelStacks = this.getLabelStacks(filteredEntries);
|
|
425
|
+
}
|
|
371
426
|
if ((0, _platformFeatureFlags.fg)('platform_ufo_display_content_track_occurrence')) {
|
|
372
427
|
result.displayContentsOccurrence = _trackDisplayContentOccurrence.cssIssueOccurrence;
|
|
373
428
|
}
|
|
374
429
|
return _context2.abrupt("return", result);
|
|
375
|
-
case
|
|
430
|
+
case 15:
|
|
376
431
|
case "end":
|
|
377
432
|
return _context2.stop();
|
|
378
433
|
}
|
|
@@ -280,6 +280,19 @@ export function getUfoNameOverrides() {
|
|
|
280
280
|
return undefined;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
+
export function getMinorInteractions() {
|
|
284
|
+
try {
|
|
285
|
+
if (!config) {
|
|
286
|
+
return undefined;
|
|
287
|
+
}
|
|
288
|
+
const {
|
|
289
|
+
minorInteractions
|
|
290
|
+
} = config;
|
|
291
|
+
return minorInteractions;
|
|
292
|
+
} catch (e) {
|
|
293
|
+
return undefined;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
283
296
|
|
|
284
297
|
// Contains the list of interactions that do not abort existing known interactions
|
|
285
298
|
export function getDoNotAbortActivePressInteraction() {
|
|
@@ -787,6 +787,9 @@ async function createInteractionMetricsPayload(interaction, interactionId, exper
|
|
|
787
787
|
} : {}),
|
|
788
788
|
...(unknownElementHierarchy ? {
|
|
789
789
|
unknownElementHierarchy
|
|
790
|
+
} : {}),
|
|
791
|
+
...(fg('platform_ufo_enable_minor_interactions') ? {
|
|
792
|
+
minorInteractions: interaction.minorInteractions
|
|
790
793
|
} : {})
|
|
791
794
|
},
|
|
792
795
|
'ufo:payloadTime': roundEpsilon(performance.now() - interactionPayloadStart)
|