@atlaskit/react-ufo 3.14.7 → 3.14.8
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 +8 -0
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +14 -12
- package/dist/cjs/create-payload/utils/get-vc-metrics.js +17 -13
- package/dist/cjs/interaction-metrics/index.js +35 -15
- package/dist/cjs/interaction-metrics-init/index.js +5 -3
- package/dist/cjs/vc/index.js +7 -0
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +4 -2
- package/dist/es2019/create-payload/utils/get-vc-metrics.js +10 -4
- package/dist/es2019/interaction-metrics/index.js +36 -16
- package/dist/es2019/interaction-metrics-init/index.js +5 -3
- package/dist/es2019/vc/index.js +5 -0
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +14 -12
- package/dist/esm/create-payload/utils/get-vc-metrics.js +17 -13
- package/dist/esm/interaction-metrics/index.js +36 -16
- package/dist/esm/interaction-metrics-init/index.js +5 -3
- package/dist/esm/vc/index.js +6 -0
- package/dist/types/common/common/types.d.ts +4 -1
- package/dist/types/vc/index.d.ts +1 -0
- package/dist/types-ts4.5/common/common/types.d.ts +4 -1
- package/dist/types-ts4.5/vc/index.d.ts +1 -0
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/ufo-interaction-ignore
|
|
2
2
|
|
|
3
|
+
## 3.14.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#179381](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/179381)
|
|
8
|
+
[`05fa3d08ecda9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/05fa3d08ecda9) -
|
|
9
|
+
User vc observer per interaction
|
|
10
|
+
|
|
3
11
|
## 3.14.7
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -95,17 +95,19 @@ function getExperimentalVCMetrics(_x) {
|
|
|
95
95
|
}
|
|
96
96
|
function _getExperimentalVCMetrics() {
|
|
97
97
|
_getExperimentalVCMetrics = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interaction) {
|
|
98
|
-
var _interaction$apdex, prefix, result, VC, pageVisibilityUpToTTAI;
|
|
98
|
+
var vcObserver, _interaction$apdex, prefix, result, VC, pageVisibilityUpToTTAI;
|
|
99
99
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
100
100
|
while (1) switch (_context.prev = _context.next) {
|
|
101
101
|
case 0:
|
|
102
|
-
if
|
|
103
|
-
|
|
102
|
+
// Use per-interaction VC observer if available, otherwise fall back to global experimentalVC
|
|
103
|
+
vcObserver = interaction.experimentalVCObserver || experimentalVC.vcObserver;
|
|
104
|
+
if (!vcObserver) {
|
|
105
|
+
_context.next = 13;
|
|
104
106
|
break;
|
|
105
107
|
}
|
|
106
108
|
prefix = 'ufo-experimental';
|
|
107
|
-
_context.next =
|
|
108
|
-
return
|
|
109
|
+
_context.next = 5;
|
|
110
|
+
return vcObserver.getVCResult({
|
|
109
111
|
start: interaction.start,
|
|
110
112
|
stop: interaction.end,
|
|
111
113
|
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,
|
|
@@ -115,28 +117,28 @@ function _getExperimentalVCMetrics() {
|
|
|
115
117
|
experienceKey: interaction.ufoName,
|
|
116
118
|
interactionId: interaction.id
|
|
117
119
|
});
|
|
118
|
-
case
|
|
120
|
+
case 5:
|
|
119
121
|
result = _context.sent;
|
|
120
122
|
VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
121
123
|
if (!(!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")]))) {
|
|
122
|
-
_context.next =
|
|
124
|
+
_context.next = 9;
|
|
123
125
|
break;
|
|
124
126
|
}
|
|
125
127
|
return _context.abrupt("return", result);
|
|
126
|
-
case
|
|
128
|
+
case 9:
|
|
127
129
|
pageVisibilityUpToTTAI = (0, _hiddenTiming.getPageVisibilityState)(interaction.start, interaction.end);
|
|
128
130
|
if (!(interaction.abortReason || pageVisibilityUpToTTAI !== 'visible')) {
|
|
129
|
-
_context.next =
|
|
131
|
+
_context.next = 12;
|
|
130
132
|
break;
|
|
131
133
|
}
|
|
132
134
|
return _context.abrupt("return", result);
|
|
133
|
-
case
|
|
135
|
+
case 12:
|
|
134
136
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
135
137
|
'metric:experimental:vc90': VC['90']
|
|
136
138
|
}));
|
|
137
|
-
case 12:
|
|
138
|
-
return _context.abrupt("return", null);
|
|
139
139
|
case 13:
|
|
140
|
+
return _context.abrupt("return", null);
|
|
141
|
+
case 14:
|
|
140
142
|
case "end":
|
|
141
143
|
return _context.stop();
|
|
142
144
|
}
|
|
@@ -23,7 +23,7 @@ function getVCMetrics(_x) {
|
|
|
23
23
|
function _getVCMetrics() {
|
|
24
24
|
_getVCMetrics = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(interaction) {
|
|
25
25
|
var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$vc2, _config$vc3, _config$experimentalI, _result$ufoVcRev;
|
|
26
|
-
var config, interactionStatus, pageVisibilityUpToTTAI, shouldReportVCMetrics, isSSREnabled, ssr, tti, prefix, result, mostRecentVCRevision, mostRecentVCRevisionPayload;
|
|
26
|
+
var config, interactionStatus, pageVisibilityUpToTTAI, shouldReportVCMetrics, observer, isSSREnabled, ssr, tti, prefix, result, mostRecentVCRevision, mostRecentVCRevisionPayload;
|
|
27
27
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
28
28
|
while (1) switch (_context.prev = _context.next) {
|
|
29
29
|
case 0:
|
|
@@ -34,7 +34,7 @@ function _getVCMetrics() {
|
|
|
34
34
|
}
|
|
35
35
|
return _context.abrupt("return", {});
|
|
36
36
|
case 3:
|
|
37
|
-
if (!(
|
|
37
|
+
if (!(0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_press_interactions')) {
|
|
38
38
|
_context.next = 8;
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
@@ -55,14 +55,15 @@ function _getVCMetrics() {
|
|
|
55
55
|
case 10:
|
|
56
56
|
interactionStatus = (0, _getInteractionStatus.default)(interaction);
|
|
57
57
|
pageVisibilityUpToTTAI = (0, _getPageVisibilityUpToTtai.default)(interaction);
|
|
58
|
-
shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible';
|
|
58
|
+
shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible'; // Use per-interaction VC observer if available, otherwise fall back to global
|
|
59
|
+
observer = interaction.vcObserver || (0, _vc.getVCObserver)();
|
|
59
60
|
if (!(!shouldReportVCMetrics && (0, _platformFeatureFlags.fg)('platform_ufo_no_vc_on_aborted'))) {
|
|
60
|
-
_context.next =
|
|
61
|
+
_context.next = 17;
|
|
61
62
|
break;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
+
observer.stop(interaction.ufoName);
|
|
64
65
|
return _context.abrupt("return", {});
|
|
65
|
-
case
|
|
66
|
+
case 17:
|
|
66
67
|
isSSREnabled = interaction.type === 'page_load' && ((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)));
|
|
67
68
|
ssr = interaction.type === 'page_load' && isSSREnabled ? {
|
|
68
69
|
ssr: (0, _getSsrDoneTimeValue.default)(config)
|
|
@@ -70,8 +71,8 @@ function _getVCMetrics() {
|
|
|
70
71
|
_interactionMetrics.postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
71
72
|
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;
|
|
72
73
|
prefix = 'ufo';
|
|
73
|
-
_context.next =
|
|
74
|
-
return
|
|
74
|
+
_context.next = 24;
|
|
75
|
+
return observer.getVCResult(_objectSpread({
|
|
75
76
|
start: interaction.start,
|
|
76
77
|
stop: interaction.end,
|
|
77
78
|
tti: tti,
|
|
@@ -83,10 +84,13 @@ function _getVCMetrics() {
|
|
|
83
84
|
interactionId: interaction.id,
|
|
84
85
|
includeSSRRatio: (_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.includeSSRRatio
|
|
85
86
|
}, ssr));
|
|
86
|
-
case
|
|
87
|
+
case 24:
|
|
87
88
|
result = _context.sent;
|
|
89
|
+
if ((0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_observer_per_interaction')) {
|
|
90
|
+
observer.stop(interaction.ufoName);
|
|
91
|
+
}
|
|
88
92
|
if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
89
|
-
|
|
93
|
+
observer.stop(interaction.ufoName);
|
|
90
94
|
}
|
|
91
95
|
_interactionMetrics.postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
92
96
|
mostRecentVCRevision = (0, _config.getMostRecentVCRevision)(interaction.ufoName);
|
|
@@ -95,15 +99,15 @@ function _getVCMetrics() {
|
|
|
95
99
|
return revision === mostRecentVCRevision;
|
|
96
100
|
});
|
|
97
101
|
if (!(!shouldReportVCMetrics || !(mostRecentVCRevisionPayload !== null && mostRecentVCRevisionPayload !== void 0 && mostRecentVCRevisionPayload.clean))) {
|
|
98
|
-
_context.next =
|
|
102
|
+
_context.next = 32;
|
|
99
103
|
break;
|
|
100
104
|
}
|
|
101
105
|
return _context.abrupt("return", result);
|
|
102
|
-
case
|
|
106
|
+
case 32:
|
|
103
107
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
104
108
|
'metric:vc90': mostRecentVCRevisionPayload['metric:vc90']
|
|
105
109
|
}));
|
|
106
|
-
case
|
|
110
|
+
case 33:
|
|
107
111
|
case "end":
|
|
108
112
|
return _context.stop();
|
|
109
113
|
}
|
|
@@ -569,7 +569,9 @@ function finishInteraction(id, data) {
|
|
|
569
569
|
(0, _experienceTraceIdContext.clearActiveTrace)();
|
|
570
570
|
callCleanUpCallbacks(data);
|
|
571
571
|
if ((_getConfig4 = (0, _config.getConfig)()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.vc) !== null && _getConfig4 !== void 0 && _getConfig4.stopVCAtInteractionFinish) {
|
|
572
|
-
|
|
572
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
573
|
+
var observer = data.vcObserver || (0, _vc.getVCObserver)();
|
|
574
|
+
data.vc = observer.getVCRawData();
|
|
573
575
|
}
|
|
574
576
|
if (!((_getConfig5 = (0, _config.getConfig)()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
|
|
575
577
|
remove(id);
|
|
@@ -781,6 +783,7 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
|
|
|
781
783
|
if ((_getConfig11 = (0, _config.getConfig)()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
|
|
782
784
|
postInteractionLog.reset();
|
|
783
785
|
}
|
|
786
|
+
var vcObserver;
|
|
784
787
|
var previousTime = startTime;
|
|
785
788
|
var timeoutTime = (0, _platformFeatureFlags.fg)('platform_ufo_enable_timeout_config') ? (0, _config.getInteractionTimeout)(ufoName) : CLEANUP_TIMEOUT;
|
|
786
789
|
var timerID = setTimeout(function () {
|
|
@@ -803,6 +806,21 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
|
|
|
803
806
|
this.timerID = newTimerID;
|
|
804
807
|
}
|
|
805
808
|
var addFeatureFlagsToInteraction = (0, _coinflip.default)((0, _config.getCapabilityRate)('feature_flag_access'));
|
|
809
|
+
var config = (0, _config.getConfig)();
|
|
810
|
+
if (config && config.vc) {
|
|
811
|
+
var vcOptions = {
|
|
812
|
+
heatmapSize: config.vc.heatmapSize,
|
|
813
|
+
oldDomUpdates: config.vc.oldDomUpdates,
|
|
814
|
+
devToolsEnabled: config.vc.devToolsEnabled,
|
|
815
|
+
selectorConfig: config.vc.selectorConfig,
|
|
816
|
+
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
817
|
+
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
818
|
+
};
|
|
819
|
+
vcObserver = (0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_observer_per_interaction') ? (0, _vc.newVCObserver)(vcOptions) : undefined;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// Create per-interaction VC observer when feature flag is enabled
|
|
823
|
+
|
|
806
824
|
var metrics = {
|
|
807
825
|
id: interactionId,
|
|
808
826
|
start: startTime,
|
|
@@ -843,7 +861,8 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
|
|
|
843
861
|
redirects: [],
|
|
844
862
|
timerID: timerID,
|
|
845
863
|
changeTimeout: changeTimeout,
|
|
846
|
-
trace: trace
|
|
864
|
+
trace: trace,
|
|
865
|
+
vcObserver: vcObserver
|
|
847
866
|
};
|
|
848
867
|
if (addFeatureFlagsToInteraction) {
|
|
849
868
|
_featureFlagsAccessed.currentFeatureFlagsAccessed.clear();
|
|
@@ -862,13 +881,21 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
|
|
|
862
881
|
metrics.cleanupCallbacks.push(function () {
|
|
863
882
|
clearTimeout(metrics.timerID);
|
|
864
883
|
});
|
|
884
|
+
// Add cleanup for per-interaction VC observer
|
|
885
|
+
if (vcObserver) {
|
|
886
|
+
metrics.cleanupCallbacks.push(function () {
|
|
887
|
+
vcObserver.stop(ufoName);
|
|
888
|
+
});
|
|
889
|
+
}
|
|
865
890
|
var awaitBM3TTIList = (0, _config.getAwaitBM3TTIList)();
|
|
866
891
|
if (awaitBM3TTIList.includes(ufoName)) {
|
|
867
892
|
addHoldByID(interactionId, [], ufoName, ufoName, true);
|
|
868
893
|
}
|
|
869
|
-
if (type === 'transition') {
|
|
894
|
+
if (type === 'transition' || type === 'page_load') {
|
|
870
895
|
var _getConfig12;
|
|
871
|
-
|
|
896
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
897
|
+
var observer = vcObserver || (0, _vc.getVCObserver)();
|
|
898
|
+
observer.start({
|
|
872
899
|
startTime: startTime,
|
|
873
900
|
experienceKey: ufoName
|
|
874
901
|
});
|
|
@@ -881,20 +908,13 @@ function addNewInteraction(interactionId, ufoName, type, startTime, rate, labelS
|
|
|
881
908
|
});
|
|
882
909
|
}
|
|
883
910
|
}
|
|
884
|
-
if (type === 'press' && (
|
|
885
|
-
|
|
886
|
-
(0, _vc.getVCObserver)()
|
|
911
|
+
if (type === 'press' && (0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_press_interactions')) {
|
|
912
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
913
|
+
var _observer = vcObserver || (0, _vc.getVCObserver)();
|
|
914
|
+
_observer.start({
|
|
887
915
|
startTime: startTime,
|
|
888
916
|
experienceKey: ufoName
|
|
889
917
|
});
|
|
890
|
-
postInteractionLog.startVCObserver({
|
|
891
|
-
startTime: startTime
|
|
892
|
-
});
|
|
893
|
-
if ((_getConfig13 = (0, _config.getConfig)()) !== null && _getConfig13 !== void 0 && (_getConfig13 = _getConfig13.experimentalInteractionMetrics) !== null && _getConfig13 !== void 0 && _getConfig13.enabled) {
|
|
894
|
-
_createExperimentalInteractionMetricsPayload.experimentalVC.start({
|
|
895
|
-
startTime: startTime
|
|
896
|
-
});
|
|
897
|
-
}
|
|
898
918
|
}
|
|
899
919
|
}
|
|
900
920
|
function addBrowserMetricEvent(event) {
|
|
@@ -101,9 +101,11 @@ function init(analyticsWebClientAsync, config) {
|
|
|
101
101
|
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
102
102
|
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
103
103
|
};
|
|
104
|
-
(0,
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
if (!(0, _platformFeatureFlags.fg)('platform_ufo_enable_vc_observer_per_interaction')) {
|
|
105
|
+
(0, _vc.getVCObserver)(vcOptions).start({
|
|
106
|
+
startTime: 0
|
|
107
|
+
});
|
|
108
|
+
}
|
|
107
109
|
_interactionMetrics.postInteractionLog.initializeVCObserver(vcOptions);
|
|
108
110
|
_interactionMetrics.postInteractionLog.startVCObserver({
|
|
109
111
|
startTime: 0
|
package/dist/cjs/vc/index.js
CHANGED
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.VCObserverWrapper = void 0;
|
|
8
8
|
exports.getVCObserver = getVCObserver;
|
|
9
9
|
exports.isEnvironmentSupported = isEnvironmentSupported;
|
|
10
|
+
exports.newVCObserver = newVCObserver;
|
|
10
11
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
13
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
@@ -241,4 +242,10 @@ function getVCObserver() {
|
|
|
241
242
|
globalThis.__vcObserver = shouldMockVCObserver ? new _noOpVcObserver.VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
242
243
|
}
|
|
243
244
|
return globalThis.__vcObserver;
|
|
245
|
+
}
|
|
246
|
+
function newVCObserver() {
|
|
247
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
248
|
+
var shouldMockVCObserver = !isEnvironmentSupported();
|
|
249
|
+
var observer = shouldMockVCObserver ? new _noOpVcObserver.VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
250
|
+
return observer;
|
|
244
251
|
}
|
|
@@ -58,10 +58,12 @@ export class ExperimentalVCMetrics {
|
|
|
58
58
|
}
|
|
59
59
|
export const experimentalVC = new ExperimentalVCMetrics();
|
|
60
60
|
export async function getExperimentalVCMetrics(interaction) {
|
|
61
|
-
if
|
|
61
|
+
// Use per-interaction VC observer if available, otherwise fall back to global experimentalVC
|
|
62
|
+
const vcObserver = interaction.experimentalVCObserver || experimentalVC.vcObserver;
|
|
63
|
+
if (vcObserver) {
|
|
62
64
|
var _interaction$apdex, _interaction$apdex$;
|
|
63
65
|
const prefix = 'ufo-experimental';
|
|
64
|
-
const result = await
|
|
66
|
+
const result = await vcObserver.getVCResult({
|
|
65
67
|
start: interaction.start,
|
|
66
68
|
stop: interaction.end,
|
|
67
69
|
tti: (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime,
|
|
@@ -11,7 +11,7 @@ async function getVCMetrics(interaction) {
|
|
|
11
11
|
if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
|
|
12
12
|
return {};
|
|
13
13
|
}
|
|
14
|
-
if (fg('
|
|
14
|
+
if (fg('platform_ufo_enable_vc_press_interactions')) {
|
|
15
15
|
if (interaction.type !== 'page_load' && interaction.type !== 'transition' && interaction.type !== 'press') {
|
|
16
16
|
return {};
|
|
17
17
|
}
|
|
@@ -23,8 +23,11 @@ async function getVCMetrics(interaction) {
|
|
|
23
23
|
const interactionStatus = getInteractionStatus(interaction);
|
|
24
24
|
const pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
25
25
|
const shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible';
|
|
26
|
+
|
|
27
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
28
|
+
const observer = interaction.vcObserver || getVCObserver();
|
|
26
29
|
if (!shouldReportVCMetrics && fg('platform_ufo_no_vc_on_aborted')) {
|
|
27
|
-
|
|
30
|
+
observer.stop(interaction.ufoName);
|
|
28
31
|
return {};
|
|
29
32
|
}
|
|
30
33
|
const isSSREnabled = interaction.type === 'page_load' && ((config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 ? void 0 : (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName)));
|
|
@@ -34,7 +37,7 @@ async function getVCMetrics(interaction) {
|
|
|
34
37
|
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
35
38
|
const tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 ? void 0 : (_interaction$apdex$ = _interaction$apdex[0]) === null || _interaction$apdex$ === void 0 ? void 0 : _interaction$apdex$.stopTime;
|
|
36
39
|
const prefix = 'ufo';
|
|
37
|
-
const result = await
|
|
40
|
+
const result = await observer.getVCResult({
|
|
38
41
|
start: interaction.start,
|
|
39
42
|
stop: interaction.end,
|
|
40
43
|
tti,
|
|
@@ -47,8 +50,11 @@ async function getVCMetrics(interaction) {
|
|
|
47
50
|
includeSSRRatio: (_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.includeSSRRatio,
|
|
48
51
|
...ssr
|
|
49
52
|
});
|
|
53
|
+
if (fg('platform_ufo_enable_vc_observer_per_interaction')) {
|
|
54
|
+
observer.stop(interaction.ufoName);
|
|
55
|
+
}
|
|
50
56
|
if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
51
|
-
|
|
57
|
+
observer.stop(interaction.ufoName);
|
|
52
58
|
}
|
|
53
59
|
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
54
60
|
const mostRecentVCRevision = getMostRecentVCRevision(interaction.ufoName);
|
|
@@ -6,7 +6,7 @@ import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComp
|
|
|
6
6
|
import { clearActiveTrace } from '../experience-trace-id-context';
|
|
7
7
|
import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
|
|
8
8
|
import { getInteractionId } from '../interaction-id-context';
|
|
9
|
-
import { getVCObserver } from '../vc';
|
|
9
|
+
import { getVCObserver, newVCObserver } from '../vc';
|
|
10
10
|
import { interactions } from './common/constants';
|
|
11
11
|
import PostInteractionLog from './post-interaction-log';
|
|
12
12
|
const PreviousInteractionLog = {
|
|
@@ -487,7 +487,9 @@ function finishInteraction(id, data, endTime = performance.now()) {
|
|
|
487
487
|
clearActiveTrace();
|
|
488
488
|
callCleanUpCallbacks(data);
|
|
489
489
|
if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4$vc = _getConfig4.vc) !== null && _getConfig4$vc !== void 0 && _getConfig4$vc.stopVCAtInteractionFinish) {
|
|
490
|
-
|
|
490
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
491
|
+
const observer = data.vcObserver || getVCObserver();
|
|
492
|
+
data.vc = observer.getVCRawData();
|
|
491
493
|
}
|
|
492
494
|
if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5$experimen = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5$experimen !== void 0 && _getConfig5$experimen.enabled)) {
|
|
493
495
|
remove(id);
|
|
@@ -656,6 +658,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
656
658
|
if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11$postInte = _getConfig11.postInteractionLog) !== null && _getConfig11$postInte !== void 0 && _getConfig11$postInte.enabled) {
|
|
657
659
|
postInteractionLog.reset();
|
|
658
660
|
}
|
|
661
|
+
let vcObserver;
|
|
659
662
|
let previousTime = startTime;
|
|
660
663
|
let timeoutTime = fg('platform_ufo_enable_timeout_config') ? getInteractionTimeout(ufoName) : CLEANUP_TIMEOUT;
|
|
661
664
|
const timerID = setTimeout(() => {
|
|
@@ -678,6 +681,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
678
681
|
this.timerID = newTimerID;
|
|
679
682
|
}
|
|
680
683
|
const addFeatureFlagsToInteraction = coinflip(getCapabilityRate('feature_flag_access'));
|
|
684
|
+
const config = getConfig();
|
|
685
|
+
if (config && config.vc) {
|
|
686
|
+
const vcOptions = {
|
|
687
|
+
heatmapSize: config.vc.heatmapSize,
|
|
688
|
+
oldDomUpdates: config.vc.oldDomUpdates,
|
|
689
|
+
devToolsEnabled: config.vc.devToolsEnabled,
|
|
690
|
+
selectorConfig: config.vc.selectorConfig,
|
|
691
|
+
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
692
|
+
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
693
|
+
};
|
|
694
|
+
vcObserver = fg('platform_ufo_enable_vc_observer_per_interaction') ? newVCObserver(vcOptions) : undefined;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
// Create per-interaction VC observer when feature flag is enabled
|
|
698
|
+
|
|
681
699
|
const metrics = {
|
|
682
700
|
id: interactionId,
|
|
683
701
|
start: startTime,
|
|
@@ -718,7 +736,8 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
718
736
|
redirects: [],
|
|
719
737
|
timerID,
|
|
720
738
|
changeTimeout,
|
|
721
|
-
trace
|
|
739
|
+
trace,
|
|
740
|
+
vcObserver
|
|
722
741
|
};
|
|
723
742
|
if (addFeatureFlagsToInteraction) {
|
|
724
743
|
currentFeatureFlagsAccessed.clear();
|
|
@@ -737,13 +756,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
737
756
|
metrics.cleanupCallbacks.push(() => {
|
|
738
757
|
clearTimeout(metrics.timerID);
|
|
739
758
|
});
|
|
759
|
+
// Add cleanup for per-interaction VC observer
|
|
760
|
+
if (vcObserver) {
|
|
761
|
+
metrics.cleanupCallbacks.push(() => {
|
|
762
|
+
vcObserver.stop(ufoName);
|
|
763
|
+
});
|
|
764
|
+
}
|
|
740
765
|
const awaitBM3TTIList = getAwaitBM3TTIList();
|
|
741
766
|
if (awaitBM3TTIList.includes(ufoName)) {
|
|
742
767
|
addHoldByID(interactionId, [], ufoName, ufoName, true);
|
|
743
768
|
}
|
|
744
|
-
if (type === 'transition') {
|
|
769
|
+
if (type === 'transition' || type === 'page_load') {
|
|
745
770
|
var _getConfig12, _getConfig12$experime;
|
|
746
|
-
|
|
771
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
772
|
+
const observer = vcObserver || getVCObserver();
|
|
773
|
+
observer.start({
|
|
747
774
|
startTime,
|
|
748
775
|
experienceKey: ufoName
|
|
749
776
|
});
|
|
@@ -756,20 +783,13 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
756
783
|
});
|
|
757
784
|
}
|
|
758
785
|
}
|
|
759
|
-
if (type === 'press' &&
|
|
760
|
-
|
|
761
|
-
getVCObserver()
|
|
786
|
+
if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
|
|
787
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
788
|
+
const observer = vcObserver || getVCObserver();
|
|
789
|
+
observer.start({
|
|
762
790
|
startTime,
|
|
763
791
|
experienceKey: ufoName
|
|
764
792
|
});
|
|
765
|
-
postInteractionLog.startVCObserver({
|
|
766
|
-
startTime
|
|
767
|
-
});
|
|
768
|
-
if ((_getConfig13 = getConfig()) !== null && _getConfig13 !== void 0 && (_getConfig13$experime = _getConfig13.experimentalInteractionMetrics) !== null && _getConfig13$experime !== void 0 && _getConfig13$experime.enabled) {
|
|
769
|
-
experimentalVC.start({
|
|
770
|
-
startTime
|
|
771
|
-
});
|
|
772
|
-
}
|
|
773
793
|
}
|
|
774
794
|
}
|
|
775
795
|
export function addBrowserMetricEvent(event) {
|
|
@@ -91,9 +91,11 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
91
91
|
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
92
92
|
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
93
93
|
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
94
|
+
if (!fg('platform_ufo_enable_vc_observer_per_interaction')) {
|
|
95
|
+
getVCObserver(vcOptions).start({
|
|
96
|
+
startTime: 0
|
|
97
|
+
});
|
|
98
|
+
}
|
|
97
99
|
postInteractionLog.initializeVCObserver(vcOptions);
|
|
98
100
|
postInteractionLog.startVCObserver({
|
|
99
101
|
startTime: 0
|
package/dist/es2019/vc/index.js
CHANGED
|
@@ -165,4 +165,9 @@ export function getVCObserver(opts = {}) {
|
|
|
165
165
|
globalThis.__vcObserver = shouldMockVCObserver ? new VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
166
166
|
}
|
|
167
167
|
return globalThis.__vcObserver;
|
|
168
|
+
}
|
|
169
|
+
export function newVCObserver(opts = {}) {
|
|
170
|
+
const shouldMockVCObserver = !isEnvironmentSupported();
|
|
171
|
+
const observer = shouldMockVCObserver ? new VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
172
|
+
return observer;
|
|
168
173
|
}
|
|
@@ -84,17 +84,19 @@ export function getExperimentalVCMetrics(_x) {
|
|
|
84
84
|
}
|
|
85
85
|
function _getExperimentalVCMetrics() {
|
|
86
86
|
_getExperimentalVCMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction) {
|
|
87
|
-
var _interaction$apdex, prefix, result, VC, pageVisibilityUpToTTAI;
|
|
87
|
+
var vcObserver, _interaction$apdex, prefix, result, VC, pageVisibilityUpToTTAI;
|
|
88
88
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
89
89
|
while (1) switch (_context.prev = _context.next) {
|
|
90
90
|
case 0:
|
|
91
|
-
if
|
|
92
|
-
|
|
91
|
+
// Use per-interaction VC observer if available, otherwise fall back to global experimentalVC
|
|
92
|
+
vcObserver = interaction.experimentalVCObserver || experimentalVC.vcObserver;
|
|
93
|
+
if (!vcObserver) {
|
|
94
|
+
_context.next = 13;
|
|
93
95
|
break;
|
|
94
96
|
}
|
|
95
97
|
prefix = 'ufo-experimental';
|
|
96
|
-
_context.next =
|
|
97
|
-
return
|
|
98
|
+
_context.next = 5;
|
|
99
|
+
return vcObserver.getVCResult({
|
|
98
100
|
start: interaction.start,
|
|
99
101
|
stop: interaction.end,
|
|
100
102
|
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,
|
|
@@ -104,28 +106,28 @@ function _getExperimentalVCMetrics() {
|
|
|
104
106
|
experienceKey: interaction.ufoName,
|
|
105
107
|
interactionId: interaction.id
|
|
106
108
|
});
|
|
107
|
-
case
|
|
109
|
+
case 5:
|
|
108
110
|
result = _context.sent;
|
|
109
111
|
VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
110
112
|
if (!(!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")]))) {
|
|
111
|
-
_context.next =
|
|
113
|
+
_context.next = 9;
|
|
112
114
|
break;
|
|
113
115
|
}
|
|
114
116
|
return _context.abrupt("return", result);
|
|
115
|
-
case
|
|
117
|
+
case 9:
|
|
116
118
|
pageVisibilityUpToTTAI = getPageVisibilityState(interaction.start, interaction.end);
|
|
117
119
|
if (!(interaction.abortReason || pageVisibilityUpToTTAI !== 'visible')) {
|
|
118
|
-
_context.next =
|
|
120
|
+
_context.next = 12;
|
|
119
121
|
break;
|
|
120
122
|
}
|
|
121
123
|
return _context.abrupt("return", result);
|
|
122
|
-
case
|
|
124
|
+
case 12:
|
|
123
125
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
124
126
|
'metric:experimental:vc90': VC['90']
|
|
125
127
|
}));
|
|
126
|
-
case 12:
|
|
127
|
-
return _context.abrupt("return", null);
|
|
128
128
|
case 13:
|
|
129
|
+
return _context.abrupt("return", null);
|
|
130
|
+
case 14:
|
|
129
131
|
case "end":
|
|
130
132
|
return _context.stop();
|
|
131
133
|
}
|
|
@@ -16,7 +16,7 @@ function getVCMetrics(_x) {
|
|
|
16
16
|
function _getVCMetrics() {
|
|
17
17
|
_getVCMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(interaction) {
|
|
18
18
|
var _config$vc, _config$vc$ssrWhiteli, _interaction$apdex, _config$vc2, _config$vc3, _config$experimentalI, _result$ufoVcRev;
|
|
19
|
-
var config, interactionStatus, pageVisibilityUpToTTAI, shouldReportVCMetrics, isSSREnabled, ssr, tti, prefix, result, mostRecentVCRevision, mostRecentVCRevisionPayload;
|
|
19
|
+
var config, interactionStatus, pageVisibilityUpToTTAI, shouldReportVCMetrics, observer, isSSREnabled, ssr, tti, prefix, result, mostRecentVCRevision, mostRecentVCRevisionPayload;
|
|
20
20
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
21
21
|
while (1) switch (_context.prev = _context.next) {
|
|
22
22
|
case 0:
|
|
@@ -27,7 +27,7 @@ function _getVCMetrics() {
|
|
|
27
27
|
}
|
|
28
28
|
return _context.abrupt("return", {});
|
|
29
29
|
case 3:
|
|
30
|
-
if (!
|
|
30
|
+
if (!fg('platform_ufo_enable_vc_press_interactions')) {
|
|
31
31
|
_context.next = 8;
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
@@ -48,14 +48,15 @@ function _getVCMetrics() {
|
|
|
48
48
|
case 10:
|
|
49
49
|
interactionStatus = getInteractionStatus(interaction);
|
|
50
50
|
pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
51
|
-
shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible';
|
|
51
|
+
shouldReportVCMetrics = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible'; // Use per-interaction VC observer if available, otherwise fall back to global
|
|
52
|
+
observer = interaction.vcObserver || getVCObserver();
|
|
52
53
|
if (!(!shouldReportVCMetrics && fg('platform_ufo_no_vc_on_aborted'))) {
|
|
53
|
-
_context.next =
|
|
54
|
+
_context.next = 17;
|
|
54
55
|
break;
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
observer.stop(interaction.ufoName);
|
|
57
58
|
return _context.abrupt("return", {});
|
|
58
|
-
case
|
|
59
|
+
case 17:
|
|
59
60
|
isSSREnabled = interaction.type === 'page_load' && ((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)));
|
|
60
61
|
ssr = interaction.type === 'page_load' && isSSREnabled ? {
|
|
61
62
|
ssr: getSSRDoneTimeValue(config)
|
|
@@ -63,8 +64,8 @@ function _getVCMetrics() {
|
|
|
63
64
|
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
64
65
|
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;
|
|
65
66
|
prefix = 'ufo';
|
|
66
|
-
_context.next =
|
|
67
|
-
return
|
|
67
|
+
_context.next = 24;
|
|
68
|
+
return observer.getVCResult(_objectSpread({
|
|
68
69
|
start: interaction.start,
|
|
69
70
|
stop: interaction.end,
|
|
70
71
|
tti: tti,
|
|
@@ -76,10 +77,13 @@ function _getVCMetrics() {
|
|
|
76
77
|
interactionId: interaction.id,
|
|
77
78
|
includeSSRRatio: (_config$vc3 = config.vc) === null || _config$vc3 === void 0 ? void 0 : _config$vc3.includeSSRRatio
|
|
78
79
|
}, ssr));
|
|
79
|
-
case
|
|
80
|
+
case 24:
|
|
80
81
|
result = _context.sent;
|
|
82
|
+
if (fg('platform_ufo_enable_vc_observer_per_interaction')) {
|
|
83
|
+
observer.stop(interaction.ufoName);
|
|
84
|
+
}
|
|
81
85
|
if ((_config$experimentalI = config.experimentalInteractionMetrics) !== null && _config$experimentalI !== void 0 && _config$experimentalI.enabled) {
|
|
82
|
-
|
|
86
|
+
observer.stop(interaction.ufoName);
|
|
83
87
|
}
|
|
84
88
|
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
85
89
|
mostRecentVCRevision = getMostRecentVCRevision(interaction.ufoName);
|
|
@@ -88,15 +92,15 @@ function _getVCMetrics() {
|
|
|
88
92
|
return revision === mostRecentVCRevision;
|
|
89
93
|
});
|
|
90
94
|
if (!(!shouldReportVCMetrics || !(mostRecentVCRevisionPayload !== null && mostRecentVCRevisionPayload !== void 0 && mostRecentVCRevisionPayload.clean))) {
|
|
91
|
-
_context.next =
|
|
95
|
+
_context.next = 32;
|
|
92
96
|
break;
|
|
93
97
|
}
|
|
94
98
|
return _context.abrupt("return", result);
|
|
95
|
-
case
|
|
99
|
+
case 32:
|
|
96
100
|
return _context.abrupt("return", _objectSpread(_objectSpread({}, result), {}, {
|
|
97
101
|
'metric:vc90': mostRecentVCRevisionPayload['metric:vc90']
|
|
98
102
|
}));
|
|
99
|
-
case
|
|
103
|
+
case 33:
|
|
100
104
|
case "end":
|
|
101
105
|
return _context.stop();
|
|
102
106
|
}
|
|
@@ -16,7 +16,7 @@ import { experimentalVC, getExperimentalVCMetrics, onExperimentalInteractionComp
|
|
|
16
16
|
import { clearActiveTrace } from '../experience-trace-id-context';
|
|
17
17
|
import { allFeatureFlagsAccessed, currentFeatureFlagsAccessed } from '../feature-flags-accessed';
|
|
18
18
|
import { getInteractionId } from '../interaction-id-context';
|
|
19
|
-
import { getVCObserver } from '../vc';
|
|
19
|
+
import { getVCObserver, newVCObserver } from '../vc';
|
|
20
20
|
import { interactions } from './common/constants';
|
|
21
21
|
import PostInteractionLog from './post-interaction-log';
|
|
22
22
|
var PreviousInteractionLog = {
|
|
@@ -523,7 +523,9 @@ function finishInteraction(id, data) {
|
|
|
523
523
|
clearActiveTrace();
|
|
524
524
|
callCleanUpCallbacks(data);
|
|
525
525
|
if ((_getConfig4 = getConfig()) !== null && _getConfig4 !== void 0 && (_getConfig4 = _getConfig4.vc) !== null && _getConfig4 !== void 0 && _getConfig4.stopVCAtInteractionFinish) {
|
|
526
|
-
|
|
526
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
527
|
+
var observer = data.vcObserver || getVCObserver();
|
|
528
|
+
data.vc = observer.getVCRawData();
|
|
527
529
|
}
|
|
528
530
|
if (!((_getConfig5 = getConfig()) !== null && _getConfig5 !== void 0 && (_getConfig5 = _getConfig5.experimentalInteractionMetrics) !== null && _getConfig5 !== void 0 && _getConfig5.enabled)) {
|
|
529
531
|
remove(id);
|
|
@@ -735,6 +737,7 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
735
737
|
if ((_getConfig11 = getConfig()) !== null && _getConfig11 !== void 0 && (_getConfig11 = _getConfig11.postInteractionLog) !== null && _getConfig11 !== void 0 && _getConfig11.enabled) {
|
|
736
738
|
postInteractionLog.reset();
|
|
737
739
|
}
|
|
740
|
+
var vcObserver;
|
|
738
741
|
var previousTime = startTime;
|
|
739
742
|
var timeoutTime = fg('platform_ufo_enable_timeout_config') ? getInteractionTimeout(ufoName) : CLEANUP_TIMEOUT;
|
|
740
743
|
var timerID = setTimeout(function () {
|
|
@@ -757,6 +760,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
757
760
|
this.timerID = newTimerID;
|
|
758
761
|
}
|
|
759
762
|
var addFeatureFlagsToInteraction = coinflip(getCapabilityRate('feature_flag_access'));
|
|
763
|
+
var config = getConfig();
|
|
764
|
+
if (config && config.vc) {
|
|
765
|
+
var vcOptions = {
|
|
766
|
+
heatmapSize: config.vc.heatmapSize,
|
|
767
|
+
oldDomUpdates: config.vc.oldDomUpdates,
|
|
768
|
+
devToolsEnabled: config.vc.devToolsEnabled,
|
|
769
|
+
selectorConfig: config.vc.selectorConfig,
|
|
770
|
+
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
771
|
+
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
772
|
+
};
|
|
773
|
+
vcObserver = fg('platform_ufo_enable_vc_observer_per_interaction') ? newVCObserver(vcOptions) : undefined;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
// Create per-interaction VC observer when feature flag is enabled
|
|
777
|
+
|
|
760
778
|
var metrics = {
|
|
761
779
|
id: interactionId,
|
|
762
780
|
start: startTime,
|
|
@@ -797,7 +815,8 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
797
815
|
redirects: [],
|
|
798
816
|
timerID: timerID,
|
|
799
817
|
changeTimeout: changeTimeout,
|
|
800
|
-
trace: trace
|
|
818
|
+
trace: trace,
|
|
819
|
+
vcObserver: vcObserver
|
|
801
820
|
};
|
|
802
821
|
if (addFeatureFlagsToInteraction) {
|
|
803
822
|
currentFeatureFlagsAccessed.clear();
|
|
@@ -816,13 +835,21 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
816
835
|
metrics.cleanupCallbacks.push(function () {
|
|
817
836
|
clearTimeout(metrics.timerID);
|
|
818
837
|
});
|
|
838
|
+
// Add cleanup for per-interaction VC observer
|
|
839
|
+
if (vcObserver) {
|
|
840
|
+
metrics.cleanupCallbacks.push(function () {
|
|
841
|
+
vcObserver.stop(ufoName);
|
|
842
|
+
});
|
|
843
|
+
}
|
|
819
844
|
var awaitBM3TTIList = getAwaitBM3TTIList();
|
|
820
845
|
if (awaitBM3TTIList.includes(ufoName)) {
|
|
821
846
|
addHoldByID(interactionId, [], ufoName, ufoName, true);
|
|
822
847
|
}
|
|
823
|
-
if (type === 'transition') {
|
|
848
|
+
if (type === 'transition' || type === 'page_load') {
|
|
824
849
|
var _getConfig12;
|
|
825
|
-
|
|
850
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
851
|
+
var observer = vcObserver || getVCObserver();
|
|
852
|
+
observer.start({
|
|
826
853
|
startTime: startTime,
|
|
827
854
|
experienceKey: ufoName
|
|
828
855
|
});
|
|
@@ -835,20 +862,13 @@ export function addNewInteraction(interactionId, ufoName, type, startTime, rate,
|
|
|
835
862
|
});
|
|
836
863
|
}
|
|
837
864
|
}
|
|
838
|
-
if (type === 'press' &&
|
|
839
|
-
|
|
840
|
-
getVCObserver()
|
|
865
|
+
if (type === 'press' && fg('platform_ufo_enable_vc_press_interactions')) {
|
|
866
|
+
// Use per-interaction VC observer if available, otherwise fall back to global
|
|
867
|
+
var _observer = vcObserver || getVCObserver();
|
|
868
|
+
_observer.start({
|
|
841
869
|
startTime: startTime,
|
|
842
870
|
experienceKey: ufoName
|
|
843
871
|
});
|
|
844
|
-
postInteractionLog.startVCObserver({
|
|
845
|
-
startTime: startTime
|
|
846
|
-
});
|
|
847
|
-
if ((_getConfig13 = getConfig()) !== null && _getConfig13 !== void 0 && (_getConfig13 = _getConfig13.experimentalInteractionMetrics) !== null && _getConfig13 !== void 0 && _getConfig13.enabled) {
|
|
848
|
-
experimentalVC.start({
|
|
849
|
-
startTime: startTime
|
|
850
|
-
});
|
|
851
|
-
}
|
|
852
872
|
}
|
|
853
873
|
}
|
|
854
874
|
export function addBrowserMetricEvent(event) {
|
|
@@ -92,9 +92,11 @@ export function init(analyticsWebClientAsync, config) {
|
|
|
92
92
|
ssrEnablePageLayoutPlaceholder: config.vc.ssrEnablePageLayoutPlaceholder,
|
|
93
93
|
disableSizeAndPositionCheck: config.vc.disableSizeAndPositionCheck
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (!fg('platform_ufo_enable_vc_observer_per_interaction')) {
|
|
96
|
+
getVCObserver(vcOptions).start({
|
|
97
|
+
startTime: 0
|
|
98
|
+
});
|
|
99
|
+
}
|
|
98
100
|
postInteractionLog.initializeVCObserver(vcOptions);
|
|
99
101
|
postInteractionLog.startVCObserver({
|
|
100
102
|
startTime: 0
|
package/dist/esm/vc/index.js
CHANGED
|
@@ -234,4 +234,10 @@ export function getVCObserver() {
|
|
|
234
234
|
globalThis.__vcObserver = shouldMockVCObserver ? new VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
235
235
|
}
|
|
236
236
|
return globalThis.__vcObserver;
|
|
237
|
+
}
|
|
238
|
+
export function newVCObserver() {
|
|
239
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
240
|
+
var shouldMockVCObserver = !isEnvironmentSupported();
|
|
241
|
+
var observer = shouldMockVCObserver ? new VCObserverNOOP() : new VCObserverWrapper(opts);
|
|
242
|
+
return observer;
|
|
237
243
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TraceIdContext } from '../../experience-trace-id-context';
|
|
2
2
|
import type { LabelStack, UFOInteractionContextType } from '../../interaction-context';
|
|
3
|
+
import type { VCObserverInterface } from '../../vc/types';
|
|
3
4
|
import { type VCRawDataType, type VCResult } from '../vc/types';
|
|
4
5
|
export type LifecycleMarkType = 'render' | 'beforePaint' | 'afterPaint' | 'nextTick' | 'mount' | 'commit';
|
|
5
6
|
export type MarkType = ('placeholder' | 'bm3_stop' | 'bundle_preload' | 'custom') | LifecycleMarkType;
|
|
@@ -113,8 +114,8 @@ export interface InteractionMetrics {
|
|
|
113
114
|
holdInfo: HoldInfo[];
|
|
114
115
|
holdExpInfo: HoldInfo[];
|
|
115
116
|
holdActive: Map<string, HoldActive>;
|
|
116
|
-
holdExpActive: Map<string, HoldActive>;
|
|
117
117
|
reactProfilerTimings: ReactProfilerTiming[];
|
|
118
|
+
holdExpActive: Map<string, HoldActive>;
|
|
118
119
|
measureStart: number;
|
|
119
120
|
rate: number;
|
|
120
121
|
cancelCallbacks: (() => void)[];
|
|
@@ -158,6 +159,8 @@ export interface InteractionMetrics {
|
|
|
158
159
|
changeTimeout: (newTime: number) => void;
|
|
159
160
|
trace: TraceIdContext | null;
|
|
160
161
|
legacyMetrics?: BM3Event[];
|
|
162
|
+
vcObserver?: VCObserverInterface;
|
|
163
|
+
experimentalVCObserver?: VCObserverInterface;
|
|
161
164
|
vc?: VCRawDataType | null;
|
|
162
165
|
experimentalTTAI?: number;
|
|
163
166
|
experimentalVC90?: number;
|
package/dist/types/vc/index.d.ts
CHANGED
|
@@ -24,3 +24,4 @@ export declare class VCObserverWrapper implements VCObserverInterface {
|
|
|
24
24
|
}
|
|
25
25
|
export declare function isEnvironmentSupported(): boolean;
|
|
26
26
|
export declare function getVCObserver(opts?: VCObserverOptions): VCObserverInterface;
|
|
27
|
+
export declare function newVCObserver(opts?: VCObserverOptions): VCObserverInterface;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TraceIdContext } from '../../experience-trace-id-context';
|
|
2
2
|
import type { LabelStack, UFOInteractionContextType } from '../../interaction-context';
|
|
3
|
+
import type { VCObserverInterface } from '../../vc/types';
|
|
3
4
|
import { type VCRawDataType, type VCResult } from '../vc/types';
|
|
4
5
|
export type LifecycleMarkType = 'render' | 'beforePaint' | 'afterPaint' | 'nextTick' | 'mount' | 'commit';
|
|
5
6
|
export type MarkType = ('placeholder' | 'bm3_stop' | 'bundle_preload' | 'custom') | LifecycleMarkType;
|
|
@@ -113,8 +114,8 @@ export interface InteractionMetrics {
|
|
|
113
114
|
holdInfo: HoldInfo[];
|
|
114
115
|
holdExpInfo: HoldInfo[];
|
|
115
116
|
holdActive: Map<string, HoldActive>;
|
|
116
|
-
holdExpActive: Map<string, HoldActive>;
|
|
117
117
|
reactProfilerTimings: ReactProfilerTiming[];
|
|
118
|
+
holdExpActive: Map<string, HoldActive>;
|
|
118
119
|
measureStart: number;
|
|
119
120
|
rate: number;
|
|
120
121
|
cancelCallbacks: (() => void)[];
|
|
@@ -158,6 +159,8 @@ export interface InteractionMetrics {
|
|
|
158
159
|
changeTimeout: (newTime: number) => void;
|
|
159
160
|
trace: TraceIdContext | null;
|
|
160
161
|
legacyMetrics?: BM3Event[];
|
|
162
|
+
vcObserver?: VCObserverInterface;
|
|
163
|
+
experimentalVCObserver?: VCObserverInterface;
|
|
161
164
|
vc?: VCRawDataType | null;
|
|
162
165
|
experimentalTTAI?: number;
|
|
163
166
|
experimentalVC90?: number;
|
|
@@ -24,3 +24,4 @@ export declare class VCObserverWrapper implements VCObserverInterface {
|
|
|
24
24
|
}
|
|
25
25
|
export declare function isEnvironmentSupported(): boolean;
|
|
26
26
|
export declare function getVCObserver(opts?: VCObserverOptions): VCObserverInterface;
|
|
27
|
+
export declare function newVCObserver(opts?: VCObserverOptions): VCObserverInterface;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/react-ufo",
|
|
3
|
-
"version": "3.14.
|
|
3
|
+
"version": "3.14.8",
|
|
4
4
|
"description": "Parts of React UFO that are publicly available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -175,9 +175,6 @@
|
|
|
175
175
|
"platform_ufo_timeout_simplification": {
|
|
176
176
|
"type": "boolean"
|
|
177
177
|
},
|
|
178
|
-
"platform_ufo_enable_interactions_vc": {
|
|
179
|
-
"type": "boolean"
|
|
180
|
-
},
|
|
181
178
|
"platform_ufo_enable_timeout_config": {
|
|
182
179
|
"type": "boolean"
|
|
183
180
|
},
|
|
@@ -210,6 +207,12 @@
|
|
|
210
207
|
},
|
|
211
208
|
"platform_ufo_vc_v3_ssr_placeholder": {
|
|
212
209
|
"type": "boolean"
|
|
210
|
+
},
|
|
211
|
+
"platform_ufo_enable_vc_press_interactions": {
|
|
212
|
+
"type": "boolean"
|
|
213
|
+
},
|
|
214
|
+
"platform_ufo_enable_vc_observer_per_interaction": {
|
|
215
|
+
"type": "boolean"
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
}
|