tracker

package
v6.19.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Store               db.Store
	Salt                string
	FingerprintKey0     uint64
	FingerprintKey1     uint64
	Worker              int
	WorkerBufferSize    int
	WorkerTimeout       time.Duration
	SessionCache        session.Cache
	HeaderParser        []ip.HeaderParser
	AllowedProxySubnets []net.IPNet
	MaxPageViews        uint16
	GeoDB               *geodb.GeoDB
	IPFilter            ip.Filter
	LogIP               bool
	Logger              *slog.Logger
}

Config is the configuration for the Tracker.

type EventOptions

type EventOptions struct {
	// Name is the name of the event (required).
	Name string

	// Duration is an optional duration that is used to calculate an average time on the dashboard.
	Duration uint32

	// Meta are optional fields used to break down the events that were send for a name.
	Meta map[string]string
}

EventOptions are the options to save a new event. The name is required. All other fields are optional.

type Options

type Options struct {
	// URL is the full request URL.
	URL string

	// Hostname is used to check the Referrer. If it's the same as the hostname, it will be ignored.
	Hostname string

	// Path sets the path.
	Path string

	// Title sets the page title.
	Title string

	// Referrer overrides the referrer. If set to Hostname it will be ignored.
	Referrer string

	// ScreenWidth is the screen width which will be translated to a screen class.
	ScreenWidth uint16

	// ScreenHeight is the screen height which will be translated to a screen class.
	ScreenHeight uint16

	// Time overrides the time the page view should be recorded for.
	// Usually this is set to the time the request arrives at the Tracker.
	Time time.Time

	// Tags are optional fields used to break down page views into segments.
	Tags map[string]string

	// MaxPageViews is an optional limit for the maximum number of page views per session.
	// This overrides Config.MaxPageViews for the Tracker.
	MaxPageViews uint16
}

Options are optional parameters for page views and events.

type Tracker

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

Tracker tracks page views, events, and updates sessions.

func NewTracker

func NewTracker(config Config) *Tracker

NewTracker creates a new tracker for given client, salt and config.

func (*Tracker) Accept added in v6.19.4

func (tracker *Tracker) Accept(r *http.Request, clientID uint64, options Options) *model.Session

Accept runs the given request through the bot filters and returns the details if accepted. This function does not update the session, nor does it save the page view or request.

func (*Tracker) Event

func (tracker *Tracker) Event(r *http.Request, clientID uint64, eventOptions EventOptions, options Options) bool

Event tracks an event. Returns true if the event has been accepted and false otherwise.

func (*Tracker) ExtendSession

func (tracker *Tracker) ExtendSession(r *http.Request, clientID uint64, options Options) bool

ExtendSession extends an existing session. Returns true if the session has been extended and false otherwise.

func (*Tracker) Flush

func (tracker *Tracker) Flush()

Flush flushes all buffered data.

func (*Tracker) PageView

func (tracker *Tracker) PageView(r *http.Request, clientID uint64, options Options) bool

PageView tracks a page view. Returns true if the page view has been accepted and false otherwise.

func (*Tracker) Stop

func (tracker *Tracker) Stop()

Stop flushes and stops all workers.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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