Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(cli): stop sending free-form strings in telemetry event properties
jkomyno3083137ffe05
diff --git a/ts/packages/cli/src/analytics/events.ts b/ts/packages/cli/src/analytics/events.tsindex 7bf73c077..27c9317d6 100644--- a/ts/packages/cli/src/analytics/events.ts+++ b/ts/packages/cli/src/analytics/events.ts@@ -160,12 +160,6 @@ const extractUnknownKeys = (issues: ReadonlyArray<string>): ReadonlyArray<stringconst errorNameOf = (error: unknown): string =>error instanceof Error && error.name ? error.name : 'UnknownError';-const errorMessageOf = (error: unknown): string => {- if (error instanceof Error && error.message) return error.message.slice(0, 500);- if (typeof error === 'string') return error.slice(0, 500);- return 'Unknown error';-};-const isFlagPresent = (argv: ReadonlyArray<string>, ...flags: string[]): boolean =>argv.slice(2).some(token => {if (flags.includes(token)) return true;@@ -252,19 +246,23 @@ const getExecuteCommandProperties = (context: CliCommandTelemetryContext) => {};};-const getSearchCommandProperties = (context: CliCommandTelemetryContext) => ({- source: 'cli',- invocation_origin: getInvocationOrigin(),- parent_run_id: getParentRunId(),- parent_command: getParentRunId() ? 'run' : undefined,- cli_version: context.cliVersion,- command_path: context.commandPath,- duration_ms: Date.now() - context.startedAt,- query: getTrailingPositionals(context)[0],- search_query: getTrailingPositionals(context)[0],- toolkits: getFlagValue(context.argv, '--toolkits'),- limit: getFlagValue(context.argv, '--limit'),-});+// Search queries are user-authored free text, so only their shape is recorded.+const getSearchCommandProperties = (context: CliCommandTelemetryContext) => {+ const query = getTrailingPositionals(context)[0] ?? '';+ return {+ source: 'cli',+ invocation_origin: getInvocationOrigin(),+ parent_run_id: getParentRunId(),+ parent_command: getParentRunId() ? 'run' : undefined,+ cli_version: context.cliVersion,+ command_path: context.commandPath,+ duration_ms: Date.now() - context.startedAt,+ query_length: query.length,+ query_term_count: query.split(/\s+/u).filter(Boolean).length,+ toolkits: getFlagValue(context.argv, '--toolkits'),+ limit: getFlagValue(context.argv, '--limit'),+ };+};const getLinkCommandProperties = (context: CliCommandTelemetryContext) => {const firstPositional = getTrailingPositionals(context)[0];@@ -348,7 +346,7 @@ const getProxyCommandProperties = (context: CliCommandTelemetryContext) => ({cli_version: context.cliVersion,command_path: context.commandPath,duration_ms: Date.now() - context.startedAt,- endpoint: getTrailingPositionals(context)[0],+ has_endpoint: typeof getTrailingPositionals(context)[0] === 'string',toolkit: getFlagValue(context.argv, '--toolkit', '-t'),method: getFlagValue(context.argv, '--method', '-X') ?? 'GET',has_data: isFlagPresent(context.argv, '--data', '-d'),@@ -439,7 +437,6 @@ const getCliCommandFailedEvent = (duration_ms: Date.now() - context.startedAt,flag_names: context.flagNames,error_name: errorNameOf(error),- error_message: errorMessageOf(error),},});@@ -559,7 +556,6 @@ export const getPrimaryLifecycleFailedEvent = (properties: {...family.getProperties(context),error_name: errorNameOf(error),- error_message: errorMessageOf(error),},};};@@ -602,7 +598,6 @@ export const getPluginLifecycleFailedEvent = (params: {agent_host: params.target,phase: params.phase,error_name: errorNameOf(params.error),- error_message: errorMessageOf(params.error),},});@@ -746,7 +741,6 @@ export const getToolExecuteToolNotFoundEvent = (params: {error_slug: params.errorSlug,http_status: params.status,api_error_code: params.apiCode,- error_message: params.message?.slice(0, 500),...argumentShape(params.args),},});@@ -781,7 +775,6 @@ export const getToolExecuteFailedEvent = (params: {http_status: params.status,api_error_code: params.apiCode,error_name: params.errorName,- error_message: params.message?.slice(0, 500),is_no_connection_error: Boolean(params.isNoConnectionError),...argumentShape(params.args),},diff --git a/ts/packages/cli/test/src/analytics.events.test.ts b/ts/packages/cli/test/src/analytics.events.test.tsindex 5586f7b34..f2d09f7e1 100644--- a/ts/packages/cli/test/src/analytics.events.test.ts+++ b/ts/packages/cli/test/src/analytics.events.test.ts@@ -197,6 +197,33 @@ describe('CLI analytics setup and install lifecycle events', () => {});});+ it('summarizes user-controlled search and proxy input without recording it', () => {+ const terminal = { stdoutIsTTY: false, stderrIsTTY: false };+ const search = getPrimaryLifecycleInvokedEvent(+ createCliCommandTelemetryContext(+ ['bun', 'composio', 'search', '[email protected] secret'],+ APP_VERSION,+ terminal+ )+ );+ const proxy = getPrimaryLifecycleInvokedEvent(+ createCliCommandTelemetryContext(+ ['bun', 'composio', 'proxy', 'https://user:[email protected]/private?token=small'],+ APP_VERSION,+ terminal+ )+ );++ expect(search?.properties).toMatchObject({+ query_length: '[email protected] secret'.length,+ query_term_count: 2,+ });+ expect(search?.properties).not.toHaveProperty('query');+ expect(search?.properties).not.toHaveProperty('search_query');+ expect(proxy?.properties).toMatchObject({ has_endpoint: true });+ expect(proxy?.properties).not.toHaveProperty('endpoint');+ });+it('tracks a verified per-host plugin change', () => {expect(getPluginLifecycleSucceededEvent({@@ -268,7 +295,7 @@ describe('CLI analytics setup runtime-context events', () => {});});- it('tracks a per-host failure with truncated error details', () => {+ it('tracks a per-host failure without recording its free-form message', () => {const error = new Error(`Adding the claude marketplace failed${'x'.repeat(600)}`);const event = getPluginLifecycleFailedEvent({@@ -289,7 +316,7 @@ describe('CLI analytics setup runtime-context events', () => {error_name: 'Error',},});- expect(String(event?.properties?.error_message).length).toBeLessThanOrEqual(500);+ expect(event?.properties).not.toHaveProperty('error_message');});it('tracks user cancellation and installer skips with normalized reasons', () => {diff --git a/ts/packages/cli/test/src/commands/setup.telemetry.cmd.test.ts b/ts/packages/cli/test/src/commands/setup.telemetry.cmd.test.tsindex cbc486bc0..29e1f90e0 100644--- a/ts/packages/cli/test/src/commands/setup.telemetry.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/setup.telemetry.cmd.test.ts@@ -355,17 +355,18 @@ describe('CLI: composio setup telemetry', () => {const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));expect(Exit.isFailure(exit)).toBe(true);- expect(eventsNamed('CLI_PLUGIN_SETUP_FAILED')).toEqual([+ const failureEvents = eventsNamed('CLI_PLUGIN_SETUP_FAILED');+ expect(failureEvents).toEqual([expect.objectContaining({properties: expect.objectContaining({agent_host: 'claude',operation: 'setup',phase: 'install',error_name: 'services/SetupProcessError',- error_message: expect.stringContaining('native operation failed'),}),}),]);+ expect(failureEvents[0]?.properties).not.toHaveProperty('error_message');expect(eventsNamed('CLI_PLUGIN_SETUP_SUCCEEDED')).toHaveLength(0);}));