brief

package
v0.91.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package brief computes the morning "what to fix" digest: the pulse (last N days vs the N before), the per-product portfolio split, and the verdict engine's findings. One struct feeds the CLI text, JSON, webhook, and the cloud's email renderings, so they can never disagree.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Format

func Format(b Brief) string

Format renders the digest as plain text — no ANSI, short lines — so it reads the same in a terminal, an email body, or a Slack message.

Types

type Brief

type Brief struct {
	GeneratedAt   time.Time         `json:"generated_at"`
	Days          int               `json:"days"`
	Visitors      int               `json:"visitors"`
	Events        int               `json:"events"`
	PriorVisitors int               `json:"prior_visitors"`
	PriorEvents   int               `json:"prior_events"`
	Sites         []SiteLine        `json:"sites,omitempty"`
	Findings      []insight.Finding `json:"findings"`
	// Investigation is the PM half: conclusions, each with a size, a cause and a next move,
	// ranked so the most expensive thing leads.
	//
	// The pulse above tells you traffic moved. That is the raw material a PM would then spend a
	// morning slicing. This is the slicing, already done — which is the difference between a
	// digest someone skims and one they act on.
	Investigation investigate.Investigation `json:"investigation"`
}

Brief is the computed digest.

func Build

func Build(evs []event.Event, days int, now time.Time) Brief

Build computes the pulse windows ([now-N, now) vs [now-2N, now-N)) and runs the verdict engine, without instance context. Prefer BuildCtx wherever the flag, deploy or acted stores are in reach.

func BuildCtx added in v0.85.2

func BuildCtx(evs []event.Event, days int, now time.Time, ctx *Context) Brief

BuildCtx is Build with the same instance context the dashboard's investigation gets.

type Context added in v0.85.2

type Context struct {
	Flags   []flag.Flag
	Deploys []deploys.Deploy
	Acted   func(string) (time.Time, bool)
	// Planned is the tracking-plan lookup. Without it the emailed brief would report
	// "checkout fell 100%" about the very event the dashboard is calling a tracking break —
	// the same split this type was created to close, one finding kind later.
	Planned investigate.PlanLookup
}

Context is the optional instance state the investigation reads beyond the events: recorded flags (the kill list), deploy markers (cause attribution), and the outcome ledger (the acted/verified overlay). All optional, all nil-safe.

It exists because the brief was the one surface built from investigate.Run while the dashboard used WithContext — so on an instance that records deploys, the emailed finding said "no deploy recorded near this day" while the desk named the ship. Same events, two answers; the email even invites the reader to record deploys they already record.

type SiteLine

type SiteLine struct {
	Site          string `json:"site"`
	Visitors      int    `json:"visitors"`
	Events        int    `json:"events"`
	PriorVisitors int    `json:"prior_visitors"`
	PriorEvents   int    `json:"prior_events"`
}

SiteLine is one product's slice of the pulse. The SDK stamps every event's `site` (hostname) — the same key the dashboard's site selector filters on — so one instance carrying several products splits cleanly per site.

Jump to

Keyboard shortcuts

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