Skip to content

feat(ENG-15367): ship the PostHog project key so released builds send - #585

Open
tigh-latte wants to merge 2 commits into
eng-15367-7-send-policyfrom
eng-15367-8-project-key
Open

tigh-latte wants to merge 2 commits into
eng-15367-7-send-policyfrom
eng-15367-8-project-key

Conversation

@tigh-latte

@tigh-latte tigh-latte commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Usage telemetry stack, part 8 of 8. Builds on #584. Do not merge until the checklist below is done: this is the PR that turns usage telemetry on.

Description

This PR ships the PostHog project key, so released builds start sending one cli command executed event per run. Everything else in the stack is already in place and sends nothing without a key.

  • core/usage/settings.py: POSTHOG_PROJECT_KEY is the write-only key of the dedicated "Cloudsmith CLI" PostHog EU project (eu.i.posthog.com).
  • The key is not a secret: a PostHog project key can only ingest events, like the Sentry DSN the CLI already ships. Its line carries # gitleaks:allow, so the secret scanner skips that line only (the same key anywhere else is still flagged), and .typos.toml ignores phc_ keys.
  • conftest.py blanks the built-in key for every unit test, so no test can send; usage_events still supplies a test key.

Behaviour changes

  • Released builds send usage events, subject to every rule in the stack: the three opt-outs, @telemetry.send policies, the first-run notice (the first interactive run sends nothing), non-Cloudsmith API hosts, SSL verification off, CI sampling, the 24 h backoff and the shared 1 s exit budget.
  • Development builds (source checkouts, editable installs) still send nothing unless CLOUDSMITH_TELEMETRY_POSTHOG_KEY is set.
  • cloudsmith telemetry status on a released build now says on (enabled) unless something turns it off.

Before merging

  • Erasure: retention only. Events keep $process_person_profile: false; PostHog deletes them 12 to 13 months after they are sent (project retention set to 12 months), and they cannot be deleted on request before then. The README, CHANGELOG and docs page say so.
  • PostHog project settings: IP discard on, GeoIP transformation off, a Drop Events transformation for every event name other than cli command executed (tested), retention 12 months, no destinations or exports.
  • Erasure runbook written (draft shared separately).
  • Notice text final: a short Homebrew-style notice that links the docs page "(and how to opt out)".
  • CHANGELOG and README entries.
  • Docs page PR for usage telemetry merged (https://docs.cloudsmith.com/developer-tools/cli-telemetry).
  • At release: switch the PostHog dashboards from the development to the production environment filter.

Type of Change

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

Additional Notes

The project already holds test data (the spike's events and synthetic events used to build the dashboards). All of it is tagged environment: development, and every product dashboard filters on the environment, so it never mixes with production data.

The repo's betterleaks.toml is not read by the secret scanner: betterleaks looks for .betterleaks.toml (with a leading dot), so pre-commit and CI use its built-in rules. That is why this PR uses an inline gitleaks:allow rather than editing betterleaks.toml. Fixing the file name is a separate change.

tigh-latte and others added 2 commits November 4, 2026 11:09
Set POSTHOG_PROJECT_KEY to the write-only key of the dedicated
"Cloudsmith CLI" PostHog EU project. Released builds now send one usage
event per run, under every rule from the rest of the stack: opt-outs,
per-command policies, the first-run notice, non-Cloudsmith hosts, SSL
off, CI sampling and the 1 s budget. Development builds still send
nothing unless CLOUDSMITH_TELEMETRY_POSTHOG_KEY is set.

The key is not a secret (PostHog project keys can only ingest events),
so its line carries gitleaks:allow and typos ignores phc_ keys. Unit
tests run with the built-in key blanked, so none can send.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first-run notice now follows Homebrew's: what is collected in one
sentence, what is never collected, a link to the docs page "(and how to
opt out)", and that nothing was sent. The install ID, the telemetry
commands, the opt-outs, log mode and retention are on the docs page. The
wording is final.

Events carry no person profile, so PostHog cannot delete one install's
events on request. The CHANGELOG and the new README Telemetry section
say that PostHog deletes events 12 to 13 months after they are sent (the
project's retention is 12 months and PostHog cleans up monthly).

The CHANGELOG describes what the event contains and what is never sent,
the install ID, the first-run notice, the runs that send nothing, the
1 s wait and the opt-outs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tigh-latte
tigh-latte force-pushed the eng-15367-8-project-key branch from 26cda54 to 918e524 Compare November 4, 2026 11:13
@tigh-latte
tigh-latte force-pushed the eng-15367-7-send-policy branch from 0b1d429 to 9a7b50f Compare November 4, 2026 11:13

This branch has not been deployed

No deployments
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.

1 participant