events

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Types = newEventTypes()

Types of events

Functions

This section is empty.

Types

type BaseEvent

type BaseEvent struct {
	TrackingID  string            `json:"tid"`
	ClientIP    string            `json:"-"`
	CountryCode string            `json:"country,omitempty"`
	UserAgent   string            `json:"-"`
	Browser     string            `json:"browser"`
	OS          string            `json:"os"`
	Tags        map[string]string `json:"tags"`
	Timestamp   time.Time         `json:"timestamp"`
}

BaseEvent contains common events fields

func NewBaseEvent added in v1.1.1

func NewBaseEvent(r *http.Request, tags map[string]string, geoipdb *geoip.DB) *BaseEvent

NewBaseEvent create new base event

func (*BaseEvent) FormattedTS added in v1.1.1

func (ev *BaseEvent) FormattedTS() string

FormattedTS returns formatted timestamp

func (*BaseEvent) Labels added in v1.1.1

func (ev *BaseEvent) Labels() Labels

Labels returns labels

func (*BaseEvent) TS added in v1.1.1

func (ev *BaseEvent) TS() time.Time

TS returns timestamp

func (*BaseEvent) ToMap added in v1.4.0

func (ev *BaseEvent) ToMap() map[string]interface{}

ToMap convert event to map structure

type Event

type Event interface {
	// Type returns event type
	Type() string
	// TS returns event timestamp
	TS() time.Time
	// FormattedTS returns event formated timestamp
	FormattedTS() string
	// Labels return event labels
	Labels() Labels
	// ToMap convert event to map structure
	ToMap() map[string]interface{}
}

Event is the generic interface for a tracking event

type Exception

type Exception struct {
	BaseEvent
	Message string `json:"msg"`
	Line    int    `json:"line"`
	Column  int    `json:"column"`
	URL     string `json:"url"`
	Error   string `json:"error"`
}

Exception contains tracked attribute when an error is triggered

func NewExceptionEvent

func NewExceptionEvent(base *BaseEvent, r *http.Request) (*Exception, error)

NewExceptionEvent create exception event from HTTP request

func (*Exception) FormattedTS

func (ex *Exception) FormattedTS() string

FormattedTS returns formatted timestamp

func (*Exception) Labels

func (ex *Exception) Labels() Labels

Labels returns exception labels

func (*Exception) TS

func (ex *Exception) TS() time.Time

TS returns timestamp

func (*Exception) ToMap added in v1.4.0

func (ex *Exception) ToMap() map[string]interface{}

ToMap convert event to map structure

func (*Exception) Type

func (ex *Exception) Type() string

Type returns event type

type Labels

type Labels map[string]string

Labels used for Loki Labels

func (Labels) String

func (l Labels) String() string

type PageView

type PageView struct {
	BaseEvent
	Protocol         string `json:"-"`
	UserLanguage     string `json:"language"`
	DocumentHostName string `json:"hostname"`
	DocumentPath     string `json:"path"`
	DocumentReferer  string `json:"referer"`
	IsNewVisitor     bool   `json:"new_visitor"`
	IsNewSession     bool   `json:"new_session"`
	TimeOnPage       int    `json:"top"`
}

PageView contains tracked attribute when a page is viewed

func NewPageViewEvent

func NewPageViewEvent(base *BaseEvent, r *http.Request) (*PageView, error)

NewPageViewEvent create page view event from HTTP request

func (*PageView) FormattedTS

func (p *PageView) FormattedTS() string

FormattedTS returns formatted timestamp

func (*PageView) HostName

func (p *PageView) HostName() string

HostName returns document hostname without scheme

func (*PageView) Labels

func (p *PageView) Labels() Labels

Labels returns page view labels

func (*PageView) TS

func (p *PageView) TS() time.Time

TS returns timestamp

func (*PageView) ToMap added in v1.4.0

func (p *PageView) ToMap() map[string]interface{}

ToMap convert event to map structure

func (*PageView) Type

func (p *PageView) Type() string

Type returns event type

type PingEvent added in v1.5.0

type PingEvent struct {
	SimpleEvent
	From string
	To   string
}

PingEvent contains tracked attribute for a ping event

func NewPingEvent added in v1.5.0

func NewPingEvent(base *BaseEvent, r *http.Request) (*PingEvent, error)

NewPingEvent create ping event from HTTP request

func (*PingEvent) ToMap added in v1.5.0

func (pe *PingEvent) ToMap() map[string]interface{}

ToMap convert event to map structure

func (*PingEvent) Type added in v1.5.0

func (pe *PingEvent) Type() string

Type returns event type

type SimpleEvent

type SimpleEvent struct {
	BaseEvent
	Payload map[string]interface{} `json:"payload"`
}

SimpleEvent contains tracked attribute for a simple event

func NewSimpleEvent

func NewSimpleEvent(base *BaseEvent, r *http.Request) (*SimpleEvent, error)

NewSimpleEvent create simple event from HTTP request

func (*SimpleEvent) FormattedTS

func (se *SimpleEvent) FormattedTS() string

FormattedTS returns formatted timestamp

func (*SimpleEvent) Labels

func (se *SimpleEvent) Labels() Labels

Labels returns exception labels

func (*SimpleEvent) TS

func (se *SimpleEvent) TS() time.Time

TS returns timestamp

func (*SimpleEvent) ToMap added in v1.4.0

func (se *SimpleEvent) ToMap() map[string]interface{}

ToMap convert event to map structure

func (*SimpleEvent) Type

func (se *SimpleEvent) Type() string

Type returns event type

Jump to

Keyboard shortcuts

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