-
Notifications
You must be signed in to change notification settings - Fork 29
[RED-2503][RED-2506][RED-2507][RED-2509] Add zaf_sdk user agent to headers for requests #220
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
base: master
Are you sure you want to change the base?
Changes from all commits
ca0d4ac
3a9251d
091e70b
23e6df8
1c88245
6398db6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,21 @@ | ||
| import NativePromise from 'native-promise-only' | ||
| import pkgJson from '../package.json' | ||
|
|
||
| const Promise = window.Promise || NativePromise | ||
|
|
||
| export function updateUserAgentWithAppId (headers, appId) { | ||
| if (!appId) { | ||
| return headers | ||
| } | ||
| const originalUserAgent = headers && headers['User-Agent'] ? headers['User-Agent'] : '' | ||
Shengming-Yan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const zafSdkUserAgentString = `zendesk_app_framework_sdk/sdk_version:${pkgJson.version}/app_id:${appId}` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reckon the version in pkgJson doesn't reflect the actual version, this PR didn't touch on the version as well There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you Sheen, should I remove this? Note that I've bumped the version in package.json in this commit but I can remove if you prefer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reckon when customer refer to zaf_sdk in their app, it is using the release version now. So this version is unrelavant unless we can manually keep align with the release version. With regarding to shall we keep this, as reviewing the purpose of this PR, wonder do you need this info for internal debug only? In that case, probably considering adding x-zendesk-app-framework-sdk-version header for this instead of chain the existing user agent? As all |
||
| const userAgent = originalUserAgent ? `${originalUserAgent} ${zafSdkUserAgentString}` : zafSdkUserAgentString | ||
Shengming-Yan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return { | ||
| ...headers, | ||
| 'User-Agent': userAgent | ||
| } | ||
| } | ||
|
|
||
| export function isObject (obj) { | ||
| return (obj !== null && typeof obj === 'object') | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.