Repository navigation
feat(ENG-15367): add the usage sender and the end-of-run send rules - #570
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
sender.py sends one event with a plain POST on its own session: the CLI's proxy and CA settings, no user headers, no client certificate, no .netrc, no retries and no redirects, inside the shared 1 second budget. run.py decides whether a run sends at all: opt-outs, excluded commands, non-Cloudsmith API hosts, SSL verification off, development builds without a test key, the first interactive run that shows the notice, CI sampling and a 24 hour backoff after a failed send. It never raises. Turning telemetry off (DO_NOT_TRACK, CLOUDSMITH_NO_TELEMETRY or telemetry = false) also deletes the stored install ID, so opting back in starts a new, unlinked one; a config.ini that cannot be read blocks sending but deletes nothing. The CI sample rate applies to CI runs only. The sender follows the command's --without-ssl-verify-strict and counts its own setup against the wait budget. Test fixtures fail any unit test that tries to send. 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 the sender and the rules for whether a run sends. Nothing calls them yet.
sender.pysends one event with a plain POST on its own session. It never reuses the API session, so user headers, the API key, client certificates and.netrccredentials can't reach PostHog. It keeps the CLI's proxy and CA settings, so it works behind TLS-intercepting proxies. It never retries or follows a redirect. It follows the command's--without-ssl-verify-strict(certificates are always verified). It runs in a background thread inside the 1 s exit budget from refactor(ENG-15367): share telemetry opt-outs and the exit wait budget #568; building the session counts against that budget too, and failures are silent.run.pydecides whether a run sends at all. The checks run cheapest first and stop at the first "no", so excluded commands such as credential helpers pay almost nothing. It never raises.We use a plain POST rather than the PostHog SDK because it adds no dependency, is faster to start, and the SDK ignores the CLI's
--proxyand CA settings.When a run sends nothing
DO_NOT_TRACK,CLOUDSMITH_NO_TELEMETRY,telemetry = falsemcp start, thetelemetrygroupmcp startis long-running.telemetrymanages telemetry itself.install,uninstallandlistundercredential-helperdo sendcloudsmith.ioorcloudsmith.comCLOUDSMITH_TELEMETRY_CI_SAMPLE_RATE, default 100; CI runs only, not containers)sample_rateso counts can be scaled back upTurning telemetry off also deletes the stored install ID, so opting back in starts a new, unlinked one. A
config.inithat can't be read blocks sending but deletes nothing.CLOUDSMITH_TELEMETRY=logprints the event to stderr and sends nothing.Type of Change
Additional Notes
The test suite's
conftest.pyreplaces the POST with one that fails the test, so unit tests can never send; a test that tries to send fails at teardown. Tests that check sending use theusage_eventsfixture.🤖 Generated with Claude Code