Documentation ¶
Overview ¶
Package tracking provides privacy-focused user tracking functions.
Index ¶
- func Footprint(r *http.Request, salt string) (string, error)
- func GetUserIP(r *http.Request) string
- type Handler
- type Hit
- type Hitter
- func (h *Hitter) Delete(ctx context.Context, id string) error
- func (h *Hitter) Get(ctx context.Context) ([]Hit, error)
- func (h *Hitter) Hit(ctx context.Context, r *http.Request) error
- func (h *Hitter) Search(ctx context.Context, query string) ([]Hit, error)
- func (h *Hitter) SearchByField(ctx context.Context, field, value string) ([]Hit, error)
- type Searcher
- type Tracker
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles tracking endpoints.
func NewHandler ¶
NewHandler returns a new tracking handler.
func (*Handler) DeleteHit ¶
func (h *Handler) DeleteHit() http.HandlerFunc
DeleteHit prints the hit with the specified day.
func (*Handler) GetHits ¶
func (h *Handler) GetHits() http.HandlerFunc
GetHits retrieves total amount of hits stored.
func (*Handler) SearchHit ¶
func (h *Handler) SearchHit() http.HandlerFunc
SearchHit returns the hits that matched with the search.
func (*Handler) SearchHitByField ¶
func (h *Handler) SearchHitByField() http.HandlerFunc
SearchHitByField returns the hits that matched with the search.
type Hit ¶
type Hit struct { ID string `json:"id"` Footprint string `json:"footprint"` Path string `json:"path"` URL string `json:"url"` Language string `json:"language"` UserAgent string `json:"user_agent" db:"user_agent"` Referer string `json:"referer"` Date time.Time `json:"date"` }
Hit represents a single data point/page visit.
func HitRequest ¶
HitRequest generates a hit for each request.
type Hitter ¶
Hitter provides methods to hit requests and store them in a data store.
func (*Hitter) Hit ¶
Hit stores the given request. The request might be ignored if it meets certain conditions.
type Searcher ¶
type Searcher interface { Search(ctx context.Context, value string) ([]Hit, error) SearchByField(ctx context.Context, field, value string) ([]Hit, error) }
Searcher is the interface that wraps hits search methods.