tevent

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const CloudDefaultTimeout = 5 * time.Second
View Source
const ErrorCooldownPeriod = time.Hour // Wait 1 hour after an error before trying again
View Source
const TEventsBatchSize = 200
View Source
const TEventsMaxBatches = 10
View Source
const TEventsUrl = "/tevents"

Variables

View Source
var Disabled atomic.Bool
View Source
var IsTrayApp atomic.Bool
View Source
var ValidEventNames = map[string]bool{
	"server:install":  true,
	"server:startup":  true,
	"server:shutdown": true,
	"server:activity": true,
	"server:panic":    true,

	"apprun:connected":    true,
	"apprun:disconnected": true,
	"apprun:activity":     true,

	"frontend:tab":              true,
	"frontend:selectapprun":     true,
	"frontend:click":            true,
	"frontend:activity":         true,
	"frontend:error":            true,
	"frontend:search:logs":      true,
	"frontend:search:goroutine": true,
	"frontend:search:watch":     true,
}

Functions

func ClientArch

func ClientArch() string

func GetEventBufferLength

func GetEventBufferLength() int

GetEventBufferLength returns the current number of events in the buffer with proper locking

func OsLang

func OsLang() string

func SendAppRunConnectedEvent

func SendAppRunConnectedEvent(sdkVersion string, goVersion string)

SendAppRunConnectedEvent sends an "apprun:connected" telemetry event

func SendAppRunDisconnectedEvent

func SendAppRunDisconnectedEvent(stats AppRunStats)

SendAppRunDisconnectedEvent sends an "apprun:disconnected" telemetry event

func SendInstallEvent

func SendInstallEvent()

SendInstallEvent sends an "outrig:install" telemetry event

func SendServerActivityEvent

func SendServerActivityEvent(stats AppRunStats, numActiveAppRuns int)

SendServerActivityEvent sends a "server:activity" telemetry event with stats aggregated across all app runs

func SendShutdownEvent

func SendShutdownEvent()

SendShutdownEvent sends a "server:shutdown" telemetry event

func SendStartupEvent

func SendStartupEvent()

SendStartupEvent sends a "server:startup" telemetry event

func SetTrayApp

func SetTrayApp(isTrayApp bool)

SetTrayApp sets whether the server was started from the tray app

func UnameKernelRelease

func UnameKernelRelease() string

func UploadEvents

func UploadEvents() error

UploadEvents uploads events to the server

func UploadEventsAsync

func UploadEventsAsync()

UploadEventsAsync calls UploadEvents in a separate goroutine It first checks if we're in the cooldown period to avoid spawning unnecessary goroutines

func WriteTEvent

func WriteTEvent(event TEvent)

WriteTEvent adds a telemetry event to the in-memory buffer If the buffer exceeds hardMaxBufferSize, the event will be dropped

Types

type AppRunStats

type AppRunStats struct {
	LogLines    int    `json:"apprun:loglines,omitempty"`
	GoRoutines  int    `json:"apprun:goroutines,omitempty"`
	Watches     int    `json:"apprun:watches,omitempty"`
	Collections int    `json:"apprun:collections,omitempty"`
	SDKVersion  string `json:"apprun:sdkversion,omitempty"`
	ConnTimeMs  int64  `json:"apprun:conntimems,omitempty"`
	AppRunCount int    `json:"apprun:count,omitempty"`
}

AppRunStats contains statistics about an app run session

func (AppRunStats) Add

func (s AppRunStats) Add(other AppRunStats) AppRunStats

Add adds another AppRunStats to this one and returns the result

func (AppRunStats) Sub

func (s AppRunStats) Sub(other AppRunStats) AppRunStats

Sub subtracts another AppRunStats from this one and returns the result

type TEvent

type TEvent struct {
	Uuid    string      `json:"uuid,omitempty"`
	Ts      int64       `json:"ts,omitempty"`
	TsLocal string      `json:"tslocal,omitempty"` // iso8601 format (wall clock converted to PT)
	Event   string      `json:"event"`
	Props   TEventProps `json:"props"` // Don't scan directly to map
}

func GrabEvents

func GrabEvents(maxSize int) []TEvent

GrabEvents takes the lock, gets up to maxSize events from the buffer, and returns them If maxSize <= 0, it returns all events

func MakeTEvent

func MakeTEvent(event string, props TEventProps) *TEvent

func MakeUntypedTEvent

func MakeUntypedTEvent(event string, propsMap map[string]any) (*TEvent, error)

func (*TEvent) EnsureTimestamps

func (t *TEvent) EnsureTimestamps()

func (*TEvent) UserSetOnceProps

func (t *TEvent) UserSetOnceProps() *TEventUserProps

func (*TEvent) UserSetProps

func (t *TEvent) UserSetProps() *TEventUserProps

func (*TEvent) Validate

func (te *TEvent) Validate(current bool) error

validates a tevent that was just created (not for validating out of the DB, or an uploaded TEvent) checks that TS is pretty current (or unset)

type TEventProps

type TEventProps struct {
	TEventUserProps `tstype:"-"` // generally don't need to set these since they will be automatically copied over

	PanicType string `json:"debug:panictype,omitempty"`

	FrontendTab            string   `json:"frontend:tab,omitempty"`
	FrontendSearchFeatures []string `json:"frontend:logsearchfeatures,omitempty"`
	FrontendSearchLatency  int      `json:"frontend:searchlatency,omitempty"`
	FrontendSearchItems    int      `json:"frontend:searchitems,omitempty"`
	FrontendClickType      string   `json:"frontend:clicktype,omitempty"`

	ServerNumAppRuns int  `json:"server:numappruns,omitempty"`
	ServerNumApps    int  `json:"server:numapps,omitempty"`
	ServerTrayApp    bool `json:"server:trayapp,omitempty"`

	// counts for app run activity
	AppRunLogLines       int    `json:"apprun:loglines,omitempty"`
	AppRunGoRoutines     int    `json:"apprun:goroutines,omitempty"`
	AppRunWatches        int    `json:"apprun:watches,omitempty"`
	AppRunCollections    int    `json:"apprun:collections,omitempty"`
	AppRunSDKVersion     string `json:"apprun:sdkversion,omitempty"`
	AppRunSDKFullVersion string `json:"apprun:sdkfullversion,omitempty"`
	AppRunGoVersion      string `json:"apprun:goversion,omitempty"`
	AppRunConnTimeMs     int64  `json:"apprun:conntimems,omitempty"`
	AppRunCount          int    `json:"apprun:count,omitempty"`

	UserSet     *TEventUserProps `json:"$set,omitempty"`
	UserSetOnce *TEventUserProps `json:"$set_once,omitempty"`
}

func (*TEventProps) ApplyAppRunStats

func (p *TEventProps) ApplyAppRunStats(stats AppRunStats)

ApplyAppRunStats applies the fields from an AppRunStats struct to this TEventProps

type TEventUserProps

type TEventUserProps struct {
	ServerArch           string `json:"server:arch,omitempty"`
	ServerVersion        string `json:"server:version,omitempty"`
	ServerFullVersion    string `json:"server:fullversion,omitempty"`
	ServerInitialVersion string `json:"server:initial_version,omitempty"`
	ServerBuildTime      string `json:"server:buildtime,omitempty"`
	ServerBuildCommit    string `json:"server:buildcommit,omitempty"`
	ServerOSRelease      string `json:"server:osrelease,omitempty"`
	ServerIsDev          bool   `json:"server:isdev,omitempty"`
	ServerLang           string `json:"server:lang,omitempty"`
	LocCountryCode       string `json:"loc:countrycode,omitempty"`
	LocRegionCode        string `json:"loc:regioncode,omitempty"`
}

type TEventsInputType

type TEventsInputType struct {
	ClientId string   `json:"clientid"`
	Events   []TEvent `json:"events"`
}

Jump to

Keyboard shortcuts

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