amplitude

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityEvent

type ActivityEvent struct {
	Type       string         `json:"type"`
	Time       string         `json:"time"`
	Properties map[string]any `json:"properties,omitempty"`
}

ActivityEvent represents a single event in a user's history.

type Client

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

Client is an Amplitude API client.

func New

func New(baseURL, apiKey, secretKey string) *Client

New creates an Amplitude client with the given base URL, API key, and secret key.

func (*Client) GetUserActivity

func (c *Client) GetUserActivity(ctx context.Context, amplitudeID string) (*UserActivity, error)

GetUserActivity fetches a user's event history by Amplitude ID.

func (*Client) ListCohorts

func (c *Client) ListCohorts(ctx context.Context) ([]Cohort, error)

ListCohorts fetches all behavioral cohorts.

func (*Client) ListEvents

func (c *Client) ListEvents(ctx context.Context) ([]EventType, error)

ListEvents fetches all event types with WAU counts.

func (*Client) ListTaxonomyEvents

func (c *Client) ListTaxonomyEvents(ctx context.Context) ([]TaxonomyEvent, error)

ListTaxonomyEvents fetches the event type schema.

func (*Client) ListTaxonomyUserProperties

func (c *Client) ListTaxonomyUserProperties(ctx context.Context) ([]TaxonomyUserProperty, error)

ListTaxonomyUserProperties fetches the user property schema.

func (*Client) QueryFunnel

func (c *Client) QueryFunnel(ctx context.Context, events []string, start, end string) (*FunnelResult, error)

QueryFunnel runs a funnel analysis for a sequence of events.

func (*Client) QueryRetention

func (c *Client) QueryRetention(ctx context.Context, startEvent, returnEvent, start, end string) (*RetentionResult, error)

QueryRetention runs a retention analysis.

func (*Client) QuerySegmentation

func (c *Client) QuerySegmentation(ctx context.Context, eventType, start, end, metric, interval string) (*SegmentationResult, error)

QuerySegmentation runs a segmentation query for an event type.

func (*Client) SearchUsers

func (c *Client) SearchUsers(ctx context.Context, query string) ([]UserMatch, error)

SearchUsers searches for users by query string.

func (*Client) SetHTTPDoer

func (c *Client) SetHTTPDoer(doer tracker.HTTPDoer)

SetHTTPDoer replaces the HTTP client used for API requests.

type Cohort

type Cohort struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Size        *int   `json:"size,omitempty"`
	Archived    bool   `json:"archived"`
}

Cohort represents a behavioral cohort.

type Config

type Config struct {
	Name        string `mapstructure:"name"`
	URL         string `mapstructure:"url"`
	Key         string `mapstructure:"key"`
	Secret      string `mapstructure:"secret"` // #nosec G117 -- config field name, not a secret value
	Description string `mapstructure:"description"`
}

Config holds the configuration for a single Amplitude instance.

func LoadConfigs

func LoadConfigs(dir string) ([]Config, error)

LoadConfigs reads a .humanconfig YAML file from dir and returns the list of configured Amplitude instances. Returns nil and no error if the file does not exist.

type EventType

type EventType struct {
	Name       string `json:"name"`
	TotalUsers int    `json:"total_users"`
}

EventType represents an event type with its total active users.

type FunnelResult

type FunnelResult struct {
	Steps []FunnelStep `json:"steps"`
}

FunnelResult holds funnel analysis data.

type FunnelStep

type FunnelStep struct {
	Name          string  `json:"name"`
	Count         int     `json:"count"`
	ConversionPct float64 `json:"conversion_pct"`
}

FunnelStep represents a single step in a funnel.

type Instance

type Instance struct {
	Name        string
	URL         string
	Description string
	Client      *Client
}

Instance represents a configured Amplitude instance ready for use.

func LoadInstances

func LoadInstances(dir string) ([]Instance, error)

LoadInstances reads config, applies env overrides, creates clients, and returns ready-to-use Amplitude instances.

type RetentionDay

type RetentionDay struct {
	Day   int     `json:"day"`
	Count int     `json:"count"`
	Pct   float64 `json:"pct"`
}

RetentionDay represents a single day in a retention curve.

type RetentionResult

type RetentionResult struct {
	StartEvent  string         `json:"start_event"`
	ReturnEvent string         `json:"return_event"`
	Days        []RetentionDay `json:"days"`
}

RetentionResult holds retention analysis data.

type SegmentationResult

type SegmentationResult struct {
	EventType string    `json:"event_type"`
	Dates     []string  `json:"dates"`
	Values    []float64 `json:"values"`
}

SegmentationResult holds event segmentation data.

type TaxonomyEvent

type TaxonomyEvent struct {
	Name        string `json:"name"`
	Category    string `json:"category"`
	Description string `json:"description"`
}

TaxonomyEvent represents an event type schema entry.

type TaxonomyUserProperty

type TaxonomyUserProperty struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Type        string `json:"type"`
}

TaxonomyUserProperty represents a user property schema entry.

type UserActivity

type UserActivity struct {
	AmplitudeID int64           `json:"amplitude_id"`
	Events      []ActivityEvent `json:"events"`
}

UserActivity holds a user's event history.

type UserMatch

type UserMatch struct {
	AmplitudeID int64  `json:"amplitude_id"`
	UserID      string `json:"user_id"`
	Platform    string `json:"platform"`
	Country     string `json:"country"`
	LastSeen    string `json:"last_seen"`
}

UserMatch represents a user found by search.

Jump to

Keyboard shortcuts

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