Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
fix(cli): stop sending free-form strings in telemetry event properties
PostHog-bound events carried raw error messages, the user's search query, and the proxied endpoint URL. Free text like this can embed API keys, customer identifiers, and private URLs, and the client-side scrubber only catches known token shapes. Record the shape instead: error_name only for failures, query_length/query_term_count for search, has_endpoint for proxy. The codact-failure path keeps its error_message: it goes to Composio's own authenticated endpoint, not to PostHog.
jkomyno committed
Jul 28, 2026 at 18:07 UTC
3083137ffe050886b6dc7dc730c587b3e531c43a
3 files changed
+50
-29
ts/packages/cli/src/analytics/events.ts
+18
-25
@@ -160,12 +160,6 @@ const extractUnknownKeys = (issues: ReadonlyArray<string>): ReadonlyArray<string
160
const errorNameOf = (error: unknown): string =>
161
error instanceof Error && error.name ? error.name : 'UnknownError';
162
163
-const errorMessageOf = (error: unknown): string => {
164
- if (error instanceof Error && error.message) return error.message.slice(0, 500);
165
- if (typeof error === 'string') return error.slice(0, 500);
166
- return 'Unknown error';
167
-};
168
-
163
const isFlagPresent = (argv: ReadonlyArray<string>, ...flags: string[]): boolean =>
164
argv.slice(2).some(token => {
165
if (flags.includes(token)) return true;
@@ -252,19 +246,23 @@ const getExecuteCommandProperties = (context: CliCommandTelemetryContext) => {
246
};
247
};
248
255
-const getSearchCommandProperties = (context: CliCommandTelemetryContext) => ({
256
- source: 'cli',
257
- invocation_origin: getInvocationOrigin(),
258
- parent_run_id: getParentRunId(),
259
- parent_command: getParentRunId() ? 'run' : undefined,
260
- cli_version: context.cliVersion,
261
- command_path: context.commandPath,
262
- duration_ms: Date.now() - context.startedAt,
263
- query: getTrailingPositionals(context)[0],
264
- search_query: getTrailingPositionals(context)[0],
265
- toolkits: getFlagValue(context.argv, '--toolkits'),
266
- limit: getFlagValue(context.argv, '--limit'),
267
-});
249
+// Search queries are user-authored free text, so only their shape is recorded.
250
+const getSearchCommandProperties = (context: CliCommandTelemetryContext) => {
251
+ const query = getTrailingPositionals(context)[0] ?? '';
252
+ return {
253
+ source: 'cli',
254
+ invocation_origin: getInvocationOrigin(),
255
+ parent_run_id: getParentRunId(),
256
+ parent_command: getParentRunId() ? 'run' : undefined,
257
+ cli_version: context.cliVersion,
258
+ command_path: context.commandPath,
259
+ duration_ms: Date.now() - context.startedAt,
260
+ query_length: query.length,
261
+ query_term_count: query.split(/\s+/u).filter(Boolean).length,
262
+ toolkits: getFlagValue(context.argv, '--toolkits'),
263
+ limit: getFlagValue(context.argv, '--limit'),
264
+ };
265
+};
266
267
const getLinkCommandProperties = (context: CliCommandTelemetryContext) => {
268
const firstPositional = getTrailingPositionals(context)[0];
@@ -348,7 +346,7 @@ const getProxyCommandProperties = (context: CliCommandTelemetryContext) => ({
346
cli_version: context.cliVersion,
347
command_path: context.commandPath,
348
duration_ms: Date.now() - context.startedAt,
351
- endpoint: getTrailingPositionals(context)[0],
349
+ has_endpoint: typeof getTrailingPositionals(context)[0] === 'string',
350
toolkit: getFlagValue(context.argv, '--toolkit', '-t'),
351
method: getFlagValue(context.argv, '--method', '-X') ?? 'GET',
352
has_data: isFlagPresent(context.argv, '--data', '-d'),
@@ -439,7 +437,6 @@ const getCliCommandFailedEvent = (
437
duration_ms: Date.now() - context.startedAt,
438
flag_names: context.flagNames,
439
error_name: errorNameOf(error),
442
- error_message: errorMessageOf(error),
440
},
441
});
442
@@ -559,7 +556,6 @@ export const getPrimaryLifecycleFailedEvent = (
556
properties: {
557
...family.getProperties(context),
558
error_name: errorNameOf(error),
562
- error_message: errorMessageOf(error),
559
},
560
};
561
};
@@ -602,7 +598,6 @@ export const getPluginLifecycleFailedEvent = (params: {
598
agent_host: params.target,
599
phase: params.phase,
600
error_name: errorNameOf(params.error),
605
- error_message: errorMessageOf(params.error),
601
},
602
});
603
@@ -746,7 +741,6 @@ export const getToolExecuteToolNotFoundEvent = (params: {
741
error_slug: params.errorSlug,
742
http_status: params.status,
743
api_error_code: params.apiCode,
749
- error_message: params.message?.slice(0, 500),
744
...argumentShape(params.args),
745
},
746
});
@@ -781,7 +775,6 @@ export const getToolExecuteFailedEvent = (params: {
775
http_status: params.status,
776
api_error_code: params.apiCode,
777
error_name: params.errorName,
784
- error_message: params.message?.slice(0, 500),
778
is_no_connection_error: Boolean(params.isNoConnectionError),
779
...argumentShape(params.args),
780
},
ts/packages/cli/test/src/analytics.events.test.ts
+29
-2
@@ -197,6 +197,33 @@ describe('CLI analytics setup and install lifecycle events', () => {
197
});
198
});
199
200
+ it('summarizes user-controlled search and proxy input without recording it', () => {
201
+ const terminal = { stdoutIsTTY: false, stderrIsTTY: false };
202
+ const search = getPrimaryLifecycleInvokedEvent(
203
+ createCliCommandTelemetryContext(
204
+ ['bun', 'composio', 'search', 'customer@example.com secret'],
205
+ APP_VERSION,
206
+ terminal
207
+ )
208
+ );
209
+ const proxy = getPrimaryLifecycleInvokedEvent(
210
+ createCliCommandTelemetryContext(
211
+ ['bun', 'composio', 'proxy', 'https://user:password@example.com/private?token=small'],
212
+ APP_VERSION,
213
+ terminal
214
+ )
215
+ );
216
+
217
+ expect(search?.properties).toMatchObject({
218
+ query_length: 'customer@example.com secret'.length,
219
+ query_term_count: 2,
220
+ });
221
+ expect(search?.properties).not.toHaveProperty('query');
222
+ expect(search?.properties).not.toHaveProperty('search_query');
223
+ expect(proxy?.properties).toMatchObject({ has_endpoint: true });
224
+ expect(proxy?.properties).not.toHaveProperty('endpoint');
225
+ });
226
+
227
it('tracks a verified per-host plugin change', () => {
228
expect(
229
getPluginLifecycleSucceededEvent({
@@ -268,7 +295,7 @@ describe('CLI analytics setup runtime-context events', () => {
295
});
296
});
297
271
- it('tracks a per-host failure with truncated error details', () => {
298
+ it('tracks a per-host failure without recording its free-form message', () => {
299
const error = new Error(`Adding the claude marketplace failed${'x'.repeat(600)}`);
300
301
const event = getPluginLifecycleFailedEvent({
@@ -289,7 +316,7 @@ describe('CLI analytics setup runtime-context events', () => {
316
error_name: 'Error',
317
},
318
});
292
- expect(String(event?.properties?.error_message).length).toBeLessThanOrEqual(500);
319
+ expect(event?.properties).not.toHaveProperty('error_message');
320
});
321
322
it('tracks user cancellation and installer skips with normalized reasons', () => {
ts/packages/cli/test/src/commands/setup.telemetry.cmd.test.ts
+3
-2
@@ -355,17 +355,18 @@ describe('CLI: composio setup telemetry', () => {
355
const exit = yield* Effect.exit(cli(['setup', '--target', 'claude', '--yes']));
356
expect(Exit.isFailure(exit)).toBe(true);
357
358
- expect(eventsNamed('CLI_PLUGIN_SETUP_FAILED')).toEqual([
358
+ const failureEvents = eventsNamed('CLI_PLUGIN_SETUP_FAILED');
359
+ expect(failureEvents).toEqual([
360
expect.objectContaining({
361
properties: expect.objectContaining({
362
agent_host: 'claude',
363
operation: 'setup',
364
phase: 'install',
365
error_name: 'services/SetupProcessError',
365
- error_message: expect.stringContaining('native operation failed'),
366
}),
367
}),
368
]);
369
+ expect(failureEvents[0]?.properties).not.toHaveProperty('error_message');
370
expect(eventsNamed('CLI_PLUGIN_SETUP_SUCCEEDED')).toHaveLength(0);
371
})
372
);