telemetry

package
v0.30.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package telemetry sends usage events to the ShellHub telemetry collector, which speaks PostHog's capture v1 protocol. It is the only package that imports posthog-go.

Index

Constants

View Source
const (
	CommunityWriteKey  = "shellhub_community_f7319c57cf0f033d6c7128f3eafc4b4b"
	EnterpriseWriteKey = "shellhub_enterprise_277b7aebd2fbd069ce337546bf36adf2"
)

CommunityWriteKey and EnterpriseWriteKey are the public write keys the Community and Enterprise binaries send. They are not secrets: they filter stray traffic and name the edition. Cloud's key is a secret its deployment provides.

View Source
const DefaultEndpoint = "https://telemetry.shellhub.io"

DefaultEndpoint is the collector an instance reports to. Released binaries carry it, so it never changes.

View Source
const SchemaVersion = 1

SchemaVersion is sent as schema_version on every event. Raise it when a property changes meaning or is removed, so the collector can tell old payloads from new ones.

Variables

View Source
var ClientProperties = []string{"$os", "$os_version", "$os_distro", "$go_version", "$is_server", "$geoip_disable"}

ClientProperties are the properties posthog-go adds to every event on its own, besides the uuid and timestamp. The public telemetry page lists them; $os_version and $os_distro are sent only when the host reports them.

Functions

This section is empty.

Types

type Client

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

Client queues events and sends them to the collector in the background.

func New

func New(endpoint, writeKey string) (*Client, error)

New returns a client that sends to endpoint, authenticating with the edition's write key. It returns an error when posthog-go rejects the configuration.

func (*Client) Close

func (c *Client) Close() error

Close flushes the queued events and stops the client, giving up after a few seconds so a collector that does not answer cannot hold up a shutdown. It returns the error posthog-go's Close reports when the queue cannot be flushed in time or the client is already closed.

func (*Client) Endpoint

func (c *Client) Endpoint() string

Endpoint returns the collector the client sends to.

func (*Client) Send

func (c *Client) Send(events ...Event) error

Send queues events for delivery. It returns the first error posthog-go reports, such as posthog.ErrQueueFull, after trying to queue every event. A queued event the collector drops or never receives is logged at debug level, not returned.

type Event

type Event struct {
	Name       string
	DistinctID string
	Properties map[string]any
	Groups     map[string]string
}

Event is one telemetry event. Name is an object and a past-tense verb, written as a literal, and never starts with "$", which PostHog reserves.

func (Event) Preview

func (e Event) Preview() Preview

Preview returns the event as posthog-go sends it: schema_version added, $groups added when the event has groups, and $process_person_profile moved out of Properties into Options.

type Preview

type Preview struct {
	Event      string         `json:"event"`
	DistinctID string         `json:"distinct_id"`
	Options    map[string]any `json:"options"`
	Properties map[string]any `json:"properties"`
}

Preview is the event as the collector receives it, without the uuid, the timestamp and the ClientProperties posthog-go adds when it sends it.

Jump to

Keyboard shortcuts

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