thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services
Other
390 stars 49 forks source link

Fix error introduced when implementing in 1byte model 🤦‍♂️ - fixes #32 #57

Closed mrchrisadams closed 2 years ago

mrchrisadams commented 2 years ago

Earlier on, a helpful soul highlighted an error in how I had implemented the 1byte model in #32.

I had missed an extra 0 when typing it, which meant that for network traffic, it's likely that numbers were 10 times higher than they would be if I hadn't introduced it .

Well, at least I'm in good company - it looks like the Shift Project Carbonalyser browser extension also made this error at one point 😅

https://github.com/carbonalyser/Carbonalyser/issues/19

Anyway, this now uses a more sensible notation based on powers of 10, and I've included the source files so we can sanity check these in future.

mrchrisadams commented 2 years ago

hi @soulgalore - I'm tagging you in this PR, as I know sitespeed consumes this module, and I think it's likely to have an impact on metrics.

Updating to this module won't break APIs, which is why I've added it to the 0.8 milestone, but it will make the metrics change quite significantly.

soulgalore commented 2 years ago

Thanks @mrchrisadams ! I plan to do a major release of sitespeed.io sometimes in December so the fix will work fine to go in that release.