diff --git a/docs/documentation/sitespeed.io/sustainable/index.md b/docs/documentation/sitespeed.io/sustainable/index.md index 1dfcd85875..6f01341992 100644 --- a/docs/documentation/sitespeed.io/sustainable/index.md +++ b/docs/documentation/sitespeed.io/sustainable/index.md @@ -81,6 +81,16 @@ By default the hosting data (knowing if a host is green) is collected from a loc You can also disable the hosting match (all hosts will be treated as grey hosting) with `--sustainable.disableHosting`. +### Country-based electricity data + +You can optionally specify a country code to calculate carbon emissions using a specific electricity grid mix (via electricitymaps): +example:- +```bash +sitespeed.io https://example.com \ + --plugins.add sustainable \ + --sustainable.countryCode IN +``` + ## How it works ### Short version @@ -110,4 +120,4 @@ Larger data centres have historically been cited close to sources of cheap power For the rest of the internet, we use the [International Energy Agency's](https://hyp.is/MPRiUlTMEeq13bM-WjChjQ/www.iea.org/reports/global-energy-co2-status-report-2019/emissions) figure from of 475g of CO2 per kilowatt hour for for 2018, as an average across the globe. -Where we know power is generated using renewables we use the figure from the UK's regulator Ofgem, for renewables including solar, wind and hydroelectricity, of 33.4 grammes of CO2 per kilowatt hour. To tell how a site is powered, we look up the domain with the Green Web Foundation's - either via the their API, or when available, using their publicly available [url2green](https://www.thegreenwebfoundation.org/green-web-datasets/) dataset. +Where we know power is generated using renewables we use the figure from the UK's regulator Ofgem, for renewables including solar, wind and hydroelectricity, of 33.4 grammes of CO2 per kilowatt hour. To tell how a site is powered, we look up the domain with the Green Web Foundation's - either via the their API, or when available, using their publicly available [url2green](https://www.thegreenwebfoundation.org/green-web-datasets/) dataset. \ No newline at end of file diff --git a/lib/plugins/sustainable/index.js b/lib/plugins/sustainable/index.js index c8e8ae2b91..177f34f2a5 100644 --- a/lib/plugins/sustainable/index.js +++ b/lib/plugins/sustainable/index.js @@ -64,6 +64,16 @@ export default class SustainablePlugin extends SitespeedioPlugin { super({ name: 'sustainable', options, context, queue }); } + static getCliOptions() { + return { + 'sustainable.countryCode': { + describe: + 'ISO driven country code used to calculate country specific carbon intensity via electricity-maps', + type: 'string' + } + }; + } + async open(context, options) { this.storageManager = context.storageManager; this.options = options; @@ -162,6 +172,9 @@ export default class SustainablePlugin extends SitespeedioPlugin { if (this.sustainableOptions.model === 'swd') { configuration.version = this.sustainableOptions.modelVersion; } + if (this.sustainableOptions.countryCode) { + configuration.countryCode = this.sustainableOptions.countryCode; + } const CO2 = new co2(configuration); const co2PerDomain = perDomain(message.data, hostingGreenCheck, CO2); const baseDomain = message.data.baseDomain;