analytics

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// APIKey contains the API key for external analytics service. It is set during application build.
	APIKey string
)

Functions

func NewSegmentLoggerAdapter

func NewSegmentLoggerAdapter(log logrus.FieldLogger) segment.Logger

NewSegmentLoggerAdapter returns new Segment logger adapter for logrus.FieldLogger.

func ReportPanicIfOccurs

func ReportPanicIfOccurs(log logrus.FieldLogger, reporter FatalErrorAnalyticsReporter)

ReportPanicIfOccurs recovers from a panic and reports it, and then calls log.Fatal. This function should be called with `defer` at the beginning of the goroutine logic.

NOTE: Make sure the reporter is not closed before reporting the panic. It will be cleaned up as a part of this function.

Types

type BatchedDataStore added in v1.6.0

type BatchedDataStore interface {
	AddSourceEvent(event batched.SourceEvent)
	HeartbeatProperties() batched.HeartbeatProperties
	IncrementTimeWindowInHours()
	Reset()
}

type FatalErrorAnalyticsReporter

type FatalErrorAnalyticsReporter interface {
	// ReportFatalError reports a fatal app error.
	ReportFatalError(err error) error

	// Close cleans up the reporter resources.
	Close() error
}

FatalErrorAnalyticsReporter reports a fatal errors.

type Identity

type Identity struct {
	DeploymentID          string
	AnonymousID           string
	KubernetesVersion     k8sVersion.Info
	BotkubeVersion        version.Details
	WorkerNodeCount       int
	ControlPlaneNodeCount int
}

Identity defines an anonymous identity for a given installation.

func (Identity) TraitsMap added in v0.14.0

func (i Identity) TraitsMap() map[string]interface{}

TraitsMap returns a map with traits based on Identity struct fields.

type NoopReporter

type NoopReporter struct{}

NoopReporter implements Reporter interface, but is a no-op (doesn't execute any logic).

func NewNoopReporter

func NewNoopReporter() *NoopReporter

NewNoopReporter creates new NoopReporter instance.

func (NoopReporter) Close

func (n NoopReporter) Close() error

Close cleans up the reporter resources.

func (NoopReporter) RegisterCurrentIdentity

func (n NoopReporter) RegisterCurrentIdentity(_ context.Context, _ kubernetes.Interface, _ string) error

RegisterCurrentIdentity loads the current anonymous identity and registers it.

func (NoopReporter) ReportBotEnabled

func (n NoopReporter) ReportBotEnabled(_ config.CommPlatformIntegration, _ int) error

ReportBotEnabled reports an enabled bot.

func (NoopReporter) ReportCommand

func (n NoopReporter) ReportCommand(_ ReportCommandInput) error

ReportCommand reports a new executed command. The command should be anonymized before using this method.

func (NoopReporter) ReportFatalError

func (n NoopReporter) ReportFatalError(_ error) error

ReportFatalError reports a fatal app error.

func (NoopReporter) ReportHandledEventError

func (n NoopReporter) ReportHandledEventError(_ ReportEventInput, _ error) error

ReportHandledEventError reports a failure while handling event using a given communication platform.

func (NoopReporter) ReportHandledEventSuccess

func (n NoopReporter) ReportHandledEventSuccess(_ ReportEventInput) error

ReportHandledEventSuccess reports a successfully handled event using a given communication platform.

func (NoopReporter) ReportPluginsEnabled added in v1.9.0

func (n NoopReporter) ReportPluginsEnabled(_ map[string]config.Executors, _ map[string]config.Sources) error

ReportPluginsEnabled reports plugins enabled.

func (NoopReporter) ReportSinkEnabled

func (n NoopReporter) ReportSinkEnabled(_ config.CommPlatformIntegration, _ int) error

ReportSinkEnabled reports an enabled sink.

func (NoopReporter) Run added in v1.6.0

func (n NoopReporter) Run(_ context.Context) error

Run runs the reporter.

type ReportCommandInput added in v1.6.0

type ReportCommandInput struct {
	Platform   config.CommPlatformIntegration
	PluginName string
	Command    string
	Origin     command.Origin
	WithFilter bool
}

type ReportEventInput added in v1.6.0

type ReportEventInput struct {
	IntegrationType       config.IntegrationType
	Platform              config.CommPlatformIntegration
	PluginName            string
	AnonymizedEventFields map[string]any
}

type Reporter

type Reporter interface {
	// RegisterCurrentIdentity loads the current anonymous identity and registers it.
	RegisterCurrentIdentity(ctx context.Context, k8sCli kubernetes.Interface, deployID string) error

	// ReportCommand reports a new executed command. The command should be anonymized before using this method.
	ReportCommand(in ReportCommandInput) error

	// ReportBotEnabled reports an enabled bot.
	ReportBotEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error

	// ReportSinkEnabled reports an enabled sink.
	ReportSinkEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error

	// ReportHandledEventSuccess reports a successfully handled event using a given integration type, communication platform, and plugin.
	ReportHandledEventSuccess(event ReportEventInput) error

	// ReportHandledEventError reports a failure while handling event using a given integration type, communication platform, and plugin.
	ReportHandledEventError(event ReportEventInput, err error) error

	// ReportFatalError reports a fatal app error.
	ReportFatalError(err error) error

	// ReportPluginsEnabled reports plugins enabled.
	ReportPluginsEnabled(executors map[string]config.Executors, sources map[string]config.Sources) error

	Run(ctx context.Context) error

	// Close cleans up the reporter resources.
	Close() error
}

Reporter defines an analytics reporter implementation.

type SegmentReporter

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

SegmentReporter is a default Reporter implementation that uses Twilio Segment.

func NewSegmentReporter

func NewSegmentReporter(log logrus.FieldLogger, cli segment.Client) *SegmentReporter

NewSegmentReporter creates a new SegmentReporter instance.

func (*SegmentReporter) Close

func (r *SegmentReporter) Close() error

Close cleans up the reporter resources.

func (*SegmentReporter) RegisterCurrentIdentity

func (r *SegmentReporter) RegisterCurrentIdentity(ctx context.Context, k8sCli kubernetes.Interface, remoteDeployID string) error

RegisterCurrentIdentity loads the current anonymous identity and registers it.

func (*SegmentReporter) ReportBotEnabled

func (r *SegmentReporter) ReportBotEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error

ReportBotEnabled reports an enabled bot. The RegisterCurrentIdentity needs to be called first.

func (*SegmentReporter) ReportCommand

func (r *SegmentReporter) ReportCommand(in ReportCommandInput) error

ReportCommand reports a new executed command. The command should be anonymized before using this method. The RegisterCurrentIdentity needs to be called first.

func (*SegmentReporter) ReportFatalError

func (r *SegmentReporter) ReportFatalError(err error) error

ReportFatalError reports a fatal app error. It doesn't need a registered identity.

func (*SegmentReporter) ReportHandledEventError

func (r *SegmentReporter) ReportHandledEventError(event ReportEventInput, err error) error

ReportHandledEventError reports a failure while handling event using a given communication platform. The RegisterCurrentIdentity needs to be called first.

func (*SegmentReporter) ReportHandledEventSuccess

func (r *SegmentReporter) ReportHandledEventSuccess(event ReportEventInput) error

ReportHandledEventSuccess reports a successfully handled event using a given communication platform. The RegisterCurrentIdentity needs to be called first.

func (*SegmentReporter) ReportPluginsEnabled added in v1.9.0

func (r *SegmentReporter) ReportPluginsEnabled(executors map[string]config.Executors, sources map[string]config.Sources) error

ReportPluginsEnabled reports plugins enabled.

func (*SegmentReporter) ReportSinkEnabled

func (r *SegmentReporter) ReportSinkEnabled(platform config.CommPlatformIntegration, commGroupIdx int) error

ReportSinkEnabled reports an enabled sink. The RegisterCurrentIdentity needs to be called first.

func (*SegmentReporter) Run added in v1.6.0

func (r *SegmentReporter) Run(ctx context.Context) error

Run runs the reporter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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