types

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

types/errors.go

types/stats.go

types/validation.go

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInput   = fmt.Errorf("invalid input")
	ErrNetworkFailure = fmt.Errorf("network failure")
	ErrTimeout        = fmt.Errorf("operation timed out")
	ErrNotConnected   = fmt.Errorf("not connected")
)

Common error types

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod string

AuthMethod represents authentication methods

const (
	AuthMethodGoogle AuthMethod = "google"
	AuthMethodEmail  AuthMethod = "email"
)

func (AuthMethod) String

func (a AuthMethod) String() string

type Currency

type Currency string

Currency represents supported currencies

const (
	CurrencyUSD Currency = "USD"
	CurrencyEUR Currency = "EUR"
	CurrencyGBP Currency = "GBP"
)

func (Currency) String

func (c Currency) String() string

type Event

type Event struct {
	ID         string
	UserId     string
	Name       EventName // Using EventName type instead of string
	Properties Properties
	Timestamp  time.Time
}

Event represents a tracking event

func (*Event) Validate

func (e *Event) Validate() error

Validate validates an Event

type EventName

type EventName string

EventName represents a strongly typed event name

const (
	// User lifecycle events
	UserSignedUp EventName = "user_signed_up"
	UserLoggedIn EventName = "user_logged_in"
	FeatureUsed  EventName = "feature_used"

	// Revenue & Conversion Events
	OrderCompleted       EventName = "order_completed"
	SubscriptionStarted  EventName = "subscription_started"
	SubscriptionChanged  EventName = "subscription_changed"
	SubscriptionCanceled EventName = "subscription_canceled"
	CartViewed           EventName = "cart_viewed"
	CheckoutStarted      EventName = "checkout_started"
	CheckoutCompleted    EventName = "checkout_completed"
)

Event Types

func (EventName) IsStandardEvent

func (e EventName) IsStandardEvent() bool

IsStandardEvent checks if the event name is a known standard event

func (EventName) String

func (e EventName) String() string

String returns the string representation of the event name

type GroupInfo

type GroupInfo struct {
	UserId     string
	GroupId    string
	Properties Properties
}

GroupInfo represents a group event

func (*GroupInfo) Validate

func (g *GroupInfo) Validate() error

Validate validates a GroupInfo

type Identity

type Identity struct {
	UserId     string
	Properties Properties
}

Identity represents a user identification event

func (*Identity) Validate

func (i *Identity) Validate() error

Validate validates an Identity

type NetworkError

type NetworkError struct {
	Operation string
	Message   string
	Retries   int
}

NetworkError represents a network-related error

func (*NetworkError) Error

func (e *NetworkError) Error() string

func (*NetworkError) Is

func (e *NetworkError) Is(target error) bool

Is implements error matching for NetworkError

type PaymentMethod

type PaymentMethod string

PaymentMethod represents payment methods

const (
	PaymentMethodCard PaymentMethod = "card"
)

func (PaymentMethod) String

func (p PaymentMethod) String() string

type Product

type Product struct {
	ID       string
	Name     string
	Price    float64
	Quantity int
}

Product represents a product in a revenue event

func (*Product) Validate

func (p *Product) Validate() error

Validate validates a Product

type Properties

type Properties map[string]interface{}

Properties represents a map of property values

type Revenue

type Revenue struct {
	OrderID    string
	Amount     float64
	Currency   Currency
	Type       RevenueType // Using RevenueType instead of string
	Products   []Product
	Properties Properties
}

Revenue represents a revenue event

func (*Revenue) Validate

func (r *Revenue) Validate() error

Validate validates a Revenue

type RevenueType

type RevenueType string

Revenue type represents different types of revenue transactions

const (
	RevenueTypeSubscription RevenueType = "subscription"
	RevenueTypeOneTime      RevenueType = "one_time"
)

func (RevenueType) String

func (r RevenueType) String() string

String methods for custom types

type Stats

type Stats struct {
	EventsInQueue    int64
	EventsSent       int64
	EventsFailed     int64
	ConnectionState  string
	ConnectionUptime time.Duration
	LastFlushTime    time.Time
	LastFailureTime  time.Time
	AverageBatchSize float64

	ActiveEndpoint    string    // Current endpoint being used
	ResolvedEndpoints []string  // All available endpoints
	LastDNSResolution time.Time // Last successful DNS resolution
	DNSFailures       int64     // Number of DNS resolution failures
}

Stats represents client statistics

type TimeoutError

type TimeoutError struct {
	Operation string
	Duration  string
}

TimeoutError represents a timeout error

func (*TimeoutError) Error

func (e *TimeoutError) Error() string

func (*TimeoutError) Is

func (e *TimeoutError) Is(target error) bool

Is implements error matching for TimeoutError

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a validation error

func NewValidationError

func NewValidationError(field, message string) *ValidationError

NewValidationError creates a new validation error

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Is

func (e *ValidationError) Is(target error) bool

Is implements error matching for ValidationError

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL