Skip to content

Commit 2e830bf

Browse files
committed
feat(telemetry): auto-capture command flags as Sentry tags
Add buildCommand wrapper that automatically captures flag values as telemetry tags (e.g., flag.verbose, flag.no-modify-path). Commands just need to import buildCommand from lib/command.js instead of @stricli/core - no other changes needed. - Add setFlagContext() helper in telemetry.ts - Add buildCommand wrapper in new lib/command.ts - Update all 19 commands to use the wrapper
1 parent faedb9e commit 2e830bf

23 files changed

Lines changed: 327 additions & 19 deletions

src/commands/auth/login.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { buildCommand, numberParser } from "@stricli/core";
21
import type { SentryContext } from "../../context.js";
32
import { getCurrentUser, getUserRegions } from "../../lib/api-client.js";
3+
import { buildCommand, numberParser } from "../../lib/command.js";
44
import { clearAuth, isAuthenticated, setAuthToken } from "../../lib/db/auth.js";
55
import { getDbPath } from "../../lib/db/index.js";
66
import { setUserInfo } from "../../lib/db/user.js";

src/commands/auth/logout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Clear stored authentication credentials.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
8+
import { buildCommand } from "../../lib/command.js";
99
import { clearAuth, isAuthenticated } from "../../lib/db/auth.js";
1010
import { getDbPath } from "../../lib/db/index.js";
1111
import { success } from "../../lib/formatters/colors.js";

src/commands/auth/refresh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Manually refresh the authentication token.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
8+
import { buildCommand } from "../../lib/command.js";
99
import { getAuthConfig, refreshToken } from "../../lib/db/auth.js";
1010
import { AuthError } from "../../lib/errors.js";
1111
import { success } from "../../lib/formatters/colors.js";

src/commands/auth/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Display authentication status and verify credentials.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
98
import { listOrganizations } from "../../lib/api-client.js";
9+
import { buildCommand } from "../../lib/command.js";
1010
import {
1111
type AuthConfig,
1212
getAuthConfig,

src/commands/auth/token.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* Useful for piping to other commands or scripts.
66
*/
77

8-
import { buildCommand } from "@stricli/core";
98
import type { SentryContext } from "../../context.js";
9+
import { buildCommand } from "../../lib/command.js";
1010
import { getAuthToken } from "../../lib/db/auth.js";
1111
import { AuthError } from "../../lib/errors.js";
1212

src/commands/cli/feedback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
// biome-ignore lint/performance/noNamespaceImport: Sentry SDK recommends namespace import
1212
import * as Sentry from "@sentry/bun";
13-
import { buildCommand } from "@stricli/core";
1413
import type { SentryContext } from "../../context.js";
14+
import { buildCommand } from "../../lib/command.js";
1515
import { ValidationError } from "../../lib/errors.js";
1616

1717
export const feedbackCommand = buildCommand({

src/commands/cli/fix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Diagnose and repair CLI database issues.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
8+
import { buildCommand } from "../../lib/command.js";
99
import { getDbPath, getRawDatabase } from "../../lib/db/index.js";
1010
import {
1111
CURRENT_SCHEMA_VERSION,

src/commands/cli/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
import { dirname } from "node:path";
9-
import { buildCommand } from "@stricli/core";
109
import type { SentryContext } from "../../context.js";
10+
import { buildCommand } from "../../lib/command.js";
1111
import { installCompletions } from "../../lib/completions.js";
1212
import { CLI_VERSION } from "../../lib/constants.js";
1313
import { setInstallInfo } from "../../lib/db/install-info.js";

src/commands/cli/upgrade.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
* Self-update the Sentry CLI to the latest or a specific version.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
8+
import { buildCommand } from "../../lib/command.js";
99
import { CLI_VERSION } from "../../lib/constants.js";
1010
import { setInstallInfo } from "../../lib/db/install-info.js";
1111
import { UpgradeError } from "../../lib/errors.js";

src/commands/event/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 Sentry event.
55
*/
66

7-
import { buildCommand } from "@stricli/core";
87
import type { SentryContext } from "../../context.js";
98
import { findProjectsBySlug, getEvent } 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 { formatEventDetails, writeJson } from "../../lib/formatters/index.js";
1818
import { resolveOrgAndProject } from "../../lib/resolve-target.js";

0 commit comments

Comments
 (0)