diff --git a/pods/account/src/index.ts b/pods/account/src/index.ts index 7e5e732a019..ea6b4c304fb 100644 --- a/pods/account/src/index.ts +++ b/pods/account/src/index.ts @@ -64,6 +64,7 @@ export function serveAccount (methods: Record, productId } setMetadata(toolPlugin.metadata.Endpoint, endpointUri) setMetadata(toolPlugin.metadata.Transactor, transactorUri) + setMetadata(toolPlugin.metadata.UserAgent, 'AccountService') let client: MongoClient diff --git a/pods/backup/src/platform.ts b/pods/backup/src/platform.ts index 1b87b82abdd..1ae679be5fd 100644 --- a/pods/backup/src/platform.ts +++ b/pods/backup/src/platform.ts @@ -21,6 +21,7 @@ import serverToken from '@hcengineering/server-token' import got from 'got' import { ObjectId } from 'mongodb' import config from './config' +import toolPlugin from '@hcengineering/server-tool' /** * @public @@ -72,6 +73,8 @@ export class PlatformWorker { secretKey: config.MinioSecretKey }) + setMetadata(toolPlugin.metadata.UserAgent, config.ServiceID) + await this.backup().then(() => { void this.schedule() }) diff --git a/server/tool/src/connect.ts b/server/tool/src/connect.ts index a7ab5b3b815..70c5fbfbc3c 100644 --- a/server/tool/src/connect.ts +++ b/server/tool/src/connect.ts @@ -16,8 +16,9 @@ import client, { clientId } from '@hcengineering/client' import { Client, systemAccountEmail, WorkspaceId } from '@hcengineering/core' -import { addLocation, getResource, setMetadata } from '@hcengineering/platform' +import { addLocation, getMetadata, getResource, setMetadata } from '@hcengineering/platform' import { generateToken } from '@hcengineering/server-token' +import plugin from './plugin' /** * @public @@ -37,7 +38,14 @@ export async function connect ( setMetadata(client.metadata.UseBinaryProtocol, true) setMetadata(client.metadata.UseProtocolCompression, true) - setMetadata(client.metadata.ClientSocketFactory, (url) => new WebSocket(url)) + setMetadata(client.metadata.ClientSocketFactory, (url) => { + const socket = new WebSocket(url, { + headers: { + 'User-Agent': getMetadata(plugin.metadata.UserAgent) ?? 'Anticrm Tool Client' + } + }) + return socket + }) addLocation(clientId, () => import('@hcengineering/client-resources')) return await ( diff --git a/server/tool/src/plugin.ts b/server/tool/src/plugin.ts index 14ee3fc055d..6a498faf578 100644 --- a/server/tool/src/plugin.ts +++ b/server/tool/src/plugin.ts @@ -12,7 +12,8 @@ const toolPlugin = plugin(toolId, { metadata: { Endpoint: '' as Metadata, Transactor: '' as Metadata, - InitWorkspace: '' as Metadata + InitWorkspace: '' as Metadata, + UserAgent: '' as Metadata } })