Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: js release yml, reduce batch size, change telemetry payload #975

Merged
merged 11 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions .github/workflows/release_js_sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:

jobs:
run-js-tests:
permissions:
contents: write
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment explaining why write permissions are needed here. This helps future maintainers understand the security implications and requirements.

timeout-minutes: 60
runs-on: ubuntu-latest

Expand All @@ -38,21 +40,6 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

- name: Update version
run: |
git config --global user.email "tech@composio.dev"
git config --global user.name "Composio"
npm version ${{ github.event.inputs.version }} --no-git-tag-version


- name: Commit and push
run: |
if git diff --quiet; then
echo "No changes to commit"
else
git commit -am "Release ${{ github.event.inputs.version }}" && git push
fi

- name: pnpm build
run: pnpm build

Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "composio-core",
"version": "0.3.2",
"version": "0.4.0-beta",
"description": "",
"main": "dist/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion js/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ACTIONS = {
// actions list end here
};

const COMPOSIO_VERSION = `0.3.0`;
const COMPOSIO_VERSION = `0.4.0-beta`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to see version alignment between package.json and constants.js. Consider implementing a single source of truth for version numbers to prevent future mismatches. This could be done through a version management script or using package.json as the primary source.


module.exports = {
APPS,
Expand Down
2 changes: 1 addition & 1 deletion js/src/sdk/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class Composio {
}

logger.info(
`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}, Log level: ${loggingLevel.toUpperCase()}`
`Initializing Composio w API Key: [REDACTED] and baseURL: ${baseURLParsed}`
);

// Initialize the BackendClient with the parsed API key and base URL.
Expand Down
7 changes: 4 additions & 3 deletions js/src/sdk/utils/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ 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
Expand Down
6 changes: 6 additions & 0 deletions js/src/sdk/utils/errors/src/composioError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export class ComposioError extends Error {
}
}

console.log(`🚀 [Info] Give Feedback / Get Help: https://dub.composio.dev/discord `);
console.log(`🐛 [Info] Create a new issue: https://github.com/ComposioHQ/composio/issues `);
if(getLogLevel() !== "debug"){
console.log(`⛔ [Info] If you need to debug this error, set env variable COMPOSIO_LOGGING_LEVEL=debug`);
}

logError({
error_id: this.errorId,
error_code: this.errCode,
Expand Down
1 change: 1 addition & 0 deletions js/src/sdk/utils/errors/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
28 changes: 19 additions & 9 deletions js/src/sdk/utils/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ import { BatchProcessor } from "../base/batchProcessor";
import { getEnvVariable } from "../../../utils/shared";

export class TELEMETRY_LOGGER {
private static batchProcessor = new BatchProcessor(
1000,
100,
async (data) => {
await TELEMETRY_LOGGER.sendTelemetry(data as Record<string, unknown>[]);
}
);
private static batchProcessor = new BatchProcessor(100, 10, async (data) => {
await TELEMETRY_LOGGER.sendTelemetry(data as Record<string, unknown>[]);
});

private static createTelemetryWrapper(method: Function, className: string) {
return async (...args: unknown[]) => {
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);
Expand Down Expand Up @@ -61,7 +64,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);
}
Expand Down
Loading