activity

package
v1.3.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 20 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package activity counts the install as active, once a day it's used (spec_054_active_installs): the first time a front end is used on a day, it's marked in ~/.blitz/activity.json and a ping goes to Retail Cortex with the install's random ID, the day, the front end, the version, the platform and whether it went through a proxy (not which), and nothing else. A ping that fails is tried again for up to Keep days. [usage] count = false turns all of it off.

Index

Constants

View Source
const (
	Desktop = "desktop"
	CLI     = "cli"
	VSCode  = "vscode"
)

The front ends (AI-01).

View Source
const AgentEnv = "BLITZ_AGENT"

AgentEnv marks the commands Blitz runs for the model (its shell, its language servers): a blitz command run there is the agent's, not the person's use of the CLI, and isn't counted (AI-03a).

View Source
const URL = "https://license.retailcortex.com/v1/blitz/active"

URL is where the pings go (AI-10); BLITZ_ACTIVITY_URL replaces it (AI-13).

Variables

View Source
var (
	Wait = 5 * time.Second
	Keep = 3
)

Wait is how long a ping may take (AI-11); Keep how many days before today a ping that failed is still tried (AI-12).

View Source
var Fronts = []string{Desktop, CLI, VSCode}

Fronts are the front ends a ping may name.

Functions

func InstallID

func InstallID(dir string) (string, error)

InstallID is the install's ID, 16 random bytes in hex, made the first time in dir/install-id and read after (AI-20).

Types

type Recorder

type Recorder struct {
	Dir     string // ~/.blitz: activity.json and install-id
	Version string // Blitz's
	// On says whether use is counted: [usage] count (AI-30), read at each
	// use so a change applies at once. nil is on.
	On func() bool
	// URL is where the pings go: URL, or BLITZ_ACTIVITY_URL, unless set.
	URL  string
	HTTP *http.Client
	Now  func() time.Time
	// CAFile is a PEM file of certificate authorities to trust besides the
	// system's ([network] ca_file: a company's TLS-inspecting proxy), read
	// at each ping; nil or "" for none.
	CAFile func() string
	// Send, when set, sends a ping another way than Go's HTTP client: the
	// desktop app's own network (AI-14), which uses the system's proxy
	// settings, its PAC file and sign-in, as the browser does. It sets
	// the ping's proxy field and says the answer's HTTP status.
	Send func(ctx context.Context, url string, ping map[string]string) (int, error)
	// contains filtered or unexported fields
}

Recorder marks the day's use and sends the pings. Its zero value isn't usable: give Dir and Version at least.

func (*Recorder) Flush

func (r *Recorder) Flush(ctx context.Context) error

Flush sends the pings still to send (AI-10, AI-12): those Retail Cortex takes, or refuses as not counted, aren't sent again; those that fail are kept for a later flush, within Keep days. The file isn't locked while the pings go (AI-11: a Mark never waits on the network), and what was sent is merged into the file as it is then, so a day marked meanwhile, here or by another process, is kept.

func (*Recorder) Mark

func (r *Recorder) Mark(front string) (bool, error)

Mark notes that front was used today, and says whether a ping is due for it: false when it was already marked today, or use isn't counted (AI-01 to AI-04, AI-30).

func (*Recorder) Use

func (r *Recorder) Use(front string) <-chan struct{}

Use marks front's use today and, when a ping is due, sends it in the background: the caller never waits (AI-11). The channel closes when that's done, for a program about to exit to wait on briefly.

func (*Recorder) UseAndSend added in v0.9.13

func (r *Recorder) UseAndSend(front string) <-chan struct{}

UseAndSend marks front's use today and sends, in the background, every ping still to send, due today or not: the desktop app's host, which sends through the system's proxy (AI-14), sends the pings another process marked and couldn't (the service, which has no proxy). The channel closes when that's done.

Jump to

Keyboard shortcuts

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