Documentation
¶
Overview ¶
Package api is a thin, typed client over the panel's management API (/api/v1). It carries the bearer token and refreshes it transparently when it is about to expire.
Index ¶
- Constants
- type APIKey
- type Catalog
- type Client
- func (c *Client) Catalog(ctx context.Context, projectID string) (*Catalog, error)
- func (c *Client) Context(ctx context.Context) (*Context, error)
- func (c *Client) CreateKey(ctx context.Context, projectID, kind, label string) (*APIKey, error)
- func (c *Client) CreateProject(ctx context.Context, teamID int, name, timezone string) (*Project, error)
- func (c *Client) Events(ctx context.Context, projectID string, filters url.Values) (*EventsPage, error)
- func (c *Client) Keys(ctx context.Context, projectID string) ([]APIKey, error)
- func (c *Client) Project(ctx context.Context, projectID string) (*Project, error)
- func (c *Client) Projects(ctx context.Context, teamID int) ([]Project, error)
- func (c *Client) SwitchProject(ctx context.Context, projectID string) (*Context, error)
- func (c *Client) SwitchTeam(ctx context.Context, teamID int) (*Context, error)
- func (c *Client) Teams(ctx context.Context) ([]Team, error)
- func (c *Client) Whoami(ctx context.Context) (*User, error)
- type Context
- type Event
- type EventsPage
- type Project
- type Team
- type User
Constants ¶
const ( KindPublic = "public" KindSecret = "secret" )
Write-key kinds (non-negotiable #12): public keys identify the project in the browser; secret keys are backend-only.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
ID int `json:"id"`
Kind string `json:"kind"`
Label string `json:"label"`
Key string `json:"key"`
CreatedAt string `json:"created_at"`
}
APIKey is a project write key. Key is masked on list, full on create.
type Catalog ¶
type Catalog struct {
Events []struct {
Name string `json:"name"`
Count int `json:"count"`
} `json:"events"`
Properties []struct {
Key string `json:"key"`
Count int `json:"count"`
} `json:"properties"`
}
Catalog is the observed event names and property keys for a project.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client talks to one panel as one signed-in user.
func New ¶
func New(creds *config.Credentials) *Client
New builds a client around stored credentials.
func (*Client) CreateProject ¶
func (c *Client) CreateProject(ctx context.Context, teamID int, name, timezone string) (*Project, error)
CreateProject creates a project inside a team.
func (*Client) Events ¶
func (c *Client) Events(ctx context.Context, projectID string, filters url.Values) (*EventsPage, error)
Events returns recent events for a project, newest first.
func (*Client) SwitchProject ¶
SwitchProject sets the active project (and pulls its team along).
func (*Client) SwitchTeam ¶
SwitchTeam sets the active team.
type Event ¶
type Event struct {
UUID string `json:"uuid"`
Event string `json:"event"`
DistinctID string `json:"distinct_id"`
PersonID string `json:"person_id"`
Properties string `json:"properties"`
Verified int `json:"verified"`
VerificationMode string `json:"verification_mode"`
Timestamp string `json:"timestamp"`
}
Event is one row from the events explorer.
type EventsPage ¶
type EventsPage struct {
Events []Event `json:"events"`
Page int `json:"page"`
PerPage int `json:"perPage"`
HasMore bool `json:"hasMore"`
}
EventsPage is the paginated events response.
type Project ¶
type Project struct {
ID string `json:"id"`
Name string `json:"name"`
TeamID int `json:"team_id"`
Timezone string `json:"timezone"`
IdentityVerificationMode string `json:"identity_verification_mode"`
PublicKey string `json:"public_key"`
CreatedAt string `json:"created_at"`
}
Project carries the summary fields the API returns. current_project on the user/context payloads only fills ID and Name; the project endpoints fill the rest.
type Team ¶
type Team struct {
ID int `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
IsPersonal bool `json:"isPersonal"`
Role string `json:"role"`
RoleLabel string `json:"roleLabel"`
IsCurrent bool `json:"isCurrent"`
}
Team mirrors the panel's UserTeam DTO (camelCase keys, straight from response()->json).