Skip to content

feat(cli): add telemetry#22

Merged
PunGrumpy merged 6 commits into
mainfrom
feat/add-posthog-analytics
May 24, 2026
Merged

feat(cli): add telemetry#22
PunGrumpy merged 6 commits into
mainfrom
feat/add-posthog-analytics

Conversation

@PunGrumpy

@PunGrumpy PunGrumpy commented May 24, 2026

Copy link
Copy Markdown
Contributor

Description

Add PostHog usage tracking for the main CLI flows and print a startup notice when telemetry is enabled.

Telemetry collects git identity (email and name from `git config`) when available, using it as the distinct ID in PostHog. When git is not configured, a persistent anonymous UUID stored at `~/.config/verno/anonymous-id` is used instead.

Related Issues

N/A

Checklist

  • I've reviewed my code
  • I've written tests
  • I've generated a change set file
  • I've updated the docs, if necessary

Opt-out

Telemetry is opt-out via DO_NOT_TRACK=1 or VERNO_TELEMETRY_DISABLED=1.

Additional Notes

N/A

@react-doctor

react-doctor Bot commented May 24, 2026

Copy link
Copy Markdown

No new issues

Reviewed by reactreview for commit 0b76f09. Configure here.

@vercel

vercel Bot commented May 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
verno-studio Ready Ready Preview, Comment May 24, 2026 6:55pm

@changeset-bot

changeset-bot Bot commented May 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0b76f09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@vernostudio/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@PunGrumpy, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 11 minutes and 12 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be5336dd-5983-4753-8d1b-c5b827685109

📥 Commits

Reviewing files that changed from the base of the PR and between 1781e9a and 0b76f09.

📒 Files selected for processing (6)
  • .changeset/telemetry-and-cli-notice.md
  • packages/cli/src/commands/create/index.ts
  • packages/cli/src/commands/doctor/index.ts
  • packages/cli/src/commands/init/index.ts
  • packages/cli/src/commands/update/index.ts
  • packages/cli/src/index.ts
📝 Walkthrough

Walkthrough

This PR introduces anonymous usage telemetry to the Verno CLI using PostHog. A new analytics module manages environment-driven enablement, persistent anonymous ID generation, and event tracking. The CLI displays an opt-out notice at startup, and four core commands (create, doctor, init, update) now emit analytics events with relevant context after completing.

Changes

CLI Telemetry with PostHog

Layer / File(s) Summary
Analytics module and PostHog integration
packages/cli/src/analytics.ts, packages/cli/package.json
PostHog client initialization and telemetry configuration via DO_NOT_TRACK and VERNO_TELEMETRY_DISABLED environment variables. Anonymous ID persisted to ~/.config/verno/anonymous-id with per-run UUID fallback. Git identity detection via git config user.email. trackEvent() asynchronously sends PostHog capture with CLI/Node/platform context; failures are silently swallowed to prevent CLI breakage.
User-facing telemetry opt-out notice
packages/cli/src/index.ts
CLI entrypoint displays a dimmed informational notice to stderr at startup when telemetry is enabled, explaining anonymous data collection and the DO_NOT_TRACK=1 opt-out mechanism.
Command instrumentation: create, doctor, init, update
packages/cli/src/commands/create/index.ts, packages/cli/src/commands/doctor/index.ts, packages/cli/src/commands/init/index.ts, packages/cli/src/commands/update/index.ts
create command tracks "create_project" with frontend, addons, package manager, and configuration selections. doctor command tracks "doctor_run" on both success (zero issues) and failure (remaining issues) paths with fix mode and package manager. init command tracks "init_project" with addons, package manager, linter, UI, and dry-run selections. update command tracks "update_run" with package manager and count of applied updates.
Release documentation
.changeset/telemetry-and-cli-notice.md
Patch release note for @vernostudio/cli documenting PostHog-based telemetry and opt-out notice.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • verno-studio/website#18: Doctor command telemetry tracking directly instruments the doctor functionality from this prior PR.

Suggested labels

enhancement

Poem

🐰 A CLI that speaks its mind,
Tracking paths with peace of mind,
PostHog calls from every place,
Anonymous, with style and grace—
But whisper soft: DO_NOT_TRACK=1! 📊

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: adding telemetry functionality to the CLI, which matches the core objective of the PR.
Description check ✅ Passed The description covers the key aspects: what telemetry does, how identity is determined, opt-out mechanisms, and includes all required checklist items marked complete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/analytics.ts`:
- Around line 38-41: The code currently uses raw git user.email and user.name as
identifiable telemetry (variables email, name) and sets distinctId to the plain
email; change this to preserve anonymity by not sending plain PII: compute a
stable one-way hash (e.g., SHA-256) of the email and use that hash as distinctId
instead of the raw email, and do not include the plain email or name in the
returned telemetry payload (remove or set them to undefined). Update the block
that calls execSync(..., GIT_EXEC_OPTIONS) to still read git values for hashing
but ensure only the hashed value is emitted (referencing the variables email,
name, distinctId, and execSync) so telemetry remains anonymous.

In `@packages/cli/src/commands/create/index.ts`:
- Around line 146-156: The telemetry call to trackEvent is currently invoked
fire-and-forget; update the async flow to await the call (replace the void
trackEvent(...) invocation with await trackEvent(...)) so the promise is
resolved before proceeding and preserves ordering/reliability; ensure this
change is made where trackEvent is called with the payload (addons:
resolved.addons, frontend: resolved.frontend, linter: resolved.ultraciteLinter,
package_manager: resolved.packageManager, shadcn_preset: resolved.shadcnPreset,
skip_git: !resolved.doGit, skip_install: !resolved.doInstall, ui: resolved.ui)
inside the async function.

In `@packages/cli/src/commands/doctor/index.ts`:
- Around line 63-67: The telemetry trackEvent calls in runDoctor are being
invoked fire-and-forget; update the logic in runDoctor to await the promises
returned by trackEvent so the async function waits for delivery (e.g., replace
bare void trackEvent(...) with await trackEvent(...) or collect both promises
and await Promise.all([...]) for the two instrumentation calls referenced around
the first instance and the second at lines ~140-144); make sure to preserve
existing payloads (fix, issues_found, package_manager) and handle/propagate any
errors per project conventions.

In `@packages/cli/src/commands/init/index.ts`:
- Around line 153-160: The telemetry call currently silences the returned
promise with "void trackEvent(...)" inside runInit; change it to "await
trackEvent(...)" so the promise is awaited and errors propagate correctly, and
ensure the enclosing function (runInit) is declared async if it isn't already;
update the call site that references trackEvent to use await rather than void.

In `@packages/cli/src/commands/update/index.ts`:
- Around line 174-178: The telemetry call inside runUpdate is being invoked with
void (void trackEvent(...)) which drops the promise; change it to await
trackEvent(...) so the async telemetry send is awaited for reliability; update
the call site in the runUpdate function (where trackEvent("update_run", {...})
is invoked) to await the promise and ensure the enclosing function remains
async/await-friendly (no suppression with void) so errors can propagate or be
handled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ebee813-5580-4252-aef1-41dac999c7ac

📥 Commits

Reviewing files that changed from the base of the PR and between 6423b7d and 1781e9a.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .changeset/telemetry-and-cli-notice.md
  • packages/cli/package.json
  • packages/cli/src/analytics.ts
  • packages/cli/src/commands/create/index.ts
  • packages/cli/src/commands/doctor/index.ts
  • packages/cli/src/commands/init/index.ts
  • packages/cli/src/commands/update/index.ts
  • packages/cli/src/index.ts

Comment thread packages/cli/src/analytics.ts
Comment thread packages/cli/src/commands/create/index.ts Outdated
Comment thread packages/cli/src/commands/doctor/index.ts Outdated
Comment thread packages/cli/src/commands/init/index.ts Outdated
Comment thread packages/cli/src/commands/update/index.ts Outdated
@PunGrumpy PunGrumpy changed the title feat(cli): add anonymous telemetry feat(cli): add telemetry May 24, 2026
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@PunGrumpy PunGrumpy merged commit 32a913e into main May 24, 2026
7 checks passed
@PunGrumpy PunGrumpy deleted the feat/add-posthog-analytics branch May 24, 2026 18:56
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