web-vitals icon indicating copy to clipboard operation
web-vitals copied to clipboard

Feature Request: Expose getInteractionCount

Open jspurlin opened this issue 6 months ago • 3 comments

performance.interactionCount isn't officially supported or widely available, it'd be great if web-vitals exposed getInteractionCount (and either call initInteractionCountPolyfill at the top of getInteractionCount or expose initInteractionCountPolyfill as well). Doing this would allow a standard way to get interaction counts when trying to compute total interactions vs slow actions for inp.

On a somewhat related note, I see that interactionCountEstimate assumes that the interactionIds increment by 7, does this break down for non-chromium browsers?

jspurlin avatar Jun 11 '25 22:06 jspurlin

In case it helps: performance.interactionCount is part of Interop 2025 for INP and Chromium has an implementation behind a flag that just needs some shepherding to finally launch.

mmocny avatar Jun 12 '25 02:06 mmocny

@mmocny, that's great to hear, but users on older browsers or browsers that don't support performance.interactionCount still won't work...

Is there any opposition to exposing the function? It should be pretty straightforward and in the case where performance.interactionCount is supported it's practically a no-op. Also, doing so would make #629 request moot from my standpoint since it more efficiently solves the problem

jspurlin avatar Jun 16 '25 15:06 jspurlin

Is there any opposition to exposing the function?

I'd rather not expose the function, since it's a short-term issue (that admittedly has lived longer than we thought it would, but has an end in sight now), and a relatively simple-function to replicate if anyone wishes to calculate this. It also depends on the magic number of 7 which, as you say, is implementation specific and not specified.

tunetheweb avatar Jun 16 '25 18:06 tunetheweb

Closing as not planned.

tunetheweb avatar Jul 15 '25 11:07 tunetheweb