client

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package client provides a client for the FancyAnalytics API.

Index

Constants

View Source
const (
	DefaultBaseURL            = "http://fancyanalytics.net"
	DefaultMaxIdleConnections = 100
	DefaultIdleTimeout        = 90 * time.Second
	DefaultTimeout            = 30 * time.Second
)

Variables

View Source
var (
	ErrNoProjectID          = errors.New("no project ID provided")
	ErrUnexpectedStatusCode = errors.New("unexpected status code")
)

Functions

This section is empty.

Types

type Client

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

Client is a client for the FancyAnalytics API.

var DefaultClient *Client

func New

func New(cfg Configuration) (*Client, error)

New creates a new FancyAnalytics client with the given configuration.

func (*Client) Ping

func (c *Client) Ping() error

Ping checks if the FancyAnalytics API is reachable.

func (*Client) SendEvent

func (c *Client) SendEvent(evt *Event) error

func (*Client) SendRecord

func (c *Client) SendRecord(records []RecordData) error

type Configuration

type Configuration struct {
	// BaseURL is the base URL of the FancyAnalytics API.
	// If empty, DefaultBaseURL is used.
	BaseURL string

	// SenderID is the sender ID to use for requests.
	// If empty a random UUID will be used.
	SenderID string

	// AuthToken is the authentication token to use for requests. Optional.
	AuthToken string

	// ProjectID is the project ID to use for requests.
	ProjectID string

	// WriteKey is the write key for the project. Optional.
	WriteKey string

	// MaxIdleConnections sets the maximum number of idle (keep-alive) connections across all hosts.
	// If zero, DefaultMaxIdleConnections is used.
	MaxIdleConnections int

	// IdleConnectionTimeout is the maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
	// If zero, DefaultIdleTimeout is used.
	IdleConnectionTimeout time.Duration

	// RequestTimeout is the maximum amount of time a request can take before timing out.
	// If zero, DefaultTimeout is used.
	RequestTimeout time.Duration
}

Configuration holds the configuration for the FancyAnalytics client.

type Event

type Event struct {
	Name       string            `json:"name"`
	Properties map[string]string `json:"properties"`
}

func (*Event) WithProperty

func (e *Event) WithProperty(key, value string)

type RecordData

type RecordData struct {
	Metric string  `json:"metric"`
	Label  string  `json:"label,omitempty"`
	Value  float64 `json:"value"`
}

Jump to

Keyboard shortcuts

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