@sentienguard/apm 1.0.23 → 1.0.24
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/package.json +1 -1
- package/src/browser/vitals.js +5 -4
package/package.json
CHANGED
package/src/browser/vitals.js
CHANGED
|
@@ -24,14 +24,14 @@ let observers = [];
|
|
|
24
24
|
* Safely create a PerformanceObserver for a given entry type.
|
|
25
25
|
* Returns null if the browser doesn't support the entry type.
|
|
26
26
|
*/
|
|
27
|
-
function createObserver(type, callback) {
|
|
27
|
+
function createObserver(type, callback, observeOptions = {}) {
|
|
28
28
|
try {
|
|
29
29
|
// Check if the entry type is supported
|
|
30
30
|
if (typeof PerformanceObserver === 'undefined') return null;
|
|
31
31
|
if (!PerformanceObserver.supportedEntryTypes?.includes(type)) return null;
|
|
32
32
|
|
|
33
33
|
const observer = new PerformanceObserver(callback);
|
|
34
|
-
observer.observe({ type, buffered: true });
|
|
34
|
+
observer.observe({ type, buffered: true, ...observeOptions });
|
|
35
35
|
observers.push(observer);
|
|
36
36
|
return observer;
|
|
37
37
|
} catch {
|
|
@@ -81,10 +81,10 @@ function captureFID() {
|
|
|
81
81
|
function captureINP() {
|
|
82
82
|
const interactions = [];
|
|
83
83
|
|
|
84
|
+
// durationThreshold defaults to 104ms in Chrome — misses fast clicks (FID can be ~13ms).
|
|
84
85
|
createObserver('event', (list) => {
|
|
85
86
|
for (const entry of list.getEntries()) {
|
|
86
87
|
// Only count discrete interactions (click, keypress, etc.)
|
|
87
|
-
// Ignore events with 0 duration (non-interactive)
|
|
88
88
|
if (entry.duration > 0 && entry.interactionId) {
|
|
89
89
|
interactions.push(entry.duration);
|
|
90
90
|
|
|
@@ -96,9 +96,10 @@ function captureINP() {
|
|
|
96
96
|
const inpValue = sorted[p98Index] || sorted[0];
|
|
97
97
|
|
|
98
98
|
getAggregator().recordWebVital('inp', Math.round(inpValue));
|
|
99
|
+
debug(`INP: ${inpValue.toFixed(1)}ms`);
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
|
-
});
|
|
102
|
+
}, { durationThreshold: 0 });
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
/**
|