Skip to content

MasonBachmann7/Bugstack-Go

Repository files navigation

bugstack-go

Official Go SDK for BugStack — capture, report, and auto-fix production errors.

Go Reference License: MIT

Installation

go get github.com/MasonBachmann7/bugstack-go

Quick Start

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)
    }
}

Panic Recovery

func handler() {
    defer bugstack.Recover()
    // ... code that might panic
}

HTTP Middleware

net/http

import "github.com/MasonBachmann7/bugstack-go/middleware"

mux := http.NewServeMux()
mux.HandleFunc("/", handler)
http.ListenAndServe(":8080", middleware.NetHTTP(mux))

Gin

import "github.com/MasonBachmann7/bugstack-go/middleware"

r := gin.Default()
r.Use(gin.HandlerFunc(middleware.GinRecovery()))

Echo

import "github.com/MasonBachmann7/bugstack-go/middleware"

e := echo.New()
e.Use(echo.MiddlewareFunc(middleware.EchoRecover()))

Configuration

bugstack.Init(bugstack.Config{
    APIKey:              "bs_live_...",       // Required
    Environment:         "production",       // Default: "production"
    AutoFix:             true,               // Enable AI-powered auto-fix
    Debug:               false,              // Log SDK activity
    DryRun:              false,              // Log without sending
    Enabled:             true,               // Kill switch
    DeduplicationWindow: 300,                // Seconds (default: 5 min)
    Timeout:             5.0,                // HTTP timeout in seconds
    MaxRetries:          3,                  // Retry attempts
    IgnoredErrors:       []string{           // Error substrings to skip
        "context canceled",
    },
    BeforeSend: func(e *bugstack.Event) *bugstack.Event {
        // Return nil to drop, modify and return to keep
        return e
    },
})

Data Transparency

BeforeSend Hook

Inspect, modify, or drop any event before it leaves your application:

bugstack.Init(bugstack.Config{
    APIKey: "bs_live_...",
    BeforeSend: func(e *bugstack.Event) *bugstack.Event {
        if e.Request != nil && e.Request.Route == "/health" {
            return nil // Drop health check errors
        }
        delete(e.Metadata, "secret")
        return e
    },
})

DryRun Mode

See exactly what would be sent without network requests:

bugstack.Init(bugstack.Config{
    APIKey: "bs_live_...",
    DryRun: true,
})
// Prints: [BugStack DryRun] Would send: { ... }

What Gets Sent

{
  "apiKey": "bs_live_...",
  "error": {
    "message": "runtime error: index out of range",
    "stackTrace": "goroutine 1 [running]: ...",
    "file": "main.go",
    "function": "main.handler",
    "fingerprint": "a1b2c3d4e5f6g7h8"
  },
  "environment": {
    "language": "go",
    "languageVersion": "go1.22.0",
    "os": "linux",
    "sdkVersion": "1.0.0"
  },
  "timestamp": "2026-01-15T08:30:00Z"
}

Zero external dependencies. No cookies, IP addresses, or user data collected.

License

MIT — see LICENSE.

About

Lightweight sdk for bugstack! Go edition

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages