From 8036e6ea2086d20a579b655a40df82dace7ad7b4 Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Mon, 18 Nov 2024 19:20:55 +0000 Subject: [PATCH 1/2] Clarify what happens for interactions less than 40ms --- README.md | 2 +- src/attribution/onINP.ts | 12 +++++++----- src/onINP.ts | 12 +++++++----- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 55c033c1..72f63834 100644 --- a/README.md +++ b/README.md @@ -693,7 +693,7 @@ function onINP(callback: (metric: INPMetric) => void, opts?: ReportOpts): void; Calculates the [INP](https://web.dev/articles/inp) value for the current page and calls the `callback` function once the value is ready, along with the `event` performance entries reported for that interaction. The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/docs/Web/API/DOMHighResTimeStamp). -A custom `durationThreshold` [configuration option](#reportopts) can optionally be passed to control what `event-timing` entries are considered for INP reporting. The default threshold is `40`, which means INP scores of less than 40 are reported as 0. Note that this will not affect your 75th percentile INP value unless that value is also less than 40 (well below the recommended [good](https://web.dev/articles/inp#what_is_a_good_inp_score) threshold). +A custom `durationThreshold` [configuration option](#reportopts) can optionally be passed to control what `event-timing` entries are considered for INP reporting. The default threshold is `40`, which means INP scores of less than 40 will not be reported. To avoid reporting no interactions in these cases, the library will fall back to the input delay of the first interaction. Note that this will not affect your 75th percentile INP value unless that value is also less than 40 (well below the recommended [good](https://web.dev/articles/inp#what_is_a_good_inp_score) threshold). If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called as soon as the value is initially determined as well as any time the value changes throughout the page lifespan (Note [not necessarily for every interaction](#report-the-value-on-every-change)). diff --git a/src/attribution/onINP.ts b/src/attribution/onINP.ts index ee1a289a..1a77e6e6 100644 --- a/src/attribution/onINP.ts +++ b/src/attribution/onINP.ts @@ -301,11 +301,13 @@ const attributeINP = (metric: INPMetric): INPMetricWithAttribution => { * the `event` performance entries reported for that interaction. The reported * value is a `DOMHighResTimeStamp`. * - * A custom `durationThreshold` configuration option can optionally be passed to - * control what `event-timing` entries are considered for INP reporting. The - * default threshold is `40`, which means INP scores of less than 40 are - * reported as 0. Note that this will not affect your 75th percentile INP value - * unless that value is also less than 40 (well below the recommended + * A custom `durationThreshold` configuration option can optionally be passed + * to control what `event-timing` entries are considered for INP reporting. The + * default threshold is `40`, which means INP scores of less than 40 will not + * be reported. To avoid reporting no interactions in these cases, the library + * will fall back to the input delay of the first interaction. Note that this + * will not affect your 75th percentile INP value unless that value is also + * less than 40 (well below the recommended * [good](https://web.dev/articles/inp#what_is_a_good_inp_score) threshold). * * If the `reportAllChanges` configuration option is set to `true`, the diff --git a/src/onINP.ts b/src/onINP.ts index ad5b530e..923a85d1 100644 --- a/src/onINP.ts +++ b/src/onINP.ts @@ -39,11 +39,13 @@ export const INPThresholds: MetricRatingThresholds = [200, 500]; * the `event` performance entries reported for that interaction. The reported * value is a `DOMHighResTimeStamp`. * - * A custom `durationThreshold` configuration option can optionally be passed to - * control what `event-timing` entries are considered for INP reporting. The - * default threshold is `40`, which means INP scores of less than 40 are - * reported as 0. Note that this will not affect your 75th percentile INP value - * unless that value is also less than 40 (well below the recommended + * A custom `durationThreshold` configuration option can optionally be passed + * to control what `event-timing` entries are considered for INP reporting. The + * default threshold is `40`, which means INP scores of less than 40 will not + * be reported. To avoid reporting no interactions in these cases, the library + * will fall back to the input delay of the first interaction. Note that this + * will not affect your 75th percentile INP value unless that value is also + * less than 40 (well below the recommended * [good](https://web.dev/articles/inp#what_is_a_good_inp_score) threshold). * * If the `reportAllChanges` configuration option is set to `true`, the From 20901baf992e1678fd4121a0b9990c9f3666613f Mon Sep 17 00:00:00 2001 From: Barry Pollard Date: Tue, 26 Nov 2024 16:39:42 +0000 Subject: [PATCH 2/2] Review feedback --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72f63834..5a40a5a7 100644 --- a/README.md +++ b/README.md @@ -693,7 +693,7 @@ function onINP(callback: (metric: INPMetric) => void, opts?: ReportOpts): void; Calculates the [INP](https://web.dev/articles/inp) value for the current page and calls the `callback` function once the value is ready, along with the `event` performance entries reported for that interaction. The reported value is a [`DOMHighResTimeStamp`](https://developer.mozilla.org/docs/Web/API/DOMHighResTimeStamp). -A custom `durationThreshold` [configuration option](#reportopts) can optionally be passed to control what `event-timing` entries are considered for INP reporting. The default threshold is `40`, which means INP scores of less than 40 will not be reported. To avoid reporting no interactions in these cases, the library will fall back to the input delay of the first interaction. Note that this will not affect your 75th percentile INP value unless that value is also less than 40 (well below the recommended [good](https://web.dev/articles/inp#what_is_a_good_inp_score) threshold). +A custom `durationThreshold` [configuration option](#reportopts) can optionally be passed to control the minimum duration filter for `event-timing`. Events which are faster than this threshold are not reported. Note that the `first-input` entry is always observed, regardless of duration, to ensure you always have some INP score. The default threshold, after the library is initialized, is `40` milliseconds (the `event-timing` default of `104` milliseconds applies to all events emitted before the library is initialised). This default threshold of `40` is chosen to strike a balance between usefulness and performance. Running this callback for any interaction that spans just one or two frames is likely not worth the insight that could be gained. If the `reportAllChanges` [configuration option](#reportopts) is set to `true`, the `callback` function will be called as soon as the value is initially determined as well as any time the value changes throughout the page lifespan (Note [not necessarily for every interaction](#report-the-value-on-every-change)).