Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/daemon/daemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {VERSION} from '../version.js';

import type {DaemonMessage} from './types.js';
import {
DAEMON_CLIENT_NAME,
getDaemonPid,
getPidFilePath,
getSocketPath,
Expand Down Expand Up @@ -65,7 +66,7 @@ async function setupMCPClient() {
});
mcpClient = new Client(
{
name: 'chrome-devtools-cli-daemon',
name: DAEMON_CLIENT_NAME,
version: VERSION,
},
{
Expand Down
1 change: 1 addition & 0 deletions src/daemon/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const INDEX_SCRIPT_PATH = path.join(
);

const APP_NAME = 'chrome-devtools-mcp';
export const DAEMON_CLIENT_NAME = 'chrome-devtools-cli-daemon';

// Using these paths due to strict limits on the POSIX socket path length.
export function getSocketPath(): string {
Expand Down
9 changes: 9 additions & 0 deletions src/telemetry/ClearcutLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import process from 'node:process';

import {DAEMON_CLIENT_NAME} from '../daemon/utils.js';
import {logger} from '../logger.js';

import type {LocalState, Persistence} from './persistence.js';
Expand Down Expand Up @@ -68,6 +69,14 @@ export class ClearcutLogger {
this.#mcpClient = McpClient.MCP_CLIENT_CLAUDE_CODE;
} else if (lowerName.includes('gemini')) {
this.#mcpClient = McpClient.MCP_CLIENT_GEMINI_CLI;
} else if (clientName === DAEMON_CLIENT_NAME) {
this.#mcpClient = McpClient.MCP_CLIENT_DT_MCP_CLI;
} else if (lowerName.includes('openclaw')) {
this.#mcpClient = McpClient.MCP_CLIENT_OPENCLAW;
} else if (lowerName.includes('codex')) {
this.#mcpClient = McpClient.MCP_CLIENT_CODEX;
} else if (lowerName.includes('antigravity')) {
this.#mcpClient = McpClient.MCP_CLIENT_ANTIGRAVITY;
} else {
this.#mcpClient = McpClient.MCP_CLIENT_OTHER;
}
Expand Down
4 changes: 4 additions & 0 deletions src/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ export enum McpClient {
MCP_CLIENT_UNSPECIFIED = 0,
MCP_CLIENT_CLAUDE_CODE = 1,
MCP_CLIENT_GEMINI_CLI = 2,
MCP_CLIENT_DT_MCP_CLI = 4,
MCP_CLIENT_OPENCLAW = 5,
MCP_CLIENT_CODEX = 6,
MCP_CLIENT_ANTIGRAVITY = 7,
MCP_CLIENT_OTHER = 3,
}

Expand Down
40 changes: 26 additions & 14 deletions tests/telemetry/ClearcutLogger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {describe, it, afterEach, beforeEach} from 'node:test';

import sinon from 'sinon';

import {DAEMON_CLIENT_NAME} from '../../src/daemon/utils.js';
import {ClearcutLogger} from '../../src/telemetry/ClearcutLogger.js';
import type {Persistence} from '../../src/telemetry/persistence.js';
import {FilePersistence} from '../../src/telemetry/persistence.js';
Expand Down Expand Up @@ -55,21 +56,32 @@ describe('ClearcutLogger', () => {
});

describe('setClientName', () => {
it('appends mapped mcp_client to payload', async () => {
const logger = new ClearcutLogger({
persistence: mockPersistence,
appVersion: '1.0.0',
watchdogClient: mockWatchdogClient,
const clients = [
{name: 'claude-code', expected: 1}, // MCP_CLIENT_CLAUDE_CODE
{name: 'gemini-cli', expected: 2}, // MCP_CLIENT_GEMINI_CLI
{name: DAEMON_CLIENT_NAME, expected: 4}, // MCP_CLIENT_DT_MCP_CLI
{name: 'openclaw-browser', expected: 5}, // MCP_CLIENT_OPENCLAW
{name: 'codex-mcp-client', expected: 6}, // MCP_CLIENT_CODEX
{name: 'antigravity-client', expected: 7}, // MCP_CLIENT_ANTIGRAVITY
];

for (const {name, expected} of clients) {
it(`maps ${name} client correctly`, async () => {
const logger = new ClearcutLogger({
persistence: mockPersistence,
appVersion: '1.0.0',
watchdogClient: mockWatchdogClient,
});

logger.setClientName(name);
await logger.logServerStart({headless: true});

assert(mockWatchdogClient.send.calledOnce);
const msg = mockWatchdogClient.send.firstCall.args[0];
assert.strictEqual(msg.type, WatchdogMessageType.LOG_EVENT);
assert.strictEqual(msg.payload.mcp_client, expected);
});

logger.setClientName('gemini-cli-mcp-client');
await logger.logServerStart({headless: true});

assert(mockWatchdogClient.send.calledOnce);
const msg = mockWatchdogClient.send.firstCall.args[0];
assert.strictEqual(msg.type, WatchdogMessageType.LOG_EVENT);
assert.strictEqual(msg.payload.mcp_client, 2); // 2 is MCP_CLIENT_GEMINI_CLI
});
}
});

describe('logServerStart', () => {
Expand Down
Loading