analytics

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analyzer

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

Analyzer runs analytics queries over Parquet data

func NewAnalyzer

func NewAnalyzer(cacheDir string) (*Analyzer, error)

NewAnalyzer creates a new DuckDB analyzer

func (*Analyzer) Close

func (a *Analyzer) Close() error

Close closes the DuckDB connection

func (*Analyzer) GetSummary

func (a *Analyzer) GetSummary() (*Summary, error)

GetSummary returns overall statistics

func (*Analyzer) GetTokensByDay

func (a *Analyzer) GetTokensByDay(days int) ([]DailyTokens, error)

GetTokensByDay returns token usage grouped by day

func (*Analyzer) GetTokensByModel

func (a *Analyzer) GetTokensByModel() ([]ModelStats, error)

GetTokensByModel returns token usage grouped by model

func (*Analyzer) GetTopProjects

func (a *Analyzer) GetTopProjects(limit int) ([]ProjectStats, error)

GetTopProjects returns top projects by token usage

type DailyTokens

type DailyTokens struct {
	Date         time.Time `json:"date"`
	InputTokens  int64     `json:"input_tokens"`
	OutputTokens int64     `json:"output_tokens"`
	TotalTokens  int64     `json:"total_tokens"`
	SessionCount int       `json:"session_count"`
}

TokensByDay returns token usage grouped by day

type Exporter

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

Exporter exports data to Parquet format

func NewExporter

func NewExporter(database *db.DB, outputDir string) *Exporter

NewExporter creates a new Parquet exporter

func (*Exporter) Export

func (e *Exporter) Export() error

Export exports all data to Parquet files

func (*Exporter) SetProgressCallback

func (e *Exporter) SetProgressCallback(fn func(string))

SetProgressCallback sets the progress callback

type ModelStats

type ModelStats struct {
	Model        string `json:"model"`
	SessionCount int    `json:"session_count"`
	TotalTokens  int64  `json:"total_tokens"`
}

ModelStats represents aggregated model statistics

type ProjectStats

type ProjectStats struct {
	ProjectPath  string    `json:"project_path"`
	SessionCount int       `json:"session_count"`
	TotalTokens  int64     `json:"total_tokens"`
	LastActive   time.Time `json:"last_active"`
}

ProjectStats represents aggregated project statistics

type SessionRecord

type SessionRecord struct {
	ID              string `parquet:"name=id, type=BYTE_ARRAY, convertedtype=UTF8"`
	ProjectID       int64  `parquet:"name=project_id, type=INT64"`
	ProjectPath     string `parquet:"name=project_path, type=BYTE_ARRAY, convertedtype=UTF8"`
	StartedAt       int64  `parquet:"name=started_at, type=INT64, convertedtype=TIMESTAMP_MILLIS"`
	EndedAt         int64  `parquet:"name=ended_at, type=INT64, convertedtype=TIMESTAMP_MILLIS"`
	Model           string `parquet:"name=model, type=BYTE_ARRAY, convertedtype=UTF8"`
	TurnCount       int32  `parquet:"name=turn_count, type=INT32"`
	InputTokens     int64  `parquet:"name=input_tokens, type=INT64"`
	OutputTokens    int64  `parquet:"name=output_tokens, type=INT64"`
	CacheReadTokens int64  `parquet:"name=cache_read_tokens, type=INT64"`
	TotalTokens     int64  `parquet:"name=total_tokens, type=INT64"`
}

SessionRecord is a Parquet-compatible session record

type Summary

type Summary struct {
	TotalSessions int       `json:"total_sessions"`
	TotalTokens   int64     `json:"total_tokens"`
	FirstSession  time.Time `json:"first_session"`
	LastSession   time.Time `json:"last_session"`
	UniqueModels  int       `json:"unique_models"`
}

Summary returns overall analytics summary

type ToolRecord

type ToolRecord struct {
	SessionID string `parquet:"name=session_id, type=BYTE_ARRAY, convertedtype=UTF8"`
	ToolName  string `parquet:"name=tool_name, type=BYTE_ARRAY, convertedtype=UTF8"`
	FilePath  string `parquet:"name=file_path, type=BYTE_ARRAY, convertedtype=UTF8"`
	Timestamp int64  `parquet:"name=timestamp, type=INT64, convertedtype=TIMESTAMP_MILLIS"`
}

ToolRecord is a Parquet-compatible tool usage record

type TurnRecord

type TurnRecord struct {
	ID           string `parquet:"name=id, type=BYTE_ARRAY, convertedtype=UTF8"`
	SessionID    string `parquet:"name=session_id, type=BYTE_ARRAY, convertedtype=UTF8"`
	Type         string `parquet:"name=type, type=BYTE_ARRAY, convertedtype=UTF8"`
	Timestamp    int64  `parquet:"name=timestamp, type=INT64, convertedtype=TIMESTAMP_MILLIS"`
	InputTokens  int32  `parquet:"name=input_tokens, type=INT32"`
	OutputTokens int32  `parquet:"name=output_tokens, type=INT32"`
}

TurnRecord is a Parquet-compatible turn record

Jump to

Keyboard shortcuts

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