Documentation ¶
Index ¶
- type Config
- type EventOptions
- type Options
- type Tracker
- func (tracker *Tracker) Accept(r *http.Request, clientID uint64, options Options) *model.Session
- func (tracker *Tracker) Event(r *http.Request, clientID uint64, eventOptions EventOptions, options Options) bool
- func (tracker *Tracker) ExtendSession(r *http.Request, clientID uint64, options Options) bool
- func (tracker *Tracker) Flush()
- func (tracker *Tracker) PageView(r *http.Request, clientID uint64, options Options) bool
- func (tracker *Tracker) Stop()
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 ¶
NewTracker creates a new tracker for given client, salt and config.
func (*Tracker) Accept ¶ added in v6.19.4
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 ¶
ExtendSession extends an existing session. Returns true if the session has been extended and false otherwise.