Skip to content

hymns/alertiqo-client-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alertiqo Go SDK

Error tracking SDK for Go applications.

Installation

go get github.com/hymns/alertiqo-go

Usage

Basic Setup

package main

import (
    "github.com/hymns/alertiqo-go"
)

func main() {
    client := alertiqo.New(alertiqo.Config{
        APIKey:      "your-api-key",
        Endpoint:    "https://alertiqo.io",
        Environment: "production",
        Release:     "1.0.0",
    })

    client.Init()

    // Your application code...
}

Capture Exceptions

err := someFunction()
if err != nil {
    client.CaptureException(err)
}

Capture Messages

client.CaptureMessage("User completed checkout", "info")

Add Breadcrumbs

client.AddBreadcrumb(
    "User clicked button",
    "user-action",
    "info",
    map[string]interface{}{"buttonId": "submit-btn"},
)

Set User Context

client.SetUser(&alertiqo.User{
    ID:       "12345",
    Email:    "user@example.com",
    Username: "johndoe",
})

Set Tags

client.SetTag("page", "checkout")
client.SetTags(map[string]string{
    "feature": "payments",
    "version": "2.1.0",
})

Recover from Panics

func handler() {
    defer client.Recover()
    
    // Code that might panic...
    panic("something went wrong")
}

HTTP Middleware

package main

import (
    "net/http"
    "github.com/hymns/alertiqo-go"
)

func main() {
    client := alertiqo.New(alertiqo.Config{
        APIKey:   "your-api-key",
        Endpoint: "https://alertiqo.io",
    })
    client.Init()

    mux := http.NewServeMux()
    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte("Hello World"))
    })

    // Wrap with middleware
    handler := client.HTTPMiddleware(mux)
    http.ListenAndServe(":8080", handler)
}

API

alertiqo.New(config)

Creates a new Alertiqo client.

Config Options:

  • APIKey (required): Your API key
  • Endpoint (required): Backend endpoint URL
  • Environment: Environment name (default: GO_ENV or "production")
  • Release: Release version
  • Tags: Default tags for all errors
  • CaptureUnhandled: Auto-capture panics (default: false)
  • BeforeSend: Callback to modify/filter errors before sending

Methods

  • Init(): Initialize error handlers
  • CaptureException(err, additionalTags...): Capture an exception
  • CaptureMessage(message, level): Capture a message
  • AddBreadcrumb(message, category, level, data): Add a breadcrumb
  • SetUser(user): Set user context
  • SetTag(key, value): Set a single tag
  • SetTags(tags): Set multiple tags
  • Recover(): Recover from panics and capture them
  • HTTPMiddleware(handler): HTTP middleware for panic recovery

License

MIT

About

Alertiqo Client for Go

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages