diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bdde4a..1dd9a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,7 @@ The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). We follow the format used by [Open Telemetry](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md). +## Version 0.2.0 (2024-07-29) + +- Adding `userAgent: string` as part of Config for requests +- Adding `retry: boolean` as part of `reportEvent` response diff --git a/README.md b/README.md index a3c108c..e59fd5a 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ const config = { // generate your api key in the auction manager - it should look some thing like this // note: this is an invalid key and won't work, you need to replace it with your own apiKey: "TSE_4S6o1g1CB5tyRENfhDMAn6viR7A5cy3j1JAR", + userAgent?: "Mozilla/5.0" // optional user agent to be added as part of the request }; createAuction(config, auctionDetails) @@ -133,6 +134,7 @@ const event: TopsortEvent = { const config = { // generate your api key in the auction manager - it should look some thing like this apiKey: "TSE_4S6o1g1CB5tyRENfhDMAn6viR7A5cy3j1JAR", + userAgent?: "Mozilla/5.0" // optional user agent to be added as part of the request }; reportEvent(config, event) diff --git a/package.json b/package.json index e7f6c58..4d50b42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@topsort/sdk", - "version": "0.1.0", + "version": "0.2.0", "description": "", "packageManager": "bun@1.1.20", "main": "dist/index.js", diff --git a/src/lib/api-client.ts b/src/lib/api-client.ts index e7a0d32..eb5f33a 100644 --- a/src/lib/api-client.ts +++ b/src/lib/api-client.ts @@ -42,7 +42,9 @@ class APIClient { headers: { "Content-Type": "application/json", Accept: "application/json", - "X-UA": `@topsort/sdk ${version}`, + "X-UA": config.userAgent + ? `@topsort/sdk ${version} ${config.userAgent}` + : `@topsort/sdk ${version}`, Authorization: `Bearer ${config.apiKey}`, }, body: JSON.stringify(body), diff --git a/src/types/shared.d.ts b/src/types/shared.d.ts index 6ed7c83..fb225b4 100644 --- a/src/types/shared.d.ts +++ b/src/types/shared.d.ts @@ -1,4 +1,5 @@ export interface Config { apiKey: string; host?: string; + userAgent?: string; }