-
Notifications
You must be signed in to change notification settings - Fork 19
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
Set custom user agent for SDK #182
Set custom user agent for SDK #182
Conversation
In browser environment, the sdk user-agent string is appended to the browser's own UA string.
8de8408
to
d644111
Compare
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined'; | ||
const navigatorUserAgent = typeof navigator !== 'undefined' ? navigator.userAgent : ''; | ||
const nodeVersion = | ||
typeof process !== 'undefined' && typeof process.versions !== 'undefined' |
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.
Couldn't this be checked as process && process.versions
? Same above ..
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 use the more strict checks in a bunch of places, so I guess that's been preferred in the past.
@@ -0,0 +1,3 @@ | |||
// Update this when updating package.json | |||
const sdkVersion = '1.17.0'; |
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.
It's not ideal to have to remember to update both versions. Is there any other way to get the version from a single place at runtime? Perhaps via the environment npm config values?
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.
Those don't work runtime, I think. Probably possible to wrap somehow in build script that generate a js
file, though. I'll leave it for future improvement, since releases aren't super frequent and it's in the instructions anyway.
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.
Looks good. I just don't like so much having to set the version in two different places, but don't have any concrete suggestions how to do it differently either.
In browser environment, the sdk user-agent string is appended to the browser's own UA string.
Adapted from earlier implmenetation sharetribe/flex-integration-sdk-js#60