Skip to content

Commit

Permalink
Detect client's version and send it to server
Browse files Browse the repository at this point in the history
  • Loading branch information
tellet-q committed Dec 18, 2024
1 parent c45d94b commit 70bfa6c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/js-client-grpc/src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Collections} from './proto/collections_service_connect.js';
import {Points} from './proto/points_service_connect.js';
import {Snapshots} from './proto/snapshots_service_connect.js';
import {Qdrant} from './proto/qdrant_connect.js';
import {PACKAGE_VERSION} from './client-version.js';

type Clients = {
collections: PromiseClient<typeof Collections>;
Expand Down Expand Up @@ -50,7 +51,7 @@ function createClients(transport: Transport) {
export function createApis(baseUrl: string, {timeout, apiKey}: {timeout: number; apiKey?: string}): GrpcClients {
const interceptors: Interceptor[] = [
(next) => (req) => {
req.header.set('user-agent', 'qdrant-js');
req.header.set('user-agent', 'qdrant-js' + String(PACKAGE_VERSION));
return next(req);
},
];
Expand Down
1 change: 1 addition & 0 deletions packages/js-client-grpc/src/client-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PACKAGE_VERSION = '1.12.0';
2 changes: 2 additions & 0 deletions packages/js-client-rest/src/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {createSnapshotsApi} from './api/snapshots-api.js';
import {createShardsApi} from './api/shards-api.js';
import {QdrantClientTimeoutError, QdrantClientUnexpectedResponseError} from './errors.js';
import {RestArgs} from './types.js';
import {PACKAGE_VERSION} from './client-version.js';

export type Client = ReturnType<typeof Fetcher.for<paths>>;

Expand Down Expand Up @@ -56,6 +57,7 @@ export function createClient(baseUrl: string, {headers, timeout, connections}: R

const client = Fetcher.for<paths>();
// Configure client with 'undici' agent which is used in Node 18+
headers.set('user-agent', 'qdrant-js/' + String(PACKAGE_VERSION));
client.configure({
baseUrl,
init: {
Expand Down
1 change: 1 addition & 0 deletions packages/js-client-rest/src/client-version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const PACKAGE_VERSION = '1.12.0';

0 comments on commit 70bfa6c

Please sign in to comment.