http-user-agent
Creates a proper HTTP User-Agent. Can be used everywhere.
⚠️ In Maintenance Mode ⚠️
This package has been replaced by the TypeScript SDK is in maintenance mode as such this tool will no longer receive new features or bug fixes.
We recommend to use the TypeScript SDK for any new implementation and plan migrating to it.
Install
Node.js
npm install --save @commercetools/http-user-agent
Browser
<script src="https://unpkg.com/@commercetools/http-user-agent/dist/commercetools-http-user-agent.umd.min.js"></script>
<script>
// global: CommercetoolsHttpUserAgent
</script>
createHttpUserAgent(options)
Creates a proper HTTP User-Agent
.
Named arguments (options)
name
(String): the name of the client sending the request (required)version
(String): the version of the client sending the request (optional)libraryName
(String): the name of the library / package / application using the SDK (optional)libraryVersion
(String): the version of the library / package / application using the SDK (optional)contactUrl
(String): the contact URL of the library / package / application using the SDK (optional)contactEmail
(String): the contact email of the library / package / application using the SDK (optional)
Usage example
import createHttpUserAgent from '@commercetools/http-user-agent'
const userAgent = createHttpUserAgent({
name: 'commercetools-node-sdk',
version: '1.0.0',
libraryName: 'my-awesome-library',
libraryVersion: '1.0.0',
contactUrl: 'https://github.com/my-company/my-awesome-library'
contactEmail: 'helpdesk@commercetools.com'
}),
// The User-Agent will be something like:
// commercetools-node-sdk/1.0.0 Node.js/6.9.0 (darwin; x64) my-awesome-library/1.0.0 (+https://github.com/my-company/my-awesome-library; +helpdesk@commercetools.com)