Application monitoring / Troubleshooting
Reporter.js is a small JavaScript library for monitoring websites and Deno applications. It sends reports for JavaScript errors, unhandled rejections, console calls, and ReportingObserver reports to your server.
- JavaScript errors
- unhandled rejections
- console calls (
error,warn,debugby default) - ReportingObserver reports, if supported by the runtime
<script>
// Load reporter.js as early as possible.
window.reporterJsOptions = {
url: 'https://example.com/errors',
max: 50,
}
</script>
<script src="https://cdn.jsdelivr.net/gh/nuxodin/reporter.js/mod.js"></script>globalThis.reporterJsOptions = {
url: 'https://example.com/reporter.php',
max: 50,
}
await import('https://cdn.jsdelivr.net/gh/nuxodin/reporter.js/mod.js');npm install @nuxodin/reporter or deno add jsr:@nuxodin/reporter, then:
globalThis.reporterJsOptions = { url: 'https://example.com/errors' };
await import('@nuxodin/reporter');Set globalThis.reporterJsOptions before loading mod.js.
globalThis.reporterJsOptions = {
url: 'https://example.com/errors',
max: 50,
showFirst: true,
console: ['error', 'warn', 'debug'],
onError(data) {
console.log(data);
},
}console.warn('test') // will be sent to the serverTo disable console reporting:
globalThis.reporterJsOptions = {
url: 'https://example.com/errors',
console: false,
}To only report selected console methods:
globalThis.reporterJsOptions = {
url: 'https://example.com/errors',
console: ['error', 'warn'],
}Reporter.js sends reports with POST and Content-Type: application/json.
Example payload:
{
"message": "Unhandled rejection in Promise: failed",
"file": "https://example.com/app.js",
"line": 12,
"col": 5,
"backtrace": [],
"prio": "error",
"referer": "https://example.com/",
"request": "https://example.com/page"
}