Skip to content

feat(ENG-15367): send the deprecated names a run used - #587

Closed
tigh-latte wants to merge 5 commits into
eng-15367-7-send-policyfrom
eng-15367-9-deprecated-usage
Closed

tigh-latte wants to merge 5 commits into
eng-15367-7-send-policyfrom
eng-15367-9-deprecated-usage

Conversation

@tigh-latte

Copy link
Copy Markdown
Collaborator

Usage telemetry stack, part 8 of 9. Builds on #584. Next: #585.

Description

This PR adds a deprecated property to the usage event. It lists the deprecated names that the run used, so we can see who still depends on a name before it is removed in 2.0.0.

Kind Example Recorded by
command command:login, command:token the deprecated login command
option option:--org, option:--show-all, option:--token deprecation.warn_option
env env:CLOUDSMITH_ORG, env:CLOUDSMITH_API_PROXY deprecation.warn_envvar
config config:api_proxy, config:org deprecation.warn_config_key
  • deprecation.record(kind, name) adds <kind>:<name> to the root ctx.meta; collect_facts reads it with deprecation.used(meta). The warn_* helpers call it before they decide whether to print, so a suppressed warning (credential helpers, shell completion) is still recorded. Those runs send no usage event anyway.
  • Every name comes from the code: option spellings and env var names that the options declare, keys of CONFIG_KEY_REPLACEMENTS, and command names. Never a value from the user.
  • A new deprecation needs no telemetry change as long as it warns through cli/deprecation.py. AGENTS.md says so.

The PostHog dashboard "CLI: Command and flag use" already has three insights on this property: the share of runs that used a deprecated name, a table of every deprecated name still in use (runs, human installs, CI and agent runs, newest version, last seen), and daily runs by persona.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

Since #574 the old spellings are hidden deprecated_* options, so flags and flags_typed already show them by parameter name and spelling. They do not cover config.ini keys, the deprecated auth flags or the login command, which is why this PR adds one explicit property.

BartoszBlizniak and others added 5 commits November 5, 2026 10:10
… every run

A hook on the root command records the command path, the flags and
aliases used, where each setting came from, the login method and the API
status, all from the Click context, so new commands and flags need no
telemetry code. AliasGroup.main hands the run to the sender when it ends.

Credential helper commands and login use the tracked command classes so
their runs are recorded (or excluded) consistently.

Grouped short options (-vS, -vPname) are split up as Click does, so a
typed -S or -P always reaches the send rules. The reported env var is
the first non-empty one, as Click uses, and a typed --help only counts
as help when the run succeeded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- telemetry status: shows whether usage telemetry would send and why not.
- telemetry id: shows the install ID.
- telemetry reset: deletes the install ID.

Our release, binary and image workflows set CLOUDSMITH_NO_TELEMETRY so
smoke tests send nothing. AGENTS.md gets the rules for working on usage
telemetry.

telemetry status applies typed flags (-S) the same way the send rules
do. The macOS clean-room smoke test passes CLOUDSMITH_NO_TELEMETRY
explicitly, since env -i drops the workflow's value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A run gets persona "agent" when the environment shows an AI coding agent
ran the command. Only markers that agents set for the commands they run
are read (Claude Code, Codex CLI, Gemini CLI, Copilot, then AI_AGENT);
markers that IDEs also set in a person's own terminal are ignored. A new
"agent" property carries a name defined in code, never the variable's
value, and unknown AI_AGENT values become "unidentified_agent". Agent
wins the persona even in CI; ci and ci_provider stay as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A command declares what it may send with @telemetry.send(...) from
cloudsmith_cli/cli/telemetry.py: NONE, ERRORS (Sentry reports only),
USAGE (usage events only) or ALL, the default. A policy on a group
applies to every command under it unless a command sets its own, and it
only narrows what is sent: the opt-outs always win.

This replaces the list of excluded command names in core/usage/run.py.
Credential helpers, mcp start and the telemetry group use ERRORS, so
they still report crashes and send no usage events, as before. A test
lists every command that sends less than ALL, so a change of policy is
always visible in review.

CLOUDSMITH_TELEMETRY=log now covers error reports too: the scrubbed
Sentry event is printed to stderr instead of being sent, even without a
DSN. Before, log mode only showed usage events and error reports were
still sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add a `deprecated` list property: the deprecated commands, option
spellings, environment variables and config.ini keys that the run used,
as `<kind>:<name>` (for example `option:--org`, `env:CLOUDSMITH_API_PROXY`,
`config:api_proxy`, `command:login`). It answers who still depends on a
name before it is removed in 2.0.0.

`deprecation.record` notes each name in the root ctx.meta. The warn_*
helpers and the deprecated login command call it before they decide
whether to print, so a suppressed warning (credential helpers, shell
completion) is still recorded; those runs send no usage event anyway.
Every name comes from the code: option spellings and env var names that
the options declare, keys of CONFIG_KEY_REPLACEMENTS, and command names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@cloudsmith-iduffy cloudsmith-iduffy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice!

@tigh-latte

Copy link
Copy Markdown
Collaborator Author

Closing: we decided not to mark deprecations in the CLI's telemetry. Old names are already visible in the raw properties (flags_typed, envvars, command, aliases_used), and #571 now adds config_keys (the config.ini / credentials.ini key names that are set, as written) so renamed config keys show too. Which names count as deprecated is decided in PostHog when building dashboards, so it also works for names we have not deprecated yet. #585 is back on #584.

@tigh-latte tigh-latte closed this Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants