Set Up Bugsly for Express
Monitor Express.js applications with automatic request handling, middleware error capture, and route-level performance tracing.
1. Install the SDK
npm install @bugsly/node @bugsly/profiling-node2. Configure Bugsly
Add the following to your application entry point. Replace the DSN with your project DSN from the Bugsly dashboard.
import * as Bugsly from "@bugsly/node";
import express from "express";
// Initialize before any other imports
Bugsly.init({
dsn: "https://your-dsn@bugsly.dev/1",
environment: "production",
tracesSampleRate: 1.0,
});
const app = express();
// Bugsly request handler (must be first middleware)
app.use(Bugsly.Handlers.requestHandler());
app.use(Bugsly.Handlers.tracingHandler());
app.get("/", (req, res) => {
res.json({ status: "ok" });
});
// Bugsly error handler (must be before other error handlers)
app.use(Bugsly.Handlers.errorHandler());
app.listen(3000);3. Verify It Works
Trigger a test error in your application and check your Bugsly dashboard. You should see the error appear within seconds, complete with stack trace, breadcrumbs, and AI-powered analysis.
What You Get with Express
- Automatic Express middleware and route instrumentation
- Request context attached to every error (URL, method, headers)
- Route-level performance tracing
- Middleware error chain capture
- Automatic user context from req.user
- Compatible with Express 4.x and 5.x
Frequently Asked Questions
How do I set up Bugsly error handling in Express?
Add Bugsly.Handlers.requestHandler() as the first middleware and Bugsly.Handlers.errorHandler() before your other error handlers. This captures all unhandled errors with full request context.
Does Bugsly track Express route performance?
Yes. The tracingHandler middleware creates performance spans for each request, including middleware execution time, database queries, and external HTTP calls.
Can I use Bugsly with Express and TypeScript?
Yes. @bugsly/node includes TypeScript definitions out of the box. All handler types and configuration options are fully typed.
Start tracking errors in Express for free
Get AI-powered error analysis, session replay, and performance monitoring — included free on every plan.
Start Free