Quickstart
You'll install the SDK, initialize it with your API key, trigger or wait for a runtime error, and watch bugstack open a pull request on your repo. Pick your stack below.
1. Get your API key
- Sign up at dashboard.bugstack.ai with your GitHub account.
- Create a project and link the repository you want bugstack to monitor.
- Copy the API key from the project settings and set it as an environment variable:
export BUGSTACK_API_KEY="bs_live_..."
2. Install and initialize
Pick the tab that matches your stack. Each example shows the minimal setup needed to start capturing errors.
JavaScript / TypeScript
Install
npm install bugstack-sdk
Initialize
// lib/bugstack.ts
import { ErrorCaptureClient } from "bugstack-sdk";
ErrorCaptureClient.init({
apiKey: process.env.BUGSTACK_API_KEY!,
endpoint: "https://bugstack-error-service.onrender.com/api/capture",
});
Next.js — wrap a server action
import { withErrorCapture } from "bugstack-sdk";
async function createUser(formData: FormData) {
"use server";
const name = formData.get("name") as string;
// If this throws, bugstack captures it and opens a PR
await db.user.create({ data: { name } });
}
export const createUserAction = withErrorCapture(createUser);
Express — error-handler middleware
import express from "express";
import { ErrorCaptureClient } from "bugstack-sdk";
const app = express();
ErrorCaptureClient.init({
apiKey: process.env.BUGSTACK_API_KEY!,
endpoint: "https://bugstack-error-service.onrender.com/api/capture",
});
// ... your routes ...
// Add as the last middleware
app.use((err, req, res, next) => {
ErrorCaptureClient.captureError(err);
res.status(500).json({ error: "Internal server error" });
});
Python
Install
pip install bugstack
Basic usage
import bugstack
bugstack.init(api_key="bs_live_...")
try:
risky_operation()
except Exception as e:
bugstack.capture_exception(e)
FastAPI middleware
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
import bugstack
bugstack.init(api_key="bs_live_...")
app = FastAPI()
@app.exception_handler(Exception)
async def bugstack_handler(request: Request, exc: Exception):
bugstack.capture_exception(exc)
return JSONResponse(
status_code=500,
content={"detail": "Internal server error"},
)
Ruby
Install
gem install bugstack
Basic usage
require "bugstack"
Bugstack.init(api_key: "bs_live_...")
begin
risky_operation
rescue => e
Bugstack.capture_exception(e)
end
Rails initializer
# config/initializers/bugstack.rb
require "bugstack"
Bugstack.init(api_key: ENV["BUGSTACK_API_KEY"])
Rails.application.config.middleware.use(Bugstack::RailsMiddleware)
Go
Install
go get github.com/MasonBachmann7/bugstack-go
Basic usage
package main
import (
"errors"
bugstack "github.com/MasonBachmann7/bugstack-go"
)
func main() {
bugstack.Init(bugstack.Config{APIKey: "bs_live_..."})
defer bugstack.Flush()
err := riskyOperation()
if err != nil {
bugstack.CaptureError(err)
}
}
net/http middleware
package main
import (
"net/http"
bugstack "github.com/MasonBachmann7/bugstack-go"
)
func main() {
bugstack.Init(bugstack.Config{APIKey: "bs_live_..."})
defer bugstack.Flush()
mux := http.NewServeMux()
mux.HandleFunc("/", homeHandler)
// Wrap the mux with bugstack's recovery middleware
wrapped := bugstack.HTTPMiddleware(mux)
http.ListenAndServe(":8080", wrapped)
}
3. What happens next
When a runtime error fires in your application, the bugstack SDK sends a structured error payload — stack trace, request context, environment metadata — to the bugstack ingestion service. The payload is deduplicated against recent events so you never get flooded with duplicate issues for the same root cause.
bugstack's triage engine assigns severity, groups the error with related events, and determines whether an automated fix is viable. If the error maps to a pattern the system has high confidence it can resolve, it moves to the fix pipeline.
The fix pipeline clones your repository at the exact commit that produced the error, builds full context from the file tree and dependency graph, and generates a surgical code change. It runs your test suite against the patch, adds edge-case tests when needed, and validates that no other components regress.
Once the fix passes all checks, bugstack opens a pull request on your GitHub repo with a clear description of the root cause, the change, and the test results. If your CI pipeline is green, you can merge immediately — or configure bugstack to auto-merge when confidence is high. For the full pipeline breakdown, see How it works.
Next steps
Start shipping fixes
Connect your repo, install the SDK, and let bugstack handle production errors automatically.