Help us shape the future of Go! Take the 2026 Go Developer Survey

analytics

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisabledInFedrampErr = errors.New("analytics are disabled in FedRAMP environments") //nolint:errname // breaking API change

Functions

func GetV2InstrumentationObject

func GetV2InstrumentationObject(collector InstrumentationCollector, opt ...serializeOptionFunc) (*api.AnalyticsRequestBody, error)

func SanitizeStaticValues

func SanitizeStaticValues(valuesToSanitize []string, replacementValue string, content []byte) ([]byte, error)

func SanitizeUsername

func SanitizeUsername(rawUserName string, userHomeDir string, replacementValue string, content []byte) ([]byte, error)

SanitizeUsername sanitizes the given content by replacing the given username with the replacement string.

func SanitizeValuesByKey

func SanitizeValuesByKey(keysToFilter []string, replacementValue string, content []byte) ([]byte, error)

func WithLogger

func WithLogger(logger *zerolog.Logger) serializeOptionFunc

Types

type Analytics

type Analytics interface {
	SetCmdArguments(args []string)
	SetOrg(org string)
	SetVersion(version string)
	SetApiUrl(apiUrl string)
	SetIntegration(name string, version string)
	SetCommand(command string)
	SetOperatingSystem(os string)
	AddError(err error)
	AddHeader(headerFunc func() http.Header)
	SetClient(clientFunc func() *http.Client)
	IsCiEnvironment() bool
	GetRequest() (*http.Request, error)
	Send() (*http.Response, error)
	GetInstrumentation() InstrumentationCollector
	AddExtensionIntegerValue(key string, value int)
	AddExtensionStringValue(key string, value string)
	AddExtensionBoolValue(key string, value bool)
}

Analytics is an interface for managing analytics.

func New

func New() Analytics

New creates a new Analytics instance.

type AnalyticsImpl

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

AnalyticsImpl is the default implementation of the Analytics interface.

func (*AnalyticsImpl) AddError

func (a *AnalyticsImpl) AddError(err error)

AddError adds an error to the error list.

func (*AnalyticsImpl) AddExtensionBoolValue

func (a *AnalyticsImpl) AddExtensionBoolValue(key string, value bool)

func (*AnalyticsImpl) AddExtensionIntegerValue

func (a *AnalyticsImpl) AddExtensionIntegerValue(key string, value int)

func (*AnalyticsImpl) AddExtensionStringValue

func (a *AnalyticsImpl) AddExtensionStringValue(key string, value string)

func (*AnalyticsImpl) AddHeader

func (a *AnalyticsImpl) AddHeader(headerFunc func() http.Header)

AddHeader adds a header to the request.

func (*AnalyticsImpl) GetInstrumentation

func (a *AnalyticsImpl) GetInstrumentation() InstrumentationCollector

func (*AnalyticsImpl) GetOutputData

func (a *AnalyticsImpl) GetOutputData() *analyticsOutput

GetOutputData returns the analyticsOutput data.

func (*AnalyticsImpl) GetRequest

func (a *AnalyticsImpl) GetRequest() (*http.Request, error)

GetRequest returns the HTTP request.

func (*AnalyticsImpl) IsCiEnvironment

func (a *AnalyticsImpl) IsCiEnvironment() bool

IsCiEnvironment returns true if the command is running in a CI environment.

func (*AnalyticsImpl) Send

func (a *AnalyticsImpl) Send() (*http.Response, error)

func (*AnalyticsImpl) SetApiUrl

func (a *AnalyticsImpl) SetApiUrl(apiUrl string)

SetApiUrl sets the API URL.

func (*AnalyticsImpl) SetClient

func (a *AnalyticsImpl) SetClient(clientFunc func() *http.Client)

SetClient sets the HTTP client.

func (*AnalyticsImpl) SetCmdArguments

func (a *AnalyticsImpl) SetCmdArguments(args []string)

SetCmdArguments sets the command arguments.

func (*AnalyticsImpl) SetCommand

func (a *AnalyticsImpl) SetCommand(command string)

func (*AnalyticsImpl) SetInstrumentation

func (a *AnalyticsImpl) SetInstrumentation(ic InstrumentationCollector)

func (*AnalyticsImpl) SetIntegration

func (a *AnalyticsImpl) SetIntegration(name string, version string)

SetIntegration sets the integration name and version.

func (*AnalyticsImpl) SetOperatingSystem

func (a *AnalyticsImpl) SetOperatingSystem(os string)

func (*AnalyticsImpl) SetOrg

func (a *AnalyticsImpl) SetOrg(org string)

SetOrg sets the organization.

func (*AnalyticsImpl) SetVersion

func (a *AnalyticsImpl) SetVersion(version string)

SetVersion sets the version.

type InstrumentationCollector

type InstrumentationCollector interface {
	SetUserAgent(ua networking.UserAgentInfo)
	SetInteractionId(id string)
	SetTimestamp(t time.Time)
	SetDuration(duration time.Duration)
	GetDuration() time.Duration
	SetStage(s string)
	SetType(t string)
	SetInteractionType(t string)
	SetCategory(c []string)
	GetCategory() []string
	SetStatus(s Status)
	SetTestSummary(s json_schemas.TestSummary)
	SetTargetId(t string) // maybe use package-url library and types
	AddError(err error)
	AddExtension(key string, value interface{})
}

func NewInstrumentationCollector

func NewInstrumentationCollector() InstrumentationCollector

type Status

type Status string
const (
	Success Status = "success"
	Failure Status = "failure"
)

Jump to

Keyboard shortcuts

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