app

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	WorkspaceID string
	UserID      string
	Type        string
	EntityType  string
	EntityID    string
	Payload     map[string]any
}

type EventRow

type EventRow struct {
	ID          int64          `json:"id"`
	WorkspaceID string         `json:"workspace_id,omitempty"`
	UserID      string         `json:"user_id,omitempty"`
	Type        string         `json:"event_type"`
	EntityType  string         `json:"entity_type,omitempty"`
	EntityID    string         `json:"entity_id,omitempty"`
	Payload     map[string]any `json:"payload"`
	CreatedAt   time.Time      `json:"created_at"`
}

type Repo

type Repo interface {
	Track(ctx context.Context, e Event, now time.Time)

	RecentByType(ctx context.Context, eventType string, limit int) ([]EventRow, error)

	Recent(ctx context.Context, since time.Time, limit int) ([]EventRow, error)

	CountByType(ctx context.Context, eventType string, since time.Time) (int, error)

	CountByTypeInWorkspace(ctx context.Context, workspaceID, eventType string, since time.Time) (int, error)
}

type TrackService

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

func NewTrackService

func NewTrackService(repo Repo, log *slog.Logger) *TrackService

func (*TrackService) CountByType

func (s *TrackService) CountByType(ctx context.Context, eventType string, since time.Time) (int, error)

func (*TrackService) CountByTypeInWorkspace

func (s *TrackService) CountByTypeInWorkspace(ctx context.Context, workspaceID, eventType string, since time.Time) (int, error)

func (*TrackService) Recent

func (s *TrackService) Recent(ctx context.Context, limit int) ([]EventRow, error)

func (*TrackService) RecentByType

func (s *TrackService) RecentByType(ctx context.Context, eventType string, limit int) ([]EventRow, error)

func (*TrackService) Track

func (s *TrackService) Track(ctx context.Context, e Event) error

Jump to

Keyboard shortcuts

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