From ead7fcca6c6e2b74912e076168cc6ccb3b4880cf Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Mon, 23 Feb 2026 12:32:43 +0000 Subject: [PATCH] fix(telemetry): fix commands importing buildCommand directly from @stricli/core trace/list, trace/view, log/view, and api.ts were importing buildCommand directly from @stricli/core, bypassing the telemetry wrapper in lib/command.ts that captures flag and arg context for Sentry. Switch all four to the local wrapper. Adds a prominent comment in command.ts documenting this requirement. help.ts is intentionally left on @stricli/core since it also needs `run` and has no meaningful flags to capture. --- src/commands/api.ts | 2 +- src/commands/log/view.ts | 2 +- src/commands/trace/list.ts | 2 +- src/commands/trace/view.ts | 2 +- src/lib/command.ts | 10 +++++++++- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/commands/api.ts b/src/commands/api.ts index 0213769f..0e156bc4 100644 --- a/src/commands/api.ts +++ b/src/commands/api.ts @@ -5,9 +5,9 @@ * Similar to 'gh api' for GitHub. */ -import { buildCommand } from "@stricli/core"; import type { SentryContext } from "../context.js"; import { rawApiRequest } from "../lib/api-client.js"; +import { buildCommand } from "../lib/command.js"; import type { Writer } from "../types/index.js"; type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH"; diff --git a/src/commands/log/view.ts b/src/commands/log/view.ts index 71bafe36..6299652e 100644 --- a/src/commands/log/view.ts +++ b/src/commands/log/view.ts @@ -4,7 +4,6 @@ * View detailed information about a Sentry log entry. */ -import { buildCommand } from "@stricli/core"; import type { SentryContext } from "../../context.js"; import { getLog } from "../../lib/api-client.js"; import { @@ -12,6 +11,7 @@ import { parseSlashSeparatedArg, } from "../../lib/arg-parsing.js"; import { openInBrowser } from "../../lib/browser.js"; +import { buildCommand } from "../../lib/command.js"; import { ContextError, ValidationError } from "../../lib/errors.js"; import { formatLogDetails, writeJson } from "../../lib/formatters/index.js"; import { diff --git a/src/commands/trace/list.ts b/src/commands/trace/list.ts index 65fea21e..d8be39bd 100644 --- a/src/commands/trace/list.ts +++ b/src/commands/trace/list.ts @@ -4,10 +4,10 @@ * List recent traces from Sentry projects. */ -import { buildCommand } from "@stricli/core"; import type { SentryContext } from "../../context.js"; import { listTransactions } from "../../lib/api-client.js"; import { validateLimit } from "../../lib/arg-parsing.js"; +import { buildCommand } from "../../lib/command.js"; import { formatTraceRow, formatTracesHeader, diff --git a/src/commands/trace/view.ts b/src/commands/trace/view.ts index c882e398..e34a6558 100644 --- a/src/commands/trace/view.ts +++ b/src/commands/trace/view.ts @@ -4,7 +4,6 @@ * View detailed information about a distributed trace. */ -import { buildCommand } from "@stricli/core"; import type { SentryContext } from "../../context.js"; import { getDetailedTrace } from "../../lib/api-client.js"; import { @@ -13,6 +12,7 @@ import { spansFlag, } from "../../lib/arg-parsing.js"; import { openInBrowser } from "../../lib/browser.js"; +import { buildCommand } from "../../lib/command.js"; import { ContextError, ValidationError } from "../../lib/errors.js"; import { computeTraceSummary, diff --git a/src/lib/command.ts b/src/lib/command.ts index 877161b1..bf7f6169 100644 --- a/src/lib/command.ts +++ b/src/lib/command.ts @@ -2,7 +2,15 @@ * Command Builder with Telemetry * * Wraps Stricli's buildCommand to automatically capture flag usage for telemetry. - * Commands should import buildCommand from this module instead of @stricli/core. + * + * ALL commands MUST import `buildCommand` from this module, NOT from `@stricli/core`. + * Importing directly from `@stricli/core` silently bypasses flag/arg telemetry capture. + * + * Correct: import { buildCommand } from "../../lib/command.js"; + * Incorrect: import { buildCommand } from "@stricli/core"; // skips telemetry! + * + * Exception: `help.ts` may import from `@stricli/core` because it also needs `run`, + * and the help command has no meaningful flags to capture. */ import {