@@ -9,6 +9,7 @@ import {describe, it, afterEach, beforeEach} from 'node:test';
99
1010import sinon from 'sinon' ;
1111
12+ import { DAEMON_CLIENT_NAME } from '../../src/daemon/utils.js' ;
1213import { ClearcutLogger } from '../../src/telemetry/ClearcutLogger.js' ;
1314import type { Persistence } from '../../src/telemetry/persistence.js' ;
1415import { FilePersistence } from '../../src/telemetry/persistence.js' ;
@@ -55,21 +56,32 @@ describe('ClearcutLogger', () => {
5556 } ) ;
5657
5758 describe ( 'setClientName' , ( ) => {
58- it ( 'appends mapped mcp_client to payload' , async ( ) => {
59- const logger = new ClearcutLogger ( {
60- persistence : mockPersistence ,
61- appVersion : '1.0.0' ,
62- watchdogClient : mockWatchdogClient ,
59+ const clients = [
60+ { name : 'claude-code' , expected : 1 } , // MCP_CLIENT_CLAUDE_CODE
61+ { name : 'gemini-cli' , expected : 2 } , // MCP_CLIENT_GEMINI_CLI
62+ { name : DAEMON_CLIENT_NAME , expected : 4 } , // MCP_CLIENT_DT_MCP_CLI
63+ { name : 'openclaw-browser' , expected : 5 } , // MCP_CLIENT_OPENCLAW
64+ { name : 'codex-mcp-client' , expected : 6 } , // MCP_CLIENT_CODEX
65+ { name : 'antigravity-client' , expected : 7 } , // MCP_CLIENT_ANTIGRAVITY
66+ ] ;
67+
68+ for ( const { name, expected} of clients ) {
69+ it ( `maps ${ name } client correctly` , async ( ) => {
70+ const logger = new ClearcutLogger ( {
71+ persistence : mockPersistence ,
72+ appVersion : '1.0.0' ,
73+ watchdogClient : mockWatchdogClient ,
74+ } ) ;
75+
76+ logger . setClientName ( name ) ;
77+ await logger . logServerStart ( { headless : true } ) ;
78+
79+ assert ( mockWatchdogClient . send . calledOnce ) ;
80+ const msg = mockWatchdogClient . send . firstCall . args [ 0 ] ;
81+ assert . strictEqual ( msg . type , WatchdogMessageType . LOG_EVENT ) ;
82+ assert . strictEqual ( msg . payload . mcp_client , expected ) ;
6383 } ) ;
64-
65- logger . setClientName ( 'gemini-cli-mcp-client' ) ;
66- await logger . logServerStart ( { headless : true } ) ;
67-
68- assert ( mockWatchdogClient . send . calledOnce ) ;
69- const msg = mockWatchdogClient . send . firstCall . args [ 0 ] ;
70- assert . strictEqual ( msg . type , WatchdogMessageType . LOG_EVENT ) ;
71- assert . strictEqual ( msg . payload . mcp_client , 2 ) ; // 2 is MCP_CLIENT_GEMINI_CLI
72- } ) ;
84+ }
7385 } ) ;
7486
7587 describe ( 'logServerStart' , ( ) => {
0 commit comments