@devries-cameron20 / composio Mirror · read-only / commits / 5ec10c66a
Fork 0

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 23, 04:15 UTC

Clean up telemetry

haxzie committed Apr 18, 2025 at 12:17 UTC 5ec10c66a7bab576e1bbcb0a6e1dfbba7273b468
1 file changed +32 -20
packages/core/src/composio.ts
+32 -20
@@ -9,7 +9,7 @@ import { ToolListParams } from "@composio/client/resources/tools";
9 import { BaseComposioToolset } from "./toolset/BaseToolset";
10 import { Telemetry } from "./telemetry/Telemetry";
11 import { BaseTelemetryTransport, ConsoleTelemetryTransport } from "./telemetry/TelemetryTransport";
12 -import type { InstrumentedInstance } from "./types/telemetry.types";
12 +import type { InstrumentedInstance, TelemetryMetadata } from "./types/telemetry.types";
13 import { getSDKConfig } from "./utils/sdk";
14 import logger from "./utils/logger";
15 import { IS_DEVELOPMENT_OR_CI } from "./utils/constants";
@@ -89,6 +89,12 @@ export class Composio<TToolset extends BaseComposioToolset<any, any> = OpenAIToo
89 `Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`
90 );
91 }
92 + if (config.userId && config.connectedAccountIds) {
93 + logger.warn(
94 + "When both userId and connectedAccountIds are provided, preference will be given to connectedAccountIds"
95 + );
96 + }
97 +
98 /**
99 * Initialize the Composio SDK client.
100 * The client is used to make API calls to the Composio API.
@@ -132,9 +138,8 @@ export class Composio<TToolset extends BaseComposioToolset<any, any> = OpenAIToo
138 /**
139 * Initialize the client telemetry.
140 */
135 - if (this.config.allowTracking) {
136 -
137 - this.telemetry = new Telemetry({
141 + if (this.config.allowTracking ?? true) {
142 + this.initializeTelemetry({
143 apiKey: apiKeyParsed ?? "",
144 baseUrl: baseURLParsed ?? "",
145 frameworkRuntime: "node",
@@ -142,23 +147,30 @@ export class Composio<TToolset extends BaseComposioToolset<any, any> = OpenAIToo
147 sessionId: this.userId,
148 composioVersion: require('../package.json').version,
149 isBrowser: typeof window !== "undefined",
145 - }, config.telemetryTransport ?? new ConsoleTelemetryTransport());
146 -
147 -
148 - /**
149 - * Instrument the client telemetry.
150 - */
151 - this.telemetry.instrumentTelemetry(this);
152 - this.telemetry.instrumentTelemetry(this.tools);
153 - this.telemetry.instrumentTelemetry(this.toolkits);
154 - this.telemetry.instrumentTelemetry(this.triggers);
155 - this.telemetry.instrumentTelemetry(this.authConfigs);
156 - this.telemetry.instrumentTelemetry(this.connectedAccounts);
157 - this.telemetry.instrumentTelemetry(this.toolset);
158 -
159 - // Check for the latest version of the Composio SDK from NPM.
160 - checkForLatestVersionFromNPM();
150 + }, config.telemetryTransport)
151 }
152 +
153 + // Check for the latest version of the Composio SDK from NPM.
154 + checkForLatestVersionFromNPM();
155 + }
156 +
157 + /**
158 + * Initialize the instrumentations and telemetry for the Composio SDK.
159 + * @param {TelemetryMetadata} config - The configuration for the telemetry.
160 + * @param {BaseTelemetryTransport} transport - The transport for the telemetry.
161 + */
162 + private initializeTelemetry(config: TelemetryMetadata, transport?: BaseTelemetryTransport) {
163 + this.telemetry = new Telemetry(config, transport);
164 + /**
165 + * Instrument the instance and all the models with telemetry.
166 + */
167 + this.telemetry.instrumentTelemetry(this);
168 + this.telemetry.instrumentTelemetry(this.tools);
169 + this.telemetry.instrumentTelemetry(this.toolkits);
170 + this.telemetry.instrumentTelemetry(this.triggers);
171 + this.telemetry.instrumentTelemetry(this.authConfigs);
172 + this.telemetry.instrumentTelemetry(this.connectedAccounts);
173 + this.telemetry.instrumentTelemetry(this.toolset);
174 }
175
176 /**