Quick Start
Core
Install the core package:
npm install @crashsense/coreyarn add @crashsense/corepnpm add @crashsense/corebun add @crashsense/coreInitialize CrashSense in your application:
import { createCrashSense } from '@crashsense/core';
const cs = createCrashSense({
appId: 'my-app',
debug: true,
onCrash: (report) => {
console.log(report.event.category); // "memory_issue"
console.log(report.event.confidence); // 0.87
console.log(report.event.contributingFactors);
},
});That's it. CrashSense is now monitoring memory, event loop, network, and capturing every crash with full system state.
React
Install the React adapter alongside core:
npm install @crashsense/core @crashsense/reactyarn add @crashsense/core @crashsense/reactpnpm add @crashsense/core @crashsense/reactbun add @crashsense/core @crashsense/reactWrap your application with CrashSenseProvider:
import { CrashSenseProvider } from '@crashsense/react';
function App() {
return (
<CrashSenseProvider
config={{ appId: 'my-app', debug: true }}
onCrash={(report) => console.log('Crash:', report)}
>
<YourApp />
</CrashSenseProvider>
);
}This automatically captures React-specific crashes: hydration mismatches, infinite re-render loops, hook ordering violations, and lifecycle errors.
Hooks
Use the useCrashSense hook for manual error capture and breadcrumbs, and useRenderTracker to detect excessive re-renders:
import { useCrashSense, useRenderTracker } from '@crashsense/react';
function Checkout() {
const { captureException, addBreadcrumb } = useCrashSense();
useRenderTracker('Checkout');
const handlePay = async () => {
addBreadcrumb({ type: 'click', message: 'User clicked pay' });
try {
await processPayment();
} catch (err) {
captureException(err, { action: 'payment' });
}
};
return <button onClick={handlePay}>Pay Now</button>;
}Vue
Install the Vue adapter alongside core:
npm install @crashsense/core @crashsense/vueyarn add @crashsense/core @crashsense/vuepnpm add @crashsense/core @crashsense/vuebun add @crashsense/core @crashsense/vueRegister the plugin with your Vue app:
import { createApp } from 'vue';
import { crashSensePlugin } from '@crashsense/vue';
const app = createApp(App);
app.use(crashSensePlugin, { appId: 'my-app', debug: true });
app.mount('#app');This catches Vue-specific crashes: reactivity loops, lifecycle errors, and component-level failures via app.config.errorHandler.
Composables
Use the useCrashSense composable for manual capture and useReactivityTracker for reactive state monitoring:
import { useCrashSense, useReactivityTracker } from '@crashsense/vue';
const { captureException, addBreadcrumb } = useCrashSense();
useReactivityTracker({
cartItems: () => store.state.cartItems,
userProfile: () => store.state.userProfile,
});AI Integration
Install the AI package:
npm install @crashsense/aiyarn add @crashsense/aipnpm add @crashsense/aibun add @crashsense/aiCreate an AI client and analyze crash events:
import { createAIClient } from '@crashsense/ai';
const ai = createAIClient({
endpoint: 'https://api.openai.com/v1/chat/completions',
apiKey: process.env.OPENAI_API_KEY!,
model: 'gpt-4',
});
const analysis = await ai.analyze(report.event);
if (analysis) {
console.log('Root cause:', analysis.rootCause);
console.log('Explanation:', analysis.explanation);
console.log('Fix:', analysis.fix?.code);
console.log('Prevention:', analysis.prevention);
}Supports OpenAI, Anthropic, Google, or any OpenAI-compatible endpoint. The AI client sends a structured, token-optimized crash payload and returns parsed, validated analysis.
TIP
All examples are in TypeScript, but CrashSense works with plain JavaScript too — just omit the type annotations.