Documentation
¶
Index ¶
- Constants
- func DistinctID(userID *uuid.UUID, tokenID *uuid.UUID, tenantID *uuid.UUID) string
- func OrganizationIDFromContext(ctx context.Context) *uuid.UUID
- func TenantIDFromContext(ctx context.Context) *uuid.UUID
- func TokenIDFromContext(ctx context.Context) *uuid.UUID
- func UserIDFromContext(ctx context.Context) *uuid.UUID
- type Action
- type Aggregator
- type Analytics
- type FlushFunc
- type NoOpAnalytics
- func (a NoOpAnalytics) Close() error
- func (a NoOpAnalytics) Count(ctx context.Context, resource Resource, action Action, props ...Properties)
- func (a NoOpAnalytics) Enqueue(ctx context.Context, resource Resource, action Action, resourceId string, ...)
- func (a NoOpAnalytics) Group(groupType string, groupKey string, data Properties)
- func (a NoOpAnalytics) Identify(userId uuid.UUID, properties Properties)
- func (a NoOpAnalytics) Tenant(tenantId uuid.UUID, data Properties)
- type Properties
- type Resource
- type Source
Constants ¶
const ( APITokenIDKey = contextKey("api_token_id") TenantIDKey = contextKey("tenant_id") OrganizationIDKey = contextKey("organization_id") UserIDKey = contextKey("user_id") SourceKey = contextKey("source") SourceMetadataKey = "x-hatchet-source" )
Variables ¶
This section is empty.
Functions ¶
func DistinctID ¶ added in v0.79.36
func OrganizationIDFromContext ¶ added in v0.79.38
func TenantIDFromContext ¶ added in v0.79.36
Types ¶
type Action ¶ added in v0.79.36
type Action string
const ( Create Action = "create" Revoke Action = "revoke" Accept Action = "accept" Reject Action = "reject" Login Action = "login" Delete Action = "delete" Cancel Action = "cancel" Replay Action = "replay" List Action = "list" Get Action = "get" Register Action = "register" Subscribe Action = "subscribe" Listen Action = "listen" Release Action = "release" Refresh Action = "refresh" Send Action = "send" )
type Aggregator ¶ added in v0.79.36
type Aggregator struct {
// contains filtered or unexported fields
}
Aggregator batches Count calls into periodic flushes. It is intended to be embedded inside an Analytics implementation (e.g. PosthogAnalytics) so that the implementation's Count method is non-blocking and high-throughput.
func NewAggregator ¶ added in v0.79.36
func (*Aggregator) Count ¶ added in v0.79.36
func (a *Aggregator) Count(resource Resource, action Action, tenantID uuid.UUID, tokenID *uuid.UUID, n int64, props ...Properties)
Count increments the aggregated counter for the given resource/action/tenant/token and optional properties. Properties are hashed into the bucket key so that different feature combinations (e.g. priority=1 vs priority=3) are counted separately. This is the non-blocking hot path: sync.Map.Load + atomic.Add on the common case.
func (*Aggregator) Shutdown ¶ added in v0.79.36
func (a *Aggregator) Shutdown()
func (*Aggregator) Start ¶ added in v0.79.36
func (a *Aggregator) Start()
type Analytics ¶
type Analytics interface {
Enqueue(ctx context.Context, resource Resource, action Action, resourceId string, properties Properties)
Count(ctx context.Context, resource Resource, action Action, props ...Properties)
Identify(userId uuid.UUID, properties Properties)
Tenant(tenantId uuid.UUID, data Properties)
Group(groupType string, groupKey string, data Properties)
Close() error
}
type NoOpAnalytics ¶
type NoOpAnalytics struct{}
func (NoOpAnalytics) Close ¶ added in v0.79.36
func (a NoOpAnalytics) Close() error
func (NoOpAnalytics) Count ¶ added in v0.79.36
func (a NoOpAnalytics) Count(ctx context.Context, resource Resource, action Action, props ...Properties)
func (NoOpAnalytics) Enqueue ¶
func (a NoOpAnalytics) Enqueue(ctx context.Context, resource Resource, action Action, resourceId string, properties Properties)
func (NoOpAnalytics) Group ¶ added in v0.79.38
func (a NoOpAnalytics) Group(groupType string, groupKey string, data Properties)
func (NoOpAnalytics) Identify ¶ added in v0.79.36
func (a NoOpAnalytics) Identify(userId uuid.UUID, properties Properties)
func (NoOpAnalytics) Tenant ¶
func (a NoOpAnalytics) Tenant(tenantId uuid.UUID, data Properties)
type Properties ¶ added in v0.79.36
type Properties map[string]interface{}
func Props ¶ added in v0.79.36
func Props(kvs ...interface{}) Properties
Props builds a property map from variadic key-value pairs, keeping all non-nil values regardless of type. Keys must be strings; non-string keys are skipped. Nil values are omitted.
type Resource ¶ added in v0.79.36
type Resource string
const ( User Resource = "user" Invite Resource = "user-invite" Tenant Resource = "tenant" Token Resource = "api-token" Workflow Resource = "workflow" Event Resource = "event" WorkflowRun Resource = "workflow-run" TaskRun Resource = "task-run" Worker Resource = "worker" RateLimit Resource = "rate-limit" Webhook Resource = "webhook" Log Resource = "log" StreamEvent Resource = "stream-event" )