Skip to content

Go SDK

Server-side tracking for Go. Events are queued, batched, and delivered asynchronously to /v1/batch with your write key.

Terminal window
go get github.com/QubelyLabs/origamy-go-sdk
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",
})
}

The message types mirror the event spec:

// Track an action
client.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 traits
client.Enqueue(origamy.Identify{
UserId: "user-123",
Traits: origamy.NewTraits().
SetEmail("alice@example.com").
SetName("Alice Smith").
Set("plan", "pro"),
})
// Track a page view
client.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/company
client.Enqueue(origamy.Group{
UserId: "user-123",
GroupId: "company-acme",
Traits: origamy.NewTraits().SetName("Acme Corp"),
})
// Alias an anonymous ID to an identified user
client.Enqueue(origamy.Alias{
UserId: "user-123",
PreviousId: "anon-session-abc",
})

For anonymous tracking, pass AnonymousId instead of (or alongside) UserId.

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

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

Swap the in-memory queue or the HTTP transport entirely:

// Bounded queue
client := origamy.New("your-write-key",
origamy.WithQueue(origamy.NewChannelQueue(
origamy.QueueWithCapacity(1000),
)),
)
// Custom transport — implement the Dispatcher interface
type Dispatcher interface {
io.Closer
Send(payload []byte) error
}

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.