1 | import type { Metric } from './base.js';
|
2 | /**
|
3 | * A TTFB-specific version of the Metric object.
|
4 | */
|
5 | export interface TTFBMetric extends Metric {
|
6 | name: 'TTFB';
|
7 | entries: PerformanceNavigationTiming[];
|
8 | }
|
9 | /**
|
10 | * An object containing potentially-helpful debugging information that
|
11 | * can be sent along with the TTFB value for the current page visit in order
|
12 | * to help identify issues happening to real-users in the field.
|
13 | *
|
14 | * NOTE: these values are primarily useful for page loads not handled via
|
15 | * service worker, as browsers differ in what they report when service worker
|
16 | * is involved, see: https://github.com/w3c/navigation-timing/issues/199
|
17 | */
|
18 | export interface TTFBAttribution {
|
19 | /**
|
20 | * The total time from when the user initiates loading the page to when the
|
21 | * page starts to handle the request. Large values here are typically due
|
22 | * to HTTP redirects, though other browser processing contributes to this
|
23 | * duration as well (so even without redirect it's generally not zero).
|
24 | */
|
25 | waitingDuration: number;
|
26 | /**
|
27 | * The total time spent checking the HTTP cache for a match. For navigations
|
28 | * handled via service worker, this duration usually includes service worker
|
29 | * start-up time as well as time processing `fetch` event listeners, with
|
30 | * some exceptions, see: https://github.com/w3c/navigation-timing/issues/199
|
31 | */
|
32 | cacheDuration: number;
|
33 | /**
|
34 | * The total time to resolve the DNS for the requested domain.
|
35 | */
|
36 | dnsDuration: number;
|
37 | /**
|
38 | * The total time to create the connection to the requested domain.
|
39 | */
|
40 | connectionDuration: number;
|
41 | /**
|
42 | * The total time from when the request was sent until the first byte of the
|
43 | * response was received. This includes network time as well as server
|
44 | * processing time.
|
45 | */
|
46 | requestDuration: number;
|
47 | /**
|
48 | * The `navigation` entry of the current page, which is useful for diagnosing
|
49 | * general page load issues. This can be used to access `serverTiming` for
|
50 | * example: navigationEntry?.serverTiming
|
51 | */
|
52 | navigationEntry?: PerformanceNavigationTiming;
|
53 | }
|
54 | /**
|
55 | * A TTFB-specific version of the Metric object with attribution.
|
56 | */
|
57 | export interface TTFBMetricWithAttribution extends TTFBMetric {
|
58 | attribution: TTFBAttribution;
|
59 | }
|