Skip to content

Commit

Permalink
feat(client): add novu user agent (#5671)
Browse files Browse the repository at this point in the history
* feat: add novu user agent

* Update packages/client/src/http-client/http-client.ts

Co-authored-by: Sokratis Vidros <[email protected]>

* Update packages/client/src/index.ts

Co-authored-by: Sokratis Vidros <[email protected]>

* refactor: user agent

* fix: typo

---------

Co-authored-by: Richard Fontein <[email protected]>
Co-authored-by: Sokratis Vidros <[email protected]>
  • Loading branch information
3 people committed Jun 13, 2024
1 parent 96f7632 commit e239093
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/client/src/http-client/http-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { CustomDataType } from '@novu/shared';

const DEFAULT_API_VERSION = 'v1';
const DEFAULT_BACKEND_URL = 'https://api.novu.co';
const PACKAGE_NAME = '@novu/client';
const PACKAGE_VERSION = '0.42.0';
const DEFAULT_USER_AGENT = `${PACKAGE_NAME}-${PACKAGE_VERSION}`;

export class HttpClient {
private backendUrl: string;
private apiVersion: string;
Expand All @@ -11,11 +15,13 @@ export class HttpClient {
constructor({
apiVersion = DEFAULT_API_VERSION,
backendUrl = DEFAULT_BACKEND_URL,
userAgent = DEFAULT_USER_AGENT,
}: ApiOptions = {}) {
this.apiVersion = apiVersion;
this.backendUrl = `${backendUrl}/${this.apiVersion}`;
this.headers = {
'Content-Type': 'application/json',
'User-Agent': userAgent,
};
}

Expand Down
1 change: 1 addition & 0 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export type PreferenceSettingsType = {
export type ApiOptions = {
apiVersion?: string;
backendUrl?: string;
userAgent?: string;
};

export { ApiService } from './api/api.service';

0 comments on commit e239093

Please sign in to comment.