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): report installed release channel
Kshitij Jhunjhunwala6d90bb3a1c24
diff --git a/ts/packages/cli/src/analytics/events.ts b/ts/packages/cli/src/analytics/events.tsindex e2257f584..c483c8556 100644--- a/ts/packages/cli/src/analytics/events.ts+++ b/ts/packages/cli/src/analytics/events.ts@@ -101,7 +101,15 @@ export const CLI_EVENT_JOURNEY_STAGES = {CLI_TOOL_INVOCATION_FAILED: 'execute',} as const satisfies Record<CliAnalyticsEventName, CliJourneyStage>;-const CLI_CHANNEL = inferSkillReleaseChannel(APP_VERSION);+let cliChannel = inferSkillReleaseChannel(APP_VERSION);++/**+ * Event builders are synchronous, so the CLI bootstrap injects the version+ * resolved from release-tag.txt before any command can emit telemetry.+ */+export const configureCliAnalyticsReleaseVersion = (version: string): void => {+ cliChannel = inferSkillReleaseChannel(version);+};const buildEvent = (name: CliAnalyticsEventName,@@ -111,7 +119,7 @@ const buildEvent = (properties: {...properties,journey_stage: CLI_EVENT_JOURNEY_STAGES[name],- cli_channel: CLI_CHANNEL,+ cli_channel: cliChannel,},});diff --git a/ts/packages/cli/src/commands/index.ts b/ts/packages/cli/src/commands/index.tsindex 5f71933cb..10ec3d9df 100644--- a/ts/packages/cli/src/commands/index.ts+++ b/ts/packages/cli/src/commands/index.ts@@ -58,6 +58,7 @@ import { CLI_EXPERIMENTAL_FEATURES } from 'src/constants';import { installSkill, type SkillInstallTarget } from 'src/effects/install-skill';import { experimental, type CommandVisibility, tagged, visibleValues } from './feature-tags';import { withBackgroundUpdateCheck } from './background-update-check';+import { configureCliAnalyticsReleaseVersion } from 'src/analytics/events';const ROOT_COMMANDS = [tagged(versionCmd),@@ -453,6 +454,7 @@ export const runWithConfig = Effect.gen(function* () {isExperimentalFeatureEnabled: feature => cliUserConfig.isExperimentalFeatureEnabled(feature),};const version = yield* getVersion;+ configureCliAnalyticsReleaseVersion(version);const rootCommand = withBackgroundUpdateCheck(buildRootCommand(visibility));const run = Command.run(rootCommand, {name: 'composio',diff --git a/ts/packages/cli/test/src/analytics.events.test.ts b/ts/packages/cli/test/src/analytics.events.test.tsindex d14acfa57..ae5456d8f 100644--- a/ts/packages/cli/test/src/analytics.events.test.ts+++ b/ts/packages/cli/test/src/analytics.events.test.ts@@ -1,10 +1,16 @@-import { readFileSync } from 'node:fs';-import { afterEach, describe, expect, it, vi } from 'vitest';+import { readFileSync, writeFileSync } from 'node:fs';+import path from 'node:path';+import * as tempy from 'tempy';+import { it } from '@effect/vitest';+import { afterEach, describe, expect, vi } from 'vitest';+import { BunFileSystem, BunPath } from '@effect/platform-bun';+import { Effect, Layer } from 'effect';import { createCliCodactFailureBody } from 'src/analytics/dispatch';import {CLI_ANALYTICS_EVENTS,CLI_EVENT_JOURNEY_STAGES,CLI_JOURNEY_STAGES,+ configureCliAnalyticsReleaseVersion,createCliCommandTelemetryContext,getPluginLifecycleFailedEvent,getPluginLifecycleSucceededEvent,@@ -24,6 +30,7 @@ import { APP_VERSION } from 'src/constants';import { inferSkillReleaseChannel } from 'src/effects/install-skill';import { CLI_RELEASE_CHANNELS } from 'src/experimental-features';import { ToolInputValidationError } from 'src/services/tool-input-validation';+import { resolveInstalledCliVersion } from 'src/services/run-companion-modules';describe('CLI analytics execute failure events', () => {it('records terminal capabilities supplied by the terminal service', () => {@@ -361,6 +368,7 @@ describe('CLI analytics setup runtime-context events', () => {describe('CLI analytics journey taxonomy', () => {afterEach(() => {+ configureCliAnalyticsReleaseVersion(APP_VERSION);vi.unstubAllEnvs();});@@ -436,6 +444,22 @@ describe('CLI analytics journey taxonomy', () => {expect(CLI_RELEASE_CHANNELS).toContain(properties?.cli_channel);});+ it.effect('uses beta release metadata even when the package version is stable', () => {+ const installDir = tempy.temporaryDirectory();+ const execPath = path.join(installDir, 'composio');+ writeFileSync(execPath, 'fake binary');+ writeFileSync(path.join(installDir, 'release-tag.txt'), '@composio/[email protected]\n');++ return Effect.gen(function* () {+ const resolvedVersion = yield* resolveInstalledCliVersion(execPath, APP_VERSION);+ configureCliAnalyticsReleaseVersion(resolvedVersion);++ const properties = getPrimaryLifecycleInvokedEvent(contextFor(['login']))?.properties;+ expect(inferSkillReleaseChannel(APP_VERSION)).toBe('stable');+ expect(properties?.cli_channel).toBe('beta');+ }).pipe(Effect.provide(Layer.merge(BunFileSystem.layer, BunPath.layer)));+ });+it('propagates the installer invocation origin from the environment', () => {vi.stubEnv('COMPOSIO_CLI_INVOCATION_ORIGIN', 'installer');