tracking

package
v0.9.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2025 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IdleDetector

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

IdleDetector handles idle time detection across platforms

func NewIdleDetector

func NewIdleDetector(threshold time.Duration) *IdleDetector

NewIdleDetector creates a new idle detector with the given threshold

func (*IdleDetector) GetIdleTime

func (id *IdleDetector) GetIdleTime() (time.Duration, error)

GetIdleTime returns the current system idle time

func (*IdleDetector) IsIdle

func (id *IdleDetector) IsIdle() (bool, error)

IsIdle returns true if the system has been idle longer than the threshold

func (*IdleDetector) StartIdleMonitoring

func (id *IdleDetector) StartIdleMonitoring(onIdleStart, onIdleEnd func()) chan struct{}

StartIdleMonitoring starts monitoring for idle state changes

type ProjectDetector

type ProjectDetector struct{}

ProjectDetector handles automatic project detection

func NewProjectDetector

func NewProjectDetector() *ProjectDetector

NewProjectDetector creates a new project detector

func (*ProjectDetector) DetectProject

func (pd *ProjectDetector) DetectProject() string

DetectProject attempts to detect the current project based on working directory

func (*ProjectDetector) SanitizeProjectName

func (pd *ProjectDetector) SanitizeProjectName(name string) string

SanitizeProjectName cleans up project names

type Session

type Session struct {
	ID        string        `json:"id"`
	Project   string        `json:"project"`
	StartTime time.Time     `json:"start_time"`
	EndTime   *time.Time    `json:"end_time,omitempty"`
	PausedAt  *time.Time    `json:"paused_at,omitempty"`
	Duration  time.Duration `json:"duration"`
	State     SessionState  `json:"state"`
}

Session represents a work session

type SessionState

type SessionState int

SessionState represents the current state of a work session

const (
	StateStopped SessionState = iota
	StateRunning
	StatePaused
)

func (SessionState) String

func (s SessionState) String() string

type Tracker

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

Tracker manages time tracking sessions

func NewTracker

func NewTracker() (*Tracker, error)

NewTracker creates a new time tracker

func NewTrackerWithIdleThreshold

func NewTrackerWithIdleThreshold(idleThreshold time.Duration) (*Tracker, error)

NewTrackerWithIdleThreshold creates a new time tracker with custom idle threshold

func (*Tracker) Close

func (t *Tracker) Close() error

Close closes the tracker and database

func (*Tracker) GetCurrentSession

func (t *Tracker) GetCurrentSession() (*Session, error)

GetCurrentSession returns the current active session

func (*Tracker) GetDailyTotal

func (t *Tracker) GetDailyTotal() (time.Duration, error)

GetDailyTotal returns the total time worked today

func (*Tracker) GetIdleTime

func (t *Tracker) GetIdleTime() (time.Duration, error)

GetIdleTime returns the current system idle time

func (*Tracker) GetProjectStats

func (t *Tracker) GetProjectStats() (map[string]time.Duration, error)

GetProjectStats returns time statistics by project

func (*Tracker) GetSessionDuration

func (t *Tracker) GetSessionDuration() (time.Duration, error)

GetSessionDuration returns the current session duration

func (*Tracker) GetSessionHistory

func (t *Tracker) GetSessionHistory(limit int) ([]*Session, error)

GetSessionHistory returns recent sessions

func (*Tracker) GetWeeklyTotal

func (t *Tracker) GetWeeklyTotal() (time.Duration, error)

GetWeeklyTotal returns the total time worked this week

func (*Tracker) IsIdle

func (t *Tracker) IsIdle() (bool, error)

IsIdle returns true if the system is currently idle

func (*Tracker) Pause

func (t *Tracker) Pause() (*Session, error)

Pause pauses the current work session

func (*Tracker) Resume

func (t *Tracker) Resume() (*Session, error)

Resume resumes a paused work session

func (*Tracker) SaveImportedSession

func (t *Tracker) SaveImportedSession(session *Session) error

SaveImportedSession saves an imported session to the database

func (*Tracker) SetIdleThreshold

func (t *Tracker) SetIdleThreshold(threshold time.Duration)

SetIdleThreshold sets the idle detection threshold

func (*Tracker) Start

func (t *Tracker) Start(project string) (*Session, error)

Start starts a new work session

func (*Tracker) StartIdleMonitoring

func (t *Tracker) StartIdleMonitoring() error

StartIdleMonitoring starts monitoring for idle state changes

func (*Tracker) Stop

func (t *Tracker) Stop() (*Session, error)

Stop stops the current work session

func (*Tracker) StopIdleMonitoring

func (t *Tracker) StopIdleMonitoring()

StopIdleMonitoring stops idle monitoring

Jump to

Keyboard shortcuts

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