session

package
v0.0.0-...-a67b36e Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryRef       = "ref"
	QueryOsName    = "os_name"
	QueryOsVersion = "os_vs"
	QueryDevice    = "device"
	QueryBrowser   = "browser"
)

Variables

View Source
var (
	ErrNoSuchType  = fmt.Errorf("unknown event type")
	ErrNoTypeFound = fmt.Errorf("no event type found")
)
View Source
var (
	ErrNoIpPort = fmt.Errorf("ip:port pair is not valid")
)

Functions

This section is empty.

Types

type BtnTimeEvent

type BtnTimeEvent struct {
	AppUuid     string
	DeviceIP    string
	Type        EventType `json:"type"`
	Target      string    `json:"target"`
	Action      string    `json:"action"`
	Timestamp   int64     `json:"timestamp"`
	ElapsedTime int64     `json:"elapsed_time"`
}

RawURLEvent holds meta data about triggered URL changes

func (BtnTimeEvent) Json

func (evt BtnTimeEvent) Json() ([]byte, error)

type Event

type Event interface {
	Json() ([]byte, error)
}

Event defines any incoming event send by a client where the Type refers to the type of action which triggered the event

type EventType

type EventType int
const (
	// RawClick used for any click-event
	RawClick EventType = iota
	// RawURL used for any URL change
	RawURL
	// BtnTime for configured btns
	BtnTime
	// FunnelChange for when the stage changes
	FunnelChange
	StartSession
)

type FunnelChangeEvent

type FunnelChangeEvent struct {
	AppUuid        string    `cql:"app"`
	DeviceIP       string    `cql:"ip"`
	Type           EventType `json:"type"`
	Action         string    `json:"action" cql:"action"`
	FromStageLabel string    `json:"from_stage_label" cql:"from_stage_label"`
	FromStageID    string    `json:"from_stage" cql:"from_stage"`
	ToStageLabel   string    `json:"to_stage_label" cql:"to_stage_label"`
	ToStageID      string    `json:"to_stage" cql:"to_stage"`
	Timestamp      int64     `json:"timestamp" cql:"timestamp"`
	ElapsedTime    int64     `json:"elapsed_time" cql:"elapsed"`
}

RawURLEvent holds meta data about triggered URL changes

func (FunnelChangeEvent) Json

func (evt FunnelChangeEvent) Json() ([]byte, error)

type RawClickEvent

type RawClickEvent struct {
	AppUuid     string
	DeviceIP    string
	Type        EventType `json:"type"`
	CurrentURL  string    `json:"current_url"`
	Target      string    `json:"target"`
	Timestamp   int64     `json:"timestamp"`
	ElapsedTime int64     `json:"elapsed_time"`
}

RawClickEvent holds meta data about triggered click events

func (RawClickEvent) Json

func (evt RawClickEvent) Json() ([]byte, error)

type RawURLEvent

type RawURLEvent struct {
	AppUuid     string
	DeviceIP    string
	Type        EventType `json:"type"`
	From        string    `json:"from"`
	To          string    `json:"to"`
	Timestamp   int64     `json:"timestamp"`
	ElapsedTime int64     `json:"elapsed_time"`
}

RawURLEvent holds meta data about triggered URL changes

func (RawURLEvent) Json

func (evt RawURLEvent) Json() ([]byte, error)

type Record

type Record struct {
	OsName    string `json:"os_name"`
	OsVersion string `json:"os_version"`
	Browser   string `json:"browser"`
	Device    string `json:"device"`
	Referrer  string `json:"referrer"`
}

Record defines the initialization data to start tracking user sessions

type SessionStart

type SessionStart struct {
	AppUuid  string
	DeviceIP string
	Session  Record
}

func (SessionStart) Json

func (evt SessionStart) Json() ([]byte, error)

type User

type User struct {
	DeviceIP string
	// AppUuid refers to the app the user is located on
	AppUuid string
	// MappedOrgn refers to the organization in the system
	// to which the App is mapped to
	MappedOrgn string
	Record     Record

	Start    time.Time
	Duration time.Duration
	// contains filtered or unexported fields
}

func NewUser

func NewUser(req *http.Request, conn *websocket.Conn, pub chan<- Event, drop chan<- *User) (*User, error)

func (User) Event

func (u User) Event(bytes []byte) (Event, error)

Event converts the given bytes slice to a session known event type

func (User) Listen

func (u User) Listen()

Listen runs in its own goroutine listening for incoming user events and sending them to the publish chan

Jump to

Keyboard shortcuts

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