Skip to content

Add opt-out PostHog telemetry to the Python CLI - #135

Open
manish-wekan wants to merge 7 commits into
developfrom
feature/analytics-telemetry
Open

manish-wekan wants to merge 7 commits into
developfrom
feature/analytics-telemetry

Conversation

@manish-wekan

@manish-wekan manish-wekan commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

What

On-by-default, opt-out PostHog telemetry for the nitrostack Python CLI, following the shared Nitrostack event taxonomy (<product>_<object>_<action>).

  • nitrostack/cli/telemetry.py: a small client with the super properties product, surface, environment and app_version; identifies by the NitroCloud user id with an email person property and groups by organization.
  • Events wired in main.py and pack.py: command runs, init, pack/deploy, and login identity.
  • Ships the public PostHog project key (a write-only phc_ key, safe to embed) as the default; NITROSTACK_POSTHOG_KEY and NITROSTACK_POSTHOG_HOST override it.
  • Opt-out: DO_NOT_TRACK=1 or NITROSTACK_TELEMETRY=0. Also off in CI (CI, GITHUB_ACTIONS) and under pytest unless NITROSTACK_TELEMETRY is set. Telemetry never blocks or fails a command.
  • Docs: docs/analytics-events.md (event dictionary), README and .env.example.

Tests

tests/test_telemetry.py runs against a local stub capture server, never real PostHog. It covers the opt-out, the payload shape, identify/group, and failure isolation.

Review notes

  • Adds the posthog dependency (pyproject.toml, uv.lock).
  • Events start flowing only after a release that includes this.

🤖 Generated with Claude Code

manish-wekan and others added 4 commits November 6, 2026 16:16
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ide.

Telemetry now uses a built-in public project key when NITROSTACK_POSTHOG_KEY is unset; NITROSTACK_POSTHOG_HOST still defaults to US Cloud. Renamed the override env to NITROSTACK_POSTHOG_KEY, documented behavior, added roadmap item, and a test that the default key is resolved without network.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@manish-wekan manish-wekan self-assigned this Nov 9, 2026
manish-wekan and others added 3 commits November 9, 2026 18:42
Vendored projects do not need the PostHog SDK; the CLI no-ops when
import posthog fails. Fix E501 on the default-key comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Assert capture is blocked under opt-out and allowed otherwise so tests
do not pass vacuously under PYTEST_CURRENT_TEST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@manish-wekan
manish-wekan marked this pull request as ready for review November 11, 2026 12:44

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant