nucliweb / webperf-snippets

⚡️ 💾 Web Performance Snippets
https://webperf-snippets.nucliweb.net
MIT License
1.33k stars 72 forks source link

Log wrong interactions. #41

Open szczepanb opened 11 months ago

szczepanb commented 11 months ago

https://github.com/nucliweb/webperf-snippets/blob/080be73765c85975fb0ba1c063d0f94a19e506fd/pages/Interaction/Interactions.mdx#L26

Please check the snippet for interaction:

I see that this snippet logs interaction only with interactionId = 0, and it seems to be wrong, according to documentation and example here: https://web.dev/articles/diagnose-slow-interactions-in-the-lab?hl=pl#use_a_javascript_snippet

We should log with interactionId > 0.

nucliweb commented 11 months ago

This line:

.filter((entry) => !entry.interactionId)) { 

It's the same that this line:

if (!entry.interactionId) continue;
szczepanb commented 11 months ago

Yes,

But You filter interactions with interactionID = 0. It gets only interaction without ID. The documentation says that only interactions with ID are made by user

if (!entry.interactionId) continue;

Here, We are in for loop, when interactionID is 0 they continue and don't log this interaction.

When I use snippets from web.dev and Your at the same time, I see logs in console only from snippet from web.dev.