stats

package
v0.16.521 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package stats answers the usage statistics pages (/api/stats/*) from this machine's Claude Code and Codex files, as the previous runtime's handlers did: the same answers, the same cache files under the data folder, each transcript read again only once it changes.

Index

Constants

This section is empty.

Variables

View Source
var DefaultCwdRewrites = []Rewrite{{"Workspace/github.com/", ""}, {"Documents/", "docs/"}}

DefaultCwdRewrites are the old runtime's: GitHub checkouts under Workspace/ lose the host, Documents/ becomes docs/.

View Source
var Shadowable = []string{"aggregated", "cache-status", "facets", "history", "overview", "projects", "sessions", "uptime", "daily-report/list"}

Shadowable are the routes of Routes that only read (a shadow may run them next to the old runtime).

Functions

This section is empty.

Types

type Rewrite

type Rewrite struct{ Prefix, To string }

Rewrite replaces a leading Prefix of a project folder with To.

func ParseCwdRewrites

func ParseCwdRewrites(s string) []Rewrite

ParseCwdRewrites reads extra rewrites as "prefix=to" pairs separated by commas (an environment value), after the defaults.

type Route

type Route struct {
	// Home is the person's home: the old handlers read ~/.claude and ~/.codex there whatever CLAUDE_CONFIG_DIR or
	// CODEX_HOME said, and shortened project folders under it.
	Home string
	// ClaudeDir and CodexDir default to Home/.claude and Home/.codex.
	ClaudeDir, CodexDir string
	// DataDir holds stats/cache.json, stats/uptime-cache.json and stats/daily-reports.
	DataDir string
	// ConfigFile is the runtime's config.json (noteSummaryProvider picks the daily report's CLI).
	ConfigFile string
	// Authorized is the old dispatcher's check: a page session or the cli-token.
	Authorized func(*http.Request) bool
	// CwdRewrites shorten a project folder (relative to Home) after the home is cut: each prefix in order, applied to
	// what the previous left. The old runtime's own are DefaultCwdRewrites.
	CwdRewrites []Rewrite
	// ShellPath is the PATH the daily report's CLI runs with (the person's login shell's); nil is this process's.
	ShellPath func() string
	// CLITimeout bounds the daily report's CLI run (120 s when 0).
	CLITimeout time.Duration
	// Now is the clock (tests freeze it); nil is the real one.
	Now func() time.Time
	// contains filtered or unexported fields
}

Route answers the routes under /api/stats/.

func (*Route) Aggregated

func (rt *Route) Aggregated(r *http.Request) (int, any, http.Header)

Aggregated answers GET /api/stats/aggregated?period=.

func (*Route) CacheStatus

func (rt *Route) CacheStatus(r *http.Request) (int, any, http.Header)

CacheStatus answers GET /api/stats/cache-status.

func (*Route) DailyReportGenerate

func (rt *Route) DailyReportGenerate(r *http.Request) (int, any, http.Header)

DailyReportGenerate answers POST /api/stats/daily-report/generate {date, force?, locale?, provider?}.

func (*Route) DailyReportList

func (rt *Route) DailyReportList(r *http.Request) (int, any, http.Header)

DailyReportList answers GET /api/stats/daily-report/list?offset=&limit=.

func (*Route) Facets

func (rt *Route) Facets(r *http.Request) (int, any, http.Header)

Facets answers GET /api/stats/facets?period=.

func (*Route) History

func (rt *Route) History(r *http.Request) (int, any, http.Header)

History answers GET /api/stats/history?period=&limit=.

func (*Route) Overview

func (rt *Route) Overview(r *http.Request) (int, any, http.Header)

Overview answers GET /api/stats/overview?period=.

func (*Route) Projects

func (rt *Route) Projects(r *http.Request) (int, any, http.Header)

Projects answers GET /api/stats/projects?period=.

func (*Route) Routes

func (rt *Route) Routes() map[string]func(*http.Request) (int, any, http.Header)

Routes are the answers by the path after /api/stats/. All are idempotent GETs except "daily-report/generate", a POST that runs a CLI and writes the report. daily-report/cache is not here: nothing calls it.

func (*Route) Sessions

func (rt *Route) Sessions(r *http.Request) (int, any, http.Header)

Sessions answers GET /api/stats/sessions?period=.

func (*Route) Uptime

func (rt *Route) Uptime(r *http.Request) (int, any, http.Header)

Uptime answers GET /api/stats/uptime.

Jump to

Keyboard shortcuts

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