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 ¶
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.
const DefaultEndpoint = "https://telemetry.shellhub.io"
DefaultEndpoint is the collector an instance reports to. Released binaries carry it, so it never changes.
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 ¶
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 ¶
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 ¶
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.
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.
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.