From d8d6d0101e7913686cffc81ad7c9f9818c32db78 Mon Sep 17 00:00:00 2001 From: barbmarcio Date: Fri, 26 Jul 2024 01:55:39 +0100 Subject: [PATCH 1/5] feat: adding custom user agent to config params --- src/lib/api-client.ts | 4 +++- src/types/shared.d.ts | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) 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; } From c346d2f5d40c05443a096e31f21ca717f10e3fef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Barbosa?= <52362496+barbmarcio@users.noreply.github.com> Date: Fri, 26 Jul 2024 12:42:11 +0100 Subject: [PATCH 2/5] fix: overriding if user agent exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Johan Bergström --- src/lib/api-client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/api-client.ts b/src/lib/api-client.ts index eb5f33a..4e3ea8f 100644 --- a/src/lib/api-client.ts +++ b/src/lib/api-client.ts @@ -43,7 +43,7 @@ class APIClient { "Content-Type": "application/json", Accept: "application/json", "X-UA": config.userAgent - ? `@topsort/sdk ${version} ${config.userAgent}` + ? `${config.userAgent}` : `@topsort/sdk ${version}`, Authorization: `Bearer ${config.apiKey}`, }, From 6d3ddb778e62ece18a3cb18244e69accd86235ee Mon Sep 17 00:00:00 2001 From: barbmarcio Date: Fri, 26 Jul 2024 23:35:43 +0100 Subject: [PATCH 3/5] feat: adding concatenation for user agent --- src/lib/api-client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/api-client.ts b/src/lib/api-client.ts index 4e3ea8f..9086b56 100644 --- a/src/lib/api-client.ts +++ b/src/lib/api-client.ts @@ -43,8 +43,8 @@ class APIClient { "Content-Type": "application/json", Accept: "application/json", "X-UA": config.userAgent - ? `${config.userAgent}` - : `@topsort/sdk ${version}`, + ? `@topsort-sdk/${version} ${config.userAgent}` + : `@topsort-sdk/${version}`, Authorization: `Bearer ${config.apiKey}`, }, body: JSON.stringify(body), From 69a88c7cf35998bff675429f17e23deaead1e0c2 Mon Sep 17 00:00:00 2001 From: barbmarcio Date: Mon, 29 Jul 2024 15:38:15 +0100 Subject: [PATCH 4/5] fix: reverting the user agente change --- src/lib/api-client.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/api-client.ts b/src/lib/api-client.ts index 9086b56..eb5f33a 100644 --- a/src/lib/api-client.ts +++ b/src/lib/api-client.ts @@ -43,8 +43,8 @@ class APIClient { "Content-Type": "application/json", Accept: "application/json", "X-UA": config.userAgent - ? `@topsort-sdk/${version} ${config.userAgent}` - : `@topsort-sdk/${version}`, + ? `@topsort/sdk ${version} ${config.userAgent}` + : `@topsort/sdk ${version}`, Authorization: `Bearer ${config.apiKey}`, }, body: JSON.stringify(body), From 0b7f332c631584a74c32d9766be9448e04821f0a Mon Sep 17 00:00:00 2001 From: barbmarcio Date: Mon, 29 Jul 2024 17:41:44 +0100 Subject: [PATCH 5/5] feat(chore): bumping version and adding change log --- CHANGELOG.md | 4 ++++ README.md | 2 ++ package.json | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) 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",