analytics

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTrackerClosed = errors.New("analytics: closed")

Functions

func WithBranch

func WithBranch(branch string) analyticsOptFn

WithBranch will override the branch setting on the event

func WithBranchId added in v0.0.42

func WithBranchId(branchId string) analyticsOptFn

WithBranchId will override the branch id setting on the event

func WithMessageId

func WithMessageId(messageId string) analyticsOptFn

WithMessageId will set the Nats-Msg-Id on the event

func WithPodID added in v0.0.42

func WithPodID(id string) analyticsOptFn

WithPodID will override the pod id setting on the event

func WithPodIPAddress added in v0.0.42

func WithPodIPAddress(ip string) analyticsOptFn

WithPodIPAddress will override the pod ip address setting on the event

func WithPodName added in v0.0.42

func WithPodName(name string) analyticsOptFn

WithPodName will override the pod name setting on the event

func WithRegion

func WithRegion(region string) analyticsOptFn

WithRegion will override the region setting on the event

func WithRequestId

func WithRequestId(requestId string) analyticsOptFn

WithRequestId will set the requestId on the event

func WithScope added in v0.0.42

func WithScope(scope string) analyticsOptFn

WithScope will override the scope setting on the event

func WithSessionId

func WithSessionId(sessionId string) analyticsOptFn

WithSessionId will set the sessionId on the event

func WithUserId

func WithUserId(userId string) analyticsOptFn

WithUserId will set the userId on the event

Types

type Analytics

type Analytics interface {
	// Queue an analytics event which will be delivered in the background
	Queue(name string, companyId string, locationId string, data any, opts ...analyticsOptFn) error

	// Close will flush all pending analytics events and close the background sender
	Close() error
}

Analytics is a background service which is used for delivering analytics events in the background

func New

func New(ctx context.Context, logger logger.Logger, js nats.JetStreamContext) (Analytics, error)

New returns a Tracker instance

type Event

type Event struct {
	Timestamp  time.Time `json:"timestamp"`
	Branch     string    `json:"branch"`
	Region     string    `json:"region"`
	Name       string    `json:"name"`
	CompanyId  string    `json:"companyId"`
	LocationId string    `json:"locationId"`
	Data       any       `json:"data,omitempty"`
	UserId     *string   `json:"userId,omitempty"`
	SessionId  *string   `json:"sessionId,omitempty"`
	RequestId  *string   `json:"requestId,omitempty"`
}

Jump to

Keyboard shortcuts

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