-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Send better user-agent values (and got config changes) #7309
Conversation
- add userAgentBase setting - send short SHA in user agent on heroku - set a version (tag or short SHA) in Dockefile and use it to report server version in UA for docker users
|
|
||
const fetchLimitBytes = bytes(publicConfig.fetchLimit) | ||
|
||
function getUserAgent(userAgentBase = publicConfig.userAgentBase) { |
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.
We will need to set USER_AGENT_BASE=Shields.io
in prod before we deploy
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.
I'm good with the changes, both code and strategic, and approving accordingly so you can move forward if you'd like. One minor inline item that could be ignored or handled in a follow up, but happy to re-:+1: if you decide to make any other changes
I've set the env var, deployed and confirmed it is working in production by using the endpoint badge to make a request to an endpoint where I can see the header. |
This was in the back of my mind as well, though I actually think this change is perhaps the best way forward to surface any potential issues. I don't think we can (or should) perpetually pin a user agent, and it feels like changing it as we've done here may be the only way for us to truly discover any such cases, which will then allow us to figure out next steps |
Refs #4655
Closes #6268
There is not loads of changed code in this PR, but there's a couple of things going on in here which are kind of linked and kind of not.
got.js
exports afetchFactory
which takesfetchLimitBytes
and returns a function. That allows us to injectfetchLimitBytes
from config in the server but then sometimes it is useful to construct it outside the context of the server object.I did have a look at completely decoupling config parsing from the server, but what I realised was that because we can set some of the args at runtime (see
shields/server.js
Lines 28 to 33 in 95a439a
The approach I settled on was making a subset of config available outside the context of the server object, which seemed like the right tradeoff.
The other bit of this is adding a feature. Basically before this PR, every instance of shields (our own, self-hosted, dev copies) sends the exact same user agent value (
Shields.io/2003a
, for..reasons).As of this PR:
shields (self-hosted)/dev
HEROKU_SLUG_COMMIT
(we have this set in production) orDOCKER_SHIELDS_VERSION
(this PR adds it to the image) are set, that will be used for the second part of the UA string (after the slash)/dev
This should mean in most cases the userAgent string will be reasonably meaningful.