mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 18:52:56 +00:00
31 lines
1.4 KiB
Go
31 lines
1.4 KiB
Go
package models
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
// VisitorEvent stores client-side analytics events
|
|
// TableName: visitor_events
|
|
// Common events: "page_view", "click", "interaction"
|
|
// Fields kept generic to avoid rigid schema changes
|
|
// Metadata stores arbitrary event payload (e.g., element details)
|
|
|
|
type VisitorEvent struct {
|
|
BaseModel
|
|
|
|
EventType string `gorm:"index;size:50" json:"event_type"`
|
|
Page string `gorm:"index;size:512" json:"page"` // Short page path
|
|
PagePath string `gorm:"index;size:512" json:"page_path"` // Full page path (alias for Page)
|
|
PageName string `gorm:"size:512" json:"page_name"` // Human-readable page name
|
|
Element string `gorm:"size:256" json:"element"` // Element identifier (for clicks/interactions)
|
|
Referrer string `gorm:"size:512" json:"referrer"`
|
|
UserAgent string `gorm:"size:512" json:"user_agent"`
|
|
IPAddress string `gorm:"size:64" json:"ip_address"`
|
|
SessionID string `gorm:"size:128;index" json:"session_id"`
|
|
UserID *uint `gorm:"index" json:"user_id,omitempty"`
|
|
Data json.RawMessage `gorm:"type:jsonb" json:"data"` // Generic event data
|
|
Metadata json.RawMessage `gorm:"type:jsonb" json:"metadata"` // Legacy metadata field
|
|
}
|
|
|
|
func (VisitorEvent) TableName() string { return "visitor_events" }
|