analytics

package
v0.32.3 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: MPL-2.0 Imports: 18 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 GetCookieId added in v0.23.3

func GetCookieId() uuid.UUID

GetCookieId 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{})

func SetUserId added in v0.23.3

func SetUserId(userId string)

Types

type Client

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

func New

func New(opts ...Option) *Client

type DiagnosticsSummary added in v0.31.7

type DiagnosticsSummary struct {
	Total      int            `json:"total,omitempty"`
	ByType     map[string]int `json:"by_type,omitempty"`
	BySeverity map[string]int `json:"by_severity,omitempty"`
}

func SummarizeDiagnostics added in v0.31.7

func SummarizeDiagnostics(diags diag.Diagnostics) DiagnosticsSummary

type Environment

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

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 WithInstanceId added in v0.23.3

func WithInstanceId(instanceId string) 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 TelemetryEvent added in v0.31.7

type TelemetryEvent struct {
	Error    string
	Resource string
	Summary  string
	Category string
}

TelemetryEvent holds data of a telemetry event collected from a Diagnostic.

func FilterTelemetryEvents added in v0.31.7

func FilterTelemetryEvents(diags diag.Diagnostics) ([]TelemetryEvent, diag.Diagnostics)

FilterTelemetryEvents splits a list of supplied Diagnostics into a list of TelemetryEvents and all other ordinary Diagnostics.

func TelemetryFromDiagnostic added in v0.31.7

func TelemetryFromDiagnostic(d diag.Diagnostic) TelemetryEvent

TelemetryFromDiagnostic converts a Diagnostic to a TelemetryEvent. Be sure to pass only Diagnostics of type TELEMETRY.

func (TelemetryEvent) Properties added in v0.31.7

func (e TelemetryEvent) Properties() map[string]interface{}

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