Skip to content

Commit 4971cda

Browse files
authored
fix: use actionCommand for telemetry command tracking (Fission-AI#472)
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.
1 parent 4715138 commit 4971cda

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/cli/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ program
5050
program.option('--no-color', 'Disable color output');
5151

5252
// Apply global flags and telemetry before any command runs
53-
program.hook('preAction', async (thisCommand) => {
53+
// Note: preAction receives (thisCommand, actionCommand) where:
54+
// - thisCommand: the command where hook was added (root program)
55+
// - actionCommand: the command actually being executed (subcommand)
56+
program.hook('preAction', async (thisCommand, actionCommand) => {
5457
const opts = thisCommand.opts();
5558
if (opts.color === false) {
5659
process.env.NO_COLOR = '1';
@@ -59,8 +62,8 @@ program.hook('preAction', async (thisCommand) => {
5962
// Show first-run telemetry notice (if not seen)
6063
await maybeShowTelemetryNotice();
6164

62-
// Track command execution
63-
const commandPath = getCommandPath(thisCommand);
65+
// Track command execution (use actionCommand to get the actual subcommand)
66+
const commandPath = getCommandPath(actionCommand);
6467
await trackCommand(commandPath, version);
6568
});
6669

0 commit comments

Comments
 (0)