1 | /*
|
2 | * Copyright 2022 Google LLC
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * https://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 |
|
17 | import {LoadState, Metric, ReportCallback} from './base.js';
|
18 |
|
19 | /**
|
20 | * An INP-specific version of the Metric object.
|
21 | */
|
22 | export interface INPMetric extends Metric {
|
23 | name: 'INP';
|
24 | entries: PerformanceEventTiming[];
|
25 | }
|
26 |
|
27 | /**
|
28 | * An object containing potentially-helpful debugging information that
|
29 | * can be sent along with the INP value for the current page visit in order
|
30 | * to help identify issues happening to real-users in the field.
|
31 | */
|
32 | export interface INPAttribution {
|
33 | /**
|
34 | * A selector identifying the element that the user interacted with for
|
35 | * the event corresponding to INP. This element will be the `target` of the
|
36 | * `event` dispatched.
|
37 | */
|
38 | eventTarget?: string;
|
39 | /**
|
40 | * The time when the user interacted for the event corresponding to INP.
|
41 | * This time will match the `timeStamp` value of the `event` dispatched.
|
42 | */
|
43 | eventTime?: number;
|
44 | /**
|
45 | * The `type` of the `event` dispatched corresponding to INP.
|
46 | */
|
47 | eventType?: string;
|
48 | /**
|
49 | * The `PerformanceEventTiming` entry corresponding to INP.
|
50 | */
|
51 | eventEntry?: PerformanceEventTiming;
|
52 | /**
|
53 | * The loading state of the document at the time when the even corresponding
|
54 | * to INP occurred (see `LoadState` for details). If the interaction occurred
|
55 | * while the document was loading and executing script (e.g. usually in the
|
56 | * `dom-interactive` phase) it can result in long delays.
|
57 | */
|
58 | loadState?: LoadState;
|
59 | }
|
60 |
|
61 | /**
|
62 | * An INP-specific version of the Metric object with attribution.
|
63 | */
|
64 | export interface INPMetricWithAttribution extends INPMetric {
|
65 | attribution: INPAttribution;
|
66 | }
|
67 |
|
68 | /**
|
69 | * An INP-specific version of the ReportCallback function.
|
70 | */
|
71 | export interface INPReportCallback extends ReportCallback {
|
72 | (metric: INPMetric): void;
|
73 | }
|
74 |
|
75 | /**
|
76 | * An INP-specific version of the ReportCallback function with attribution.
|
77 | */
|
78 | export interface INPReportCallbackWithAttribution extends INPReportCallback {
|
79 | (metric: INPMetricWithAttribution): void;
|
80 | }
|