Documentation
¶
Overview ¶
Package analytics provides HTTP endpoints for event collection. This supports astley.js automatic tracking and manual event submission.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ASTRequest ¶
type ASTRequest struct {
Context string `json:"@context"` // hanzo.ai/schema
Type string `json:"@type"` // Website, WebsiteSection, etc.
// Page metadata
Head struct {
Title string `json:"title"`
Description string `json:"description"`
OG struct {
Title string `json:"title"`
Description string `json:"description"`
Image string `json:"image"`
} `json:"og"`
} `json:"head"`
// Sections
Sections []struct {
Name string `json:"name"`
Type string `json:"type"` // hero, block, cta
ID string `json:"id"`
Class string `json:"class"`
Content []struct {
Type string `json:"type"` // text, image, link, button
Text string `json:"text"`
Href string `json:"href"`
Src string `json:"src"`
Alt string `json:"alt"`
} `json:"content"`
} `json:"sections"`
// User context
DistinctID string `json:"distinct_id"`
OrganizationID string `json:"organization_id"`
SessionID string `json:"session_id"`
URL string `json:"url"`
}
ASTRequest is the astley.js page AST request format.
type BatchRequest ¶
type BatchRequest struct {
Events []EventRequest `json:"events" binding:"required"`
}
BatchRequest is a batch of events.
type EventRequest ¶
type EventRequest struct {
// Core
Event string `json:"event" binding:"required"`
DistinctID string `json:"distinct_id"`
Timestamp string `json:"timestamp"`
// Organization context
OrganizationID string `json:"organization_id"`
ProjectID string `json:"project_id"`
// Session
SessionID string `json:"session_id"`
VisitID string `json:"visit_id"`
// Properties
Properties map[string]interface{} `json:"properties"`
// Web context
URL string `json:"url"`
Referrer string `json:"referrer"`
// AST context (astley.js)
Context string `json:"@context"`
Type string `json:"@type"`
// Element tracking
ElementID string `json:"element_id"`
ElementType string `json:"element_type"`
ElementSelector string `json:"element_selector"`
ElementText string `json:"element_text"`
ElementHref string `json:"element_href"`
// Section tracking
SectionName string `json:"section_name"`
SectionType string `json:"section_type"`
SectionID string `json:"section_id"`
// Page info
PageTitle string `json:"page_title"`
PageDescription string `json:"page_description"`
PageType string `json:"page_type"`
// Component hierarchy
ComponentPath string `json:"component_path"`
ComponentData string `json:"component_data"`
// AI/Cloud
ModelProvider string `json:"model_provider"`
ModelName string `json:"model_name"`
TokenCount int `json:"token_count"`
TokenPrice float64 `json:"token_price"`
PromptTokens int `json:"prompt_tokens"`
OutputTokens int `json:"output_tokens"`
// Commerce
OrderID string `json:"order_id"`
ProductID string `json:"product_id"`
CartID string `json:"cart_id"`
Revenue float64 `json:"revenue"`
Quantity int `json:"quantity"`
}
EventRequest is the standard event request format.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles analytics event collection.
func NewHandler ¶
NewHandler creates a new analytics handler.
Click to show internal directories.
Click to hide internal directories.