function webVitalsSingleReport(entry) { if (window.__wpk && window.__wpk.report) { var name = entry && entry.name || ''; var delta = entry && entry.delta || ''; const categories = { FCP: 101, CLS: 103, FID: 104, LCP: 102, INP: 119 }; window.__wpk.report({ category: categories[name], msg: window.location.host, wl_avgv1: delta, bl1: entry && Object.prototype.toString.call(entry) === "[object Object]" ? JSON.stringify(entry) : '', c1: entry && entry.rating ||'' }); } } window.webVitals.getFCP(webVitalsCb); window.webVitals.getCLS(webVitalsCb); window.webVitals.getFID(webVitalsCb); window.webVitals.getLCP(webVitalsCb); window.webVitals.getINP(webVitalsCb); }; if(document.head) document.head.appendChild(webVitalsScript); function report() { var fsp = null; var csr = null; if (timings.start && timings.render) { // for ssr if (timings.ssr) { fsp = timings.ssr - timings.start; csr = timings.render - timings.ssr; } else { fsp = timings.render - timings.start; } } if (fsp && window.__wpk && window.__wpk.report) { __wpk.report({ category: 105, msg: window.location.host, wl_avgv1: fsp, wl_avgv2: csr || 0, c1: window.__hasSSR__ ? 1 : 0, }); } } document.addEventListener('DOMContentLoaded', function () { if (window.timings) { if (window.timings.render) { report(); } else { setTimeout(function () { report(); }, 3000); } } }) } catch (err) { console.log(err && err.message) } })();