Skip to content

Commit

Permalink
feat: handle TTFB from web-vitals without transform (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperOleg39 authored Feb 21, 2023
1 parent 6ad2d60 commit f846326
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 4 additions & 7 deletions src/observe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ import { po } from './performanceObserver';
import { initResourceTiming } from './resourceTiming';

export const initPerformanceObserver = (): void => {
// @ts-ignore
onTTFB(report => {
// Calculate the request time by subtracting from TTFB
// everything that happened prior to the request starting.
// @ts-ignore
report.value = report.value - report.entries[0].requestStart;
// @ts-ignore
logMetric(report);
if (report.value > 0) {
// @ts-ignore
logMetric(report);
}
}, config.reportOptions.ttfb);
// @ts-ignore
onCLS(report => logMetric(report), config.reportOptions.cls);
Expand Down

0 comments on commit f846326

Please sign in to comment.