Skip to content

Commit

Permalink
Add user agent for requests. (#42)
Browse files Browse the repository at this point in the history
* Add user agent for requests.

* Bump version.

* Fix lint

* More closely follow the spec for user agent strings.
  • Loading branch information
jmoseley authored Jul 30, 2024
1 parent 91b2eec commit 879972e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"url": "https://github.com/cortexclick/cortex-sdk",
"type": "git"
},
"version": "0.0.8",
"version": "0.0.9",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions src/api-client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { version } from "../package.json";

type Method = "POST" | "GET" | "PUT" | "DELETE";

// body can be any object
Expand Down Expand Up @@ -38,6 +40,7 @@ export class CortexApiClient {
method: "POST",
headers: {
Authorization: `Bearer ${this.accessToken}`,
"User-Agent": `cortex-js-sdk/${version}`,
},
body: form,
});
Expand All @@ -56,6 +59,7 @@ export class CortexApiClient {
headers: {
Authorization: `Bearer ${this.accessToken}`,
"Content-Type": "application/json",
"User-Agent": `cortex-js-sdk-v${version}`,
},
body: requestBody,
});
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
// "resolveJsonModule": true, /* Enable importing .json files. */
"resolveJsonModule": true /* Enable importing .json files. */,
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
/* JavaScript Support */
Expand Down

0 comments on commit 879972e

Please sign in to comment.