@adobe/helix-rum-enhancer 2.52.0 → 2.53.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/.releaserc.cjs +5 -6
- package/docs/CI-CREDENTIALS.md +92 -0
- package/docs/RELEASE-MANIFEST.md +38 -0
- package/package.json +7 -8
- package/plugins/cwv.js +40 -41
- package/release-manifest.json +110 -0
- package/release-manifest.mjs +183 -0
- package/release-notes.md +18 -0
- package/rollup.config.js +13 -0
- package/src/plugins/cwv.js +340 -342
- package/src/plugins/cwv.map.js +341 -343
- package/src/plugins/cwv.md5 +1 -1
- package/src/plugins/form.md5 +1 -1
- package/src/plugins/redirect.md5 +1 -1
- package/src/plugins/usercentrics.md5 +1 -1
- package/src/plugins/video.md5 +1 -1
- package/src/plugins/webcomponent.md5 +1 -1
- package/src/vendor/web-vitals.iife.js +2 -0
- package/tagger.sh +139 -147
package/src/plugins/cwv.js
CHANGED
|
@@ -9,281 +9,268 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return a => {
|
|
24
|
-
n.value >= 0 && (a || i) && (s = n.value - (o ?? 0), (s || void 0 === o) && (o = n.value, n.delta = s, n.rating = ((t, n) => t > n[1] ? "poor" : t > n[0] ? "needs-improvement" : "good")(n.value, e), t(n)));
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
s = t => {
|
|
28
|
-
requestAnimationFrame(() => requestAnimationFrame(() => t()));
|
|
29
|
-
},
|
|
30
|
-
a = () => {
|
|
31
|
-
const t = performance.getEntriesByType("navigation")[0];
|
|
32
|
-
if (t && t.responseStart > 0 && t.responseStart < performance.now()) return t;
|
|
33
|
-
},
|
|
34
|
-
r = () => a()?.activationStart ?? 0;
|
|
35
|
-
let c = -1;
|
|
36
|
-
const f = new Set(),
|
|
37
|
-
h = () => "hidden" !== document.visibilityState || document.prerendering ? 1 / 0 : 0,
|
|
38
|
-
d = t => {
|
|
39
|
-
if ("hidden" === document.visibilityState) {
|
|
40
|
-
if ("visibilitychange" === t.type) for (const t of f) t();
|
|
41
|
-
isFinite(c) || (c = "visibilitychange" === t.type ? t.timeStamp : 0, removeEventListener("prerenderingchange", d, true));
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
l = (t = false) => {
|
|
45
|
-
if (t && (c = 1 / 0), c < 0) {
|
|
46
|
-
const t = r(),
|
|
47
|
-
n = document.prerendering ? void 0 : globalThis.performance.getEntriesByType("visibility-state").find(n => "hidden" === n.name && n.startTime >= t)?.startTime;
|
|
48
|
-
c = n ?? h(), addEventListener("visibilitychange", d, true), addEventListener("prerenderingchange", d, true), i(() => {
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
c = h();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
get firstHiddenTime() {
|
|
56
|
-
return c;
|
|
57
|
-
},
|
|
58
|
-
onHidden(t) {
|
|
59
|
-
f.add(t);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
g = (t, n = -1, i, o = 0, s, c, f) => {
|
|
64
|
-
const h = a(),
|
|
65
|
-
d = h?.navigationId || 0;
|
|
66
|
-
let l = "navigate";
|
|
67
|
-
i ? l = i : e() >= 0 ? l = "back-forward-cache" : h && (document.prerendering || r() > 0 ? l = "prerender" : document.wasDiscarded ? l = "restore" : h.type && (l = h.type.replace(/_/g, "-")));
|
|
68
|
-
return {
|
|
69
|
-
name: t,
|
|
70
|
-
value: n,
|
|
71
|
-
rating: "good",
|
|
72
|
-
delta: 0,
|
|
73
|
-
entries: [],
|
|
74
|
-
id: `v6-${Date.now()}-${Math.floor(8999999999999 * Math.random()) + 1e12}`,
|
|
75
|
-
navigationType: l,
|
|
76
|
-
navigationId: o || d,
|
|
77
|
-
navigationInteractionId: s,
|
|
78
|
-
navigationURL: c || h?.name,
|
|
79
|
-
navigationStartTime: f || 0
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
u = new WeakMap();
|
|
83
|
-
function v(t, n) {
|
|
84
|
-
let e = u.get(n);
|
|
85
|
-
return e || (e = new WeakMap(), u.set(n, e)), e.get(t) || e.set(t, new n()), e.get(t);
|
|
86
|
-
}
|
|
87
|
-
class m {
|
|
88
|
-
t;
|
|
89
|
-
i = 0;
|
|
90
|
-
o = [];
|
|
91
|
-
h(t) {
|
|
92
|
-
if (t.hadRecentInput) return;
|
|
93
|
-
const n = this.o[0],
|
|
94
|
-
e = this.o.at(-1);
|
|
95
|
-
this.i && n && e && t.startTime - e.startTime < 1e3 && t.startTime - n.startTime < 5e3 ? (this.i += t.value, this.o.push(t)) : (this.i = t.value, this.o = [t]), this.t?.(t);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
const p = (t, n, e = {}) => {
|
|
99
|
-
try {
|
|
100
|
-
const i = t.filter(t => PerformanceObserver.supportedEntryTypes.includes(t));
|
|
101
|
-
if (i.length > 0) {
|
|
102
|
-
const t = new PerformanceObserver(t => {
|
|
103
|
-
queueMicrotask(() => {
|
|
104
|
-
const e = t.getEntries();
|
|
105
|
-
i.length > 1 && e.sort((t, n) => t.startTime + t.duration - (n.startTime + n.duration)), n(e);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
for (const n of i) t.observe({
|
|
109
|
-
type: n,
|
|
110
|
-
buffered: !0,
|
|
111
|
-
...e
|
|
112
|
-
});
|
|
113
|
-
return t;
|
|
114
|
-
}
|
|
115
|
-
} catch {}
|
|
116
|
-
},
|
|
117
|
-
b = t => globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation") && "function" == typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint && t && t.reportSoftNavs,
|
|
118
|
-
T = (t, n) => {
|
|
119
|
-
if (t.set(n.navigationId, n), t.size > 2) {
|
|
120
|
-
const n = t.keys().next().value;
|
|
121
|
-
void 0 !== n && t.delete(n);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
y = t => {
|
|
125
|
-
let n = false;
|
|
126
|
-
return () => {
|
|
127
|
-
n || (t(), n = true);
|
|
128
|
-
};
|
|
12
|
+
let t = -1;
|
|
13
|
+
const n = () => t,
|
|
14
|
+
e = n => {
|
|
15
|
+
addEventListener("pageshow", e => {
|
|
16
|
+
e.persisted && (t = e.timeStamp, n(e));
|
|
17
|
+
}, true);
|
|
18
|
+
},
|
|
19
|
+
i = (t, n, e, i) => {
|
|
20
|
+
let o, s;
|
|
21
|
+
return a => {
|
|
22
|
+
n.value >= 0 && (a || i) && (s = n.value - (o ?? 0), (s || void 0 === o) && (o = n.value, n.delta = s, n.rating = ((t, n) => t > n[1] ? "poor" : t > n[0] ? "needs-improvement" : "good")(n.value, e), t(n)));
|
|
129
23
|
};
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
24
|
+
},
|
|
25
|
+
o = t => {
|
|
26
|
+
requestAnimationFrame(() => requestAnimationFrame(() => t()));
|
|
27
|
+
},
|
|
28
|
+
s = () => {
|
|
29
|
+
const t = performance.getEntriesByType("navigation")[0];
|
|
30
|
+
if (t && t.responseStart > 0 && t.responseStart < performance.now()) return t;
|
|
31
|
+
},
|
|
32
|
+
a = () => s()?.activationStart ?? 0;
|
|
33
|
+
let r = -1;
|
|
34
|
+
const c = new Set(),
|
|
35
|
+
f = () => "hidden" !== document.visibilityState || document.prerendering ? 1 / 0 : 0,
|
|
36
|
+
h = t => {
|
|
37
|
+
if ("hidden" === document.visibilityState) {
|
|
38
|
+
if ("visibilitychange" === t.type) for (const t of c) t();
|
|
39
|
+
isFinite(r) || (r = "visibilitychange" === t.type ? t.timeStamp : 0, removeEventListener("prerenderingchange", h, true));
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
d = (t = false) => {
|
|
43
|
+
if (t && (r = 1 / 0), r < 0) {
|
|
44
|
+
const t = a(),
|
|
45
|
+
n = document.prerendering ? void 0 : globalThis.performance.getEntriesByType("visibility-state").find(n => "hidden" === n.name && n.startTime >= t)?.startTime;
|
|
46
|
+
r = n ?? f(), addEventListener("visibilitychange", h, true), addEventListener("prerenderingchange", h, true), e(() => {
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
r = f();
|
|
146
49
|
});
|
|
147
|
-
if (u && (h = o(t, d, M, n.reportAllChanges), i(i => {
|
|
148
|
-
d = g("FCP", -1, "back-forward-cache", d.navigationId, d.navigationInteractionId, d.navigationURL, e()), h = o(t, d, M, n.reportAllChanges), s(() => {
|
|
149
|
-
d.value = performance.now() - i.timeStamp, h(true);
|
|
150
|
-
});
|
|
151
|
-
})), a) {
|
|
152
|
-
p(["soft-navigation"], e => {
|
|
153
|
-
e.forEach(e => {
|
|
154
|
-
c.l && e.navigationId && T(c.l, e);
|
|
155
|
-
const i = Math.max((e.presentationTime || e.paintTime || 0) - e.startTime, 0);
|
|
156
|
-
d = g("FCP", i, "soft-navigation", e.navigationId, e.interactionId, e.name, e.startTime), h = o(t, d, M, n.reportAllChanges), h(true);
|
|
157
|
-
});
|
|
158
|
-
}, n);
|
|
159
|
-
}
|
|
160
50
|
});
|
|
161
|
-
},
|
|
162
|
-
w = [.1, .25];
|
|
163
|
-
let P = 0,
|
|
164
|
-
I = 1 / 0,
|
|
165
|
-
k = 0;
|
|
166
|
-
const C = t => {
|
|
167
|
-
for (const n of t) n.interactionId && (I = Math.min(I, n.interactionId), k = Math.max(k, n.interactionId), P = k ? (k - I) / 7 + 1 : 0);
|
|
168
|
-
};
|
|
169
|
-
let F;
|
|
170
|
-
const N = () => F ? P : performance.interactionCount ?? 0,
|
|
171
|
-
B = () => {
|
|
172
|
-
"interactionCount" in performance || F || (F = p(["event"], C, {
|
|
173
|
-
durationThreshold: 0
|
|
174
|
-
}));
|
|
175
|
-
};
|
|
176
|
-
class S {
|
|
177
|
-
u = 0;
|
|
178
|
-
v = [];
|
|
179
|
-
m = new Map();
|
|
180
|
-
p;
|
|
181
|
-
T;
|
|
182
|
-
_() {
|
|
183
|
-
return N() - this.u;
|
|
184
|
-
}
|
|
185
|
-
M() {
|
|
186
|
-
this.u = N(), this.v.length = 0, this.m.clear();
|
|
187
51
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
entries: []
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
h(t) {
|
|
198
|
-
if (this.p?.(t), !t.interactionId) return;
|
|
199
|
-
const n = this.v.at(-1);
|
|
200
|
-
let e = this.m.get(t.interactionId);
|
|
201
|
-
if (e || this.v.length < 10 || t.duration > n.P) {
|
|
202
|
-
if (e ? t.duration > e.P ? (e.entries = [t], e.P = t.duration) : t.duration === e.P && t.startTime === e.entries[0].startTime && e.entries.push(t) : (e = {
|
|
203
|
-
id: t.interactionId,
|
|
204
|
-
entries: [t],
|
|
205
|
-
P: t.duration
|
|
206
|
-
}, this.m.set(e.id, e), this.v.push(e)), this.v.sort((t, n) => n.P - t.P), this.v.length > 10) {
|
|
207
|
-
const t = this.v.splice(10);
|
|
208
|
-
for (const n of t) this.m.delete(n.id);
|
|
209
|
-
}
|
|
210
|
-
this.T?.(e);
|
|
52
|
+
return {
|
|
53
|
+
get firstHiddenTime() {
|
|
54
|
+
return r;
|
|
55
|
+
},
|
|
56
|
+
onHidden(t) {
|
|
57
|
+
c.add(t);
|
|
211
58
|
}
|
|
212
|
-
}
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
l = (t, e = -1, i, o = 0, r, c, f) => {
|
|
62
|
+
const h = s(),
|
|
63
|
+
d = h?.navigationId || 0;
|
|
64
|
+
let l = "navigate";
|
|
65
|
+
i ? l = i : n() >= 0 ? l = "back-forward-cache" : h && (document.prerendering || a() > 0 ? l = "prerender" : document.wasDiscarded ? l = "restore" : h.type && (l = h.type.replace(/_/g, "-")));
|
|
66
|
+
return {
|
|
67
|
+
name: t,
|
|
68
|
+
value: e,
|
|
69
|
+
rating: "good",
|
|
70
|
+
delta: 0,
|
|
71
|
+
entries: [],
|
|
72
|
+
id: `v6-${Date.now()}-${Math.floor(8999999999999 * Math.random()) + 1e12}`,
|
|
73
|
+
navigationType: l,
|
|
74
|
+
navigationId: o || d,
|
|
75
|
+
navigationInteractionId: r,
|
|
76
|
+
navigationURL: c || h?.name,
|
|
77
|
+
navigationStartTime: f || 0
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
g = new WeakMap();
|
|
81
|
+
function u(t, n) {
|
|
82
|
+
let e = g.get(n);
|
|
83
|
+
return e || (e = new WeakMap(), g.set(n, e)), e.get(t) || e.set(t, new n()), e.get(t);
|
|
84
|
+
}
|
|
85
|
+
class v {
|
|
86
|
+
t;
|
|
87
|
+
i = 0;
|
|
88
|
+
o = [];
|
|
89
|
+
h(t) {
|
|
90
|
+
if (t.hadRecentInput) return;
|
|
91
|
+
const n = this.o[0],
|
|
92
|
+
e = this.o.at(-1);
|
|
93
|
+
this.i && n && e && t.startTime - e.startTime < 1e3 && t.startTime - n.startTime < 5e3 ? (this.i += t.value, this.o.push(t)) : (this.i = t.value, this.o = [t]), this.t?.(t);
|
|
213
94
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
capture: true
|
|
230
|
-
}), o();
|
|
231
|
-
}, {
|
|
232
|
-
timeout: n
|
|
95
|
+
}
|
|
96
|
+
const m = (t, n, e = {}) => {
|
|
97
|
+
try {
|
|
98
|
+
const i = t.filter(t => PerformanceObserver.supportedEntryTypes.includes(t));
|
|
99
|
+
if (i.length > 0) {
|
|
100
|
+
const t = new PerformanceObserver(t => {
|
|
101
|
+
queueMicrotask(() => {
|
|
102
|
+
const e = t.getEntries();
|
|
103
|
+
i.length > 1 && e.sort((t, n) => t.startTime + t.duration - (n.startTime + n.duration)), n(e);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
for (const n of i) t.observe({
|
|
107
|
+
type: n,
|
|
108
|
+
buffered: !0,
|
|
109
|
+
...e
|
|
233
110
|
});
|
|
111
|
+
return t;
|
|
234
112
|
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
113
|
+
} catch {}
|
|
114
|
+
},
|
|
115
|
+
p = t => globalThis.PerformanceObserver?.supportedEntryTypes?.includes("soft-navigation") && "function" == typeof globalThis.PerformanceSoftNavigation?.prototype?.getLargestInteractionContentfulPaint && t && t.reportSoftNavs,
|
|
116
|
+
b = (t, n) => {
|
|
117
|
+
if (t.set(n.navigationId, n), t.size > 2) {
|
|
118
|
+
const n = t.keys().next().value;
|
|
119
|
+
void 0 !== n && t.delete(n);
|
|
242
120
|
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
121
|
+
},
|
|
122
|
+
T = t => {
|
|
123
|
+
let n = false;
|
|
124
|
+
return () => {
|
|
125
|
+
n || (t(), n = true);
|
|
248
126
|
};
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
127
|
+
};
|
|
128
|
+
class y {
|
|
129
|
+
l;
|
|
130
|
+
}
|
|
131
|
+
const _ = t => {
|
|
132
|
+
document.prerendering ? addEventListener("prerenderingchange", t, true) : t();
|
|
133
|
+
},
|
|
134
|
+
E = [1800, 3e3],
|
|
135
|
+
M = (t, s = {}) => {
|
|
136
|
+
const r = p(s);
|
|
137
|
+
_(() => {
|
|
138
|
+
const c = u(s, y),
|
|
139
|
+
f = d();
|
|
140
|
+
let h,
|
|
141
|
+
g = l("FCP");
|
|
142
|
+
const v = m(["paint"], t => {
|
|
143
|
+
for (const n of t) "first-contentful-paint" === n.name && (v.disconnect(), n.startTime < f.firstHiddenTime && (g.value = Math.max(n.startTime - a(), 0), g.entries.push(n), g.navigationId = n.navigationId || g.navigationId, h(true)));
|
|
144
|
+
});
|
|
145
|
+
if (v && (h = i(t, g, E, s.reportAllChanges), e(e => {
|
|
146
|
+
g = l("FCP", -1, "back-forward-cache", g.navigationId, g.navigationInteractionId, g.navigationURL, n()), h = i(t, g, E, s.reportAllChanges), o(() => {
|
|
147
|
+
g.value = performance.now() - e.timeStamp, h(true);
|
|
148
|
+
});
|
|
149
|
+
})), r) {
|
|
150
|
+
m(["soft-navigation"], n => {
|
|
151
|
+
n.forEach(n => {
|
|
152
|
+
c.l && n.navigationId && b(c.l, n);
|
|
153
|
+
const e = Math.max((n.presentationTime || n.paintTime || 0) - n.startTime, 0);
|
|
154
|
+
g = l("FCP", e, "soft-navigation", n.navigationId, n.interactionId, n.name, n.startTime), h = i(t, g, E, s.reportAllChanges), h(true);
|
|
155
|
+
});
|
|
156
|
+
}, s);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
},
|
|
160
|
+
L = [.1, .25],
|
|
161
|
+
P = (t, s = {}) => {
|
|
162
|
+
const a = d();
|
|
163
|
+
M(T(() => {
|
|
252
164
|
let r,
|
|
253
|
-
c =
|
|
254
|
-
const f =
|
|
255
|
-
h = (
|
|
256
|
-
c =
|
|
165
|
+
c = l("CLS", 0);
|
|
166
|
+
const f = u(s, v),
|
|
167
|
+
h = (n, e, o, a, h) => {
|
|
168
|
+
c = l("CLS", 0, n, e, o, a, h), f.i = 0, r = i(t, c, L, s.reportAllChanges);
|
|
257
169
|
},
|
|
258
170
|
d = (t = false) => {
|
|
259
171
|
f.i > c.value && (c.value = f.i, c.entries = f.o), r(t);
|
|
260
172
|
},
|
|
261
|
-
|
|
173
|
+
g = t => {
|
|
262
174
|
d(true), h("soft-navigation", t.navigationId, t.interactionId, t.name, t.startTime);
|
|
263
175
|
},
|
|
264
|
-
|
|
265
|
-
for (const n of t) "soft-navigation" !== n.entryType ? f.h(n) :
|
|
176
|
+
b = t => {
|
|
177
|
+
for (const n of t) "soft-navigation" !== n.entryType ? f.h(n) : g(n);
|
|
266
178
|
d();
|
|
267
179
|
},
|
|
268
180
|
T = ["layout-shift"];
|
|
269
|
-
|
|
270
|
-
const y =
|
|
271
|
-
y && (r =
|
|
272
|
-
|
|
273
|
-
}),
|
|
274
|
-
h("back-forward-cache", c.navigationId, c.navigationInteractionId, c.navigationURL,
|
|
181
|
+
p(s) && T.push("soft-navigation");
|
|
182
|
+
const y = m(T, b);
|
|
183
|
+
y && (r = i(t, c, L, s.reportAllChanges), a.onHidden(() => {
|
|
184
|
+
b(y.takeRecords()), r(true);
|
|
185
|
+
}), e(() => {
|
|
186
|
+
h("back-forward-cache", c.navigationId, c.navigationInteractionId, c.navigationURL, n()), o(r);
|
|
275
187
|
}), setTimeout(r));
|
|
276
188
|
}));
|
|
277
|
-
}
|
|
189
|
+
};
|
|
190
|
+
let w = 0,
|
|
191
|
+
I = 1 / 0,
|
|
192
|
+
k = 0;
|
|
193
|
+
const C = t => {
|
|
194
|
+
for (const n of t) n.interactionId && (I = Math.min(I, n.interactionId), k = Math.max(k, n.interactionId), w = k ? (k - I) / 7 + 1 : 0);
|
|
195
|
+
};
|
|
196
|
+
let F;
|
|
197
|
+
const N = () => F ? w : performance.interactionCount ?? 0,
|
|
198
|
+
B = () => {
|
|
199
|
+
"interactionCount" in performance || F || (F = m(["event"], C, {
|
|
200
|
+
durationThreshold: 0
|
|
201
|
+
}));
|
|
202
|
+
};
|
|
203
|
+
class S {
|
|
204
|
+
u = 0;
|
|
205
|
+
v = [];
|
|
206
|
+
m = new Map();
|
|
207
|
+
p;
|
|
208
|
+
T;
|
|
209
|
+
_() {
|
|
210
|
+
return N() - this.u;
|
|
211
|
+
}
|
|
212
|
+
M() {
|
|
213
|
+
this.u = N(), this.v.length = 0, this.m.clear();
|
|
214
|
+
}
|
|
215
|
+
L(t) {
|
|
216
|
+
const n = this._(),
|
|
217
|
+
e = Math.min(this.v.length - 1, Math.floor(n / 50));
|
|
218
|
+
return !n || -1 !== e || "soft-navigation" !== t && "back-forward-cache" !== t ? this.v[e] : {
|
|
219
|
+
P: 8,
|
|
220
|
+
id: -1,
|
|
221
|
+
entries: []
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
h(t) {
|
|
225
|
+
if (this.p?.(t), !t.interactionId) return;
|
|
226
|
+
const n = this.v.at(-1);
|
|
227
|
+
let e = this.m.get(t.interactionId);
|
|
228
|
+
if (e || this.v.length < 10 || t.duration > n.P) {
|
|
229
|
+
if (e ? t.duration > e.P ? (e.entries = [t], e.P = t.duration) : t.duration === e.P && t.startTime === e.entries[0].startTime && e.entries.push(t) : (e = {
|
|
230
|
+
id: t.interactionId,
|
|
231
|
+
entries: [t],
|
|
232
|
+
P: t.duration
|
|
233
|
+
}, this.m.set(e.id, e), this.v.push(e)), this.v.sort((t, n) => n.P - t.P), this.v.length > 10) {
|
|
234
|
+
const t = this.v.splice(10);
|
|
235
|
+
for (const n of t) this.m.delete(n.id);
|
|
236
|
+
}
|
|
237
|
+
this.T?.(e);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const q = t => {
|
|
242
|
+
const n = "requestIdleCallback" in globalThis ? 1e3 : 0,
|
|
243
|
+
e = globalThis.requestIdleCallback || setTimeout,
|
|
244
|
+
i = globalThis.cancelIdleCallback || clearTimeout;
|
|
245
|
+
if ("hidden" === document.visibilityState) t();else {
|
|
246
|
+
const o = T(t);
|
|
247
|
+
let s = -1;
|
|
248
|
+
const a = () => {
|
|
249
|
+
i(s), o();
|
|
250
|
+
};
|
|
251
|
+
addEventListener("visibilitychange", a, {
|
|
252
|
+
once: true,
|
|
253
|
+
capture: true
|
|
254
|
+
}), s = e(() => {
|
|
255
|
+
removeEventListener("visibilitychange", a, {
|
|
256
|
+
capture: true
|
|
257
|
+
}), o();
|
|
258
|
+
}, {
|
|
259
|
+
timeout: n
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
A = [200, 500],
|
|
264
|
+
x = (t, o = {}) => {
|
|
278
265
|
if (!globalThis.PerformanceEventTiming || !("interactionId" in PerformanceEventTiming.prototype)) return;
|
|
279
|
-
const s =
|
|
280
|
-
|
|
266
|
+
const s = d();
|
|
267
|
+
_(() => {
|
|
281
268
|
B();
|
|
282
269
|
let a,
|
|
283
|
-
r =
|
|
284
|
-
const c =
|
|
285
|
-
f = (
|
|
286
|
-
c.M(), r =
|
|
270
|
+
r = l("INP");
|
|
271
|
+
const c = u(o, S),
|
|
272
|
+
f = (n, e, s, f, h) => {
|
|
273
|
+
c.M(), r = l("INP", -1, n, e, s, f, h), a = i(t, r, A, o.reportAllChanges);
|
|
287
274
|
},
|
|
288
275
|
h = () => {
|
|
289
276
|
const t = c.L(r.navigationType);
|
|
@@ -292,114 +279,133 @@
|
|
|
292
279
|
d = t => {
|
|
293
280
|
h(), a(true), f("soft-navigation", t.navigationId, t.interactionId, t.name, t.startTime);
|
|
294
281
|
},
|
|
295
|
-
|
|
282
|
+
g = (t, n = false) => {
|
|
296
283
|
q(() => {
|
|
297
284
|
for (const n of t) "soft-navigation" !== n.entryType ? c.h(n) : d(n);
|
|
298
285
|
h(), n && a(true);
|
|
299
286
|
});
|
|
300
287
|
},
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
...
|
|
305
|
-
durationThreshold:
|
|
288
|
+
v = ["event", "first-input"];
|
|
289
|
+
p(o) && v.push("soft-navigation");
|
|
290
|
+
const b = m(v, g, {
|
|
291
|
+
...o,
|
|
292
|
+
durationThreshold: o.durationThreshold ?? 40
|
|
306
293
|
});
|
|
307
|
-
a =
|
|
308
|
-
|
|
309
|
-
}),
|
|
310
|
-
f("back-forward-cache", r.navigationId, r.navigationInteractionId, r.navigationURL,
|
|
294
|
+
a = i(t, r, A, o.reportAllChanges), b && (s.onHidden(() => {
|
|
295
|
+
g(b.takeRecords(), true);
|
|
296
|
+
}), e(() => {
|
|
297
|
+
f("back-forward-cache", r.navigationId, r.navigationInteractionId, r.navigationURL, n());
|
|
311
298
|
}));
|
|
312
299
|
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
300
|
+
};
|
|
301
|
+
class H {
|
|
302
|
+
p;
|
|
303
|
+
l;
|
|
304
|
+
h(t) {
|
|
305
|
+
this.p?.(t);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
const O = [2500, 4e3],
|
|
309
|
+
U = (t, s = {}) => {
|
|
310
|
+
let r = false;
|
|
311
|
+
const c = p(s);
|
|
312
|
+
_(() => {
|
|
317
313
|
let f,
|
|
318
|
-
h =
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
|
|
314
|
+
h = d(),
|
|
315
|
+
g = l("LCP");
|
|
316
|
+
const v = u(s, H),
|
|
317
|
+
p = (n, e, o, a, c) => {
|
|
318
|
+
g = l("LCP", -1, n, e, o, a, c), f = i(t, g, O, s.reportAllChanges), r = false, "soft-navigation" === n && (h = d(true));
|
|
323
319
|
},
|
|
324
|
-
|
|
325
|
-
|
|
320
|
+
T = t => {
|
|
321
|
+
v.l && t.navigationId && b(v.l, t), r || f(true), p("soft-navigation", t.navigationId, t.interactionId, t.name, t.startTime);
|
|
326
322
|
const n = t.getLargestInteractionContentfulPaint?.();
|
|
327
323
|
n && y([n]);
|
|
328
324
|
},
|
|
329
325
|
y = t => {
|
|
330
|
-
|
|
326
|
+
s.reportAllChanges || c || (t = t.slice(-1));
|
|
331
327
|
for (const n of t) {
|
|
332
328
|
if (!n) continue;
|
|
333
329
|
if ("soft-navigation" === n.entryType) {
|
|
334
|
-
|
|
330
|
+
T(n);
|
|
335
331
|
continue;
|
|
336
332
|
}
|
|
337
333
|
let t = 0,
|
|
338
334
|
e = [],
|
|
339
335
|
i = n.startTime;
|
|
340
|
-
if ("largest-contentful-paint" === n.entryType) t = Math.max(n.startTime -
|
|
336
|
+
if ("largest-contentful-paint" === n.entryType) t = Math.max(n.startTime - a(), 0), v.h(n), e = [n];else if ("interaction-contentful-paint" === n.entryType) {
|
|
341
337
|
const o = n;
|
|
342
|
-
if (!
|
|
343
|
-
if ("interactionId" in o && o.interactionId !=
|
|
344
|
-
i = o.largestContentfulPaint?.renderTime || 0, t = Math.max(i - n.startTime, 0), o.largestContentfulPaint && (
|
|
338
|
+
if (!g.navigationId) continue;
|
|
339
|
+
if ("interactionId" in o && o.interactionId != g.navigationInteractionId) continue;
|
|
340
|
+
i = o.largestContentfulPaint?.renderTime || 0, t = Math.max(i - n.startTime, 0), o.largestContentfulPaint && (v.h(o.largestContentfulPaint), e = [o.largestContentfulPaint]);
|
|
345
341
|
}
|
|
346
|
-
i < h.firstHiddenTime && (
|
|
342
|
+
i < h.firstHiddenTime && (g.value = t, g.entries = e, f());
|
|
347
343
|
}
|
|
348
344
|
},
|
|
349
345
|
_ = ["largest-contentful-paint"];
|
|
350
346
|
c && _.push("interaction-contentful-paint", "soft-navigation");
|
|
351
|
-
const E =
|
|
347
|
+
const E = m(_, y);
|
|
352
348
|
if (E) {
|
|
353
|
-
f =
|
|
354
|
-
const
|
|
349
|
+
f = i(t, g, O, s.reportAllChanges);
|
|
350
|
+
const a = ["keydown", "click", "visibilitychange"],
|
|
355
351
|
h = t => {
|
|
356
|
-
if (t.isTrusted && !
|
|
357
|
-
const t =
|
|
352
|
+
if (t.isTrusted && !r) {
|
|
353
|
+
const t = g.id;
|
|
358
354
|
q(() => {
|
|
359
|
-
if (!
|
|
355
|
+
if (!r) {
|
|
360
356
|
if (!c) {
|
|
361
357
|
E.disconnect();
|
|
362
|
-
for (const t of
|
|
358
|
+
for (const t of a) removeEventListener(t, h, {
|
|
363
359
|
capture: true
|
|
364
360
|
});
|
|
365
361
|
}
|
|
366
|
-
t ===
|
|
362
|
+
t === g.id && (r = true, f(true));
|
|
367
363
|
}
|
|
368
364
|
});
|
|
369
365
|
}
|
|
370
366
|
};
|
|
371
|
-
for (const t of
|
|
367
|
+
for (const t of a) addEventListener(t, h, {
|
|
372
368
|
capture: true
|
|
373
369
|
});
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
370
|
+
e(e => {
|
|
371
|
+
p("back-forward-cache", g.navigationId, g.navigationInteractionId, g.navigationURL, n()), f = i(t, g, O, s.reportAllChanges), o(() => {
|
|
372
|
+
g.value = performance.now() - e.timeStamp, r = true, f(true);
|
|
377
373
|
});
|
|
378
374
|
});
|
|
379
375
|
}
|
|
380
376
|
});
|
|
381
|
-
},
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
377
|
+
},
|
|
378
|
+
W = [800, 1800],
|
|
379
|
+
$ = t => {
|
|
380
|
+
document.prerendering ? _(() => $(t)) : "complete" !== document.readyState ? addEventListener("load", () => $(t), true) : setTimeout(t);
|
|
381
|
+
},
|
|
382
|
+
D = (t, o = {}) => {
|
|
383
|
+
const r = p(o);
|
|
384
|
+
let c = l("TTFB"),
|
|
385
|
+
f = i(t, c, W, o.reportAllChanges);
|
|
386
|
+
$(() => {
|
|
387
|
+
const h = s();
|
|
387
388
|
if (h) {
|
|
388
|
-
const
|
|
389
|
-
if (c.value = Math.max(
|
|
390
|
-
c =
|
|
391
|
-
}),
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
389
|
+
const s = h.responseStart;
|
|
390
|
+
if (c.value = Math.max(s - a(), 0), c.entries = [h], f(true), e(() => {
|
|
391
|
+
c = l("TTFB", 0, "back-forward-cache", c.navigationId, c.navigationInteractionId, c.navigationURL, n()), f = i(t, c, W, o.reportAllChanges), f(true);
|
|
392
|
+
}), r) {
|
|
393
|
+
m(["soft-navigation"], n => {
|
|
394
|
+
n.forEach(n => {
|
|
395
|
+
n.navigationId && (c = l("TTFB", 0, "soft-navigation", n.navigationId, n.interactionId, n.name, n.startTime), c.entries = [n], f = i(t, c, W, o.reportAllChanges), f(true));
|
|
395
396
|
});
|
|
396
|
-
},
|
|
397
|
+
}, o);
|
|
397
398
|
}
|
|
398
399
|
}
|
|
399
400
|
});
|
|
400
|
-
}
|
|
401
|
-
})({});
|
|
401
|
+
};
|
|
402
402
|
|
|
403
|
+
const METRICS = {
|
|
404
|
+
CLS: P,
|
|
405
|
+
INP: x,
|
|
406
|
+
LCP: U,
|
|
407
|
+
TTFB: D
|
|
408
|
+
};
|
|
403
409
|
function addCWVTracking({
|
|
404
410
|
sampleRUM,
|
|
405
411
|
sourceSelector,
|
|
@@ -412,45 +418,37 @@ function addCWVTracking({
|
|
|
412
418
|
if (document.querySelector(`script[src="${cwvScript}"]`)) {
|
|
413
419
|
return;
|
|
414
420
|
}
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
const storeCWV = measurement => {
|
|
419
|
-
const data = {
|
|
420
|
-
cwv: {}
|
|
421
|
-
};
|
|
422
|
-
data.cwv[measurement.name] = measurement.value;
|
|
423
|
-
if (measurement.name === 'LCP' && measurement.entries.length > 0) {
|
|
424
|
-
const {
|
|
425
|
-
element
|
|
426
|
-
} = measurement.entries.pop();
|
|
427
|
-
data.target = targetSelector(element);
|
|
428
|
-
data.source = sourceSelector(element) || element && element.outerHTML.slice(0, 30);
|
|
429
|
-
}
|
|
430
|
-
if (measurement.name === 'CLS' && measurement.entries.length > 0) {
|
|
431
|
-
const largest = measurement.entries.reduce((a, b) => b.value > (a ? a.value : 0) ? b : a, undefined);
|
|
432
|
-
const node = largest && largest.sources && largest.sources.map(s => s.node).find(n => n && n.nodeType === 1);
|
|
433
|
-
if (node) {
|
|
434
|
-
data.source = sourceSelector(node) || node.outerHTML.slice(0, 30);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
sampleRUM('cwv', data);
|
|
421
|
+
const storeCWV = measurement => {
|
|
422
|
+
const data = {
|
|
423
|
+
cwv: {}
|
|
438
424
|
};
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
const
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
425
|
+
data.cwv[measurement.name] = measurement.value;
|
|
426
|
+
if (measurement.name === 'LCP' && measurement.entries.length > 0) {
|
|
427
|
+
const {
|
|
428
|
+
element
|
|
429
|
+
} = measurement.entries.pop();
|
|
430
|
+
data.target = targetSelector(element);
|
|
431
|
+
data.source = sourceSelector(element) || element && element.outerHTML.slice(0, 30);
|
|
432
|
+
}
|
|
433
|
+
if (measurement.name === 'CLS' && measurement.entries.length > 0) {
|
|
434
|
+
const largest = measurement.entries.reduce((a, b) => b.value > (a ? a.value : 0) ? b : a, undefined);
|
|
435
|
+
const node = largest && largest.sources && largest.sources.map(s => s.node).find(n => n && n.nodeType === 1);
|
|
436
|
+
if (node) {
|
|
437
|
+
data.source = sourceSelector(node) || node.outerHTML.slice(0, 30);
|
|
450
438
|
}
|
|
451
|
-
}
|
|
439
|
+
}
|
|
440
|
+
sampleRUM('cwv', data);
|
|
452
441
|
};
|
|
453
|
-
|
|
442
|
+
const isEager = metric => ['CLS', 'LCP'].includes(metric);
|
|
443
|
+
['INP', 'TTFB', 'CLS', 'LCP'].forEach(metric => {
|
|
444
|
+
let opts = {};
|
|
445
|
+
fflags.enabled('eagercwv', () => {
|
|
446
|
+
opts = {
|
|
447
|
+
reportAllChanges: isEager(metric)
|
|
448
|
+
};
|
|
449
|
+
});
|
|
450
|
+
METRICS[metric](storeCWV, opts);
|
|
451
|
+
});
|
|
454
452
|
} catch (error) {}
|
|
455
453
|
}, 2000);
|
|
456
454
|
}
|