analytics

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApproximateRegion

func ApproximateRegion(lat, lon float64) string

ApproximateRegion converts coordinates into a coarse, human-readable descriptor so summaries stay meaningful without external GeoIP data.

func ClassifyDose

func ClassifyDose(markers []database.Marker) (string, float64)

ClassifyDose summarizes dose-rate observations so logs read like quick health checks instead of raw numbers.

Types

type Service

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

Service wires session tracking, event ingestion, and hourly summaries together using channels so request handlers never block on IO-heavy operations.

func NewService

func NewService(db *database.Database, dbType string, logf func(string, ...any)) *Service

NewService prepares the analytics pipeline without starting it so callers can decide when to spawn goroutines.

func (*Service) Middleware

func (s *Service) Middleware(next http.Handler) http.Handler

Middleware assigns session cookies and logs high-level HTTP activity without blocking request handlers.

func (*Service) RecordEvent

func (s *Service) RecordEvent(event database.AnalyticsEvent)

RecordEvent enqueues a single analytics event, dropping it if the queue is saturated to keep the UI responsive.

func (*Service) Start

func (s *Service) Start(ctx context.Context)

Start launches the background worker that flushes events and emits summaries.

type Session

type Session struct {
	ID   string
	Name string
}

Session keeps the resolved visitor identity handy for handlers that want to attach richer details to activity events.

func SessionFromContext

func SessionFromContext(ctx context.Context) (Session, bool)

SessionFromContext exposes the resolved visitor identity to request handlers.

Jump to

Keyboard shortcuts

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