analytics

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CQTeamID = "12345678-0000-0000-0000-c1a0dbeef000"
)

Variables

This section is empty.

Functions

func Capture

func Capture(eventType string, providers registry.Providers, data Message, diags diag.Diagnostics, extra ...interface{})

func Close

func Close()

func Enabled

func Enabled() bool

func GetUserId

func GetUserId() uuid.UUID

GetUserId will read or generate a persistent `telemetry-random-id` file and return its value. First it will try reading ~/.cq/telemetry-random-id and use that value if found. If not, it will move on to ./cq/telemetry-random-id, first attempting a read and if not found, will create that file filling it with a newly generated ID. If a directory with the same name is encountered, process is aborted and an empty string is returned. If a new file is generated, c.newRandomId is set.

func HashAttribute

func HashAttribute(value string) string

HashAttribute creates a one-way hash from an attribute

func Init

func Init(opts ...Option) error

Init initializes the Analytics Client with options. The returned error is non-nil if options is invalid, for instance if a malformed DSN is provided.

func IsCI

func IsCI() bool

IsCI determines if we're running under a CI env by checking CI-specific env vars

func IsFaaS

func IsFaaS() bool

IsFaaS determines if we're running under a Lambda env by checking Lambda-specific env vars

func SetGlobalProperty

func SetGlobalProperty(k string, v interface{})

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) *Client

type Environment

type Environment struct {
	// OS Client executing
	OS string `json:"os,omitempty"`
	// Terminal is true if Client is executed inside a terminal environment
	Terminal bool `json:"terminal,omitempty"`
	// CI is true if the Client is executed inside a CI i.e github actions etc'
	CI bool `json:"ci,omitempty"`
	// FaaS is true if Client is executed inside a function i.e lambda etc'
	FaaS bool `json:"faas,omitempty"`
	// Hashed hostname identifier
	Hostname string `json:"hostname,omitempty"`
	MacAddr  string `json:"mac_addr,omitempty"`
}

type Message

type Message interface {
	Properties() map[string]interface{}
}

type Option

type Option func(c *Client)

func WithApiKey

func WithApiKey(apikey string) Option

func WithDebug

func WithDebug() Option

func WithDisabled

func WithDisabled() Option

func WithInspect

func WithInspect() Option

func WithProperties

func WithProperties(properties map[string]interface{}) Option

func WithTerminal

func WithTerminal(terminal bool) Option

func WithVersionInfo

func WithVersionInfo(version, commit, buildDate string) Option

type VersionInfo

type VersionInfo struct {
	Version   string `json:"version,omitempty"`
	BuildDate string `json:"build_date,omitempty"`
	CommitId  string `json:"commit_id,omitempty"`
}

Jump to

Keyboard shortcuts

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