events

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 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

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
}

Event is the generic interface for a tracking event

func NewExceptionEvent

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

NewExceptionEvent create exception event from HTTP request

func NewPageViewEvent

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

NewPageViewEvent create page view event from HTTP request

func NewSimpleEvent

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

NewSimpleEvent create simple event from HTTP request

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 (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) 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 (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) Type

func (p PageView) 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 (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) 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