Quickstart
You'll connect your repository, 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. Connecting the repository also starts repository scanning for vulnerable packages, secrets and outdated packages. 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://api.bugstack.ai/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://api.bugstack.ai/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 then works on the fix. It reads the files named in the stack trace, works out the cause, and writes the change. A fix over 3 files or 30 changed lines always waits for your review.
The change arrives as a pull request on your GitHub repo with a description of the root cause and the change. Your CI runs on it. New accounts start at the review level, so you review and merge. You can change the autonomy level per repository later.
Crashes are not the only thing bugstack watches. Connecting the repository also starts repository scanning: vulnerable packages every four hours, secrets nightly, outdated packages daily. For the full breakdown, see How it works.
Next steps
Hand off the upkeep
Connect your repo, install the SDK, and choose how much bugstack does without asking.