Skip to content
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

Client information headers #31

Merged
merged 5 commits into from
May 8, 2015
Merged

Client information headers #31

merged 5 commits into from
May 8, 2015

Conversation

benschwarz
Copy link
Contributor

I'd like to discuss the idea of adding some client information to our API libraries — these changes would need to be implemented in a all of our official clients, as well as requiring some effort on the devops, and data tracking sides. I'll do my best to explain why this could be such a valuable enhancement.


What I want to do

Add two headers to all of our API clients when they're talking to auth0 APIs. These headers would carry the "platform" of the client, and the "version", so in the case of this Ruby client, it'd have the following two headers:

User-Agent: Ruby/2.2.1 (Rails 4.2.2)
Auth0-Client: Ruby/3.4.1

To break it down a little bit: The client is "ruby" (language/sdk), and the version of ruby that we're using is 2.2.1. The client version corresponds to the semantic version used for this gem (at next bump, it'll be 3.4.1)

In addition, the each client library should allow "overloading" the client, for example, this ruby library might be used in rails applications. For the omniauth library, we could set Auth0::ClientVersion to Ruby/2.2.1 (Rails 4.2.2).

Client side example:

  • User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36
  • As a querystring: ?auth0_client=auth0.js/1.1.1

What it'll give us the ability to do

Support & CSE

I understand I'm speaking for team @eugeniop a little here, but I can foresee that adding client information to an given companies requests (then store them in something like intercom) would make for really useful information when trying to help diagnose client issues, or help us point to relevant documentation.

Developer advocacy

Understanding the volume and capacity of clients that are in use (and also tracking package downloads from rubygems, npm, bower etc) helps the advocacy team understand the effect/results of efforts with vertical conferences and events (Eg, if we speak at a ruby event, do we get a client bump? Do we get sign ups?). Additionally, we can work harder to improve documentation or SDKs for the more popular platforms (or, perhaps the UNpopular ones). In short, data helps us better understand our work.

Statistics

screen shot 2015-05-07 at 12 34 57 pm

(Mocked graph) — We could show API requests by client type, and then also intersect that information by region, or customer details.

Further to this, we could identify customers that are using older versions of clients that require updates, or help them deal with deprecations.

Webtask to store this in Google analytics anyone? (cc @tjanczuk )


Effort required to make it a reality

  • Server side logging needs to be able to log API headers somewhere (Redshift, Librato, or Google Analytics would be an obvious place)
  • Update PHP client
  • Update auth0.js
  • Update iOS Lock
  • Update Android Lock
  • Update Auth0 Xamarin Client
  • Update clients that I missed above

The changes to the Ruby client were conducted in less than an hour, and while this isn't an exact guide for all clients, its a good indication that we should be able to knock through the PRs pretty easily.


Feedback

Clearly, I'm not yet familiar with pitching features at auth0, nor am I aware of the entire way that this stack works. If you've got thoughts, pointers or general hand holding advice, please leave it below in the comments. From here, I can do my best to drive this through to the end.

@woloski
Copy link

woloski commented May 7, 2015

+1000

@woloski
Copy link

woloski commented May 7, 2015

@ntotten had this on the roadmap I think, but the sooner we do it the better

@mgonto
Copy link
Contributor

mgonto commented May 7, 2015

Nice Ben!! It was on our backlog as well but it's nice to see it implemented in the first SDK! 
Good job! 

On Thu, May 7, 2015 at 3:50 PM -0700, "Matias Woloski" notifications@github.com wrote:

@ntotten had this on the roadmap I think, but the sooner we do it the better


Reply to this email directly or view it on GitHub.

@eugeniop
Copy link

eugeniop commented May 7, 2015

Yes, @ntotten, @benschwarz and I are on the same room here :-)

@woloski
Copy link

woloski commented May 7, 2015

🎱

@jfromaniello
Copy link
Member

👍 good idea

@hzalaz
Copy link
Member

hzalaz commented May 7, 2015

@benschwarz great, Lucky I only have to add the X-Auth0-Client header to iOS/Android 😄

let(:headers) { client.class.headers }

it "has the correct headers present" do
headers.keys.sort.should eql ['Authorization', 'Content-Type', 'User-Agent', 'X-Auth0-Client']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use expect syntax instead of should.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we use implicit subject..

@ntotten
Copy link
Contributor

ntotten commented May 7, 2015

I just read the spec on the use of X- headers. It seems the new recommendation is to just prefix with organization name so we might as well just use Auth0-Client without the X-.

@hzalaz
Copy link
Member

hzalaz commented May 7, 2015

That's true @ntotten, also we can add all the information in the User-Agent but either way is fine

@ntotten
Copy link
Contributor

ntotten commented May 8, 2015

The one thing about user agent is that it doesnt work in the case of lock where we would add the version to the /authorize query string. /authorize?auth0_client=lock%2F3.4.5

@hzalaz
Copy link
Member

hzalaz commented May 8, 2015

@ntotten 👍 you're right

@benschwarz
Copy link
Contributor Author

I've updated the proposal to not use X-Auth0-Client, but Auth0-Client instead.
Thanks for the feedback on that folks 🍃

@hzalaz I updated to use the newer expect syntax also.

Finally, the build on this project seems to be a bit flakey — fails then pretty much always passes on second run.

@hzalaz
Copy link
Member

hzalaz commented May 8, 2015

@benschwarz yes, I've thought the brittle build was that fixed but I must have missed something. Will merge it now and fix the build later.

hzalaz added a commit that referenced this pull request May 8, 2015
@hzalaz hzalaz merged commit 0b59a28 into master May 8, 2015
@hzalaz hzalaz deleted the client-headers branch May 8, 2015 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants