Skip to content

fix: use actionCommand for telemetry command tracking#472

Merged
TabishB merged 1 commit intomainfrom
fix/telemetry-command-tracking
Jan 10, 2026
Merged

fix: use actionCommand for telemetry command tracking#472
TabishB merged 1 commit intomainfrom
fix/telemetry-command-tracking

Conversation

@TabishB
Copy link
Copy Markdown
Contributor

@TabishB TabishB commented Jan 10, 2026

Summary

  • Fix telemetry command tracking to use the correct command parameter
  • The preAction hook receives (thisCommand, actionCommand) where thisCommand is the root program and actionCommand is the actual subcommand being executed
  • Previously, using thisCommand would incorrectly track the root command instead of the actual subcommand run by the user

Test plan

  • Run openspec init and verify telemetry tracks "init" not the root command
  • Run other subcommands and verify correct tracking

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Improved CLI command tracking to correctly identify and track subcommands instead of parent commands.
  • Refactor

    • Updated internal command handling logic to ensure more accurate command path resolution.

✏️ Tip: You can customize this high-level summary in your review settings.

The preAction hook receives (thisCommand, actionCommand) where thisCommand
is the root program and actionCommand is the actual subcommand being run.
Using thisCommand was incorrectly tracking the root command instead of
the actual subcommand executed by the user.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 10, 2026

📝 Walkthrough

Walkthrough

The preAction hook callback in the CLI now accepts two parameters (thisCommand, actionCommand) instead of one, using actionCommand to correctly track the actual subcommand path. Clarifying comments were added. No exported signatures or core behavior changed.

Changes

Cohort / File(s) Summary
CLI Hook Parameter Update
src/cli/index.ts
Modified preAction hook callback signature from single parameter to two parameters (thisCommand, actionCommand). Updated command path derivation to use actionCommand instead of thisCommand. Added inline comments clarifying parameter usage.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hook that tracks the right command's call,
Two parameters dance, no longer just one,
The path is now clear, the subcommands enthrall,
With comments to guide, the telemetry's fun! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately summarizes the main change: fixing telemetry command tracking to use actionCommand instead of thisCommand.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4715138 and 8ea48c5.

📒 Files selected for processing (1)
  • src/cli/index.ts
🔇 Additional comments (2)
src/cli/index.ts (2)

53-56: LGTM! Excellent documentation and correct signature.

The comments clearly explain the distinction between thisCommand and actionCommand, which is crucial for understanding why actionCommand is used for telemetry tracking. The signature change correctly captures both parameters from the hook.


65-67: Approved: Fix correctly uses actionCommand for accurate subcommand telemetry tracking.

The change from thisCommand to actionCommand is correct and fixes the telemetry bug. The preAction hook receives the actual subcommand being executed via actionCommand, allowing getCommandPath to properly resolve nested command paths (e.g., "init", "change:show") instead of always tracking the root command.

Consider adding automated tests to verify telemetry captures the correct command name across various subcommands and nested scenarios.


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.

@vibe-kanban-cloud
Copy link
Copy Markdown

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

@TabishB TabishB merged commit 4971cda into main Jan 10, 2026
6 of 7 checks passed
torykit pushed a commit to OpenLoaf/OpenSpec-Chinese that referenced this pull request Feb 21, 2026
The preAction hook receives (thisCommand, actionCommand) where thisCommand
is the root program and actionCommand is the actual subcommand being run.
Using thisCommand was incorrectly tracking the root command instead of
the actual subcommand executed by the user.
StevenWolfe pushed a commit to AnchorSpec/AnchorSpec that referenced this pull request Mar 27, 2026
The preAction hook receives (thisCommand, actionCommand) where thisCommand
is the root program and actionCommand is the actual subcommand being run.
Using thisCommand was incorrectly tracking the root command instead of
the actual subcommand executed by the user.
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