Fundebug JavaScript Error Monitoring
raw JSON →Fundebug-javascript is a client-side library designed for real-time error monitoring of JavaScript applications, enabling developers to quickly detect and diagnose issues impacting user experience. The current stable version is 2.8.8, last published in March 2023. While its core functionality has been stable, updates have historically addressed browser compatibility, added new features like performance metrics, and improved TypeScript support. Key differentiators include automatic capture of various frontend errors (JavaScript execution, resource loading, HTTP requests), support for Source Map restoration, recording of user behavior (clicks, HTTP requests, page navigation, console logs), and a 'screen recording' feature to visually re-create error scenarios, aiding rapid debugging and issue reproduction. It's primarily used for web and frontend applications, with companion libraries for specific frameworks like Vue.js and environments like WeChat Mini Programs.
Common errors
error ReferenceError: fundebug is not defined ↓
import * as fundebug from 'fundebug-javascript'; for ESM) and that the script is loaded before any calls to fundebug functions. For older browsers, ensure the CDN script tag is placed appropriately. error TypeError: fundebug.init is not a function ↓
fundebug-javascript to version 2.0.0 or higher. Verify your import statement: import * as fundebug from 'fundebug-javascript'; is recommended. If using a CDN, ensure you're referencing a modern version of the script. error Fundebug: api key is not configured. ↓
fundebug.init({ apikey: 'YOUR_APIKEY' }) with a valid API key obtained from your Fundebug account. Ensure the key is a string and that there are no typos. Warnings
breaking Version 2.0.0 introduced `fundebug.init()` as the primary configuration method, providing better type safety and extensibility. While direct property assignments (e.g., `fundebug.apikey = '...'`) might still function in CommonJS environments, migrating to `fundebug.init()` is crucial for full TypeScript compatibility and recommended for all new projects and upgrades. ↓
gotcha Fundebug-javascript is designed for browser-side error monitoring. Embedding your API key directly in client-side code exposes it publicly. Consider using environment variables during build time or a backend proxy to securely manage and inject the API key, especially in production environments. ↓
gotcha Error monitoring tools, including Fundebug, can collect sensitive user data from error contexts. Features like `setHttpBody` (v1.3.0) and `monitorHttpBody`/`monitorHttpResponse` (v2.8.4) can capture HTTP request/response bodies, which may contain personally identifiable information (PII) or other sensitive data. These options are typically opt-in. ↓
gotcha Mixing CommonJS `require()` and ES Modules `import` in the same project, especially for packages that primarily target one module system, can lead to interoperability issues (e.g., `ERR_REQUIRE_ESM`). Although `fundebug-javascript` has types and can be imported as ESM, its original README shows `require`, suggesting a CommonJS primary export. ↓
Install
npm install fundebug-javascript yarn add fundebug-javascript pnpm add fundebug-javascript Imports
- fundebug wrong
const fundebug = require('fundebug-javascript');correctimport * as fundebug from 'fundebug-javascript'; - fundebug.init wrong
fundebug.apikey = 'YOUR_APIKEY';correctfundebug.init({ apikey: 'YOUR_APIKEY' }); - FundebugEvent
import type { FundebugEvent } from 'fundebug-javascript';
Quickstart
import * as fundebug from 'fundebug-javascript';
const FUNDEBUG_API_KEY = process.env.FUNDEBUG_API_KEY ?? '';
// Initialize Fundebug with your API key and other optional configurations
fundebug.init({
apikey: FUNDEBUG_API_KEY,
metaData: { // Example of custom metadata
user: { id: 'user-123', name: 'John Doe' },
appVersion: '1.0.0'
},
// Opt-in to monitor HTTP request bodies for detailed debugging
monitorHttpBody: true, // Introduced in v2.8.4
// To silently ignore performance data on errors
silentPerformance: false // Introduced in v1.5.0
});
console.log('Fundebug initialized. Try triggering an error...');
// Simulate a JavaScript error
document.addEventListener('DOMContentLoaded', () => {
const btn = document.createElement('button');
btn.textContent = 'Trigger Error';
document.body.appendChild(btn);
btn.onclick = () => {
throw new Error('This is a simulated error from Fundebug quickstart!');
};
});
// Manually report an error
try {
// Some risky operation
const data: any = null;
data.property.doSomething();
} catch (error: any) {
fundebug.notifyError(error, { customInfo: 'Caught error in try-catch block' });
}