scout-error
v0.2.8
Published
Lightweight error tracking for JavaScript applications
Maintainers
Readme
scout-error
Lightweight error tracking for JavaScript applications. Works with any framework or vanilla JS, plus Node.js backends.
Install
npm install scout-errorBrowser (Vanilla)
import { init } from 'scout-error'
init({
app: 'My App',
project: 'my-project',
version: '1.0.0',
}, {
endpoint: 'https://your-scout-instance.com/errors',
})Vue.js
import { init } from 'scout-error'
import { ScoutVue } from 'scout-error/vue'
init({
app: 'My App',
project: 'my-project',
version: '1.0.0',
}, {
endpoint: 'https://your-scout-instance.com/errors',
})
const app = createApp(App)
app.use(ScoutVue) // Captures Vue component errors and warnings
app.mount('#app')React
import { init } from 'scout-error'
import { ScoutErrorBoundary } from 'scout-error/react'
init({
app: 'My App',
project: 'my-project',
version: '1.0.0',
}, {
endpoint: 'https://your-scout-instance.com/errors',
})
<ScoutErrorBoundary fallback={<p>Something went wrong</p>}>
<App />
</ScoutErrorBoundary>Node.js + Express
import { initTracker, errorHandlingMiddleware } from 'scout-error/node'
initTracker({
environment: 'production',
project: 'my-backend',
release: '1.0.0',
}, {
endpoint: 'https://your-scout-instance.com/errors',
})
// Add as last middleware
app.use(errorHandlingMiddleware)Configuration
Options passed as the second argument to init() / initTracker():
| Option | Default | Description |
|---|---|---|
| endpoint | '' | URL to send errors to |
| sampleRate | 1.0 | Fraction of errors to capture (0.0 - 1.0) |
| debug | false | Log captured errors to console |
| ignoreErrors | null | Array of string/regex patterns to ignore |
| sendErrors | true | Enable/disable sending |
Manual Capture
import { captureError } from 'scout-error'
try {
riskyOperation()
} catch (err) {
captureError({
message: err.message,
stack: err.stack,
type: 'manual',
})
}License
MIT
