tracker

package
v5.10.8 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2023 License: AGPL-3.0 Imports: 22 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
	Logger              *log.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          string
	Hostname     string
	Path         string
	Title        string
	Referrer     string
	ScreenWidth  uint16
	ScreenHeight uint16
	Time         time.Time
}

Options are optional parameters for page views and events.

func OptionsFromRequest

func OptionsFromRequest(r *http.Request) Options

OptionsFromRequest returns Options for the client request.

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) Event

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

Event tracks an event.

func (*Tracker) ExtendSession

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

ExtendSession extends an existing session.

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)

PageView tracks a page view.

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