SDKs
Go
Server-side capture and flags for Go 1.21+, standard library only, never panics.
go get github.com/atrixdigital/atrix-analytics/sdks/goQuickstart
package main
import (
"context"
"os"
"time"
atrix "github.com/atrixdigital/atrix-analytics/sdks/go"
)
func main() {
client := atrix.New(os.Getenv("ATRIX_PUBLIC_KEY"), atrix.Config{})
defer func() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
client.Close(ctx) // flushes what is queued, then turns the client off
}()
// Money is integer minor units plus an ISO 4217 currency: AED 19.99 → 1999.
client.Capture(atrix.Event{
DistinctID: "user_42",
Event: "order_completed",
Properties: map[string]any{"amount": 1999, "currency": "AED"},
Groups: map[string]string{"company": "acme"},
})
// Stateless identify: sets person properties and, with AnonID (the browser SDK's anonymous id,
// forwarded by your frontend), links the visitor's pre-login events to the user.
client.Identify(atrix.Identify{DistinctID: "user_42", AnonID: "0190f2a4-5b6c-7d8e-9f01-23456789abcd", Set: map[string]any{"plan": "pro"}})
client.GroupIdentify(atrix.GroupIdentify{Type: "company", Key: "acme", Properties: map[string]any{"name": "Acme"}})
client.SetRevenueCustomer(atrix.RevenueCustomer{DistinctID: "user_42", CustomerID: "cus_Nffrfeu", Provider: atrix.RevenueProviderStripe})
}The public key picks the capture host, for example https://eu.i.analytics.atrix.dev. Set Config.Host to
send through your own proxy. A missing or invalid key gives a client that does nothing.
Feature flags
client := atrix.New(os.Getenv("ATRIX_KEY"), atrix.Config{FlagsSecretKey: os.Getenv("ATRIX_FLAGS_SECRET")})
on, ok := client.IsFeatureEnabled(ctx, "new-checkout", "user_42", atrix.FlagOptions{PersonProperties: map[string]any{"plan": "pro"}})
variant, _ := client.GetFeatureFlag(ctx, "pricing", "user_42", atrix.FlagOptions{}) // "test" | "control" | false
payload, _ := client.GetFeatureFlagPayload(ctx, "pricing", "user_42", atrix.FlagOptions{})
all := client.GetAllFlags(ctx, "user_42", atrix.FlagOptions{})With FlagsSecretKey, flags are evaluated locally from /flags/definitions (ETag, 30 s poll) and only
inconclusive flags call /flags. ok is false when a flag is unknown. Reads emit $feature_flag_called.
Config
| Field | Default |
|---|---|
Host | from the key |
FlushAt / FlushInterval | 20 / 30 s |
MaxBatchSize | 100 |
MaxQueueSize / MaxQueueBytes | 1000 / 5 MB |
RequestTimeout | 10 s |
Consent | ConsentGranted (ConsentPending holds, ConsentDenied discards) |
BeforeSend, PropertyDenylist | Edit or drop events; strip keys. BeforeSend must not call the client. |
FlagsSecretKey | Local flag evaluation |
Logger | silent |
HTTPClient, Transport, Clock, Random | stdlib; override for proxies and tests |
Always Close the client before exit. Close with a context that has already expired closes without flushing.