Documentation
¶
Overview ¶
Package analytics records and reports local concept retrieval events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConceptLoad ¶
type ConceptLoad struct {
OccurredAt time.Time
BatchID string
ConceptID string
EntryPoint EntryPoint
}
ConceptLoad is one successfully rendered concept retrieval event.
func NewBatch ¶
func NewBatch(entryPoint EntryPoint, conceptIDs []string) ([]ConceptLoad, error)
NewBatch creates one timestamped, deduplicated batch of concept loads.
type ConceptUsage ¶
ConceptUsage contains one concept's retrieval count.
type EntryPoint ¶
type EntryPoint string
EntryPoint identifies the command that returned a concept body.
const ( EntryPointShow EntryPoint = "show" EntryPointContext EntryPoint = "context" )
type Reader ¶
type Reader interface {
Report(context.Context, ReportOptions) (Report, error)
}
Reader produces aggregate analytics reports.
type Recorder ¶
type Recorder interface {
RecordConceptLoads(context.Context, []ConceptLoad) error
}
Recorder persists concept retrieval events.
type Report ¶
type Report struct {
Enabled bool
Provider Provider
Since *time.Time
ConceptLoads int
RetrievalBatches int
AverageConceptsPerBatch float64
EntryPoints map[EntryPoint]int
TopConcepts []ConceptUsage
RecentBatches []RetrievalBatch
}
Report contains aggregate concept usage and retrieval batches.
type ReportOptions ¶
ReportOptions controls analytics report filtering and result limits.
type RetrievalBatch ¶
type RetrievalBatch struct {
BatchID string
OccurredAt time.Time
EntryPoint EntryPoint
ConceptIDs []string
}
RetrievalBatch groups concepts returned by one retrieval invocation.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service isolates analytics persistence from retrieval commands.
func New ¶
New creates a lazy analytics service. Provider initialization is deferred until recording or reporting so unrelated commands do not create storage.
func (*Service) RecordConceptLoads ¶
func (service *Service) RecordConceptLoads(ctx context.Context, loads []ConceptLoad) error
RecordConceptLoads records events when analytics is enabled.