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): read user and CLI config from the cache dir in analytics
The analytics module resolved user_data.json and config.json from a hardcoded ~/.composio, but the CLI writes both under the cache dir (COMPOSIO_CACHE_DIR override, ~/.composio otherwise; see setup-cache-dir.ts and cli-user-config.ts). With the override set, telemetry silently lost the api key fingerprint, org_id, and the keychain-mode signal it needs for identity attribution.
jkomyno committed
Jul 28, 2026 at 18:11 UTC
a59b6480dd58eced100ae8c776582bb0d91658fc
2 files changed
+35
-5
ts/packages/cli/src/analytics/dispatch.ts
+4
-2
@@ -157,8 +157,10 @@ const getAnalyticsPaths = Effect.gen(function* () {
157
return {
158
analyticsDir,
159
analyticsStatePath: path.join(analyticsDir, ANALYTICS_STATE_FILE_NAME),
160
- userConfigPath: path.join(analyticsDir, constants.USER_CONFIG_FILE_NAME),
161
- cliConfigPath: path.join(analyticsDir, constants.CLI_CONFIG_FILE_NAME),
160
+ // user_data.json and config.json live in the cache dir (setup-cache-dir.ts,
161
+ // cli-user-config.ts), which COMPOSIO_CACHE_DIR relocates away from ~/.composio.
162
+ userConfigPath: path.join(cacheDir, constants.USER_CONFIG_FILE_NAME),
163
+ cliConfigPath: path.join(cacheDir, constants.CLI_CONFIG_FILE_NAME),
164
consumerShortTermCachePath: path.join(cacheDir, CONSUMER_SHORT_TERM_CACHE_FILE_NAME),
165
};
166
});
ts/packages/cli/test/src/analytics.dispatch.test.ts
+31
-3
@@ -110,10 +110,8 @@ describe('CLI analytics dispatch', () => {
110
return Effect.gen(function* () {
111
const fs = yield* FileSystem.FileSystem;
112
const path = yield* Path.Path;
113
- const composioDir = path.join(home, '.composio');
114
- yield* fs.makeDirectory(composioDir, { recursive: true });
113
yield* fs.writeFileString(
116
- path.join(composioDir, USER_CONFIG_FILE_NAME),
114
+ path.join(cacheDir, USER_CONFIG_FILE_NAME),
115
JSON.stringify({ base_url: 'https://backend.example.test///' })
116
);
117
yield* fs.writeFileString(
@@ -739,6 +737,7 @@ describe('CLI analytics dispatch', () => {
737
const home = tempy.temporaryDirectory();
738
const scriptPath = `${home}/composio.ts`;
739
enableTelemetry();
740
+ vi.stubEnv('COMPOSIO_CACHE_DIR', `${home}/.composio`);
741
process.argv[1] = scriptPath;
742
743
return Effect.gen(function* () {
@@ -760,6 +759,33 @@ describe('CLI analytics dispatch', () => {
759
}).pipe(Effect.provide(makePlatformLayer(home)));
760
});
761
762
+ it.effect('reads the user config from COMPOSIO_CACHE_DIR rather than the homedir', () => {
763
+ const home = tempy.temporaryDirectory();
764
+ const cacheDir = tempy.temporaryDirectory();
765
+ const scriptPath = `${home}/composio.ts`;
766
+ enableTelemetry();
767
+ vi.stubEnv('COMPOSIO_CACHE_DIR', cacheDir);
768
+ process.argv[1] = scriptPath;
769
+
770
+ return Effect.gen(function* () {
771
+ const fs = yield* FileSystem.FileSystem;
772
+ const path = yield* Path.Path;
773
+ yield* fs.writeFileString(scriptPath, '');
774
+ // The user config exists only in the relocated cache dir; ~/.composio
775
+ // never receives a copy.
776
+ yield* fs.writeFileString(
777
+ path.join(cacheDir, USER_CONFIG_FILE_NAME),
778
+ JSON.stringify({ api_key: 'uak_test', org_id: 'org_cache_dir' })
779
+ );
780
+
781
+ yield* trackCliEventEffect({ name: 'producer_event' });
782
+
783
+ const args = childProcessMocks.spawn.mock.calls[0]![1] as string[];
784
+ const payload = decodeWorkerPayload<{ properties?: { org_id?: string } }>(args[2]!);
785
+ expect(payload.properties?.org_id).toBe('org_cache_dir');
786
+ }).pipe(Effect.provide(makePlatformLayer(home)));
787
+ });
788
+
789
it.effect('does not create the identity file when logging out with telemetry disabled', () => {
790
const home = tempy.temporaryDirectory();
791
enableTelemetry();
@@ -823,6 +849,7 @@ describe('CLI analytics dispatch', () => {
849
const scriptPath = `${home}/composio.ts`;
850
// No env key and no plaintext api_key on disk -> no fingerprint.
851
enableTelemetry('');
852
+ vi.stubEnv('COMPOSIO_CACHE_DIR', `${home}/.composio`);
853
process.argv[1] = scriptPath;
854
855
return Effect.gen(function* () {
@@ -861,6 +888,7 @@ describe('CLI analytics dispatch', () => {
888
const home = tempy.temporaryDirectory();
889
const scriptPath = `${home}/composio.ts`;
890
enableTelemetry('');
891
+ vi.stubEnv('COMPOSIO_CACHE_DIR', `${home}/.composio`);
892
process.argv[1] = scriptPath;
893
894
return Effect.gen(function* () {