-
Notifications
You must be signed in to change notification settings - Fork 891
Added custom application information to the User-Agent headers #294
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
Conversation
0533ceb to
c031fe3
Compare
| ); | ||
| if ($appInfo !== null) { | ||
| $uaString .= ' ' . $appInfo; | ||
| $ua['application'] = $appInfo; |
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.
Is it possible to do nested values in here - i.e., leave the 'object' as an object? It might be easier to grok [0] for analytics etc. if it didn't require parsing the string.
[0] This might actually be the first time I've typed grok on the internet.
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.
Excellent point. It definitely should be possible, I'll give it a try!
c031fe3 to
9c01622
Compare
| 'User-Agent' => 'Stripe/v1 PhpBindings/' . Stripe::VERSION, | ||
| 'Authorization' => 'Bearer ' . $myApiKey, | ||
| ); | ||
| $defaultHeaders = $this->_defaultHeaders($myApiKey); |
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.
Nice. Way cleaner here now.
|
@olivierbellone Awesome! Thanks again for picking this up and running with it; it should be hugely helpful in tracking down future compatibility problems. LGTM. |
|
Released as 3.22.0. |
|
Hey guys, could we please get a port of this for the older 1.x libraries? If a 1.19.0 is under consideration, could you please throw in 3D Secure as well based on snez/stripe-php@15df5eb Thanks! |
|
@snez Sorry for the answer that's sure to be disappointing, but 1.x is not maintained and we don't backport changes to it. Is there anything that we can do to help you upgrade? Being on such an ancient release is going to cause other trouble in the long run like not getting other more minor bug fixes, etc. |
r? @brandur
cc @stripe/api-libraries
This PR adds a
setAppInfomethod to the staticStripeclass. The method takes three parameters:$appName(mandatory): the application's name$appVersion(optional): the application's version$appUrl(optional): the URL for the application's siteThe method is meant to be used by plugin developers. After the method has been called, the headers sent with every request will be modified like this:
User-Agentwill have the additional information appended at the end, e.g.Stripe/v1 PhpBindings/3.21.0would becomeStripe/v1 PhpBindings/3.21.0 MyAwesomeApp/1.2.34 (https://myawesomeapp.example)X-Stripe-Client-User-Agentwill have an additionalapplicationkey with the same string that's appended toUser-Agent, e.g.MyAwesomeApp/1.2.34 (https://myawesomeapp.example)For more context about the motivation behind this PR, see the DX-120 issue internally.