Go SDK
Server-side tracking for Go. Events are queued, batched, and delivered asynchronously to
/v1/batch with your write key.
Installation
Section titled “Installation”go get github.com/QubelyLabs/origamy-go-sdkBasic usage
Section titled “Basic usage”package main
import ( "os"
origamy "github.com/QubelyLabs/origamy-go-sdk")
func main() { client := origamy.New(os.Getenv("ORIGAMY_WRITE_KEY"), origamy.WithEndpoint("https://events.origamy.io"), ) defer client.Close()
client.Enqueue(origamy.Track{ UserId: "user-123", Event: "Signed Up", })}Message types
Section titled “Message types”The message types mirror the event spec:
// Track an actionclient.Enqueue(origamy.Track{ UserId: "user-123", Event: "Order Completed", Properties: origamy.NewProperties(). Set("orderId", "ORD-9999"). SetRevenue(99.99). SetCurrency("USD"),})
// Identify a user with traitsclient.Enqueue(origamy.Identify{ UserId: "user-123", Traits: origamy.NewTraits(). SetName("Alice Smith"). Set("plan", "pro"),})
// Track a page viewclient.Enqueue(origamy.Page{ UserId: "user-123", Name: "Pricing", Properties: origamy.Properties{ "url": "https://example.com/pricing", "title": "Pricing Plans", },})
// Associate a user with a group/companyclient.Enqueue(origamy.Group{ UserId: "user-123", GroupId: "company-acme", Traits: origamy.NewTraits().SetName("Acme Corp"),})
// Alias an anonymous ID to an identified userclient.Enqueue(origamy.Alias{ UserId: "user-123", PreviousId: "anon-session-abc",})For anonymous tracking, pass AnonymousId instead of (or alongside) UserId.
Configuration
Section titled “Configuration”Functional options on New:
client := origamy.New("your-write-key", origamy.WithEndpoint("https://events.origamy.io"), origamy.WithBatchSize(100), origamy.WithInterval(10*time.Second), origamy.WithVerbose(true),)Or full configuration with NewWithConfig:
client, err := origamy.NewWithConfig("your-write-key", origamy.Config{ Endpoint: "https://events.origamy.io", Interval: 30 * time.Second, BatchSize: 250, Verbose: true, Logger: origamy.StdLogger(log.New(os.Stderr, "origamy ", log.LstdFlags)), QueueCapacity: 500,})Development mode
Section titled “Development mode”Use the noop dispatcher to log events to the console instead of sending them:
client := origamy.New("your-write-key", origamy.WithDispatcher(origamy.NewNoopDispatcher(origamy.DispatcherConfig{ Verbose: true, })),)Custom queue and transport
Section titled “Custom queue and transport”Swap the in-memory queue or the HTTP transport entirely:
// Bounded queueclient := origamy.New("your-write-key", origamy.WithQueue(origamy.NewChannelQueue( origamy.QueueWithCapacity(1000), )),)
// Custom transport — implement the Dispatcher interfacetype Dispatcher interface { io.Closer Send(payload []byte) error}Wire format
Section titled “Wire format”Batches post to POST /v1/batch using the same payload as every Origamy SDK — events carry
per-event context with library: {name: "origamy-go", version}, and requests authenticate
with HTTP Basic auth (write key as username, empty password). See the
Ingestion API for endpoints, limits, and response codes.
