Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

埋点监控指标及收集方式 #202

Open
funnycoderstar opened this issue May 17, 2022 · 0 comments
Open

埋点监控指标及收集方式 #202

funnycoderstar opened this issue May 17, 2022 · 0 comments

Comments

@funnycoderstar
Copy link
Owner

funnycoderstar commented May 17, 2022

指标收集

异常

  • JS 语法错误、代码运行异常 ✅
  • 静态资源加载异常 ✅
  • promise 异常 ✅
  • Http 请求异常 ✅
    • ajax ✅
    • fetch ✅
  • Iframe 异常
  • 跨域 Script error ✅
  • 崩溃和卡顿

性能

  • 白屏时间 ✅
  • 首屏时间 ✅
  • TTFB(Time to First Byte) ✅
  • FP(First Paint) ✅
  • FCP(First Contentful Paint) ✅
  • FMP ✅
  • LCP(Largest Contentful Paint) ✅
  • FID(First Input Delay) ✅
  • CLS(Cumulative Layout Shift)
  • 卡顿
  • TBT(Total Blocking Time)

业务

  • PV
  • UV

性能

核心指标

https://web.dev/learn-core-web-vitals/

let cls = 0;
new PerformanceObserver((entryList) => {
  for (const entry of entryList.getEntries()) {
    if (!entry.hadRecentInput) {
      cls += entry.value;
      console.log('Current CLS value:', cls, entry);
    }
  }
}).observe({type: 'layout-shift', buffered: true});

重要指标

https://web.dev/metrics/

长任务(longtask)

https://web.dev/custom-metrics/#long-tasks-api

// Catch errors since some browsers throw when using the new `type` option.
// https://bugs.webkit.org/show_bug.cgi?id=209216
try {
  // Create the performance observer.
  const po = new PerformanceObserver((list) => {
    for (const entry of list.getEntries()) {
      // Log the entry and all associated details.
      console.log(entry.toJSON());
    }
  });
  // Start listening for `longtask` entries to be dispatched.
  po.observe({type: 'longtask', buffered: true});
} catch (e) {
  // Do nothing if the browser doesn't support this API.
}

TTI

可以使用 tti-polyfill

TBT

SI

使用 speedline

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant