analytics

package
v0.2.3-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessLogDispatcher

type AccessLogDispatcher struct {
	// contains filtered or unexported fields
}

func NewAccessLogDispatcher

func NewAccessLogDispatcher(cfg map[string]interface{}, logger *slog.Logger) (*AccessLogDispatcher, error)

func (*AccessLogDispatcher) Close

func (a *AccessLogDispatcher) Close() error

func (*AccessLogDispatcher) Name

func (a *AccessLogDispatcher) Name() string

func (*AccessLogDispatcher) Send

func (a *AccessLogDispatcher) Send(ctx context.Context, evt Event) error

type Config

type Config struct {
	Enabled    bool
	NumWorkers int
	Providers  map[string]map[string]interface{}
}

Config represents analytics configuration

type Dispatcher

type Dispatcher interface {
	Send(context.Context, Event) error
	Name() string
	Close() error
}

Dispatcher interface that all providers must implement

type Event

type Event struct {
	Name       string
	Domain     string
	URL        string
	Referrer   string
	UserAgent  string
	UserIP     string
	RemoteAddr string
	Timestamp  string
	ShortCode  string
	TargetURL  string
}

Event represents an analytics event

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles multiple dispatchers and workers

func NewManager

func NewManager(cfg Config, logger *slog.Logger) (*Manager, error)

NewManager creates a new analytics manager

func (*Manager) Close

func (m *Manager) Close() error

Close cleans up resources

func (*Manager) Start

func (m *Manager) Start(ctx context.Context)

Start begins the worker routines

func (*Manager) Track

func (m *Manager) Track(evt Event)

Track sends an event to the analytics channel

type MatomoConfig

type MatomoConfig struct {
	TrackingURL string
	SiteID      int
	AuthToken   string
	Timeout     time.Duration
}

type MatomoDispatcher

type MatomoDispatcher struct {
	// contains filtered or unexported fields
}

func NewMatomoDispatcher

func NewMatomoDispatcher(config MatomoConfig, logger *slog.Logger) (*MatomoDispatcher, error)

func (*MatomoDispatcher) Close

func (m *MatomoDispatcher) Close() error

func (*MatomoDispatcher) Name

func (m *MatomoDispatcher) Name() string

func (*MatomoDispatcher) Send

func (m *MatomoDispatcher) Send(ctx context.Context, evt Event) error

type PlausibleConfig

type PlausibleConfig struct {
	Endpoint string
	Timeout  time.Duration
}

type PlausibleDispatcher

type PlausibleDispatcher struct {
	// contains filtered or unexported fields
}

func NewPlausibleDispatcher

func NewPlausibleDispatcher(config PlausibleConfig, logger *slog.Logger) (*PlausibleDispatcher, error)

func (*PlausibleDispatcher) Close

func (p *PlausibleDispatcher) Close() error

noop

func (*PlausibleDispatcher) Name

func (p *PlausibleDispatcher) Name() string

func (*PlausibleDispatcher) Send

func (p *PlausibleDispatcher) Send(ctx context.Context, evt Event) error

type WebhookConfig

type WebhookConfig struct {
	Endpoint string
	Timeout  time.Duration
	Headers  map[string]string
}

type WebhookDispatcher

type WebhookDispatcher struct {
	// contains filtered or unexported fields
}

func NewWebhookDispatcher

func NewWebhookDispatcher(config WebhookConfig, logger *slog.Logger) (*WebhookDispatcher, error)

func (*WebhookDispatcher) Close

func (w *WebhookDispatcher) Close() error

noop

func (*WebhookDispatcher) Name

func (w *WebhookDispatcher) Name() string

func (*WebhookDispatcher) Send

func (w *WebhookDispatcher) Send(ctx context.Context, event Event) error

Jump to

Keyboard shortcuts

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