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 ¶
const ( Desktop = "desktop" CLI = "cli" VSCode = "vscode" )
The front ends (AI-01).
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).
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 ¶
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).
var Fronts = []string{Desktop, CLI, VSCode}
Fronts are the front ends a ping may name.
Functions ¶
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 ¶
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 ¶
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 ¶
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
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.