Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,9 @@
"@hono/node-server": "^2.0.10",
"@mastra/client-js": "^1.38.0",
"@sentry/api": "catalog:",
"@sentry/core": "10.63.0",
"@sentry/core": "catalog:",
"@sentry/mcp-server": "workspace:*",
"@sentry/node": "10.65.0",
"@sentry/node-core": "10.63.0",
"@sentry/node": "catalog:",
"@sentry/sqlish": "^1.0.1",
"@sentry/symbolic": "13.7.0",
"@sentry/toolkit-core": "workspace:*",
Expand Down
309 changes: 0 additions & 309 deletions packages/cli/patches/@sentry%2Fcore@10.63.0.patch

This file was deleted.

77 changes: 0 additions & 77 deletions packages/cli/patches/@sentry%2Fnode-core@10.63.0.patch

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cli/script/bench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ type OpEntry = {

async function buildOps(): Promise<OpEntry[]> {
// Lazy-import production code so unit tests can import the helpers/fixtures
// without loading all of @sentry/node-core.
// without loading all of @sentry/node.
const { detectDsn, detectAllDsns } =
await import("../src/lib/dsn/detector.js");
const { findProjectRoot } = await import("../src/lib/dsn/project-root.js");
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ async function bundleJs(): Promise<boolean> {
SENTRY_CLIENT_ID_BUILD: JSON.stringify(SENTRY_CLIENT_ID),
"process.env.NODE_ENV": JSON.stringify("production"),
__SENTRY_DEBUG_ID__: JSON.stringify(PLACEHOLDER_DEBUG_ID),
// Tree-shakes the SDK's runtime module hooks, which can't instrument a
// bundle and would hook the host app in library mode.
__SENTRY_CHANNEL_INJECTION__: "false",
},
plugins: [
textImportPlugin,
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/script/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ const commonDefine: Record<string, string> = {
SENTRY_CLIENT_ID_BUILD: JSON.stringify(SENTRY_CLIENT_ID),
"process.env.NODE_ENV": JSON.stringify("production"),
__SENTRY_DEBUG_ID__: JSON.stringify(PLACEHOLDER_DEBUG_ID),
// Tree-shakes the SDK's runtime module hooks, which can't instrument a
// bundle and would hook the host app in library mode.
__SENTRY_CHANNEL_INJECTION__: "false",
};

// In an ESM bundle, `require`, `__dirname`, and `__filename` don't exist, but
Expand Down
33 changes: 0 additions & 33 deletions packages/cli/script/check-patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,6 @@ for (const [key, patchPath] of Object.entries(patches)) {
* `-v`=version alias in `runApplication` so `-v` stays the Sentry CLI's
* `--verbose` alias at every position; `--version` remains the version flag.
* The stale marker is the original `inputs[0] === "-v"` version check.
*
* @sentry/core and @sentry/node-core: these are tree-shaking patches that strip
* unused re-exports (AI/integration modules) from the build barrels so esbuild
* excludes them from the bundle. They edit bundler-generated barrels and are
* therefore especially prone to silent context drift on a version bump. Each
* marker is a re-export the patch removes (present in the pristine package,
* absent once patched); its presence means the strip did NOT apply and the
* bundle will re-bloat with the AI integrations — re-introducing the dangling
* re-export class the patch guards against.
*/
const CONTENT_ASSERTIONS: ReadonlyArray<{
/** Installed file to inspect, relative to the resolved node_modules dir. */
Expand Down Expand Up @@ -308,30 +299,6 @@ const CONTENT_ASSERTIONS: ReadonlyArray<{
description:
"@stricli/core CJS: pluggable `renderHelp` hook missing (`sentry --help --json` will fall back to text help instead of structured JSON)",
},
{
file: "@sentry/core/build/cjs/index.js",
staleMarker: "exports.instrumentOpenAiClient",
description:
"@sentry/core CJS: tree-shaking strip not applied (AI integrations re-bundled)",
},
{
file: "@sentry/core/build/esm/index.js",
staleMarker: "from './tracing/openai/index.js'",
description:
"@sentry/core ESM: tree-shaking strip not applied (AI integrations re-bundled)",
},
{
file: "@sentry/node-core/build/cjs/light/index.js",
staleMarker: "exports.dedupeIntegration",
description:
"@sentry/node-core CJS light: integration re-export strip not applied",
},
{
file: "@sentry/node-core/build/esm/light/index.js",
staleMarker: "dedupeIntegration",
description:
"@sentry/node-core ESM light: integration re-export strip not applied",
},
];

for (const assertion of CONTENT_ASSERTIONS) {
Expand Down
14 changes: 8 additions & 6 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* CLI runner with fast-path dispatch.
*
* Shell completion (`__complete`) is dispatched before any heavy imports
* to avoid loading `@sentry/node-core` (~280ms). All other commands go through
* to avoid loading `@sentry/node` (~100ms). All other commands go through
* the full CLI with telemetry, middleware, and error recovery.
*
* Extracted from `bin.ts` so the logic is testable and reusable without
Expand All @@ -26,7 +26,7 @@ async function preloadProjectContext(cwd: string): Promise<void> {
// Snapshot env-token host BEFORE anything mutates env.SENTRY_HOST/URL
// (the .sentryclirc shim or the default-URL fallback below). Pins the
// env-token's trust scope to the user's shell, not a repo-local file.
// Dynamic import: env-token-host chains into db/auth → telemetry → @sentry/node-core
// Dynamic import: env-token-host chains into db/auth → telemetry → @sentry/node
const { captureEnvTokenHost } = await import("./lib/env-token-host.js");
captureEnvTokenHost();

Expand Down Expand Up @@ -70,12 +70,12 @@ async function preloadProjectContext(cwd: string): Promise<void> {
/**
* Fast-path: shell completion.
*
* Dispatched before importing the full CLI to avoid loading @sentry/node-core,
* Dispatched before importing the full CLI to avoid loading @sentry/node,
* @stricli/core, and other heavy dependencies. Only loads the lightweight
* completion engine and SQLite cache modules.
*/
export async function runCompletion(completionArgs: string[]): Promise<void> {
// Disable telemetry so db/index.ts skips the @sentry/node-core lazy-require (~280ms)
// Disable telemetry so db/index.ts skips the @sentry/node lazy-require (~100ms)
getEnv().SENTRY_CLI_NO_TELEMETRY = "1";
const { handleComplete } = await import("./lib/complete.js");
handleComplete(completionArgs);
Expand Down Expand Up @@ -624,7 +624,7 @@ export async function runCli(cliArgs: string[]): Promise<void> {
* fuzzy matches and extracts org/project context from the raw argv.
*/
async function reportUnknownCommand(argv: string[]): Promise<void> {
const Sentry = await import("@sentry/node-core/light");
const Sentry = await import("@sentry/node");
const { resolveCommandPath } = await import("./lib/introspect.js");
const { routes } = await import("./app.js");
const { getDefaultOrganization } = await import("./lib/db/defaults.js");
Expand Down Expand Up @@ -665,7 +665,9 @@ export async function runCli(cliArgs: string[]): Promise<void> {
// Fixed message string so all unknown commands group into one Sentry
// issue. The per-event detail (which token, suggestions) lives in the
// structured context above and is queryable via Discover.
Sentry.captureMessage("unknown_command", "info");
// captureEvent, not captureMessage: with `attachStacktrace` on,
// captureMessage adds a synthetic exception that marks the session errored.
Sentry.captureEvent({ message: "unknown_command", level: "info" });
}

/** Build the command executor by composing error-recovery middlewares. */
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { access, readFile } from "node:fs/promises";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import type { SentryContext } from "../context.js";
import { appendSearchParams, rawApiRequest } from "../lib/api-client.js";
import { buildCommand } from "../lib/command.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/cli/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import { isatty } from "node:tty";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import type { SentryContext } from "../../context.js";
import { buildCommand } from "../../lib/command.js";
import { ConfigError, ValidationError } from "../../lib/errors.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/cli/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { existsSync, unlinkSync } from "node:fs";
import { chmod, copyFile, mkdir, rename, unlink } from "node:fs/promises";
import { dirname, join } from "node:path";
import { isatty } from "node:tty";
import { captureException } from "@sentry/node-core/light";
import { captureException } from "@sentry/node";
import type { SentryContext } from "../../context.js";
import { installAgentSkills } from "../../lib/agent-skills.js";
import { assertAutoLoginHostTrusted } from "../../lib/auto-auth.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import path from "node:path";
import { setTag } from "@sentry/node-core/light";
import { setTag } from "@sentry/node";
import type { SentryContext } from "../context.js";
import { looksLikePath, parseOrgProjectArg } from "../lib/arg-parsing.js";
import { buildCommand } from "../lib/command.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/log/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import type { SentryContext } from "../../context.js";
import {
type LogSortDirection,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/agent-skills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import { accessSync, constants, existsSync, mkdirSync } from "node:fs";
import { rename, rm, writeFile } from "node:fs/promises";
import { basename, dirname, join } from "node:path";
import { captureException } from "@sentry/node-core/light";
import { captureException } from "@sentry/node";
import { SKILL_FILES } from "../generated/skill-content.js";

/** Where skills are installed */
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/api/dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
updateOrganizationDashboard,
} from "@sentry/api";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import { resolveEventsSort } from "@sentry/toolkit-core/events-sort";

import { array, safeParse } from "valibot";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/api/infrastructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
paginate as paginateFrom,
} from "@sentry/toolkit-core/pagination";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import { type GenericSchema, safeParse } from "valibot";

import { extractRequiredScopes } from "../api-scope.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/api/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { listOrganizationEvents } from "@sentry/api";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import { type GenericSchema, safeParse } from "valibot";

import {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/api/teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
listProjectTeams as sdkListProjectTeams,
} from "@sentry/api";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";

import type { SentryTeam } from "../../types/index.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/auth-hint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import {
getActiveEnvVarName,
getRawEnvToken,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export function getDatabase(): Database {
}

// Wrap with tracing proxy for automatic query instrumentation.
// Lazy-require telemetry to avoid top-level import of @sentry/node-core (~85ms).
// Lazy-require telemetry to avoid top-level import of @sentry/node (~100ms).
// Shell completions set SENTRY_CLI_NO_TELEMETRY=1 to skip this entirely.
if (getEnv().SENTRY_CLI_NO_TELEMETRY === "1") {
db = rawDb;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/delta-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { join } from "node:path";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import {
applyPatchChainInMemory,
extractStableChain as binpatchExtractStableChain,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/dsn/fs-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { stat } from "node:fs/promises";
// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";

/**
* Check if an error is an expected file system error that should be silently ignored.
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/lib/error-reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/

// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import {
AliasNotFoundError,
ArgumentParseError,
Expand Down Expand Up @@ -491,7 +491,10 @@ function argumentErrorClassName(error: unknown): string {
*/
export function reportArgumentError(error: unknown, message: string): void {
const errorClass = argumentErrorClassName(error);
Sentry.captureMessage("invalid_argument", {
// captureEvent, not captureMessage: with `attachStacktrace` on,
// captureMessage adds a synthetic exception that marks the session errored.
Sentry.captureEvent({
message: "invalid_argument",
level: "info",
tags: { "argument_error.class": errorClass },
contexts: {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/formatters/human.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

// oxlint-disable-next-line sentry-cli/no-namespace-import -- Sentry SDK recommends namespace import
import * as Sentry from "@sentry/node-core/light";
import * as Sentry from "@sentry/node";
import prettyMs from "pretty-ms";
import type {
DashboardDetail,
Expand Down
Loading
Loading