-
Notifications
You must be signed in to change notification settings - Fork 420
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
Fix 228: Change onINP to also use FID duration
when under durationTheshold
#231
Conversation
@@ -30,19 +30,21 @@ interface PerformanceEntriesHandler { | |||
* try/catch to avoid errors in unsupporting browsers. | |||
*/ | |||
export const observe = ( | |||
type: string, | |||
types: string[], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered making this string || string[]
and adjusting this implementation to support either option... decided it was better to make a single choice but totally understand alterantive.
po.observe(Object.assign({ | ||
type, | ||
buffered: true, | ||
}, opts || {}) as PerformanceObserverInit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, the same options are passed for all registered types. This is fine for this specific case.
But in general we may want to have [string, PerformanceObserverInit][]
(aka array of tuple) instead
@@ -116,7 +116,7 @@ export const onINP = (onReport: ReportCallback, opts?: ReportOpts) => { | |||
|
|||
const handleEntries = (entries: Metric['entries']) => { | |||
(entries as PerformanceEventTiming[]).forEach((entry) => { | |||
if (entry.interactionId) { | |||
if (entry.entryType == 'first-input' || entry.interactionId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only needed until first-input
gets a proper interactionID.
For now, this leads to the "10 worst" list being 1 larger. But since web-vitals.js doesn't use that to count number of interactions, it doesn't really matter. The only time it matters is if the first-input
duration becomes the 10th largest and ends up evicting another interaction from the list, and then you also have 500 interactions.
Thanks for filing @mmocny. This PR helped me realize that the change to support #228 wouldn't end up being much extra code. I did have some concerns about this implementation, though, so I filed #232 to compare. One issue I encountered with this PR is that some of the tests fail (specifically the ones that test the high-percentile logic) because they create a long first interaction and then assert that that interaction is not INP after 50 additional interactions. But if we don't dedupe cases where the I also thought it would be easier to do a one-off additional LMKWYT. |
Yes I figured those types of tests would break, but decided it wasn't likely a big deal on real sites (i.e. the difference wouldn't come up in p75 field data). However, if you found a way to dedupe, woot! I'll take a look at that patch. |
This is a PROTOTYPE for adding support for registering multiple observer types with the same PO observer -- specifically to use both
first-input
andevent
timing together, with the same PerformanceObserver / handler.I have not tested this thoroughly, just checking to see how it would look for now and to continue conversation.
Context:
duration
as firstINP
score, for cases when its underdurationThreshold
#228 (comment)