Skip to content

chore(cli): mute telemetry without removing instrumentation#2695

Open
ymc9 wants to merge 1 commit into
devfrom
chore/mute-cli-telemetry
Open

chore(cli): mute telemetry without removing instrumentation#2695
ymc9 wants to merge 1 commit into
devfrom
chore/mute-cli-telemetry

Conversation

@ymc9
Copy link
Copy Markdown
Member

@ymc9 ymc9 commented Jun 1, 2026

Summary

Mutes all CLI telemetry without deleting the telemetry code. The Mixpanel client is no longer initialized in the Telemetry constructor, so every track() call short-circuits on its if (this.mixpanel) guard and no events are sent.

Changes

  • packages/cli/src/telemetry.ts: early-return in the constructor before Mixpanel init(); the original init logic is preserved as a comment. Removed now-unused init / TELEMETRY_TRACKING_TOKEN imports.

Why this is sufficient

  • this.mixpanel stays undefined, so all events (cli:*, cli:command:*, cli:plugin:*, errors) no-op — no network requests to Mixpanel.
  • isTracking returns false, so the exit-flush delay in index.ts is also skipped.

Not removed

The full instrumentation pipeline (trackSpan, trackCommand, trackCli, payload assembly, all call sites) is intact. Re-enabling is just restoring the constructor body.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Disabled telemetry data collection.

Prevent the Mixpanel client from being initialized so all telemetry
events no-op and no data is sent. The tracking instrumentation
(trackSpan/trackCommand/trackCli and call sites) is left intact and
can be re-enabled by restoring the constructor body.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The PR disables telemetry in the CLI by modifying the Telemetry class constructor to return early, preventing Mixpanel client initialization. The telemetry API surface remains unchanged; all tracking methods continue to exist but will no longer function.

Changes

Telemetry Disablement

Layer / File(s) Summary
Disable telemetry initialization
packages/cli/src/telemetry.ts
Imports are reordered and the Telemetry constructor is modified with an early return statement; Mixpanel initialization code is commented out, preventing the mixpanel client from being created and effectively disabling all tracking.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Telemetry sleeps beneath the stars,
No pings to send, no near or far,
The mixpanel hushes, falls silent and still,
The CLI taps dance to its own free will.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore(cli): mute telemetry without removing instrumentation' accurately reflects the main change: disabling telemetry transmission while preserving all tracking code for future re-enablement.
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.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/mute-cli-telemetry

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/cli/src/telemetry.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.


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.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Jun 1, 2026

Claude finished @ymc9's task —— View job


Code Review

Reviewing PR: chore(cli): mute telemetry without removing instrumentation

Todo List

  • Read and analyze the changed telemetry.ts file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Assess performance considerations
  • Evaluate security concerns
  • Review test coverage implications
  • Provide comprehensive feedback

✅ Review Summary

This PR effectively achieves its goal of muting telemetry while preserving the instrumentation code. The implementation is clean and follows good practices.

Code Quality & Best Practices

✅ Excellent approach: The solution elegantly disables telemetry by preventing Mixpanel initialization rather than removing tracking calls throughout the codebase. This makes re-enabling trivial.

✅ Clean implementation:

  • Commented out the original initialization logic in packages/cli/src/telemetry.ts:46-50
  • Removed unused imports (init function and TELEMETRY_TRACKING_TOKEN)
  • Added clear comment explaining the current state

✅ Maintains code structure: All telemetry methods (track(), trackSpan(), trackCommand(), etc.) remain intact and functional - they just no-op when this.mixpanel is undefined.

Potential Issues

✅ No bugs identified: The implementation correctly leverages the existing guard clause if (this.mixpanel) in the track() method at packages/cli/src/telemetry.ts:61, ensuring all tracking calls are safely no-ops.

✅ Consistent behavior: The isTracking getter at packages/cli/src/telemetry.ts:56-58 correctly returns false, which prevents the 200ms exit delay in packages/cli/src/index.ts:312-319.

Performance Considerations

✅ Improved performance:

  • No Mixpanel client initialization reduces startup time
  • No network requests to telemetry endpoints
  • Skips the 200ms exit delay when telemetry is disabled
  • All metadata collection (OS info, versions, etc.) still happens but is immediately discarded

Minor consideration: The telemetry constructor still collects system metadata (OS type, version, Prisma version, etc.) at packages/cli/src/telemetry.ts:31-43 even though it won't be used. This has minimal performance impact but could be optimized if desired.

Security Concerns

✅ No security issues:

  • No sensitive data exposure
  • Removes the external network dependency to Mixpanel
  • Preserves existing privacy protections (DO_NOT_TRACK environment variable respect)

Test Coverage

Consideration needed: While the change is straightforward, consider adding tests to verify:

  • isTracking returns false when telemetry is muted
  • track() calls complete without errors
  • No network requests are made to telemetry endpoints

The change maintains backward compatibility and doesn't break existing functionality, making it low-risk.

Overall Assessment

Verdict: ✅ Approved - This is a well-executed solution that achieves the stated goal with minimal code changes and no breaking changes. The approach is reversible and maintainable.


Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/cli/src/telemetry.ts (1)

46-50: 💤 Low value

Consider documenting the required imports for re-enabling.

The commented code references init and TELEMETRY_TRACKING_TOKEN, which are not currently imported. To make re-enabling telemetry more straightforward, consider adding a comment indicating that the following import should be restored:

// To re-enable, also restore: import { init, TELEMETRY_TRACKING_TOKEN } from 'mixpanel';

This will help future developers avoid reference errors when uncommenting this code.

🤖 Prompt for 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.

In `@packages/cli/src/telemetry.ts` around lines 46 - 50, Add a short comment near
the commented telemetry block indicating the missing imports so future devs can
re-enable it without errors: mention restoring "import { init,
TELEMETRY_TRACKING_TOKEN } from 'mixpanel';" and note that these symbols (init
and TELEMETRY_TRACKING_TOKEN) are required by the commented code that
initializes this.mixpanel; place the comment adjacent to the existing commented
block in telemetry.ts.
🤖 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.

Nitpick comments:
In `@packages/cli/src/telemetry.ts`:
- Around line 46-50: Add a short comment near the commented telemetry block
indicating the missing imports so future devs can re-enable it without errors:
mention restoring "import { init, TELEMETRY_TRACKING_TOKEN } from 'mixpanel';"
and note that these symbols (init and TELEMETRY_TRACKING_TOKEN) are required by
the commented code that initializes this.mixpanel; place the comment adjacent to
the existing commented block in telemetry.ts.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0185fdbc-0e51-43af-baf5-9e48b306509d

📥 Commits

Reviewing files that changed from the base of the PR and between f41a1f6 and f8826d8.

📒 Files selected for processing (1)
  • packages/cli/src/telemetry.ts

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