api

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 67 Imported by: 0

Documentation

Overview

Package api serves the single-binary HTTP surface: event ingestion + the server-rendered dashboard. No web framework, no SPA build step — the whole UI is embedded in the binary and rendered fast on the server (the speed IS a feature).

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.1.0"

Version is the build version (overridable at build time via -ldflags).

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(s store.Store) *Server

func (*Server) EvaluateAlerts

func (s *Server) EvaluateAlerts()

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) SetAlerts

func (s *Server) SetAlerts(a *alert.Store)

func (*Server) SetAliases added in v0.4.0

func (s *Server) SetAliases(a *alias.Map)

SetAliases attaches the identity-stitching map (ingest records anon→user on $identify; the MCP import tool does the same for imported history).

func (*Server) SetAudit

func (s *Server) SetAudit(l *audit.Log)

SetAudit swaps in a persistent audit log.

func (*Server) SetCloudURL added in v0.12.1

func (s *Server) SetCloudURL(u string)

SetCloudURL sets where the dashboard header's "Cloud ↗" link points. The hosted product passes the project's own page so a user who lands on their instance has a way back into their account. Empty (every self-hosted install) keeps the default link to smolanalytics.com, so a self-hoster never sees a cloud-specific or broken link.

func (*Server) SetCohorts

func (s *Server) SetCohorts(st *cohort.Store)

SetCohorts swaps in a persistent cohort store (shared with MCP).

func (*Server) SetDefined added in v0.9.0

func (s *Server) SetDefined(d *defined.Store)

SetDefined attaches the retroactive defined-events store (shared with MCP + the dashboard "save as event" builder).

func (*Server) SetDeploys added in v0.9.3

func (s *Server) SetDeploys(d *deploys.Store)

SetDeploys attaches the store to both the HTTP server and the MCP server, so a marker recorded over HTTP is visible to the editor and vice-versa (one store, every surface).

func (s *Server) SetExportLinks(st *exportlink.Store)

SetExportLinks attaches the one-time export-link store (minted by the create_export_link MCP tool, served by GET /export/{token}).

func (*Server) SetFlags added in v0.9.6

func (s *Server) SetFlags(f *flag.Store)

SetFlags attaches the feature-flag store (shared with MCP + the SDK evaluate endpoint).

func (*Server) SetGSC added in v0.4.1

func (s *Server) SetGSC(g *gsc.Store)

SetGSC attaches the Search Console store (dashboard card + MCP report).

func (*Server) SetGeo added in v0.9.1

func (s *Server) SetGeo(g *geo.Resolver)

SetGeo enables ingest-time country resolution (the IP is used for one lookup and never stored, only the ISO code lands on the event).

func (*Server) SetGoals added in v0.4.0

func (s *Server) SetGoals(g *goal.Store)

SetGoals attaches the goals store (dashboard card + MCP goal tools).

func (*Server) SetInsights

func (s *Server) SetInsights(st *insights.Store)

SetInsights swaps in a persistent saved-reports store (shared with the MCP action tools, so "save this report" from the editor lands on the dashboard instantly).

func (*Server) SetMCPReadOnly added in v0.13.0

func (s *Server) SetMCPReadOnly(v bool)

SetMCPReadOnly refuses every mutating MCP tool. The public demo serves /mcp with no credential on purpose (nothing is configured, so authorized() opens it), which also means any stranger could otherwise create flags, delete goals, mint export links or change retention on the very instance the marketing site renders.

func (*Server) SetReadKey added in v0.9.1

func (s *Server) SetReadKey(k string)

SetReadKey sets the SECRET read/MCP key. It authorizes reads (GET /v1/* reports, the raw export) and MCP — everything that returns data. It must NEVER be embedded in client code; only the write key is public. This is what stops a scraped write key from reading data.

func (*Server) SetSettings

func (s *Server) SetSettings(st *settings.Store)

SetSettings swaps in a persistent settings store (project, keys, session secret).

func (*Server) SetShares added in v0.4.0

func (s *Server) SetShares(st *share.Store)

func (*Server) SetSurveys added in v0.9.9

func (s *Server) SetSurveys(sv *survey.Store)

SetSurveys attaches the survey store (shared with MCP + the SDK active-surveys endpoint).

func (*Server) SetTrackPlan added in v0.3.0

func (s *Server) SetTrackPlan(tp *trackplan.Store)

SetTrackPlan attaches the tracking-plan store (shared with the MCP instrumentation tools).

func (*Server) SetWebhooks

func (s *Server) SetWebhooks(w *webhook.Store)

SetWebhooks / SetAlerts swap in the persistent notification stores (shared with MCP).

func (*Server) SetWriteKey

func (s *Server) SetWriteKey(k string)

SetWriteKey gates event ingestion behind a write key (production). Empty = open (dev). The SDK passes the same key.

Jump to

Keyboard shortcuts

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