defined

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 defined implements retroactive, zero-code events — the Heap wedge. A person with autocapture flowing has raw $click / $pageview / $form_submit rows; a defined event names a slice of them ("checkout = $click where text contains Buy") and makes it a first-class event across EVERY report, retroactive to install, with no tracking code and no coding agent. It is the non-agent instrumentation path.

A Store decorator injects a synthetic event for every autocaptured row that matches a definition, so funnels, trends, retention, and the ask bar see the defined name like any tracked event. Reports already recompute from history, so the backfill is free.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Wrap

func Wrap(s store.Store, ds *Store) store.Store

Wrap decorates s so reads resolve defined events. A nil ds is a no-op passthrough.

Types

type Condition

type Condition struct {
	Field string `json:"field"` // text | id | classes | href | path | tag | name
	Op    string `json:"op"`    // equals | contains | prefix
	Value string `json:"value"`
}

Condition matches one autocapture property. Fields are the flat props the SDK stamps.

type Definition

type Definition struct {
	Name        string      `json:"name"`
	Description string      `json:"description,omitempty"`
	Event       string      `json:"event"` // base autocapture event
	Where       []Condition `json:"where"`
	Created     time.Time   `json:"created"`
}

Definition is one retroactive event: a name over a base autocapture event + AND-ed conditions.

func (Definition) Matches

func (d Definition) Matches(e event.Event) bool

Matches reports whether an autocaptured event belongs to this definition.

type Store

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

Store persists the definitions (a small JSON file, like the tracking plan / cohorts).

func Open

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

func (*Store) Delete

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

Delete removes a definition by name; reports stop resolving it immediately.

func (*Store) List

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

List returns a copy of the definitions.

func (*Store) Save

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

Save adds or replaces a definition by name and validates it.

Jump to

Keyboard shortcuts

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