GoogleChrome / web-vitals

Essential metrics for a healthy site.
https://web.dev/vitals
Apache License 2.0
7.49k stars 410 forks source link

INP retuning same data each interaction #382

Closed decafcoffee-yu closed 11 months ago

decafcoffee-yu commented 11 months ago
var e = document.createElement("script");
        e.src = "https://unpkg.com/web-vitals@3/dist/web-vitals.iife.js";
        e.onload = function() {
            webVitals.getCLS(sendToGoogleAnalytics);
            webVitals.getFID(sendToGoogleAnalytics);
            webVitals.getLCP(sendToGoogleAnalytics);
            webVitals.getFCP(sendToGoogleAnalytics);
            webVitals.getTTFB(sendToGoogleAnalytics);

            document.addEventListener('click', function(event) {
                // Call wasFIDBeforeDCL if defined
                if (typeof wasFIDBeforeDCL === 'function') {
                    wasFIDBeforeDCL(event);
                }

                webVitals.getINP(function(info) {
                    console.log("INP: ", info);
                }, {reportAllChanges: true});
            });
        };
        document.head.appendChild(e);

Upon each click, the returned INP data remains the same. Does anyone have any suggestions on how to address this? Additionally, when I access it in desktop mode, the target is null, but not in mobile mode.

image

image