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
3 changes: 2 additions & 1 deletion apps/cli-docs/src/content/docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ toolkit/
│ │ │ ├── init.ts # Print instructions for a coding agent to set up Sentry
│ │ │ ├── mcp.ts # Start a local Sentry MCP server
│ │ │ ├── schema.ts # Browse the Sentry API schema
│ │ │ └── wasm-split.ts# Add build ids to WebAssembly modules and split out debug data
│ │ │ ├── wasm-split.ts# Add build ids to WebAssembly modules and split out debug data
│ │ │ └── wizard.ts # Set up the Sentry SDK in your project interactively
│ │ ├── lib/ # Shared utilities
│ │ └── types/ # TypeScript types and Valibot schemas
│ ├── test/ # Test files (mirrors src/ structure)
Expand Down
52 changes: 52 additions & 0 deletions apps/cli-docs/src/fragments/commands/wizard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@


## Setting up Sentry interactively

`sentry wizard` sets up the Sentry SDK in the project in the current
directory. It asks a few questions, installs the SDK for your framework,
writes its configuration, and sets up source map or debug file uploads. It
takes an optional `<org>/<project>` first, then an optional integration:

- Pass an integration, such as `nextjs`, to skip the integration picker.
- Pass `<org>/<project>` first to skip the org and project pickers, or
`<org>/` to pick only the project. Without it, the wizard asks; it doesn't
detect a project from your files.
- An integration id is never read as a project or org, and a single bare
word is always read as an integration. Write a project or org with a `/`:
`my-org/my-project`, `my-org/`, or `/my-project`. For a project spelled
like an integration, write `my-org/nextjs`.
- `-f`/`--force` changes a project with uncommitted changes without asking,
and installs the SDK even when the package manager's checks fail.

It logs in with your `sentry auth login` account, or starts a login when you
have none, on the Sentry instance the rest of the CLI uses: `SENTRY_URL`, or
the stored login's. To use a self-hosted instance, log in to it first with
`sentry auth login --url`.

Set `SENTRY_SPOTLIGHT=1` to set up Spotlight for local development instead,
with no Sentry account or login. Telemetry follows the CLI's settings
(`SENTRY_CLI_NO_TELEMETRY`, `DO_NOT_TRACK`, `sentry cli defaults`), and the
global `--verbose` flag shows the wizard's debug output.

`sentry wizard` changes your project's files. To have a coding agent set up
Sentry instead, run `sentry init`, which prints the agent's setup guide and
changes nothing.

## Coming from `@sentry/wizard`

`sentry wizard` takes the same integration ids as `npx @sentry/wizard -i`,
but not its flags or `SENTRY_WIZARD_*` environment variables:

| `@sentry/wizard` | `sentry wizard` |
| -------------------------------------- | ------------------------------------------------ |
| `-i nextjs` | `nextjs` |
| `--org my-org --project my-project` | `my-org/my-project`, before the integration |
| `--url`, `-u`, `--saas` | `sentry auth login --url`, or `SENTRY_URL` |
| `--spotlight` | `SENTRY_SPOTLIGHT=1` |
| `--force-install`, `--ignore-git-changes` | `-f`/`--force` |
| `--disable-telemetry` | `SENTRY_CLI_NO_TELEMETRY=1` or `DO_NOT_TRACK=1` |
| `--debug` | `--verbose` or `--log-level debug` |
| `--signup`, `--promo-code`, `--coming-from` | Sign up at https://sentry.io/signup/ first |

The Cordova and Electron wizards were retired. Follow their setup guides in
the Sentry docs instead.
1 change: 1 addition & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"http-cache-semantics": "^4.2.0",
"ignore": "^7.0.5",
"jpeg-js": "^0.4.4",
"magicast": "0.2.11",
"marked": "catalog:",
"node-sqlite3-wasm": "0.8.59",
"p-limit": "^7.3.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/plugins/sentry-cli/skills/sentry-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ Print instructions for a coding agent to set up Sentry

→ Full flags and examples: `references/init.md`

### Wizard

Set up the Sentry SDK in your project interactively

- `sentry wizard [<org>/<project>] [<integration>]` — Set up the Sentry SDK in your project interactively

→ Full flags and examples: `references/wizard.md`

### Info

Print configuration and verify authentication
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: sentry-cli-wizard
version: 0.52.0-dev.0
description: Set up the Sentry SDK in your project interactively
requires:
bins: ["sentry"]
auth: true
---

# Wizard Commands

Set up the Sentry SDK in your project interactively

### `sentry wizard [<org>/<project>] [<integration>]`

Set up the Sentry SDK in your project interactively

**Arguments:**

| Argument | Description |
|----------|-------------|
| `[<org>/<project>] [<integration>]` | &lt;org&gt;/&lt;project&gt; to set up (skips the project picker), then the integration (skips the integration picker) |

**Flags:**
- `-f, --force - Change a project with uncommitted changes without asking, and install the SDK even when the package manager's checks fail`

**Examples:**

```bash
# Pick an integration and a project, then set it up
sentry wizard

# Set up Next.js, picking the project
sentry wizard nextjs

# Set up Next.js for a known org and project
sentry wizard my-org/my-project nextjs

# Set up Next.js for Spotlight, without a Sentry account
SENTRY_SPOTLIGHT=1 sentry wizard nextjs
```

All commands also support `--json`, `--fields`, `--help`, `--log-level`, and `--verbose` flags.
37 changes: 32 additions & 5 deletions packages/cli/script/check-env-coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
* test-only hooks, and vars inherited from the SDK are listed (with a reason) in
* INTERNAL_ENV_VARS so their exclusion is explicit and reviewable.
*
* It also fails when any file under src/ names a prefix in
* RETIRED_ENV_PREFIXES, such as the `SENTRY_WIZARD_*` vars of `@sentry/wizard`.
*
* Usage:
* pnpm ts script/check-env-coverage.ts
*
* Exit codes:
* 0 - Every user-facing env var read by the CLI or an installer is documented
* or explicitly internal
* 1 - Coverage gap, redundant allowlist entry, or stale allowlist entry
* 1 - Coverage gap, redundant allowlist entry, stale allowlist entry, or a
* retired env var prefix (RETIRED_ENV_PREFIXES) under src/
*/

import { readFile } from "node:fs/promises";
Expand Down Expand Up @@ -51,10 +55,6 @@ const INTERNAL_ENV_VARS = new Map<string, string>([
"SENTRY_ENVIRONMENT",
"bash-hook traceback template only; inherited SDK convention",
],
[
"SENTRY_SPOTLIGHT",
"set by `local run` for the child app; the CLI only names it in Worker setup hints",
],
[
"SENTRY_TRACES_SAMPLE_RATE",
"inherited from the SDK when spawning subprocesses, not a CLI config knob",
Expand All @@ -79,6 +79,17 @@ const INTERNAL_ENV_VARS = new Map<string, string>([
["SENTRY_RN_SOURCEMAP_REPORT", "internal react-native wrapper plumbing"],
]);

/**
* Env var prefixes the CLI dropped on purpose. No file under src/ may name
* one, read or not, so none comes back as a hidden alias. Each has a reason.
*/
const RETIRED_ENV_PREFIXES = new Map<string, string>([
[
"SENTRY_WIZARD_",
"`sentry wizard` takes `<org>/<project>` and the integration as positionals, and reads only the CLI's own env vars (SENTRY_URL, SENTRY_SPOTLIGHT, SENTRY_LOG_LEVEL)",
],
]);

const registryNames = new Set(ENV_VAR_REGISTRY.map((entry) => entry.name));

/**
Expand Down Expand Up @@ -230,6 +241,22 @@ for (const name of INTERNAL_ENV_VARS.keys()) {
}
}

// Every file type under src/, generated files included, not just the env
// reads above: a retired name in a string or a comment fails too.
for (const file of await glob("src/**/*")) {
const content = await readFile(file, "utf-8");
for (const [prefix, reason] of RETIRED_ENV_PREFIXES) {
const index = content.indexOf(prefix);
if (index !== -1) {
const line = content.slice(0, index).split("\n").length;
errors.push(
`Retired env var prefix: ${prefix} (at ${file}:${line})\n` +
` Remove it: ${reason}.`,
);
}
}
}

if (errors.length > 0) {
logger.error(
[
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import { listCommand as traceListCommand } from "./commands/trace/list.js";
import { trialRoute } from "./commands/trial/index.js";
import { listCommand as trialListCommand } from "./commands/trial/list.js";
import { wasmSplitCommand } from "./commands/wasm-split.js";
import { wizardCommand } from "./commands/wizard.js";
import { buildSentryApp, buildSentryRoutes } from "./app-root.js";
import { registerGraphicsBanner } from "./graphics-banner.js";

Expand Down Expand Up @@ -116,6 +117,7 @@ export const routes = buildSentryRoutes({
trace: traceRoute,
trial: trialRoute,
init: initCommand,
wizard: wizardCommand,
info: infoCommand,
local: localRoute,
api: apiCommand,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/command-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const COMMAND_MANIFEST: Readonly<Record<string, ManifestEntry>> = {
trace: route(() => import("./commands/trace/index.js"), "traceRoute"),
trial: route(() => import("./commands/trial/index.js"), "trialRoute"),
init: route(() => import("./commands/init.js"), "initCommand"),
wizard: route(() => import("./commands/wizard.js"), "wizardCommand"),
info: route(() => import("./commands/info.js"), "infoCommand"),
local: route(() => import("./commands/local/index.js"), "localRoute"),
api: route(() => import("./commands/api.js"), "apiCommand"),
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export const initCommand = buildCommand({
"project already uses Sentry, the guide covers upgrading the SDKs and " +
"turning on more features instead.\n\n" +
"The command changes nothing and needs no login. The same guide is " +
"published at https://cli.sentry.dev/get-started-with-sentry.md.",
"published at https://cli.sentry.dev/get-started-with-sentry.md.\n\n" +
"To set up Sentry yourself with an interactive wizard that changes " +
"your project's files, run `sentry wizard` instead.",
examples: [
{
description: "Print the setup guide",
Expand Down
Loading
Loading