GoogleChrome / web-vitals-extension

A Chrome extension to measure essential metrics for a healthy site
https://chrome.google.com/webstore/detail/web-vitals/ahfhijdlegdabablpippeagghigmibma?hl=en
Apache License 2.0
2.34k stars 105 forks source link

Bug fix for postMessage change #162

Closed tunetheweb closed 7 months ago

tunetheweb commented 1 year ago

Bug fix following on from #161 as started noticing some errors when using console logging as the metric needed for that is not available in the new listener function.

Annoyingly postMessage doesn't get a response, so can no longer get the tabId (which we use as a key to see if the tab was started in background) hence why we needed to set this up as a separate listener. We now set a tabLoadedInBackground variable - and also only set this once rather than for each update as it shouldn't change.

In theory it can be a little racy as depends on the message coming back, but it always was racy anyway, and will be updated on next metric.