Repository navigation
feat(ENG-15367): add the usage event, install identity and first-run notice - #569
Draft
tigh-latte wants to merge 1 commit into
Draft
tigh-latte wants to merge 1 commit into
tigh-latte wants to merge 1 commit into
Conversation
…notice Add cloudsmith_cli/core/usage with the pieces that decide what a usage event contains, before anything sends it: - event.py: the only properties that can leave the machine, each with its type and the question it answers. Setting sources are sent by name only. - identity.py and state.py: a random install ID kept in telemetry.json on laptops; CI, containers and the Docker image get a new ID per run. - environment.py: CI provider and container detection. - notice.py: a one-time, versioned notice on stderr. - settings.py: developer switches (test project key and host, log mode). Nothing calls this code yet. Every read-modify-write of telemetry.json holds an inter-process lock, so two CLI runs cannot undo each other's changes, such as putting back an install ID that was just reset. The list properties (flags, flags_typed, envvars, aliases_used) must be lists of strings; anything else is left out of the event. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds
core/usage/, the code that decides what a usage event can contain. Nothing calls it yet.event.pylists every property that can leave the machine, with its type and the question it answers. A value with the wrong type, or a property that isn't listed, is dropped. The list properties (flags,flags_typed,envvars,aliases_used) must be lists of strings; anything else is left out rather than sent one character at a time.identity.pyandstate.pykeep a random install ID intelemetry.jsonon laptops. CI runs, containers and the Docker image never keep an ID, and get a new one on every run. No event ever creates a PostHog person profile. Every change totelemetry.jsonholds an inter-process lock, so two CLI runs can't undo each other, for example by putting back an install ID thattelemetry resetjust deleted. If the lock is busy for more than 0.5 s the write is skipped rather than delaying the command.environment.pydetects CI providers and containers.notice.pyholds the one-time, versioned notice printed on stderr.settings.pyholds the developer switches: test project key and host, log mode, the install ID switch, internal tagging and the CI sample rate.What one event captures
commandlist packagesflags,flags_typed["page_size"],["-F", "--page-size"]aliases_used["ls"]envvars["CLOUDSMITH_API_KEY"]source_<setting>source_api_key: envflag,env,config_file,config_profile,credentials_file,credentials_profileauth_sourcekeyringoutput_formatjsonoutcome,exit_code,api_statusapi_error,1,404duration_ms557cli_version,channel,environment1.30.0,homebrew,productionos,os_version,python_version,archDarwin,25.6,3.13,arm64persona,ci,ci_provider,stdout_ttyci,true,github_actions,falseagentarrives in #573)first_run,install_id_persistedtrue,truesample_rate,internal,schema_version100, unset,1$geoip_disable,$process_person_profiletrue,falseNever captured: argument values, file names, package, repository or workspace names, credentials, setting values, hostnames, usernames, free text, or IP-derived location.
Sentry and PostHog: what each holds
Notice text
Type of Change
Additional Notes
N/A: no behaviour change, because nothing calls this code until #571.
🤖 Generated with Claude Code