posthog

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package posthog is a dumb analytics.Sink over the PostHog batch capture API. It maps each analytics event to a PostHog event and POSTs one gzipped batch per flush. Apps that need a different mapping can bring their own sink.

PostHog requires a distinct_id. This package uses the app-supplied identity from analytics.Tracker.Identify (Event.UserID) when present, falling back to the ephemeral session id — it never synthesises a device identifier.

Index

Constants

View Source
const DefaultHost = "https://us.i.posthog.com"

DefaultHost is PostHog's US cloud host. Pass a different host to New for EU cloud or self-hosted instances.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sink

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

Sink delivers events to PostHog's /batch endpoint.

func New

func New(apiKey string) *Sink

New returns a PostHog analytics.Sink for the given project API key, using DefaultHost.

func NewWithHost

func NewWithHost(apiKey, host string) *Sink

NewWithHost returns a PostHog analytics.Sink posting to a custom host (EU cloud or self-hosted).

func (*Sink) Send

func (s *Sink) Send(batch []analytics.Event) error

Send implements analytics.Sink.

Jump to

Keyboard shortcuts

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