diff --git a/packages/client/src/http-client/http-client.ts b/packages/client/src/http-client/http-client.ts index bad5afc7481..ac39f5f60fc 100644 --- a/packages/client/src/http-client/http-client.ts +++ b/packages/client/src/http-client/http-client.ts @@ -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; @@ -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, }; } diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 55302463ea8..b26e705f28b 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -53,6 +53,7 @@ export type PreferenceSettingsType = { export type ApiOptions = { apiVersion?: string; backendUrl?: string; + userAgent?: string; }; export { ApiService } from './api/api.service';