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

Set custom user agent for SDK #182

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

bladealslayer
Copy link
Member

@bladealslayer bladealslayer commented Apr 13, 2023

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

In browser environment, the sdk user-agent string is appended to the browser's
own UA string.
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'
Copy link
Contributor

@walterrw walterrw Apr 14, 2023

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 ..

Copy link
Member Author

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';
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@walterrw walterrw left a 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.

@bladealslayer bladealslayer merged commit 20f3b30 into support-for-multitenant-api Apr 14, 2023
@bladealslayer bladealslayer deleted the sdk-custom-user-agent branch April 14, 2023 09:43
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.

None yet

2 participants