clickstream

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 8 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

Index

Constants

View Source
const (
	TrackEndpoint = "/track"

	// HeaderClientID etc. are spelled canonically: HTTP header names are
	// case-insensitive and Go canonicalizes them on Set anyway.
	HeaderClientID     = "Openpanel-Client-Id"
	HeaderClientSecret = "Openpanel-Client-Secret"
	HeaderSDKName      = "Openpanel-Sdk-Name"
	HeaderSDKVersion   = "Openpanel-Sdk-Version"

	DefaultTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssignGroupPayload

type AssignGroupPayload struct {
	GroupIDs  []string `json:"groupIds"`
	ProfileID string   `json:"profileId,omitempty"`
}

AssignGroupPayload links a profile to one or more groups.

type Client

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

Client sends server-side analytics events to an OpenPanel instance.

func NewClient

func NewClient(baseURL, clientID, clientSecret, sdkVersion string) *Client

func (*Client) AssignGroup

func (c *Client) AssignGroup(ctx context.Context, payload AssignGroupPayload) (*TrackResponse, error)

AssignGroup links a profile to one or more groups. Note: groups are never auto-populated on events — pass Groups explicitly on each Track call.

func (*Client) Decrement

func (c *Client) Decrement(ctx context.Context, payload CounterPayload) (*TrackResponse, error)

Decrement decreases a numeric profile property.

func (*Client) Group

func (c *Client) Group(ctx context.Context, payload GroupPayload) (*TrackResponse, error)

Group creates or updates a group.

func (*Client) Identify

func (c *Client) Identify(ctx context.Context, payload IdentifyPayload) (*TrackResponse, error)

Identify creates or updates a user profile.

func (*Client) Increment

func (c *Client) Increment(ctx context.Context, payload CounterPayload) (*TrackResponse, error)

Increment increases a numeric profile property.

func (*Client) SetUserAgent

func (c *Client) SetUserAgent(userAgent string)

SetUserAgent overrides the User-Agent header. OpenPanel derives device, OS and session handling from it: UAs shaped like "name/1.0" are treated as server SDKs and never open sessions.

func (*Client) Track

func (c *Client) Track(ctx context.Context, payload TrackPayload) (*TrackResponse, error)

Track records a named event with optional properties.

type CounterPayload

type CounterPayload struct {
	ProfileID string  `json:"profileId"`
	Property  string  `json:"property"`
	Value     float64 `json:"value,omitempty"`
}

CounterPayload increments or decrements a numeric profile property. Value must be positive; zero means "use server default of 1".

type Event

type Event struct {
	Type    EventType `json:"type"`
	Payload any       `json:"payload"`
}

Event is the envelope OpenPanel expects: {"type": "...", "payload": {...}}.

type EventType

type EventType string

EventType discriminates the payload variant sent to the /track endpoint.

const (
	EventTypeTrack       EventType = "track"
	EventTypeIdentify    EventType = "identify"
	EventTypeIncrement   EventType = "increment"
	EventTypeDecrement   EventType = "decrement"
	EventTypeGroup       EventType = "group"
	EventTypeAssignGroup EventType = "assign_group"
)

type GroupPayload

type GroupPayload struct {
	ID         string         `json:"id"`
	Type       string         `json:"type"`
	Name       string         `json:"name"`
	Properties map[string]any `json:"properties,omitempty"`
}

GroupPayload creates or updates a group.

type IdentifyPayload

type IdentifyPayload struct {
	ProfileID  string         `json:"profileId"`
	FirstName  string         `json:"firstName,omitempty"`
	LastName   string         `json:"lastName,omitempty"`
	Email      string         `json:"email,omitempty"`
	Avatar     string         `json:"avatar,omitempty"`
	Properties map[string]any `json:"properties,omitempty"`
}

IdentifyPayload creates or updates a user profile.

type TrackPayload

type TrackPayload struct {
	Name       string         `json:"name"`
	Properties map[string]any `json:"properties,omitempty"`
	ProfileID  string         `json:"profileId,omitempty"`
	Groups     []string       `json:"groups,omitempty"`
}

TrackPayload records a named event with optional properties.

type TrackResponse

type TrackResponse struct {
	DeviceID  string `json:"deviceId,omitempty"`
	SessionID string `json:"sessionId,omitempty"`
}

TrackResponse is returned by /track; both fields may be empty for server-side events.

Jump to

Keyboard shortcuts

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