diff --git a/lib/client.js b/lib/client.js index cdf0a45..4beedfe 100644 --- a/lib/client.js +++ b/lib/client.js @@ -557,7 +557,8 @@ export default class Client { options = { url: options } } - options.headers = addUserAgent(options.headers) + const appId = this._metadata && this._metadata.appId + options.headers = addUserAgent(options.headers, appId) const doneEventKey = `${requestKey}.done` const failEventKey = `${requestKey}.fail` diff --git a/lib/utils.js b/lib/utils.js index b34418f..5ade59c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -3,11 +3,13 @@ import pkgJson from '../package.json' const Promise = window.Promise || NativePromise -export function addUserAgent (headers) { +export function addUserAgent (headers, appId) { const originalUserAgent = headers && headers['User-Agent'] ? headers['User-Agent'] : '' + const zafSdkUserAgentString = `zendesk_app_framework_sdk/sdk_version:${pkgJson.version}/app_id:${appId}` + const userAgent = originalUserAgent ? `${originalUserAgent} ${zafSdkUserAgentString}` : zafSdkUserAgentString return { ...headers, - 'User-Agent': originalUserAgent ? `${originalUserAgent} zendesk_app_framework_sdk/${pkgJson.version}` : `zendesk_app_framework_sdk/${pkgJson.version}` + 'User-Agent': userAgent } }