Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding custom user agent to config params #21

Merged
merged 5 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@topsort/sdk",
"version": "0.1.0",
"version": "0.2.0",
"description": "",
"packageManager": "[email protected]",
"main": "dist/index.js",
Expand Down
4 changes: 3 additions & 1 deletion src/lib/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions src/types/shared.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface Config {
apiKey: string;
host?: string;
userAgent?: string;
}