background

Record front-end performance data, intention rate, touch rate, attrition rate and other business-related data.Copy the code

To prepare

The method for obtaining each field is as follows

function getPerformanceData() { 
   const e = window.performance.timing; 
   const p = e.responseEnd - e.fetchStart; 
   const params = { 
        general: e.domComplete - e.navigationStart, 
        redirect: e.fetchStart - e.navigationStart,
        dns: e.domainLookupEnd - e.domainLookupStart,
        connect_tcp: e.domainLookupEnd - e.domainLookupStart,
        request: e.responseStart - e.requestStart,
        response: e.responseEnd - e.responseStart,
        assets: e.domComplete - e.responseEnd,
        pathname: location.pathname, 
        tti: e.domInteractive - e.fetchStart, 
        ready: e.domContentLoadedEventEnd - e.fetchStart, 
        load: e.loadEventStart - e.fetchStart 
    } 
    p >= 0 && p < 36e5 && (params.fpt = p); 
    return params 
}
Copy the code