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(client): add novu user agent #5671

Merged
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';
Loading