Help us shape the future of Go! Take the 2026 Go Developer Survey

splitter

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package splitter provides session splitting conditions.

Package splitter provides session splitting functionality.

Index

Constants

This section is empty.

Variables

AllCauses is a list of all possible split causes, usable for documentation.

Functions

func FunctionOptions added in v0.35.0

func FunctionOptions() []expr.Option

FunctionOptions returns expr.Option values to register custom functions.

Types

type CachingRegistryOption added in v0.35.0

type CachingRegistryOption func(*cachingRegistryConfig)

CachingRegistryOption configures a caching registry.

func WithCapacity added in v0.35.0

func WithCapacity(n int64) CachingRegistryOption

WithCapacity sets the maximum number of entries in the cache.

func WithTTL added in v0.35.0

WithTTL sets the time-to-live for cached entries.

type Condition

type Condition interface {
	ShouldSplit(ctx *Context, current *schema.Event) (SplitCause, bool)
}

Condition determines if a session should be split at a given event.

func NewMaxXEventsCondition

func NewMaxXEventsCondition(maxXEvents int) Condition

NewMaxXEventsCondition creates a new split condition that splits the session when the number of events exceeds the maximum number of events.

func NewTimeSinceFirstEventCondition

func NewTimeSinceFirstEventCondition(timeSinceFirstEvent time.Duration) Condition

NewTimeSinceFirstEventCondition creates a new split condition that splits the session when the time since the first event exceeds the maximum time.

func NewUTMCampaignCondition

func NewUTMCampaignCondition() Condition

NewUTMCampaignCondition creates a new split condition that splits the session when the UTM campaign value changes.

func NewUserIDCondition

func NewUserIDCondition() Condition

NewUserIDCondition creates a new split condition that splits the session when the user id value changes.

type Context

type Context struct {
	// EventCount is the number of events processed so far in the current session.
	EventCount int
	// FirstEvent is the timestamp of the first event in the current session.
	FirstEvent *schema.Event
	// ColumnValues stores the last seen value for each column name.
	// Conditions can use this to track value changes without re-scanning all events.
	ColumnValues map[string]any
}

Context holds state accumulated while processing events. Conditions can read and update this context to maintain state efficiently.

func NewSplitContext

func NewSplitContext() *Context

NewSplitContext creates a new context for session splitting.

type MultiModifier added in v0.35.0

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

MultiModifier chains multiple SessionModifiers, feeding the output sessions of one into the next.

func (*MultiModifier) Split added in v0.35.0

func (m *MultiModifier) Split(session *schema.Session) ([]*schema.Session, error)

type Registry

type Registry interface {
	SessionModifier(propertyID string) (SessionModifier, error)
}

Registry provides session splitters for properties.

func NewCachingRegistry added in v0.35.0

func NewCachingRegistry(underlying Registry, opts ...CachingRegistryOption) (Registry, error)

NewCachingRegistry creates a registry that caches SessionModifier lookups.

func NewFromPropertySettingsRegistry

func NewFromPropertySettingsRegistry(psr properties.SettingsRegistry, cacheOpts ...CachingRegistryOption) Registry

NewFromPropertySettingsRegistry creates a registry that builds splitters from property settings.

func NewStaticRegistry

func NewStaticRegistry(splitter SessionModifier) Registry

NewStaticRegistry always returns the same splitter.

type SessionModifier added in v0.17.0

type SessionModifier interface {
	Split(*schema.Session) ([]*schema.Session, error)
}

SessionModifier splits a session into multiple sessions based on conditions.

func NewFilter added in v0.35.0

func NewFilter(config properties.FiltersConfig) (SessionModifier, error)

New creates a new filter modifier from configuration. Returns a noop modifier when config has no conditions.

func NewMultiModifier added in v0.35.0

func NewMultiModifier(modifiers ...SessionModifier) SessionModifier

NewMultiModifier creates a new multi-modifier that chains multiple SessionModifiers.

func NewNoop

func NewNoop() SessionModifier

NewNoop creates a new session splitter that does not split the session.

func NewSplitter added in v0.35.0

func NewSplitter(conditions ...Condition) SessionModifier

NewSplitter creates a new session splitter with the given conditions.

type SplitCause

type SplitCause string

SplitCause indicates the reason why a session was split.

const (
	// SplitCauseNone indicates no split occurred.
	SplitCauseNone SplitCause = ""
	// SplitCauseUtmCampaignChange indicates split due to UTM campaign change.
	SplitCauseUtmCampaignChange SplitCause = "utm_campaign_changed"
	// SplitCauseUserIDChange indicates split due to user ID change.
	SplitCauseUserIDChange SplitCause = "user_id_changed"
	// SplitCauseMaxXEvents indicates split due to maximum number of events.
	SplitCauseMaxXEvents SplitCause = "max_events_reached"
	// SplitCauseTimeSinceFirstEvent indicates split due to time since first event.
	SplitCauseTimeSinceFirstEvent SplitCause = "max_time_since_first_event_reached"
)

Jump to

Keyboard shortcuts

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