-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds user agent header for requests to Green Web Foundation APIs #184
Adds user agent header for requests to Green Web Foundation APIs #184
Conversation
the version from package.json is used to inject an environment variable when esbuild runs, which the running code can read to create the correct user agent string when making requests. fixes thegreenwebfoundation#181
@fershad let me know if this looks like the right direction. there were a couple of things i wasn't sure of:
|
@sfishel18 thanks for this. I'll go through it in the next week or two with a view to merge it into the v0.14.1 release |
commit 0246400 Author: fershad <[email protected]> Date: Tue Jan 9 16:49:57 2024 +0800 update changelog commit fcd392c Author: fershad <[email protected]> Date: Tue Jan 9 14:29:30 2024 +0800 0.14.1 commit 6555fcf Author: fershad <[email protected]> Date: Tue Jan 9 14:12:01 2024 +0800 build with latest grid intensity figures commit 27e2ed4 Merge: b22bf09 e53da02 Author: fershad <[email protected]> Date: Mon Jan 8 12:14:09 2024 +0800 Use type definitions from DefinitelyTyped. commit e53da02 Author: fershad <[email protected]> Date: Mon Jan 8 12:09:31 2024 +0800 change title commit bf834fe Author: fershad <[email protected]> Date: Mon Jan 8 12:06:51 2024 +0800 add links to npm and DT commit b5d8828 Author: fershad <[email protected]> Date: Mon Jan 8 12:03:02 2024 +0800 add guidance on installing type definitions commit ff6f767 Author: fershad <[email protected]> Date: Mon Jan 8 12:02:46 2024 +0800 remove index.d.ts file commit b22bf09 Author: fershad <[email protected]> Date: Mon Jan 8 11:52:53 2024 +0800 update test constants commit dbd9d7d Merge: 49da1c4 d7eca01 Author: fershad <[email protected]> Date: Mon Jan 8 11:47:56 2024 +0800 Reduce NPM package size commit 49da1c4 Merge: 51b85e2 84384da Author: fershad <[email protected]> Date: Thu Jan 4 16:34:48 2024 +0800 [AUTOMATED] Update average annual grid intensities commit 84384da Author: fershad <[email protected]> Date: Wed Jan 3 10:09:01 2024 +0000 Update average annual grid intensities commit d7eca01 Author: fershad <[email protected]> Date: Mon Jan 1 17:42:28 2024 +0800 commit iife bundle commit f4a6834 Author: fershad <[email protected]> Date: Mon Jan 1 17:09:36 2024 +0800 add file to ignore when packaging for npm
@sfishel18 thanks for this one. I went through it and made some changes:
There's one hurdle for this update though. Right now, the package version gets written to the code when the build is run. However, when we publish to NPM we use the
|
@mrchrisadams this PR is ready for a review when you've got a moment. The changes made add a The output of the For example: import {hosting} from '@tgwf/co2'
hosting.check("google.com", "MyCoolApp").then((result) => {
console.log(result,);
}); This would send a fetch request to the Greencheck API with the Note, that when used in the browser the Happy to walk you through the code if you need. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fershad thanks for tagging me - this looks good, and the comments I had are small quibbles, which while being nice to address, would not stop this being merged in.
Feel free to merge in, but do please take a mo to review the comments about whether we update related issues like the pagexray one, or adding the use of jest mocks instead of just spies.
Thanks @mrchrisadams I've made most of those changes, including reverting the API calls to mocks. Going to let this cool for a couple of days before merging & releasing a new build. @sfishel18 welcome to cast your eye over this as well :) |
Thanks for making those changes @fershad particularly adding the networking mocks (I've been feeling a bit uneasy about nock, as it's a library I'm not very familiar with, and was a bit scared of changing it.) One last thing (and this is likely a response to you saying let's let it cool a couple of days so we can view it in with fresh eyes later) is that we're passing in It might make sense to just name the argument I reckon this probably is worth deciding before we merge in, but I'd leave the final decision with you. WDYT? |
Makes a ton of sense. I've renamed it to |
thanks @fershad! sorry for the delayed reply, just got back from a vacation. all looks good to me. let me know if there's anything in particular still missing here that i could look into. |
@sfishel18 all good mate, added you to the contributors list. Thanks for helping with this change. |
my pleasure! let me know if you have any other good starter tasks top-of-mind for someone new. no worries if not, i can look over the open issues and pick one that speaks to me :) |
the version from package.json is used to inject an environment variable when esbuild runs, which the running code can read to create the correct user agent string when making requests.
fixes #181