Documentation
¶
Index ¶
- Constants
- type AssignGroupPayload
- type Client
- func (c *Client) AssignGroup(ctx context.Context, payload AssignGroupPayload) (*TrackResponse, error)
- func (c *Client) Decrement(ctx context.Context, payload CounterPayload) (*TrackResponse, error)
- func (c *Client) Group(ctx context.Context, payload GroupPayload) (*TrackResponse, error)
- func (c *Client) Identify(ctx context.Context, payload IdentifyPayload) (*TrackResponse, error)
- func (c *Client) Increment(ctx context.Context, payload CounterPayload) (*TrackResponse, error)
- func (c *Client) SetUserAgent(userAgent string)
- func (c *Client) Track(ctx context.Context, payload TrackPayload) (*TrackResponse, error)
- type CounterPayload
- type Event
- type EventType
- type GroupPayload
- type IdentifyPayload
- type TrackPayload
- type TrackResponse
Constants ¶
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 (*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 ¶
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 EventType ¶
type EventType string
EventType discriminates the payload variant sent to the /track endpoint.
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.