activity

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 15 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 and the platform, 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 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
	// 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.

Jump to

Keyboard shortcuts

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