diff --git a/packages/js/src/api/http-client.ts b/packages/js/src/api/http-client.ts index cd29640a78c..ef3f093c08b 100644 --- a/packages/js/src/api/http-client.ts +++ b/packages/js/src/api/http-client.ts @@ -1,10 +1,12 @@ export type HttpClientOptions = { apiVersion?: string; backendUrl?: string; + userAgent?: string; }; const DEFAULT_API_VERSION = 'v1'; const DEFAULT_BACKEND_URL = 'https://api.novu.co'; +const DEFAULT_USER_AGENT = `${PACKAGE_NAME}@${PACKAGE_VERSION}`; export class HttpClient { private backendUrl: string; @@ -12,13 +14,17 @@ export class HttpClient { private headers: Record; constructor(options: HttpClientOptions = {}) { - const { apiVersion = DEFAULT_API_VERSION, backendUrl = DEFAULT_BACKEND_URL } = options || {}; + const { + apiVersion = DEFAULT_API_VERSION, + backendUrl = DEFAULT_BACKEND_URL, + userAgent = DEFAULT_USER_AGENT, + } = options || {}; this.apiVersion = apiVersion; this.backendUrl = `${backendUrl}/${this.apiVersion}`; this.headers = { 'Novu-API-Version': NOVU_API_VERSION, 'Content-Type': 'application/json', - 'User-Agent': `${PACKAGE_NAME}@${PACKAGE_VERSION}`, + 'User-Agent': userAgent, }; } diff --git a/packages/js/src/novu.ts b/packages/js/src/novu.ts index 9b18c37a27f..feebd4564c3 100644 --- a/packages/js/src/novu.ts +++ b/packages/js/src/novu.ts @@ -26,6 +26,7 @@ export class Novu implements Pick { constructor(options: NovuOptions) { this.#inboxService = new InboxService({ backendUrl: options.backendUrl ?? PRODUCTION_BACKEND_URL, + userAgent: options.__userAgent, }); this.#emitter = new NovuEventEmitter(); this.#session = new Session(