healcode-client
v1.0.10
Published
HealCode - Automatic error detection and fix generation for your frontend projects
Maintainers
Readme
@healcode/client
🩺 HealCode - Automatic error detection and fix generation for your frontend projects.
Installation
npm install @healcode/clientQuick Start
1. Initialize in your project
npx healcode initThis will prompt you for your HealCode token and create a healcode.config.json file.
2. Import in your app
// main.ts or index.js
import { initFromConfig } from '@healcode/client';
initFromConfig();Or with manual configuration:
import { HealCode } from '@healcode/client';
const healcode = new HealCode({
token: 'hc_your_token_here',
endpoint: 'https://api.healcode.io', // optional
enabled: true,
captureConsoleErrors: true,
captureUnhandledRejections: true,
maxBreadcrumbs: 20,
});Features
- 🔍 Automatic Error Capture - Catches window errors, console.error, and unhandled rejections
- 🍞 Breadcrumbs - Tracks user interactions leading up to errors
- 🔧 Auto-Fix - Generates and creates PRs with fixes automatically
- 🔒 Secure - Your repository tokens are encrypted
- 📊 Dashboard - View all errors and fixes at healcode.io
CLI Commands
npx healcode init # Initialize HealCode in your project
npx healcode status # Check configuration status
npx healcode enable # Enable error tracking
npx healcode disable # Disable error trackingManual Error Capture
import { captureError, addBreadcrumb } from '@healcode/client';
// Add custom breadcrumb
addBreadcrumb('user.action', 'User clicked checkout button', { cartItems: 3 });
// Manually capture an error
try {
riskyOperation();
} catch (error) {
captureError(error.message, error.stack);
}Configuration Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| token | string | required | Your HealCode integration token |
| endpoint | string | https://api.healcode.io | API endpoint |
| enabled | boolean | true | Enable/disable tracking |
| captureConsoleErrors | boolean | true | Capture console.error calls |
| captureUnhandledRejections | boolean | true | Capture unhandled promise rejections |
| maxBreadcrumbs | number | 20 | Maximum breadcrumbs to store |
| beforeSend | function | - | Modify or filter errors before sending |
beforeSend Hook
const healcode = new HealCode({
token: 'hc_...',
beforeSend: (payload) => {
// Filter out specific errors
if (payload.message.includes('ResizeObserver')) {
return null; // Don't send
}
// Modify payload
payload.message = payload.message.replace(/secret/gi, '[REDACTED]');
return payload;
},
});License
MIT
