web

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package web composes the one-glance web-analytics view — live visitors, top pages, referrers, UTM sources, device split — from $pageview events. This is the Plausible-shaped report indie devs otherwise run a SECOND tool for; here it's the same engine, same events, one binary. Deterministic like every other report.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	PeriodDays  int   `json:"period_days"`
	Visitors    int   `json:"visitors"`  // unique visitors in period
	Pageviews   int   `json:"pageviews"` // total $pageview in period
	LiveNow     int   `json:"live_now"`  // unique visitors in the last 5 minutes
	TopPages    []Row `json:"top_pages"`
	Referrers   []Row `json:"referrers"`    // grouped by host, "" → "direct"
	UTMSources  []Row `json:"utm_sources"`  // only when utm_source is present
	DeviceSplit []Row `json:"device_split"` // mobile / desktop
	// the dimensions people open first — browsers/os come from the ingest-time UA
	// parse, countries from ingest-time geo (when enabled), entry pages from the
	// SDK's session_id, titles from the SDK's title prop
	Browsers     []Row   `json:"browsers"`
	OSes         []Row   `json:"oses"`
	Countries    []Row   `json:"countries"`
	UTMMediums   []Row   `json:"utm_mediums"`
	UTMCampaigns []Row   `json:"utm_campaigns"`
	EntryPages   []Row   `json:"entry_pages"`
	TopTitles    []Row   `json:"top_titles"`
	Hours        [24]int `json:"hours"` // pageviews by UTC hour of day — the activity rhythm
	// engagement — from $engagement events (SDK measures visible+focused time).
	// Omitted (zero) when the SDK predates engagement tracking.
	HasEngagement  bool `json:"has_engagement"`
	AvgEngagedSecs int  `json:"avg_engaged_secs"` // mean engaged time per engaged visitor
	BounceRatePct  int  `json:"bounce_rate_pct"`  // 1 pageview AND <10s engaged
	// the AI channel — humans arriving FROM AI assistants (chatgpt/claude/perplexity...).
	// distinct from AI crawlers, which the bot filter drops before storage.
	AIVisitors  int   `json:"ai_visitors"`
	AIReferrers []Row `json:"ai_referrers"`
}

Result is the web overview for a period.

func Compute

func Compute(evs []event.Event, days int, asof time.Time) Result

Compute builds the overview over the trailing `days` (default 30) as of `asof`.

type Row

type Row struct {
	Value    string `json:"value"`
	Count    int    `json:"count"` // pageviews
	Visitors int    `json:"visitors"`
}

Row is one ranked value (a page, a referrer, a source...).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL