-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add PostHog error monitoring for CLI executions #156
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
Conversation
- Implement error reporter module with PostHog client - Configure for short-running CLI tools (immediate flush, no batching) - Integrate error reporting in bin/run.js with proper shutdown - Add environment variable configuration (POSTHOG_API_KEY, POSTHOG_HOST) - Include error context (command, Node version, platform) - Add unit tests for error reporter - Graceful degradation when PostHog is not configured Resolves #55 Co-authored-by: Kfir Stri <[email protected]>
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/[email protected]Prefer not to change any import paths? Install using npm alias so your code still imports npm i "base44@npm:@base44-preview/[email protected]"Or add it to your {
"dependencies": {
"base44": "npm:@base44-preview/[email protected]"
}
}
Preview published to npm registry — try new features instantly! |
Code ReviewI've found a critical bug that will cause runtime errors. Issue: Function signature mismatch in entry point filesFiles affected:
Problem:
Current code in both files: const program = createProgram(); // ❌ Missing required CLIContext parameter
await runCLI(program); // ❌ runCLI doesn't accept parametersWhy this will fail:
Fix: await runCLI();The
|
Description
This PR implements comprehensive error monitoring and telemetry infrastructure for the CLI using PostHog. It introduces an ErrorReporter singleton that captures unhandled exceptions, controlled errors, and contextual information (command, user, app ID, agent detection). The implementation is optimized for short-running CLI tools with immediate event flushing, proper shutdown handling, and graceful degradation when telemetry is disabled via the BASE44_DISABLE_TELEMETRY environment variable.
Related Issue
Fixes #55
Type of Change
Changes Made
Testing
Checklist
Additional Notes
The error reporter requires POSTHOG_API_KEY (configured in src/cli/telemetry/consts.ts) to function. Telemetry can be disabled via BASE44_DISABLE_TELEMETRY=1 environment variable. The implementation ensures all PostHog events are flushed before CLI exit through the runCLI() shutdown sequence using process.exitCode instead of process.exit() to allow the event loop to drain. The ErrorReporter displays error details (session ID, app ID, command, CLI version) to stderr for user support and debugging. CLIExitError instances (user cancellations) are not reported to PostHog.
🤖 Generated by Claude | 2026-01-31 09:33 UTC