thegreenwebfoundation / co2.js

An npm module for accessing the green web API, and estimating the carbon emissions from using digital services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add the ability to pass custom % of returning visitors with perVisit

JayBox325 opened this issue · comments

Not all sites have the same returning visit percentages and with Analytics, a user may be able to provide their exact % of returning visitors to create a more accurate estimate for their platform.

Thanks @JayBox325. You are referring to the figures used in the Sustainable Web Design model, correct? This is similar to what's been raised in #109, so if it's okay I'll close this issue & we can track the discussion in #109.

Right now, you can modify the source code & rebuild the library if you need to change values of returning visitors for a particular site. That still leaves it as a constant for the entire site, though, rather than being different at the page level.

I've flagged this as something we'd like to make possible in v0.12, but we currently don't have a fixed time frame for that. If this is something you need soon then we'd be happy for you to create a PR so we can work this into the library.

Hi, thanks for getting back to me. Yeah, so the SWD model uses 25% returning visitors to calculate it's estimate. I'm building a data size transfer auditor to learn how to use CO2js and I'm ending with this when I run my audit:

const perVisit = swd.perVisit((auditConfig.size * 1000), auditConfig.intensity.value)

So the auditConfig is the users' selection on the form where they add a size in KB then choose a country for it's intensity. Then I'm passing these to the perVisit function generate a SWD estimate with these values. However, I might try and look at how you can pass a third variable that is the returning users %.

I think this is covered in that other topic, so please do close this one if you'd like to focus on this discussion there.

@JayBox325 have a look in the PR above. I've made a first pass at implementing an API for this, feedback welcome.

This is now possible using new functions perVisitTrace and perByteTrace in #126.