cohort

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package cohort defines reusable user groups — "users who did checkout", "users from Hacker News who activated" — that you define once and apply across every report. A definition is event membership + property filters; Resolve turns it into the matching user-id set; the Store persists definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterToUsers

func FilterToUsers(events []event.Event, users map[string]bool) []event.Event

FilterToUsers keeps only events belonging to the given user set.

func Resolve

func Resolve(events []event.Event, d Definition) map[string]bool

Resolve returns the set of distinct_ids that match the definition. Membership is evaluated over the user's full history (filters applied first).

Types

type Definition

type Definition struct {
	ID      string         `json:"id"`
	Name    string         `json:"name"`
	Match   string         `json:"match"` // "any" (default) or "all"
	Events  []string       `json:"events"`
	Filters []query.Filter `json:"filters"`
	Created time.Time      `json:"created"`
}

Definition is a saved cohort: users who did the listed events (any/all), with optional property filters applied when checking membership.

type Store

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

Store persists cohort definitions to a JSON file (atomic rewrite), like saved reports. Empty path = in-memory only.

func Open

func Open(path string) (*Store, error)

func (*Store) Delete

func (s *Store) Delete(id string) error

func (*Store) Get

func (s *Store) Get(id string) (Definition, bool)

func (*Store) List

func (s *Store) List() []Definition

func (*Store) Save

func (s *Store) Save(d Definition) (Definition, error)

Jump to

Keyboard shortcuts

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