-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In browser environment, the sdk user-agent string is appended to the browser's own UA string.
- Loading branch information
1 parent
641e594
commit d644111
Showing
6 changed files
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import sdkVersion from './version'; | ||
|
||
/* global window, navigator, process */ | ||
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' | ||
? process.versions.node | ||
: ''; | ||
|
||
// User-Agent string for the SDK | ||
// For browsers, append to the browser's user agent string, | ||
let userAgent = `sharetribe-flex-sdk-js/${sdkVersion}`; | ||
if (isBrowser && navigatorUserAgent !== '') { | ||
userAgent = `${navigatorUserAgent} ${userAgent}`; | ||
} else if (nodeVersion !== '') { | ||
userAgent = `${userAgent} (node/${nodeVersion})`; | ||
} | ||
|
||
const sdkUserAgentString = userAgent; | ||
|
||
export { isBrowser, sdkUserAgentString }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Update this when updating package.json | ||
const sdkVersion = '1.17.0'; | ||
export default sdkVersion; |