Skip to content

Commit 0a8e649

Browse files
authored
fix(telemetry): fix commands importing buildCommand directly from @stricli/core (#275)
## Summary `trace/list`, `trace/view`, `log/view`, and `api.ts` were importing `buildCommand` directly from `@stricli/core`, silently bypassing the telemetry wrapper in `src/lib/command.ts` that captures flag and arg context as Sentry tags. ## Changes - Switch all four commands to import from `../../lib/command.js` (or `../lib/command.js`) - Add a prominent JSDoc comment in `command.ts` documenting the requirement and the exception for `help.ts` ## Not changed `help.ts` is intentionally left on `@stricli/core` — it also imports `run` from there, and the help command has no meaningful flags to capture for telemetry. ## Notes A Biome `noRestrictedImports` lint rule to enforce this statically was investigated but the rule is not available in the version of Biome used here. The JSDoc comment in `command.ts` serves as the documented convention instead.
1 parent 24fe62c commit 0a8e649

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

src/commands/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
* Similar to 'gh api' for GitHub.
66
*/
77

8-
import { buildCommand } from "@stricli/core";
98
import type { SentryContext } from "../context.js";
109
import { rawApiRequest } from "../lib/api-client.js";
10+
import { buildCommand } from "../lib/command.js";
1111
import type { Writer } from "../types/index.js";
1212

1313
type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";

src/commands/log/view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* View detailed information about a Sentry log entry.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
98
import { getLog } from "../../lib/api-client.js";
109
import {
1110
parseOrgProjectArg,
1211
parseSlashSeparatedArg,
1312
} from "../../lib/arg-parsing.js";
1413
import { openInBrowser } from "../../lib/browser.js";
14+
import { buildCommand } from "../../lib/command.js";
1515
import { ContextError, ValidationError } from "../../lib/errors.js";
1616
import { formatLogDetails, writeJson } from "../../lib/formatters/index.js";
1717
import {

src/commands/trace/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
* List recent traces from Sentry projects.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
98
import { listTransactions } from "../../lib/api-client.js";
109
import { validateLimit } from "../../lib/arg-parsing.js";
10+
import { buildCommand } from "../../lib/command.js";
1111
import {
1212
formatTraceRow,
1313
formatTracesHeader,

src/commands/trace/view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* View detailed information about a distributed trace.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
98
import { getDetailedTrace } from "../../lib/api-client.js";
109
import {
@@ -13,6 +12,7 @@ import {
1312
spansFlag,
1413
} from "../../lib/arg-parsing.js";
1514
import { openInBrowser } from "../../lib/browser.js";
15+
import { buildCommand } from "../../lib/command.js";
1616
import { ContextError, ValidationError } from "../../lib/errors.js";
1717
import {
1818
computeTraceSummary,

src/lib/command.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22
* Command Builder with Telemetry
33
*
44
* Wraps Stricli's buildCommand to automatically capture flag usage for telemetry.
5-
* Commands should import buildCommand from this module instead of @stricli/core.
5+
*
6+
* ALL commands MUST import `buildCommand` from this module, NOT from `@stricli/core`.
7+
* Importing directly from `@stricli/core` silently bypasses flag/arg telemetry capture.
8+
*
9+
* Correct: import { buildCommand } from "../../lib/command.js";
10+
* Incorrect: import { buildCommand } from "@stricli/core"; // skips telemetry!
11+
*
12+
* Exception: `help.ts` may import from `@stricli/core` because it also needs `run`,
13+
* and the help command has no meaningful flags to capture.
614
*/
715

816
import {

0 commit comments

Comments
 (0)