Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 18:30 UTC
feat(cli): track plugin setup lifecycle
Kshitij Jhunjhunwala committed
Jul 14, 2026 at 19:35 UTC
4e68e652809d1039a3e4b8da9888121ba607ac98
5 files changed
+169
-1
install.sh
+1
-1
@@ -407,7 +407,7 @@ rm -f "$install_err"
407
if [[ $install_plugins = true ]]; then
408
echo
409
info "Checking for supported agent hosts..."
410
- if ! "$exe" setup --target auto --yes --if-present; then
410
+ if ! COMPOSIO_CLI_INVOCATION_ORIGIN=installer "$exe" setup --target auto --yes --if-present; then
411
error 'Composio CLI was installed, but agent plugin setup failed. Retry with `composio setup --target auto --yes`.'
412
fi
413
fi
test/install-sh-release-resolution.test.sh
+4
@@ -154,6 +154,10 @@ install)
154
exit 0
155
;;
156
setup)
157
+ if [[ "${COMPOSIO_CLI_INVOCATION_ORIGIN:-}" != 'installer' ]]; then
158
+ echo 'Expected automatic plugin setup telemetry origin to be installer.' >&2
159
+ exit 97
160
+ fi
161
exit "${TEST_SETUP_EXIT:-0}"
162
;;
163
--version|version)
ts/packages/cli/src/analytics/events.ts
+70
@@ -27,6 +27,14 @@ export const CLI_ANALYTICS_EVENTS = {
27
CLI_RUN_INVOKED: 'CLI_RUN_INVOKED',
28
CLI_RUN_SUCCEEDED: 'CLI_RUN_SUCCEEDED',
29
CLI_RUN_FAILED: 'CLI_RUN_FAILED',
30
+ CLI_INSTALL_INVOKED: 'CLI_INSTALL_INVOKED',
31
+ CLI_INSTALL_SUCCEEDED: 'CLI_INSTALL_SUCCEEDED',
32
+ CLI_INSTALL_FAILED: 'CLI_INSTALL_FAILED',
33
+ CLI_SETUP_INVOKED: 'CLI_SETUP_INVOKED',
34
+ CLI_SETUP_SUCCEEDED: 'CLI_SETUP_SUCCEEDED',
35
+ CLI_SETUP_FAILED: 'CLI_SETUP_FAILED',
36
+ CLI_PLUGIN_SETUP_SUCCEEDED: 'CLI_PLUGIN_SETUP_SUCCEEDED',
37
+ CLI_PLUGIN_UNINSTALL_SUCCEEDED: 'CLI_PLUGIN_UNINSTALL_SUCCEEDED',
38
CLI_TOOL_INVOCATION_VALIDATION_FAILED: 'CLI_TOOL_INVOCATION_VALIDATION_FAILED',
39
CLI_TOOL_INVOCATION_TOOL_NOT_FOUND: 'CLI_TOOL_INVOCATION_TOOL_NOT_FOUND',
40
CLI_TOOL_INVOCATION_FAILED: 'CLI_TOOL_INVOCATION_FAILED',
@@ -40,6 +48,7 @@ const KNOWN_COMMAND_TOKENS = new Set([
48
'logout',
49
'run',
50
'install',
51
+ 'setup',
52
'dev',
53
'generate',
54
'tools',
@@ -281,6 +290,28 @@ const getRunCommandProperties = (context: CliCommandTelemetryContext) => ({
290
arg_count: Math.max(0, context.argv.length - 3),
291
});
292
293
+const getInstallCommandProperties = (context: CliCommandTelemetryContext) => ({
294
+ source: 'cli',
295
+ invocation_origin: getInvocationOrigin(),
296
+ cli_version: context.cliVersion,
297
+ command_path: context.commandPath,
298
+ duration_ms: Date.now() - context.startedAt,
299
+ completions: isFlagPresent(context.argv, '--completions'),
300
+ no_completions: isFlagPresent(context.argv, '--no-completions'),
301
+});
302
+
303
+const getSetupCommandProperties = (context: CliCommandTelemetryContext) => ({
304
+ source: 'cli',
305
+ invocation_origin: getInvocationOrigin(),
306
+ cli_version: context.cliVersion,
307
+ command_path: context.commandPath,
308
+ duration_ms: Date.now() - context.startedAt,
309
+ operation: isFlagPresent(context.argv, '--uninstall') ? 'uninstall' : 'setup',
310
+ target: getFlagValue(context.argv, '--target') ?? 'auto',
311
+ yes: isFlagPresent(context.argv, '--yes', '-y'),
312
+ if_present: isFlagPresent(context.argv, '--if-present'),
313
+});
314
+
315
const getLoginCommandProperties = (context: CliCommandTelemetryContext) => ({
316
source: 'cli',
317
invocation_origin: getInvocationOrigin(),
@@ -333,6 +364,10 @@ const isProxyCommand = (commandPath: string): boolean => commandPath === 'proxy'
364
365
const isRunCommand = (commandPath: string): boolean => commandPath === 'run';
366
367
+const isInstallCommand = (commandPath: string): boolean => commandPath === 'install';
368
+
369
+const isSetupCommand = (commandPath: string): boolean => commandPath === 'setup';
370
+
371
const isGenericOnlyCommand = (commandPath: string): boolean =>
372
commandPath === 'composio' || commandPath.startsWith('dev');
373
@@ -452,6 +487,20 @@ const SPECIAL_LIFECYCLE_FAMILIES: ReadonlyArray<SpecialLifecycleFamily> = [
487
failedEventName: CLI_ANALYTICS_EVENTS.CLI_RUN_FAILED,
488
getProperties: getRunCommandProperties,
489
},
490
+ {
491
+ match: isInstallCommand,
492
+ invokedEventName: CLI_ANALYTICS_EVENTS.CLI_INSTALL_INVOKED,
493
+ succeededEventName: CLI_ANALYTICS_EVENTS.CLI_INSTALL_SUCCEEDED,
494
+ failedEventName: CLI_ANALYTICS_EVENTS.CLI_INSTALL_FAILED,
495
+ getProperties: getInstallCommandProperties,
496
+ },
497
+ {
498
+ match: isSetupCommand,
499
+ invokedEventName: CLI_ANALYTICS_EVENTS.CLI_SETUP_INVOKED,
500
+ succeededEventName: CLI_ANALYTICS_EVENTS.CLI_SETUP_SUCCEEDED,
501
+ failedEventName: CLI_ANALYTICS_EVENTS.CLI_SETUP_FAILED,
502
+ getProperties: getSetupCommandProperties,
503
+ },
504
];
505
506
const getSpecialLifecycleFamily = (commandPath: string): SpecialLifecycleFamily | undefined =>
@@ -501,6 +550,27 @@ export const getPrimaryLifecycleFailedEvent = (
550
};
551
};
552
553
+export const getPluginLifecycleSucceededEvent = (params: {
554
+ readonly operation: 'setup' | 'uninstall';
555
+ readonly target: 'claude' | 'codex';
556
+ readonly action: 'installed' | 'enabled' | 'configured' | 'uninstalled';
557
+ readonly cliVersion: string;
558
+}): TrackEvent => ({
559
+ name:
560
+ params.operation === 'uninstall'
561
+ ? CLI_ANALYTICS_EVENTS.CLI_PLUGIN_UNINSTALL_SUCCEEDED
562
+ : CLI_ANALYTICS_EVENTS.CLI_PLUGIN_SETUP_SUCCEEDED,
563
+ properties: {
564
+ source: 'cli',
565
+ invocation_origin: getInvocationOrigin(),
566
+ cli_version: params.cliVersion,
567
+ command_path: 'setup',
568
+ operation: params.operation,
569
+ agent_host: params.target,
570
+ action: params.action,
571
+ },
572
+});
573
+
574
export const getToolExecuteValidationFailedEvent = (params: {
575
readonly toolSlug: string;
576
readonly args: Record<string, unknown>;
ts/packages/cli/src/services/setup.ts
+28
@@ -1,6 +1,9 @@
1
import { Command } from '@effect/platform';
2
import { Data, Effect } from 'effect';
3
import semver from 'semver';
4
+import { trackCliEventEffect } from 'src/analytics/dispatch';
5
+import { getPluginLifecycleSucceededEvent } from 'src/analytics/events';
6
+import { APP_VERSION } from 'src/constants';
7
import { CommandRunner, type CommandResult } from './command-runner';
8
import { SetupSkillInstaller } from './setup-skill-installer';
9
@@ -746,6 +749,21 @@ export const installSetupTargets = (inspected: ReadonlyArray<InspectedSetupTarge
749
);
750
})
751
);
752
+ if (result.plugin_changed) {
753
+ const action = !status.plugin_installed
754
+ ? 'installed'
755
+ : !status.plugin_enabled
756
+ ? 'enabled'
757
+ : 'configured';
758
+ yield* trackCliEventEffect(
759
+ getPluginLifecycleSucceededEvent({
760
+ operation: 'setup',
761
+ target: result.target,
762
+ action,
763
+ cliVersion: APP_VERSION,
764
+ })
765
+ );
766
+ }
767
completed.push(result);
768
}
769
return completed;
@@ -764,6 +782,16 @@ export const uninstallSetupTargets = (inspected: ReadonlyArray<InspectedSetupTar
782
);
783
})
784
);
785
+ if (result.plugin_changed) {
786
+ yield* trackCliEventEffect(
787
+ getPluginLifecycleSucceededEvent({
788
+ operation: 'uninstall',
789
+ target: result.target,
790
+ action: 'uninstalled',
791
+ cliVersion: APP_VERSION,
792
+ })
793
+ );
794
+ }
795
completed.push(result);
796
}
797
return completed;
ts/packages/cli/test/src/analytics.events.test.ts
+66
@@ -1,12 +1,19 @@
1
import { describe, expect, it } from 'vitest';
2
import { createCliCodactFailureBody } from 'src/analytics/dispatch';
3
import {
4
+ CLI_ANALYTICS_EVENTS,
5
+ createCliCommandTelemetryContext,
6
+ getPluginLifecycleSucceededEvent,
7
+ getPrimaryLifecycleFailedEvent,
8
+ getPrimaryLifecycleInvokedEvent,
9
+ getPrimaryLifecycleSucceededEvent,
10
getToolExecuteFailedEvent,
11
getToolExecuteToolNotFoundEvent,
12
getToolExecuteValidationFailedEvent,
13
isMaybeToolNotFoundError,
14
isMaybeToolValidationError,
15
} from 'src/analytics/events';
16
+import { APP_VERSION } from 'src/constants';
17
import { ToolInputValidationError } from 'src/services/tool-input-validation';
18
19
describe('CLI analytics execute failure events', () => {
@@ -127,3 +134,62 @@ describe('CLI analytics execute failure events', () => {
134
});
135
});
136
});
137
+
138
+describe('CLI analytics setup and install lifecycle events', () => {
139
+ it('tracks setup as a dedicated lifecycle with safe option properties', () => {
140
+ const context = createCliCommandTelemetryContext(
141
+ ['bun', 'composio', 'setup', '--target', 'codex', '--uninstall', '--yes'],
142
+ APP_VERSION
143
+ );
144
+
145
+ const invoked = getPrimaryLifecycleInvokedEvent(context);
146
+ const succeeded = getPrimaryLifecycleSucceededEvent(context);
147
+ const failed = getPrimaryLifecycleFailedEvent(context, new Error('native failure'));
148
+
149
+ expect(invoked?.name).toBe(CLI_ANALYTICS_EVENTS.CLI_SETUP_INVOKED);
150
+ expect(succeeded?.name).toBe(CLI_ANALYTICS_EVENTS.CLI_SETUP_SUCCEEDED);
151
+ expect(failed?.name).toBe(CLI_ANALYTICS_EVENTS.CLI_SETUP_FAILED);
152
+ expect(invoked?.properties).toMatchObject({
153
+ command_path: 'setup',
154
+ operation: 'uninstall',
155
+ target: 'codex',
156
+ yes: true,
157
+ if_present: false,
158
+ });
159
+ });
160
+
161
+ it('tracks shell installation separately from plugin setup', () => {
162
+ const context = createCliCommandTelemetryContext(
163
+ ['bun', 'composio', 'install', '--completions'],
164
+ APP_VERSION
165
+ );
166
+
167
+ expect(getPrimaryLifecycleInvokedEvent(context)).toMatchObject({
168
+ name: CLI_ANALYTICS_EVENTS.CLI_INSTALL_INVOKED,
169
+ properties: {
170
+ command_path: 'install',
171
+ completions: true,
172
+ no_completions: false,
173
+ },
174
+ });
175
+ });
176
+
177
+ it('tracks a verified per-host plugin change', () => {
178
+ expect(
179
+ getPluginLifecycleSucceededEvent({
180
+ operation: 'setup',
181
+ target: 'claude',
182
+ action: 'installed',
183
+ cliVersion: APP_VERSION,
184
+ })
185
+ ).toMatchObject({
186
+ name: CLI_ANALYTICS_EVENTS.CLI_PLUGIN_SETUP_SUCCEEDED,
187
+ properties: {
188
+ command_path: 'setup',
189
+ operation: 'setup',
190
+ agent_host: 'claude',
191
+ action: 'installed',
192
+ },
193
+ });
194
+ });
195
+});