From 0f84c29841a44bc809b6370a1a27798b27d30397 Mon Sep 17 00:00:00 2001 From: Himanshu Dixit Date: Wed, 11 Dec 2024 09:11:50 +0530 Subject: [PATCH] fix: contenxt issues --- js/src/sdk/utils/error.ts | 6 +++--- js/src/sdk/utils/errors/src/constants.ts | 1 + js/src/sdk/utils/telemetry/index.ts | 20 +++++++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/js/src/sdk/utils/error.ts b/js/src/sdk/utils/error.ts index 5bb37f1bdfc..89d8fcd603d 100644 --- a/js/src/sdk/utils/error.ts +++ b/js/src/sdk/utils/error.ts @@ -107,9 +107,9 @@ export class CEG { } throw new ComposioError( - SDK_ERROR_CODES.COMMON.UNKNOWN, - error.message, - "", + SDK_ERROR_CODES.BACKEND.SERVER_UNREACHABLE, + error.message || "Server is unreachable. Please contact tech@composio.dev with the error details.", + "Server is unreachable. Please contact tech@composio.dev with the error details.", "Please contact tech@composio.dev with the error details.", metadata, error diff --git a/js/src/sdk/utils/errors/src/constants.ts b/js/src/sdk/utils/errors/src/constants.ts index 42c4641f479..912cf23c7c7 100644 --- a/js/src/sdk/utils/errors/src/constants.ts +++ b/js/src/sdk/utils/errors/src/constants.ts @@ -6,6 +6,7 @@ export const SDK_ERROR_CODES = { UNAUTHORIZED: "BACKEND::UNAUTHORIZED", SERVER_ERROR: "BACKEND::SERVER_ERROR", SERVER_UNAVAILABLE: "BACKEND::SERVER_UNAVAILABLE", + SERVER_UNREACHABLE: "BACKEND::SERVER_UNREACHABLE", UNKNOWN: "BACKEND::UNKNOWN", }, COMMON: { diff --git a/js/src/sdk/utils/telemetry/index.ts b/js/src/sdk/utils/telemetry/index.ts index 64ea610434f..1e0348b85d4 100644 --- a/js/src/sdk/utils/telemetry/index.ts +++ b/js/src/sdk/utils/telemetry/index.ts @@ -6,8 +6,8 @@ import { getEnvVariable } from "../../../utils/shared"; export class TELEMETRY_LOGGER { private static batchProcessor = new BatchProcessor( - 1000, 100, + 10, async (data) => { await TELEMETRY_LOGGER.sendTelemetry(data as Record[]); } @@ -18,7 +18,14 @@ export class TELEMETRY_LOGGER { const payload = { eventName: method.name, data: { className, args }, - sdk_meta: ComposioSDKContext, + sdk_meta: { + apiKey: ComposioSDKContext.apiKey, + baseURL: ComposioSDKContext.baseURL, + composioVersion: ComposioSDKContext.composioVersion, + frameworkRuntime: ComposioSDKContext.frameworkRuntime, + source: ComposioSDKContext.source, + isBrowser: typeof window !== "undefined", + }, }; TELEMETRY_LOGGER.batchProcessor.pushItem(payload); @@ -61,7 +68,14 @@ export class TELEMETRY_LOGGER { const payload = { eventName, data, - sdk_meta: ComposioSDKContext, + sdk_meta: { + apiKey: ComposioSDKContext.apiKey, + baseURL: ComposioSDKContext.baseURL, + composioVersion: ComposioSDKContext.composioVersion, + frameworkRuntime: ComposioSDKContext.frameworkRuntime, + source: ComposioSDKContext.source, + isBrowser: typeof window !== "undefined", + }, }; TELEMETRY_LOGGER.batchProcessor.pushItem(payload); }