diff --git a/lib/index.js b/lib/index.js index 4b89ca2..76a4ab3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -222,7 +222,15 @@ function startAlarmPushClient(options) { } socket.addEventListener("open", () => { setPhase("authenticating", wsUrl, { detail: "auth" }); - socket?.send(JSON.stringify({ type: "auth", token })); + let clientLabel = "netxops"; + try { + const env = typeof process !== "undefined" ? process.env : undefined; + const hostname = env?.HOSTNAME || env?.COMPUTERNAME; + if (typeof hostname === "string" && hostname.trim()) { + clientLabel = `netxops@${hostname.trim()}`; + } + } catch {} + socket?.send(JSON.stringify({ type: "auth", token, client: clientLabel })); }); socket.addEventListener("message", (event) => { let msg; diff --git a/src/netx/alarm-push.ts b/src/netx/alarm-push.ts index be7022a..65a4b14 100644 --- a/src/netx/alarm-push.ts +++ b/src/netx/alarm-push.ts @@ -173,7 +173,18 @@ export function startAlarmPushClient(options: AlarmPushClientOptions): () => voi socket.addEventListener('open', () => { setPhase('authenticating', wsUrl, { detail: 'auth' }) - socket?.send(JSON.stringify({ type: 'auth', token })) + let clientLabel = 'netxops' + try { + // Node / Bun hosts: include hostname so NetX hub can list multi-DSH links. + const env = typeof process !== 'undefined' ? process.env : undefined + const hostname = env?.HOSTNAME || env?.COMPUTERNAME + if (typeof hostname === 'string' && hostname.trim()) { + clientLabel = `netxops@${hostname.trim()}` + } + } catch { + // browser / restricted runtime — keep generic label + } + socket?.send(JSON.stringify({ type: 'auth', token, client: clientLabel })) }) socket.addEventListener('message', (event) => {