databeat

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

go-databeat

Go databeat client

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	Privacy:             DefaultPrivacyOptions,
	AssertEventTypes:    []string{},
	FlushBatchSize:      100,
	FlushInterval:       2000 * time.Millisecond,
	FlushTimeout:        30 * time.Second,
	FlushConcurrency:    10,
	MaxQueueSize:        10_000,
	SetServerClientProp: false,
	HTTPClient:          &http.Client{},
}
View Source
var DefaultPrivacyOptions = PrivacyOptions{
	UserIDHash: true, UserAgentSalt: false, ExtraSalt: "",
}

Functions

func CountryCodeFromRequest added in v0.2.2

func CountryCodeFromRequest(r *http.Request) string

func DeviceFromUserAgent added in v0.2.0

func DeviceFromUserAgent(userAgent string) *proto.Device

func EventTypes added in v0.2.0

func EventTypes(eventTypesMap ...map[string]uint32) []string

func GenSessionID added in v0.2.0

func GenSessionID() string

func ProxyHandler

func ProxyHandler(databeatHost string) func(next http.Handler) http.Handler

ProxyHandler routes requests from /rpc/Databeat/* to the remote Databeat server.

func String

func String(s string) *string

func StructToProps added in v0.4.0

func StructToProps(v any) (map[string]string, map[string]float64, map[string]interface{}, error)

func TimeNow

func TimeNow() *time.Time

Types

type Databeat

type Databeat struct {
	Client  proto.Databeat
	Enabled bool
	// contains filtered or unexported fields
}

func NewDatabeatClient

func NewDatabeatClient(host, authKey string, logger logger.Logger, opts ...Options) (*Databeat, error)

func (*Databeat) Flush

func (t *Databeat) Flush(ctx context.Context) error

func (*Databeat) IsRunning

func (t *Databeat) IsRunning() bool

func (*Databeat) Options added in v0.4.0

func (t *Databeat) Options() Options

func (*Databeat) Reset

func (t *Databeat) Reset()

func (*Databeat) Run

func (t *Databeat) Run(ctx context.Context) error

func (*Databeat) Stats

func (t *Databeat) Stats() Stats

func (*Databeat) Stop

func (t *Databeat) Stop()

func (*Databeat) Track

func (t *Databeat) Track(events ...*Event)

Track is a low-level track function where you control the full payload. The method TrackUserEvent calls Track as well.

func (*Databeat) TrackEvent added in v0.6.0

func (t *Databeat) TrackEvent(from From, trackEvents ...Event)

func (*Databeat) TrackRaw

func (t *Databeat) TrackRaw(events ...*RawEvent)

func (*Databeat) TrackUserEvent added in v0.3.0

func (t *Databeat) TrackUserEvent(r *http.Request, userID string, userEvents ...Event)

TrackUserEvent will track the event associated to a particular user. We use the http request `r` for User-Agent and IP information. Note that `r` is optional, and you can pass `nil` as the argument, but it will be unable to offer device and country information.

type Device

type Device = proto.Device

func ServerDevice

func ServerDevice() *Device

type Event

type Event = proto.Event

type From added in v0.6.0

type From struct {
	UserID          string
	UserHTTPRequest *http.Request
	ProjectID       uint64
}

type Ident added in v0.3.0

type Ident uint8
const (
	IDENT_ANON Ident = iota
	IDENT_PRIVATE
	IDENT_USER
	IDENT_SERVICE
)

func GenUserID added in v0.3.0

func GenUserID(userID string, privacyOptions PrivacyOptions) (string, Ident)

func GenUserIDFromRequest added in v0.3.0

func GenUserIDFromRequest(r *http.Request, userID string, privacyOptions PrivacyOptions) (string, Ident)

func UserID added in v0.3.0

func UserID(userID string, privacyOptions PrivacyOptions, r ...*http.Request) (string, Ident)

type Options

type Options struct {
	Privacy             PrivacyOptions
	AssertEventTypes    []string
	FlushBatchSize      int
	FlushInterval       time.Duration
	FlushTimeout        time.Duration
	FlushConcurrency    int
	MaxQueueSize        int
	SetServerClientProp bool
	HTTPClient          *http.Client
}

type PrivacyOptions added in v0.3.0

type PrivacyOptions struct {
	UserIDHash    bool
	UserAgentSalt bool
	ExtraSalt     string
}

type Props added in v0.4.0

type Props map[string]interface{}

Props is a sugar type to make it easier to track props

func (Props) ToEventProps added in v0.4.0

func (p Props) ToEventProps() (map[string]string, map[string]float64, map[string]interface{})

type RawEvent added in v0.2.0

type RawEvent = proto.RawEvent

type Stats

type Stats struct {
	NumEvents uint64
	NumFails  uint64
}

type ToEventProps added in v0.4.0

type ToEventProps interface {
	ToEventProps() (map[string]string, map[string]float64, map[string]interface{})
}

Directories

Path Synopsis
databeat v0.1.0 05b62e4c87147149adb52dd13fe2de8c53a3c72f -- Code generated by webrpc-gen@v0.14.0-dev with golang generator.
databeat v0.1.0 05b62e4c87147149adb52dd13fe2de8c53a3c72f -- Code generated by webrpc-gen@v0.14.0-dev with golang generator.

Jump to

Keyboard shortcuts

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