Compare commits

...
Author SHA1 Message Date
Tabish Bidiwale 8ea48c5eaa fix: use actionCommand for telemetry command tracking
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.
2026-01-10 15:07:06 -08:00
+6 -3
View File
@@ -50,7 +50,10 @@ program
program.option('--no-color', 'Disable color output');
// Apply global flags and telemetry before any command runs
program.hook('preAction', async (thisCommand) => {
// Note: preAction receives (thisCommand, actionCommand) where:
// - thisCommand: the command where hook was added (root program)
// - actionCommand: the command actually being executed (subcommand)
program.hook('preAction', async (thisCommand, actionCommand) => {
const opts = thisCommand.opts();
if (opts.color === false) {
process.env.NO_COLOR = '1';
@@ -59,8 +62,8 @@ program.hook('preAction', async (thisCommand) => {
// Show first-run telemetry notice (if not seen)
await maybeShowTelemetryNotice();
// Track command execution
const commandPath = getCommandPath(thisCommand);
// Track command execution (use actionCommand to get the actual subcommand)
const commandPath = getCommandPath(actionCommand);
await trackCommand(commandPath, version);
});