Honeybadger
Integrating Honeybadger for exception monitoring, uptime checks, and check-in monitoring with minimal configuration overhead
You are an expert in integrating Honeybadger for error tracking and crash reporting. ## Key Points - Always set `revision` to the git SHA so errors link directly to the code that caused them. - Use `beforeNotify` to filter out known noise (browser extension errors, bot traffic) and scrub PII. - Leverage check-ins for every critical cron job and background worker so you are alerted on missed runs. - Keep context objects small and relevant; avoid attaching large payloads that slow down error processing. - Use Honeybadger's deploy notifications to mark deploys and compare error rates before and after. - Not setting `revision`, losing the ability to correlate errors with specific commits. - Forgetting to add `Honeybadger.errorHandler` as the last middleware in Express, causing unhandled errors to not be reported. - Setting context with sensitive data without a `beforeNotify` hook to scrub it. - Not configuring check-ins for critical background jobs and discovering failures hours late. - Uploading source maps with a `revision` that does not match the one set in `configure()`. ## Quick Example ```bash npm install @honeybadger-io/js ``` ```bash npm install @honeybadger-io/react ```
skilldb get error-tracking-services-skills/HoneybadgerFull skill: 242 linesHoneybadger — Error Tracking
You are an expert in integrating Honeybadger for error tracking and crash reporting.
Core Philosophy
Overview
Honeybadger is an error and uptime monitoring service designed for developers who want straightforward exception tracking without excessive complexity. It combines error monitoring, uptime checks, and cron job monitoring (check-ins) in one tool. It supports Ruby, Python, JavaScript, Go, Java, and other languages. Use Honeybadger when you want a focused, low-noise error tracker with built-in uptime and scheduled task monitoring.
Setup & Configuration
JavaScript Browser
npm install @honeybadger-io/js
import Honeybadger from "@honeybadger-io/js";
Honeybadger.configure({
apiKey: "YOUR_API_KEY",
environment: "production",
revision: "git-sha-here",
});
React
npm install @honeybadger-io/react
import Honeybadger from "@honeybadger-io/js";
import { HoneybadgerErrorBoundary } from "@honeybadger-io/react";
const honeybadger = Honeybadger.configure({
apiKey: "YOUR_API_KEY",
environment: "production",
revision: "git-sha-here",
});
const App = () => (
<HoneybadgerErrorBoundary honeybadger={honeybadger}>
<MyApp />
</HoneybadgerErrorBoundary>
);
Node.js
npm install @honeybadger-io/js
const Honeybadger = require("@honeybadger-io/js");
Honeybadger.configure({
apiKey: "YOUR_API_KEY",
environment: process.env.NODE_ENV,
revision: process.env.GIT_SHA,
});
Express Middleware
const express = require("express");
const Honeybadger = require("@honeybadger-io/js");
const app = express();
app.use(Honeybadger.requestHandler);
// Your routes here
app.use(Honeybadger.errorHandler);
Core Patterns
Error Capturing
// Notify of a caught error
try {
riskyOperation();
} catch (error) {
Honeybadger.notify(error);
}
// Notify with context
Honeybadger.notify(error, {
name: "PaymentError",
message: "Charge failed for order",
context: {
orderId: "abc-123",
amount: 49.99,
},
});
Context and Breadcrumbs
// Set context for all future errors
Honeybadger.setContext({
userId: "user-42",
accountTier: "premium",
});
// Reset context
Honeybadger.resetContext();
// Breadcrumbs are captured automatically for console, clicks, and network
// Add custom breadcrumbs
Honeybadger.addBreadcrumb("User started checkout", {
metadata: { cartItems: 3 },
category: "custom",
});
User Identification
Honeybadger.setContext({
user_id: "user-42",
user_email: "user@example.com",
});
Release Tracking
Set the revision config option to your git SHA or version tag. Honeybadger uses this to track which deploy introduced errors.
Source Maps
# Upload source maps via CLI
npx honeybadger-cli sourcemaps upload \
--api-key YOUR_API_KEY \
--revision $(git rev-parse HEAD) \
./dist
Or use the webpack plugin:
const HoneybadgerSourceMapPlugin = require("@honeybadger-io/webpack");
module.exports = {
devtool: "source-map",
plugins: [
new HoneybadgerSourceMapPlugin({
apiKey: "YOUR_API_KEY",
assetsUrl: "https://example.com/assets",
revision: process.env.GIT_SHA,
}),
],
};
Advanced Features
Check-Ins (Cron Monitoring)
Monitor scheduled jobs and background tasks. If a check-in is missed, Honeybadger alerts you.
// Report a check-in
const Honeybadger = require("@honeybadger-io/js");
async function dailyBackup() {
await performBackup();
Honeybadger.checkIn("your-check-in-id");
}
Uptime Monitoring
Configure uptime checks in the Honeybadger dashboard. It monitors HTTP endpoints from multiple regions and alerts you when a service goes down. No code changes needed.
Custom Fingerprinting
Honeybadger.notify(error, {
fingerprint: "custom-payment-timeout",
});
Before-Notify Hook
Honeybadger.beforeNotify((notice) => {
// Scrub sensitive data
if (notice.context && notice.context.password) {
delete notice.context.password;
}
// Return false to suppress the notification
if (notice.message.includes("ResizeObserver")) {
return false;
}
});
Best Practices
- Always set
revisionto the git SHA so errors link directly to the code that caused them. - Use
beforeNotifyto filter out known noise (browser extension errors, bot traffic) and scrub PII. - Leverage check-ins for every critical cron job and background worker so you are alerted on missed runs.
- Keep context objects small and relevant; avoid attaching large payloads that slow down error processing.
- Use Honeybadger's deploy notifications to mark deploys and compare error rates before and after.
Common Pitfalls
- Not setting
revision, losing the ability to correlate errors with specific commits. - Forgetting to add
Honeybadger.errorHandleras the last middleware in Express, causing unhandled errors to not be reported. - Setting context with sensitive data without a
beforeNotifyhook to scrub it. - Not configuring check-ins for critical background jobs and discovering failures hours late.
- Uploading source maps with a
revisionthat does not match the one set inconfigure().
Anti-Patterns
Over-engineering for hypothetical scale. Building for millions of users when you have hundreds adds complexity without value. Solve today's problems first.
Ignoring the existing ecosystem. Reinventing functionality that mature libraries already provide well wastes time and introduces unnecessary risk.
Premature abstraction. Creating elaborate frameworks and utilities before you have enough concrete cases to know what the abstraction should look like produces the wrong abstraction.
Neglecting error handling at boundaries. Internal code can trust its inputs, but system boundaries (user input, APIs, file I/O) require defensive validation.
Skipping documentation for obvious code. What is obvious to you today will not be obvious to your colleague next month or to you next year.
Install this skill directly: skilldb add error-tracking-services-skills
Related Skills
Airbrake
Integrating Airbrake for error monitoring, performance tracking, and deploy management across web and backend applications
Bugsnag
Integrating Bugsnag for application stability monitoring, error tracking, and release health across web and mobile platforms
Datadog Rum
Integrating Datadog Real User Monitoring for frontend error tracking, performance monitoring, and session replay within the Datadog observability platform
Highlight
Integrating Highlight.io for open-source session replay, error monitoring, and log management with full-stack observability
Logrocket
Integrating LogRocket for session replay, frontend error tracking, and product analytics to understand exactly what users experience
Rollbar
Integrating Rollbar for real-time error monitoring, deploy tracking, and automated error grouping across server and client applications