README

Pirsch Golang SDK

Go Reference Chat on Discord

This is the official Golang client SDK for Pirsch. For details, please check out our documentation.

Changelog

See CHANGELOG.md.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a client used to access the Pirsch API.

func NewClient

func NewClient(clientID, clientSecret, hostname string, config *ClientConfig) *Client

NewClient creates a new client for given client ID, client secret, hostname, and optional configuration. A new client ID and secret can be generated on the Pirsch dashboard. The hostname must match the hostname you configured on the Pirsch dashboard (e.g. example.com).

func (*Client) Hit

func (client *Client) Hit(r *http.Request) error

Hit sends a page hit to Pirsch for given http.Request.

func (*Client) HitWithOptions

func (client *Client) HitWithOptions(r *http.Request, options *HitOptions) error

HitWithOptions sends a page hit to Pirsch for given http.Request and options.

type ClientConfig

type ClientConfig struct {
	// BaseURL is optional and can be used to configure a different host for the API.
	// This is usually left empty in production environments.
	BaseURL string

	// Logger is an optional logger for debugging.
	Logger *log.Logger
}

ClientConfig is used to configure the Client.

type Hit

type Hit struct {
	Hostname       string
	URL            string `json:"url"`
	IP             string `json:"ip"`
	CFConnectingIP string `json:"cf_connecting_ip"`
	XForwardedFor  string `json:"x_forwarded_for"`
	Forwarded      string `json:"forwarded"`
	XRealIP        string `json:"x_real_ip"`
	UserAgent      string `json:"user_agent"`
	AcceptLanguage string `json:"accept_language"`
	Referrer       string `json:"referrer"`
	ScreenWidth    int    `json:"screen_width"`
	ScreenHeight   int    `json:"screen_height"`
}

Hit are the parameters to send a page hit to Pirsch.

type HitOptions

type HitOptions struct {
	ScreenWidth  int
	ScreenHeight int
}

HitOptions optional parameters to send with the hit request.

Source Files

Directories

Path Synopsis