context.Context and returns an error. The calling goroutine does about 320 ns of work (serialize, encode, enqueue) and never touches the network.
Installation
Quick start
collect.tell.rs:50000, batches up to 100 events, and flushes every 10 seconds or when you call Close.
Configuration
Use one of the two presets, or pass a customConfig struct.
NewClient returns an error if it’s invalid.
Tracking events
Every tracking method takescontext.Context and userID as its first parameters. Properties are tell.Properties (map[string]interface{}) or nil.
nil instead of tell.Properties{} when you don’t need properties:
Standard event names
The SDK provides constants for common events:Super properties
Register properties that get merged into everyTrack, Group, and Revenue call:
Structured logging
Send logs alongside events through the same pipeline. Each log has an RFC 5424 severity level.service parameter is *string — use tell.Ptr("myservice") to pass a value, or nil to default to "app". Convenience methods are available for all nine levels: LogEmergency, LogAlert, LogCritical, LogError, LogWarning, LogNotice, LogInfo, LogDebug, and LogTrace.
For full control, use the Log method with a LogEntry struct:
Properties
tell.Properties is map[string]interface{}. Supported value types:
stringint,int32,int64,float32,float64booltime.Time[]interface{}(arrays)map[string]interface{}(nested objects)nil
Lifecycle
Close before your process exits to avoid losing buffered events. Use defer client.Close(ctx) right after creating the client.
Goroutine safety
The client is safe to share across goroutines:Error handling
Constructor errors are returned directly:OnError callback:
Advanced
Configuration reference
| Parameter | Default (production) | Default (development) | Description |
|---|---|---|---|
Endpoint | collect.tell.rs:50000 | localhost:50000 | TCP collector address |
BatchSize | 100 | 10 | Events per batch before auto-flush |
FlushInterval | 10s | 2s | Time between auto-flushes |
MaxRetries | 3 | 3 | Retry attempts on send failure |
CloseTimeout | 5s | 5s | Max wait on Close |
NetworkTimeout | 30s | 30s | TCP connect timeout |
OnError | silent | silent | Error callback |
Validation rules
| Field | Rule |
|---|---|
| API key | 32-character hex string |
| UserID | Non-empty |
| Event name | Non-empty |
| GroupID | Non-empty |
| Revenue amount | Positive number |
| Currency | Non-empty |
| OrderID | Non-empty |
| Log message or data | At least one required |
Performance
Caller latency — serialize, encode, and enqueue (Apple M4 Pro):| Operation | ns/op | allocs/op |
|---|---|---|
Track (no props) | 320 | 2 |
Track (2 props) | 494 | 2 |
Track (14 props) | 1,061 | 2 |
Identify | 511 | 2 |
Revenue | 554 | 3 |
Log (with data) | 421 | 3 |
| Batch size | events/sec |
|---|---|
| 10 | 1.2M/s |
| 100 | 1.9M/s |
| 500 | 2.2M/s |