analytics

package
v0.40.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(claudeDir string, snap Snapshot) error

Append adds a new snapshot to the analytics log.

func LogPath

func LogPath(claudeDir string) string

LogPath returns the path to the analytics log within the given claude dir.

Types

type FilterOpts

type FilterOpts struct {
	Since   time.Duration
	Project string
}

FilterOpts controls filtering of snapshots.

type Snapshot

type Snapshot struct {
	Timestamp          time.Time      `json:"timestamp"`
	SessionID          string         `json:"session_id"`
	Project            string         `json:"project"`
	Slug               string         `json:"slug,omitempty"`
	Client             string         `json:"client,omitempty"`
	DurationHours      float64        `json:"duration_hours"`
	Turns              int            `json:"turns"`
	Compactions        int            `json:"compactions"`
	ContextPct         float64        `json:"context_pct"`
	SignalGrade        string         `json:"signal_grade"`
	SignalPct          float64        `json:"signal_pct"`
	NoiseTokens        int            `json:"noise_tokens"`
	CostTotal          float64        `json:"cost_total"`
	CostPerTurn        float64        `json:"cost_per_turn"`
	CostVelocityHr     float64        `json:"cost_velocity_hr"`
	ModelPrimary       string         `json:"model_primary"`
	Models             map[string]int `json:"models,omitempty"`
	CleanupTokensSaved int            `json:"cleanup_tokens_saved"`
	CleanupCount       int            `json:"cleanup_count"`
	TopNoise           string         `json:"top_noise,omitempty"`
}

Snapshot records a point-in-time session analytics snapshot.

func Filter

func Filter(snapshots []Snapshot, opts FilterOpts) []Snapshot

Filter returns snapshots matching the given filter options.

func Load

func Load(claudeDir string) ([]Snapshot, error)

Load reads all analytics snapshots from disk.

type Summary

type Summary struct {
	Sessions       int            `json:"sessions"`
	TotalCost      float64        `json:"total_cost"`
	AvgCost        float64        `json:"avg_cost"`
	TotalTurns     int            `json:"total_turns"`
	AvgSignalPct   float64        `json:"avg_signal_pct"`
	AvgGrade       string         `json:"avg_grade"`
	TokensSaved    int            `json:"tokens_saved"`
	CleanupCount   int            `json:"cleanup_count"`
	ModelMix       map[string]int `json:"model_mix"`
	AvgCompactions float64        `json:"avg_compactions"`
}

Summary aggregates analytics across multiple snapshots.

func Aggregate

func Aggregate(snapshots []Snapshot) *Summary

Aggregate computes summary statistics from a set of snapshots.

Jump to

Keyboard shortcuts

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