-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat: client identification headers #690
Conversation
nock(url).get('/client/features').reply(200, { features: toggles }); | ||
nock(url) | ||
.get('/client/features') | ||
.matchHeader('x-unleash-connection-id', /^.{36}$/) |
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.
every request to unleash should have 36 digit uuid
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 one!
// TODO: delete | ||
head['UNLEASH-APPNAME'] = appName; | ||
// TODO: delete |
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.
delete when, though? Next major?
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.
Either next major or at least another PR to avoid expanding and contracting headers in the same one
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 want to have a super safe version upgrade that I can recommend to everyone even if for some unknown reason they relied on he old headers
src/test/repository.test.ts
Outdated
@@ -177,12 +183,15 @@ test('should request with etag', (t) => | |||
repo.start(); | |||
})); | |||
|
|||
test('should request with custom headers', (t) => | |||
test('should request with correct headers', (t) => |
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 see why you're co-opting the tests here, but we're also losing a bit of information about the tests with this rename. Before, it was clear that we're talking about custom headers, so if you're scanning through the tests, it was easy enough to find (or grep for). "Correct headers" is more ... ambiguous. How about renaming this one to something like this?
test('should request with correct headers', (t) => | |
test('should request with custom and `x-unleash` headers', (t) => |
The same goes for the other tests that were changed from "custom" to "correct".
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.
Good call. I also updated one more test with the same change
About the changes
This PR adds standardised client identification headers to the feature and metrics calls that the client makes to Unleash. The headers are:
x-unleash-appname
: the name of the application that is using the client.UNLEASH-APPNAME
andUser-Agent
will be deleted in another PRx-unleash-connection-id
: a unique identifier for the current instance of the client generated by the built-in crypto libx-unleash-sdk
: sdk information in the formatunleash-node@<version>
All the headers are intended for the Unleash team so clients should not be affected.
The main use cases we have are:
Interesting parts:
Important files
Discussion points