Go SDK

traceiq for Go 1.22+ — standard library only, with a background goroutine that batches events. Request handlers never wait on the network.

bash
go get github.com/enigma-137/trace-iq/sdks/go
go
package main

import (
  "context"
  "log"

  traceiq "github.com/enigma-137/trace-iq/sdks/go"
)

func main() {
  client, err := traceiq.New(
    "YOUR_PROJECT_ID",
    "YOUR_WRITE_KEY", // keep server write keys secret
    traceiq.WithEndpoint("https://api.traceiq.run"),
  )
  if err != nil {
    log.Fatal(err)
  }
  defer client.Shutdown(context.Background())

  ctx := context.Background()
  _ = client.Capture(ctx, traceiq.Event{
    Name:       "payout_succeeded",
    UserID:     "user_123",
    Properties: map[string]any{"amount": 50000, "currency": "NGN"},
  })
  _ = client.Identify(ctx, "user_123", map[string]any{"kyc_tier": 2})
}

net/http servers

Pass the request context to Capture and CaptureError, then call Shutdown after the HTTP server stops so queued events flush.

go
mux.HandleFunc("POST /checkout", func(w http.ResponseWriter, r *http.Request) {
  if err := checkout(r.Context()); err != nil {
    _ = client.CaptureError(r.Context(), err, traceiq.ErrorOptions{
      UserID: "user_123",
    })
    http.Error(w, "checkout failed", http.StatusInternalServerError)
    return
  }
  _ = client.Capture(r.Context(), traceiq.Event{
    Name:   "checkout_completed",
    UserID: "user_123",
  })
  w.WriteHeader(http.StatusNoContent)
})

The same pattern works with chi, gorilla/mux, Gin, Echo, and Fiber. Keep the write key in an environment variable and call Shutdown before the process exits.