Documentation
¶
Overview ¶
Package segops is the official Go SDK for SegOps behavioral segmentation.
Usage:
client := segops.New(segops.Options{
APIURL: "https://api.segops.ai",
APIKey: "sk_...",
})
defer client.Shutdown(context.Background())
client.Track(segops.Event{
UserID: "user-123",
EventType: "page_viewed",
Payload: map[string]any{"path": "/home"},
})
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client sends user events to SegOps asynchronously. All methods are safe for concurrent use.
func New ¶
New creates and starts a SegOps client with the given options. Call Shutdown when the process exits to flush remaining events.
type Context ¶
Context represents a user identity / trait update. It is translated to a context_identified event.
type Event ¶
type Event struct {
UserID string `json:"user_id"`
EventType string `json:"event_type"`
OccurredAt string `json:"occurred_at,omitempty"` // RFC3339; defaults to now
Payload map[string]any `json:"payload,omitempty"`
}
Event is a single user event in the canonical SegOps schema.
type Options ¶
type Options struct {
// APIURL is the base URL of your SegOps deployment, e.g. "https://api.segops.ai".
APIURL string
// APIKey is the API key with ingest permission (sk_…).
APIKey string
// BatchSize is the maximum number of events queued before an automatic flush. Default: 20.
BatchSize int
// FlushEvery is the periodic flush interval. Default: 5s.
FlushEvery time.Duration
// MaxRetries is the number of retry attempts on transient failures. Default: 3.
MaxRetries int
// Logger is used for error output. Defaults to the standard logger.
Logger *log.Logger
}
Options configures the SegOps client.
Click to show internal directories.
Click to hide internal directories.