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
fix(cli): configure telemetry before invocation
Kshitij Jhunjhunwala committed
Jul 29, 2026 at 16:07 UTC
87236ff642cd223f2f8321c23a01d6c82b19997d
3 files changed
+36
-14
ts/packages/cli/src/analytics/events.ts
+12
-8
@@ -114,14 +114,18 @@ export const configureCliAnalyticsReleaseVersion = (version: string): void => {
114
const buildEvent = (
115
name: CliAnalyticsEventName,
116
properties: Record<string, unknown>
117
-): TrackEvent => ({
118
- name,
119
- properties: {
120
- ...properties,
121
- journey_stage: CLI_EVENT_JOURNEY_STAGES[name],
122
- cli_channel: cliChannel,
123
- },
124
-});
117
+): TrackEvent => {
118
+ const eventVersion =
119
+ typeof properties.cli_version === 'string' ? properties.cli_version : undefined;
120
+ return {
121
+ name,
122
+ properties: {
123
+ ...properties,
124
+ journey_stage: CLI_EVENT_JOURNEY_STAGES[name],
125
+ cli_channel: eventVersion ? inferSkillReleaseChannel(eventVersion) : cliChannel,
126
+ },
127
+ };
128
+};
129
130
const KNOWN_COMMAND_TOKENS = new Set([
131
'version',
ts/packages/cli/src/cli-main.ts
+5
-5
@@ -36,12 +36,14 @@ import { CommandRunner } from 'src/services/command-runner';
36
import { StdinLive } from 'src/services/stdin';
37
import { showUpdateNotice } from 'src/services/update-check';
38
import {
39
+ configureCliAnalyticsReleaseVersion,
40
createCliCommandTelemetryContext,
41
getPrimaryLifecycleFailedEvent,
42
getPrimaryLifecycleInvokedEvent,
43
getPrimaryLifecycleSucceededEvent,
44
} from 'src/analytics/events';
45
import { ensureAnalyticsIdentity, trackCliEventEffect } from 'src/analytics/dispatch';
46
+import { getVersion } from 'src/effects/version';
47
import { mapOnlyComposioOverrideError } from 'src/services/composio-error-overrides';
48
import { SetupSkillInstaller } from 'src/services/setup-skill-installer';
49
import { SetupCommandError } from 'src/services/setup';
@@ -161,11 +163,9 @@ const runWithTelemetry = Effect.gen(function* () {
163
});
164
}
165
164
- const commandTelemetryContext = createCliCommandTelemetryContext(
165
- process.argv,
166
- constants.APP_VERSION,
167
- terminal
168
- );
166
+ const version = yield* getVersion;
167
+ configureCliAnalyticsReleaseVersion(version);
168
+ const commandTelemetryContext = createCliCommandTelemetryContext(process.argv, version, terminal);
169
if (commandTelemetryContext.commandPath === 'run' && commandTelemetryContext.runId) {
170
// effect/Config is read-only; the run id must be written into the environment so the run
171
// command and the child processes it spawns observe the same telemetry run id.
ts/packages/cli/test/src/analytics.events.test.ts
+19
-1
@@ -454,12 +454,30 @@ describe('CLI analytics journey taxonomy', () => {
454
const resolvedVersion = yield* resolveInstalledCliVersion(execPath, APP_VERSION);
455
configureCliAnalyticsReleaseVersion(resolvedVersion);
456
457
- const properties = getPrimaryLifecycleInvokedEvent(contextFor(['login']))?.properties;
457
+ const context = createCliCommandTelemetryContext(
458
+ ['bun', 'composio', 'login'],
459
+ resolvedVersion,
460
+ { stdoutIsTTY: false, stderrIsTTY: false }
461
+ );
462
+ const properties = getPrimaryLifecycleInvokedEvent(context)?.properties;
463
expect(inferSkillReleaseChannel(APP_VERSION)).toBe('stable');
464
expect(properties?.cli_channel).toBe('beta');
465
}).pipe(Effect.provide(Layer.merge(BunFileSystem.layer, BunPath.layer)));
466
});
467
468
+ it('derives invoked-event channel from its resolved runtime version', () => {
469
+ configureCliAnalyticsReleaseVersion(APP_VERSION);
470
+ const context = createCliCommandTelemetryContext(['bun', 'composio', 'login'], '0.3.1-beta.7', {
471
+ stdoutIsTTY: true,
472
+ stderrIsTTY: true,
473
+ });
474
+
475
+ expect(getPrimaryLifecycleInvokedEvent(context)?.properties).toMatchObject({
476
+ cli_version: '0.3.1-beta.7',
477
+ cli_channel: 'beta',
478
+ });
479
+ });
480
+
481
it('propagates the installer invocation origin from the environment', () => {
482
vi.stubEnv('COMPOSIO_CLI_INVOCATION_ORIGIN', 'installer');
483