@atlaskit/react-ufo 2.7.0 → 2.8.0
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 +12 -0
- package/dist/cjs/config/index.js +18 -40
- package/dist/cjs/create-payload/common/utils/index.js +2 -66
- package/dist/cjs/create-payload/index.js +78 -55
- package/dist/cjs/interaction-metrics/common/constants.js +3 -8
- package/dist/cjs/interaction-metrics/index.js +238 -166
- package/dist/cjs/interaction-metrics-init/index.js +9 -31
- package/dist/cjs/load-hold/UFOLoadHold.js +3 -5
- package/dist/cjs/segment/segment.js +8 -9
- package/dist/es2019/config/index.js +0 -22
- package/dist/es2019/create-payload/common/utils/index.js +1 -68
- package/dist/es2019/create-payload/index.js +77 -48
- package/dist/es2019/interaction-metrics/common/constants.js +2 -7
- package/dist/es2019/interaction-metrics/index.js +131 -91
- package/dist/es2019/interaction-metrics-init/index.js +8 -28
- package/dist/es2019/load-hold/UFOLoadHold.js +3 -5
- package/dist/es2019/segment/segment.js +11 -8
- package/dist/esm/config/index.js +18 -39
- package/dist/esm/create-payload/common/utils/index.js +1 -63
- package/dist/esm/create-payload/index.js +78 -53
- package/dist/esm/interaction-metrics/common/constants.js +2 -7
- package/dist/esm/interaction-metrics/index.js +158 -86
- package/dist/esm/interaction-metrics-init/index.js +8 -28
- package/dist/esm/load-hold/UFOLoadHold.js +3 -5
- package/dist/esm/segment/segment.js +8 -9
- package/dist/types/common/common/types.d.ts +4 -6
- package/dist/types/config/index.d.ts +0 -6
- package/dist/types/create-payload/common/utils/index.d.ts +0 -9
- package/dist/types/create-payload/index.d.ts +5660 -13
- package/dist/types/interaction-context/index.d.ts +0 -1
- package/dist/types/interaction-metrics/common/constants.d.ts +3 -32
- package/dist/types/interaction-metrics/index.d.ts +17 -1
- package/dist/types/load-hold/UFOLoadHold.d.ts +2 -1
- package/dist/types-ts4.5/common/common/types.d.ts +4 -6
- package/dist/types-ts4.5/config/index.d.ts +0 -6
- package/dist/types-ts4.5/create-payload/common/utils/index.d.ts +0 -9
- package/dist/types-ts4.5/create-payload/index.d.ts +5660 -13
- package/dist/types-ts4.5/interaction-context/index.d.ts +0 -1
- package/dist/types-ts4.5/interaction-metrics/common/constants.d.ts +3 -32
- package/dist/types-ts4.5/interaction-metrics/index.d.ts +17 -1
- package/dist/types-ts4.5/load-hold/UFOLoadHold.d.ts +2 -1
- package/package.json +2 -3
- package/create-experimental-interaction-metrics-payload/package.json +0 -15
- package/dist/cjs/create-experimental-interaction-metrics-payload/index.js +0 -100
- package/dist/cjs/interaction-metrics/common/index.js +0 -151
- package/dist/es2019/create-experimental-interaction-metrics-payload/index.js +0 -71
- package/dist/es2019/interaction-metrics/common/index.js +0 -103
- package/dist/esm/create-experimental-interaction-metrics-payload/index.js +0 -90
- package/dist/esm/interaction-metrics/common/index.js +0 -132
- package/dist/types/create-experimental-interaction-metrics-payload/index.d.ts +0 -16
- package/dist/types/interaction-metrics/common/index.d.ts +0 -16
- package/dist/types-ts4.5/create-experimental-interaction-metrics-payload/index.d.ts +0 -16
- package/dist/types-ts4.5/interaction-metrics/common/index.d.ts +0 -16
|
@@ -2,14 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
|
|
5
|
-
|
|
6
5
|
import { REACT_UFO_VERSION } from '../../../common/constants';
|
|
7
|
-
import { getConfig } from '../../../config';
|
|
8
|
-
import { getPageVisibilityState } from '../../../hidden-timing';
|
|
9
|
-
import PostInteractionLog from '../../../interaction-metrics/post-interaction-log';
|
|
10
|
-
import { getSSRDoneTime } from '../../../ssr';
|
|
11
|
-
import { getVCObserver } from '../../../vc';
|
|
12
|
-
export var postInteractionLog = new PostInteractionLog();
|
|
13
6
|
export var sanitizeUfoName = function sanitizeUfoName(name) {
|
|
14
7
|
return name.replace(/_/g, '-');
|
|
15
8
|
};
|
|
@@ -66,59 +59,4 @@ export function optimizeLabelStack(labelStack) {
|
|
|
66
59
|
s: ls.segmentId
|
|
67
60
|
} : {});
|
|
68
61
|
});
|
|
69
|
-
}
|
|
70
|
-
export var getPageVisibilityUpToTTAI = function getPageVisibilityUpToTTAI(interaction) {
|
|
71
|
-
var start = interaction.start,
|
|
72
|
-
end = interaction.end;
|
|
73
|
-
return getPageVisibilityState(start, end);
|
|
74
|
-
};
|
|
75
|
-
export var calculateVCMetrics = function calculateVCMetrics(interaction, prefix, getVCResultFn) {
|
|
76
|
-
var _interaction$apdex;
|
|
77
|
-
var result = getVCResultFn({
|
|
78
|
-
start: interaction.start,
|
|
79
|
-
stop: interaction.end,
|
|
80
|
-
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,
|
|
81
|
-
prefix: prefix,
|
|
82
|
-
vc: interaction.vc
|
|
83
|
-
});
|
|
84
|
-
var VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
85
|
-
if (!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")])) {
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
88
|
-
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
89
|
-
if (interaction.abortReason || pageVisibilityUpToTTAI !== 'visible') {
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
return result;
|
|
93
|
-
};
|
|
94
|
-
export function getSSRDoneTimeValue(config) {
|
|
95
|
-
var _config$ssr, _config$ssr2;
|
|
96
|
-
return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 || (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : getSSRDoneTime();
|
|
97
|
-
}
|
|
98
|
-
export var getVCMetrics = function getVCMetrics(interaction) {
|
|
99
|
-
var _config$vc, _config$vc$ssrWhiteli, _result$metricsVc;
|
|
100
|
-
var config = getConfig();
|
|
101
|
-
if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
|
|
102
|
-
return {};
|
|
103
|
-
}
|
|
104
|
-
if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
105
|
-
return {};
|
|
106
|
-
}
|
|
107
|
-
var isSSREnabled = (config === null || config === void 0 ? void 0 : config.ssr) || (config === null || config === void 0 || (_config$vc$ssrWhiteli = config.vc.ssrWhitelist) === null || _config$vc$ssrWhiteli === void 0 ? void 0 : _config$vc$ssrWhiteli.includes(interaction.ufoName));
|
|
108
|
-
var ssr = interaction.type === 'page_load' && isSSREnabled ? {
|
|
109
|
-
ssr: getSSRDoneTimeValue(config)
|
|
110
|
-
} : null;
|
|
111
|
-
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
112
|
-
var result = calculateVCMetrics(interaction, 'ufo', getVCObserver().getVCResult);
|
|
113
|
-
getVCObserver().stop();
|
|
114
|
-
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
115
|
-
return _objectSpread(_objectSpread({}, result), {}, {
|
|
116
|
-
'metric:vc90': result === null || result === void 0 || (_result$metricsVc = result['metrics:vc']) === null || _result$metricsVc === void 0 ? void 0 : _result$metricsVc['90']
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
export var getTTAI = function getTTAI(interaction) {
|
|
120
|
-
var start = interaction.start,
|
|
121
|
-
end = interaction.end;
|
|
122
|
-
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
123
|
-
return !interaction.abortReason && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
|
|
124
|
-
};
|
|
62
|
+
}
|
|
@@ -12,20 +12,19 @@ import Bowser from 'bowser-ultralight';
|
|
|
12
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { getLighthouseMetrics } from '../additional-payload';
|
|
14
14
|
import * as bundleEvalTiming from '../bundle-eval-timing';
|
|
15
|
-
import coinflip from '../coinflip';
|
|
16
15
|
import { REACT_UFO_VERSION } from '../common/constants';
|
|
17
|
-
import { getConfig,
|
|
18
|
-
import { getExperimentalVCMetrics } from '../create-experimental-interaction-metrics-payload';
|
|
16
|
+
import { getConfig, getUfoNameOverrides } from '../config';
|
|
19
17
|
import { getBm3Timings } from '../custom-timings';
|
|
20
18
|
import { getGlobalErrorCount } from '../global-error-handler';
|
|
21
19
|
import { getPageVisibilityState } from '../hidden-timing';
|
|
22
20
|
import * as initialPageLoadExtraTiming from '../initial-page-load-extra-timing';
|
|
23
|
-
import { interactionSpans as atlaskitInteractionSpans } from '../interaction-metrics';
|
|
21
|
+
import { interactionSpans as atlaskitInteractionSpans, postInteractionLog } from '../interaction-metrics';
|
|
24
22
|
import * as resourceTiming from '../resource-timing';
|
|
25
23
|
import { roundEpsilon } from '../round-number';
|
|
26
24
|
import * as ssr from '../ssr';
|
|
27
|
-
import {
|
|
28
|
-
|
|
25
|
+
import { getVCObserver } from '../vc';
|
|
26
|
+
import { buildSegmentTree, labelStackStartWith, optimizeLabelStack, sanitizeUfoName, stringifyLabelStackFully } from './common/utils';
|
|
27
|
+
function getUfoNameOverride(interaction) {
|
|
29
28
|
var ufoName = interaction.ufoName,
|
|
30
29
|
apdex = interaction.apdex;
|
|
31
30
|
try {
|
|
@@ -37,6 +36,7 @@ export function getUfoNameOverride(interaction) {
|
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
return ufoName;
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
40
|
} catch (e) {
|
|
41
41
|
return ufoName;
|
|
42
42
|
}
|
|
@@ -71,6 +71,11 @@ var getPageVisibilityUpToTTI = function getPageVisibilityUpToTTI(interaction) {
|
|
|
71
71
|
var bm3EndTimeOrInteractionEndTime = getBm3EndTimeOrFallbackValue(interaction);
|
|
72
72
|
return getPageVisibilityState(start, bm3EndTimeOrInteractionEndTime);
|
|
73
73
|
};
|
|
74
|
+
var getPageVisibilityUpToTTAI = function getPageVisibilityUpToTTAI(interaction) {
|
|
75
|
+
var start = interaction.start,
|
|
76
|
+
end = interaction.end;
|
|
77
|
+
return getPageVisibilityState(start, end);
|
|
78
|
+
};
|
|
74
79
|
var getVisibilityStateFromPerformance = function getVisibilityStateFromPerformance(stop) {
|
|
75
80
|
try {
|
|
76
81
|
var results = performance.getEntriesByType('visibility-state');
|
|
@@ -126,6 +131,15 @@ var getMoreAccuratePageVisibilityUpToTTAI = function getMoreAccuratePageVisibili
|
|
|
126
131
|
}
|
|
127
132
|
return old;
|
|
128
133
|
};
|
|
134
|
+
var getInteractionStatus = function getInteractionStatus(interaction) {
|
|
135
|
+
var originalInteractionStatus = interaction.abortReason ? 'ABORTED' : 'SUCCEEDED';
|
|
136
|
+
var hasBm3TTI = interaction.apdex.length > 0;
|
|
137
|
+
var overrideStatus = hasBm3TTI ? 'SUCCEEDED' : originalInteractionStatus;
|
|
138
|
+
return {
|
|
139
|
+
originalInteractionStatus: originalInteractionStatus,
|
|
140
|
+
overrideStatus: overrideStatus
|
|
141
|
+
};
|
|
142
|
+
};
|
|
129
143
|
var getResourceTimings = function getResourceTimings(start, end) {
|
|
130
144
|
var _resourceTiming$getRe;
|
|
131
145
|
return (_resourceTiming$getRe = resourceTiming.getResourceTimings(start, end)) !== null && _resourceTiming$getRe !== void 0 ? _resourceTiming$getRe : undefined;
|
|
@@ -154,6 +168,42 @@ var getPaintMetrics = function getPaintMetrics(type) {
|
|
|
154
168
|
});
|
|
155
169
|
return metrics;
|
|
156
170
|
};
|
|
171
|
+
var getVCMetrics = function getVCMetrics(interaction) {
|
|
172
|
+
var _config$vc, _interaction$apdex;
|
|
173
|
+
var config = getConfig();
|
|
174
|
+
if (!(config !== null && config !== void 0 && (_config$vc = config.vc) !== null && _config$vc !== void 0 && _config$vc.enabled)) {
|
|
175
|
+
return {};
|
|
176
|
+
}
|
|
177
|
+
if (interaction.type !== 'page_load' && interaction.type !== 'transition') {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
var ssr = interaction.type === 'page_load' && config !== null && config !== void 0 && config.ssr ? {
|
|
181
|
+
ssr: getSSRDoneTimeValue(config)
|
|
182
|
+
} : null;
|
|
183
|
+
postInteractionLog.setVCObserverSSRConfig(ssr);
|
|
184
|
+
var tti = (_interaction$apdex = interaction.apdex) === null || _interaction$apdex === void 0 || (_interaction$apdex = _interaction$apdex[0]) === null || _interaction$apdex === void 0 ? void 0 : _interaction$apdex.stopTime;
|
|
185
|
+
var prefix = 'ufo';
|
|
186
|
+
var result = getVCObserver().getVCResult(_objectSpread({
|
|
187
|
+
start: interaction.start,
|
|
188
|
+
stop: interaction.end,
|
|
189
|
+
tti: tti,
|
|
190
|
+
prefix: prefix,
|
|
191
|
+
vc: interaction.vc
|
|
192
|
+
}, ssr));
|
|
193
|
+
postInteractionLog.setLastInteractionFinishVCResult(result);
|
|
194
|
+
var VC = result === null || result === void 0 ? void 0 : result['metrics:vc'];
|
|
195
|
+
if (!VC || !(result !== null && result !== void 0 && result["".concat(prefix, ":vc:clean")])) {
|
|
196
|
+
return result;
|
|
197
|
+
}
|
|
198
|
+
var interactionStatus = getInteractionStatus(interaction);
|
|
199
|
+
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
200
|
+
if (interactionStatus.originalInteractionStatus !== 'SUCCEEDED' || pageVisibilityUpToTTAI !== 'visible') {
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
return _objectSpread(_objectSpread({}, result), {}, {
|
|
204
|
+
'metric:vc90': VC['90']
|
|
205
|
+
});
|
|
206
|
+
};
|
|
157
207
|
var getNavigationMetrics = function getNavigationMetrics(type) {
|
|
158
208
|
if (type !== 'page_load') {
|
|
159
209
|
return {};
|
|
@@ -201,13 +251,14 @@ var getNavigationMetrics = function getNavigationMetrics(type) {
|
|
|
201
251
|
};
|
|
202
252
|
};
|
|
203
253
|
var getPPSMetrics = function getPPSMetrics(interaction) {
|
|
204
|
-
var _interaction$
|
|
254
|
+
var _interaction$apdex2;
|
|
205
255
|
var start = interaction.start,
|
|
206
256
|
end = interaction.end;
|
|
207
257
|
var config = getConfig();
|
|
258
|
+
var interactionStatus = getInteractionStatus(interaction);
|
|
208
259
|
var pageVisibilityUpToTTAI = getPageVisibilityUpToTTAI(interaction);
|
|
209
|
-
var tti = (_interaction$
|
|
210
|
-
var ttai =
|
|
260
|
+
var tti = (_interaction$apdex2 = interaction.apdex) === null || _interaction$apdex2 === void 0 || (_interaction$apdex2 = _interaction$apdex2[0]) === null || _interaction$apdex2 === void 0 ? void 0 : _interaction$apdex2.stopTime;
|
|
261
|
+
var ttai = interactionStatus.originalInteractionStatus === 'SUCCEEDED' && pageVisibilityUpToTTAI === 'visible' ? Math.round(end - start) : undefined;
|
|
211
262
|
var PPSMetricsAtTTI = tti !== undefined ? getLighthouseMetrics({
|
|
212
263
|
start: start,
|
|
213
264
|
stop: tti
|
|
@@ -297,13 +348,13 @@ function optimizeCustomData(interaction) {
|
|
|
297
348
|
for (var _i = 0, _Object$entries = Object.entries(currentValue.custom || {}); _i < _Object$entries.length; _i++) {
|
|
298
349
|
var _result$get$data2, _result$get2;
|
|
299
350
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
300
|
-
|
|
351
|
+
_key = _Object$entries$_i[0],
|
|
301
352
|
value = _Object$entries$_i[1];
|
|
302
353
|
var label = stringifyLabelStackFully([]);
|
|
303
354
|
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 : {};
|
|
304
355
|
result.set(label, {
|
|
305
356
|
labelStack: optimizeLabelStack([]),
|
|
306
|
-
data: Object.assign(labelValue, _defineProperty({},
|
|
357
|
+
data: Object.assign(labelValue, _defineProperty({}, _key, value))
|
|
307
358
|
});
|
|
308
359
|
}
|
|
309
360
|
return result;
|
|
@@ -541,6 +592,10 @@ function getBm3TrackerTimings(interaction) {
|
|
|
541
592
|
legacyMetrics: legacyMetrics
|
|
542
593
|
};
|
|
543
594
|
}
|
|
595
|
+
function getSSRDoneTimeValue(config) {
|
|
596
|
+
var _config$ssr, _config$ssr2;
|
|
597
|
+
return config !== null && config !== void 0 && (_config$ssr = config.ssr) !== null && _config$ssr !== void 0 && _config$ssr.getSSRDoneTime ? config === null || config === void 0 || (_config$ssr2 = config.ssr) === null || _config$ssr2 === void 0 ? void 0 : _config$ssr2.getSSRDoneTime() : ssr.getSSRDoneTime();
|
|
598
|
+
}
|
|
544
599
|
function getPayloadSize(payload) {
|
|
545
600
|
return Math.round(new TextEncoder().encode(JSON.stringify(payload)).length / 1024);
|
|
546
601
|
}
|
|
@@ -583,15 +638,13 @@ function getStylesheetMetrics() {
|
|
|
583
638
|
return {};
|
|
584
639
|
}
|
|
585
640
|
}
|
|
586
|
-
var regularTTAI;
|
|
587
|
-
var expTTAI;
|
|
588
641
|
function getErrorCounts(interaction) {
|
|
589
642
|
return {
|
|
590
643
|
'ufo:errors:globalCount': getGlobalErrorCount(),
|
|
591
644
|
'ufo:errors:count': interaction.errors.length
|
|
592
645
|
};
|
|
593
646
|
}
|
|
594
|
-
function createInteractionMetricsPayload(interaction, interactionId
|
|
647
|
+
function createInteractionMetricsPayload(interaction, interactionId) {
|
|
595
648
|
var _window$location, _config$additionalPay;
|
|
596
649
|
var interactionPayloadStart = performance.now();
|
|
597
650
|
var config = getConfig();
|
|
@@ -626,7 +679,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
626
679
|
} : {};
|
|
627
680
|
// Page Load
|
|
628
681
|
var getPageLoadInteractionMetrics = function getPageLoadInteractionMetrics() {
|
|
629
|
-
var _config$
|
|
682
|
+
var _config$ssr3;
|
|
630
683
|
if (!isPageLoad) {
|
|
631
684
|
return {};
|
|
632
685
|
}
|
|
@@ -637,12 +690,12 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
637
690
|
} : {};
|
|
638
691
|
return _objectSpread(_objectSpread({}, SSRDoneTime), {}, {
|
|
639
692
|
isBM3ConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp,
|
|
640
|
-
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$
|
|
693
|
+
isUFOConfigSSRDoneAsFmp: interaction.metaData.__legacy__bm3ConfigSSRDoneAsFmp || !!(config !== null && config !== void 0 && (_config$ssr3 = config.ssr) !== null && _config$ssr3 !== void 0 && _config$ssr3.getSSRDoneTime)
|
|
641
694
|
});
|
|
642
695
|
};
|
|
643
696
|
// Detailed payload. Page visibility = visible
|
|
644
697
|
var getDetailedInteractionMetrics = function getDetailedInteractionMetrics() {
|
|
645
|
-
if (
|
|
698
|
+
if (window.__UFO_COMPACT_PAYLOAD__ || !isDetailedPayload) {
|
|
646
699
|
return {};
|
|
647
700
|
}
|
|
648
701
|
var spans = [].concat(_toConsumableArray(interaction.spans), _toConsumableArray(atlaskitInteractionSpans));
|
|
@@ -657,7 +710,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
657
710
|
}),
|
|
658
711
|
holdActive: _toConsumableArray(interaction.holdActive.values()),
|
|
659
712
|
redirects: optimizeRedirects(interaction.redirects, start),
|
|
660
|
-
holdInfo: optimizeHoldInfo(
|
|
713
|
+
holdInfo: optimizeHoldInfo(interaction.holdInfo, start),
|
|
661
714
|
spans: optimizeSpans(spans, start),
|
|
662
715
|
requestInfo: optimizeRequestInfo(interaction.requestInfo, start),
|
|
663
716
|
customTimings: optimizeCustomTimings(interaction.customTimings, start),
|
|
@@ -667,21 +720,16 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
667
720
|
};
|
|
668
721
|
// Page load & detailed payload
|
|
669
722
|
var getPageLoadDetailedInteractionMetrics = function getPageLoadDetailedInteractionMetrics() {
|
|
670
|
-
var _config$
|
|
723
|
+
var _config$ssr4;
|
|
671
724
|
if (!isPageLoad || !isDetailedPayload) {
|
|
672
725
|
return {};
|
|
673
726
|
}
|
|
674
727
|
var config = getConfig();
|
|
675
728
|
return {
|
|
676
729
|
initialPageLoadExtraTimings: objectToArray(initialPageLoadExtraTiming.getTimings()),
|
|
677
|
-
SSRTimings: config !== null && config !== void 0 && (_config$
|
|
730
|
+
SSRTimings: config !== null && config !== void 0 && (_config$ssr4 = config.ssr) !== null && _config$ssr4 !== void 0 && _config$ssr4.getSSRTimings ? config.ssr.getSSRTimings() : objectToArray(ssr.getSSRTimings())
|
|
678
731
|
};
|
|
679
732
|
};
|
|
680
|
-
if (experimental) {
|
|
681
|
-
expTTAI = getTTAI(interaction);
|
|
682
|
-
} else {
|
|
683
|
-
regularTTAI = getTTAI(interaction);
|
|
684
|
-
}
|
|
685
733
|
var newUFOName = sanitizeUfoName(ufoName);
|
|
686
734
|
var payload = {
|
|
687
735
|
actionSubject: 'experience',
|
|
@@ -690,7 +738,7 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
690
738
|
source: 'measured',
|
|
691
739
|
tags: ['observability'],
|
|
692
740
|
attributes: {
|
|
693
|
-
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
741
|
+
properties: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
694
742
|
// basic
|
|
695
743
|
'event:hostname': ((_window$location = window.location) === null || _window$location === void 0 ? void 0 : _window$location.hostname) || 'unknown',
|
|
696
744
|
'event:product': config.product,
|
|
@@ -702,10 +750,10 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
702
750
|
payloadSource: 'platform'
|
|
703
751
|
},
|
|
704
752
|
'event:region': config.region || 'unknown',
|
|
705
|
-
'experience:key':
|
|
753
|
+
'experience:key': 'custom.interaction-metrics',
|
|
706
754
|
'experience:name': newUFOName
|
|
707
|
-
}, getBrowserMetadata()), getSSRProperties(type)), getPPSMetrics(interaction)), getPaintMetrics(type)), getNavigationMetrics(type)), getVCMetrics(interaction)),
|
|
708
|
-
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
755
|
+
}, 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()), getErrorCounts(interaction)), {}, {
|
|
756
|
+
interactionMetrics: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
709
757
|
namePrefix: config.namePrefix || '',
|
|
710
758
|
segmentPrefix: config.segmentPrefix || '',
|
|
711
759
|
interactionId: interactionId,
|
|
@@ -736,18 +784,11 @@ function createInteractionMetricsPayload(interaction, interactionId, experimenta
|
|
|
736
784
|
marks: optimizeMarks(interaction.marks),
|
|
737
785
|
customData: optimizeCustomData(interaction),
|
|
738
786
|
reactProfilerTimings: optimizeReactProfilerTimings(interaction.reactProfilerTimings, start)
|
|
739
|
-
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
740
|
-
'metric:ttai': experimental ? regularTTAI || expTTAI : undefined,
|
|
741
|
-
'metric:experimental:ttai': expTTAI
|
|
742
|
-
}),
|
|
787
|
+
}, labelStack), getPageLoadInteractionMetrics()), getDetailedInteractionMetrics()), getPageLoadDetailedInteractionMetrics()), getBm3TrackerTimings(interaction)),
|
|
743
788
|
'ufo:payloadTime': roundEpsilon(performance.now() - interactionPayloadStart)
|
|
744
789
|
})
|
|
745
790
|
}
|
|
746
791
|
};
|
|
747
|
-
if (experimental) {
|
|
748
|
-
regularTTAI = undefined;
|
|
749
|
-
expTTAI = undefined;
|
|
750
|
-
}
|
|
751
792
|
payload.attributes.properties['event:sizeInKb'] = getPayloadSize(payload.attributes.properties);
|
|
752
793
|
return payload;
|
|
753
794
|
}
|
|
@@ -758,20 +799,4 @@ export function createPayloads(interactionId, interaction) {
|
|
|
758
799
|
});
|
|
759
800
|
var interactionMetricsPayload = createInteractionMetricsPayload(modifiedInteraction, interactionId);
|
|
760
801
|
return [interactionMetricsPayload];
|
|
761
|
-
}
|
|
762
|
-
export function createExperimentalMetricsPayload(interactionId, interaction) {
|
|
763
|
-
var config = getConfig();
|
|
764
|
-
if (!config) {
|
|
765
|
-
throw Error('UFO Configuration not provided');
|
|
766
|
-
}
|
|
767
|
-
var ufoName = sanitizeUfoName(interaction.ufoName);
|
|
768
|
-
var rate = getExperimentalInteractionRate(ufoName, interaction.type);
|
|
769
|
-
if (!coinflip(rate)) {
|
|
770
|
-
return null;
|
|
771
|
-
}
|
|
772
|
-
var pageVisibilityState = getPageVisibilityState(interaction.start, interaction.end);
|
|
773
|
-
if (pageVisibilityState !== 'visible') {
|
|
774
|
-
return null;
|
|
775
|
-
}
|
|
776
|
-
return createInteractionMetricsPayload(interaction, interactionId, true);
|
|
777
802
|
}
|
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export var CLEANUP_TIMEOUT_AFTER_APDEX = 15 * 1000;
|
|
4
|
-
export var interactionQueue = [];
|
|
5
|
-
export var segmentCache = new Map();
|
|
6
|
-
export var segmentObservers = [];
|
|
7
|
-
export var moduleLoadingRequests = {};
|
|
1
|
+
var interactions = new Map();
|
|
2
|
+
export default interactions;
|