{"modulePath":"github.com/chainloop-dev/chainloop","version":"v1.138.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package telemetry\n\n## Constants\n\n```go\nconst FlushTimeout = 2 * time.Second\n```\nFlushTimeout bounds how long the detached \\`chainloop telemetry flush\\` process spends delivering an event before giving up. The PostHog client takes it as the deadline for flushing its batch on close, and the flush command takes it as the deadline on the context it tracks with. Both read it from here so the two cannot drift apart. It does not bound anything the user waits for: the command that produced the event has already returned by the time the flush process runs.\n\n```go\nconst UnrecognisedUserID = \"unrecognised\"\n```\n\n## Types\n\n```go\ntype Client interface {\n\tTrackEvent(ctx context.Context, eventName string, id string, tags Tags) error\n}\n```\nClient defines the interface for tracking events.\n\n```go\ntype CommandTracker struct {\n\t// contains filtered or unexported fields\n}\n```\nCommandTracker is an implementation in charge of tracking Commands events sent from the CLI.\n\n```go\nfunc NewCommandTracker(client Client) *CommandTracker\n```\nNewCommandTracker creates a new CommandTracker instance.\n\n```go\nfunc (t *CommandTracker) Track(ctx context.Context, cmd string, tags Tags) error\n```\nTrack sends a command event to the telemetry.Client.\n\n```go\ntype Tags map[string]any\n```\nTags represents a collection of event properties. Values are typed rather than stringified so numbers and booleans reach the analytics backend as numbers and booleans: a duration stored as \"1234\" cannot be averaged or bucketed into percentiles in an insight. Use String to read a value back as a string.\n\nNote that \"ci\" stays a string (\"true\"/\"false\") on purpose. It reads like a boolean that was missed, but it has been a string in every event the CLI has ever sent, and changing its type now would split the existing dashboards across two property types.\n\n```go\nfunc (tg Tags) IsInteractiveUserSession() bool\n```\nIsInteractiveUserSession reports whether the command was run by a logged-in human outside of CI. API and federated tokens are shared identities: an API token belongs to an organization rather than a person, and a federated token resolves to the issuer URL, which is the same value for every Chainloop installation using that provider. Anything derived from the machine the command ran on is only meaningful for the interactive case.\n\n```go\nfunc (tg Tags) String(key string) string\n```\nString returns the value of key when it is a string, and \"\" when the key is absent or holds another type. Callers that compare a tag against a known string value go through it so a mistyped value reads as absent instead of panicking.\n\n```go\nfunc (tg Tags) WithEnvironmentInfo() Tags\n```\nWithEnvironmentInfo adds environment information to the Tags.\n\n```go\nfunc (tg Tags) WithRuntimeInfo() Tags\n```\nWithRuntimeInfo adds runtime information to the Tags.\n\n","path":"github.com/chainloop-dev/chainloop/app/cli/internal/telemetry","name":"telemetry","synopsis":"","isRedistributable":true}
