handlers

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: EUPL-1.2, ISC, MIT, + 1 more Imports: 63 Imported by: 0

Documentation

Index

Constants

View Source
const DailyView = 90

DailyView forces the "view by day" if the number of selected days is larger than this.

Variables

This section is empty.

Functions

func NewBackend

func NewBackend(db zdb.DB, acmeh http.HandlerFunc) chi.Router

func NewStatic

func NewStatic(r chi.Router, dir string, prod bool) chi.Router

func NewWebsite

func NewWebsite(db zdb.DB) chi.Router

func Site

func Site(ctx context.Context) *goatcounter.Site

Site calls goatcounter.MustGetSite; it's just shorter :-)

Types

type APICountRequest

type APICountRequest struct {
	// Don't try to count unique visitors; every pageview will be considered a
	// "visit".
	NoSessions bool `json:"no_sessions"`

	Hits []APICountRequestHit `json:"hits"`
}

type APICountRequestHit

type APICountRequestHit struct {
	// Path of the pageview, or the event name. {required}
	Path string `json:"path"`

	// Page title, or some descriptive event title.
	Title string `json:"title"`

	// Is this an event?
	Event zdb.Bool `json:"event"`

	// Referrer value, can be an URL (i.e. the Referal: header) or any
	// string.
	Ref string `json:"ref"`

	// Screen size as "x,y,scaling"
	Size zdb.Floats `json:"size"`

	// Query parameters for this pageview, used to get campaign parameters.
	Query string `json:"query"`

	// Hint if this should be considered a bot; should be one of the JSBot*`
	// constants from isbot; note the backend may override this if it
	// detects a bot using another method.
	// https://github.com/zgoat/isbot/blob/master/isbot.go#L28
	Bot int `json:"bot"`

	// User-Agent header.
	UserAgent string `json:"user_agent"`

	// Location as ISO-3166-1 alpha2 string (e.g. NL, ID, etc.)
	Location string `json:"location"`

	// IP to get location from; not used if location is set. Also used for
	// session generation.
	IP string `json:"ip"`

	// Time this pageview should be recorded at; this can be in the past,
	// but not in the future.
	CreatedAt time.Time `json:"created_at"`

	// Normally a session is based on hash(User-Agent+IP+salt), but if you don't
	// send the IP address then we can't determine the session.
	//
	// In those cases, you can store your own session identifiers and send them
	// along. Note these will not be stored in the database as the sessionID
	// (just as the hashes aren't), they're just used as a unique grouping
	// identifier.
	//
	// You can also just disable sessions entirely with NoSessions.
	Session string `json:"session"`
}

type Globals

type Globals struct {
	Context        context.Context
	User           *goatcounter.User
	Site           *goatcounter.Site
	HasUpdates     bool
	Path           string
	Flash          *zhttp.FlashMessage
	Static         string
	StaticDomain   string
	Domain         string
	Version        string
	Billing        bool
	GoatcounterCom bool
	Dev            bool
	Port           string
}

type Session

type Session struct {
	ClientReferenceID string `json:"client_reference_id"`
	Customer          string `json:"customer"`
	DisplayItems      []struct {
		Amount   int    `json:"amount"`
		Currency string `json:"currency"`
		Quantity int    `json:"quantity"`
		Plan     struct {
			ID string `json:"id"`
		} `json:"plan"`
	} `json:"display_items"`
}

Jump to

Keyboard shortcuts

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