Repository navigation
feat(cli): add iOS, Apple Snapshots and React Native to sentry wizard - #2544
sentry-junior[bot] wants to merge 20 commits into
Conversation
Start moving getsentry/sentry-wizard into the CLI as `sentry wizard`. This adds the command with the `@sentry/wizard` integrations and flags (`-i`, `--url`, `--org`, `--project`, `--saas`, `--spotlight`, and the rest), the shared wizard helpers, and the Next.js flow. The other integrations report that they are not available in this version yet. The wizard logs in with the CLI's own login: a stored `sentry auth login` session, an agent handoff, or the device flow, instead of the `account/settings/wizard/<hash>` browser flow. It then picks or creates the project, reads its DSN, and creates an org auth token for source map uploads. Telemetry goes through the CLI's client. `sentry init` stays the agent setup guide; its help now points to `sentry wizard` for the interactive setup. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Port `ast-utils` and `url` from getsentry/sentry-wizard into `src/lib/wizard/utils/`. The SvelteKit, Remix, React Router, Angular, Nuxt, source maps, Cloudflare, React Native and Android wizards all use them, so they land once here and the platform PRs that follow build on them in parallel. `ast-utils` edits recast ASTs, so recast and ast-types become direct dev dependencies; both already came in through magicast. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
`sentry wizard` logs in with the CLI's login, which has no sign-up or partner step, so `--signup`, `--promo-code` and `--coming-from` no longer do anything. Passing one now fails with a message that points to https://sentry.io/signup/ instead of being accepted silently. `promoCode` and `comingFrom` leave `WizardOptions`, the welcome banner and `setupCI`, which loses its Vercel partner branch. The help text and the docs say which `@sentry/wizard` flags were removed. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…st-helpers Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
- Skip the `.sentryclirc` URL check, like `sentry init`: the wizard picks its instance (`--url`, `--saas` or a prompt) before it logs in. - Use the stored login's instance for `sentryUrl` when none was chosen, and log in again when the stored login is for another instance. - Link self-hosted users to `/settings/<org>/auth-tokens/`. - Leave an unparseable MCP config alone (show the copy-paste fallback), and let a cancel inside the MCP setup stop the wizard. - Resolve `catalog:` and `catalog:default` against both pnpm default catalog forms. - Find an existing `SENTRY_AUTH_TOKEN` after the comment header of `.env.sentry-build-plugin`, so re-runs don't add a second one. - Run Windows formatters with Node in the standalone binary, where `process.execPath` is `sentry`. - Ask before updating an `@sentry/nextjs` listed in devDependencies, and treat an unknown SDK version as the `^11` the wizard installs. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…st-helpers Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Address review feedback on the shared wizard helpers: - Enable unicorn/no-array-for-each repo-wide and convert every .forEach call site to for...of, including getLastRequireIndex. - Add buildProjectIssuesUrl to lib/sentry-urls.ts, built on getOrgBaseUrl like buildEventSearchUrl, and delete the wizard-specific wizard/utils/url.ts. - Move findFile into lib/dsn/fs-utils.ts and build it on isRegularFile, so a directory or FIFO with a matching name is skipped. It is async now. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
`sentry wizard [<org>/<project>] [<integration>]` replaces the `@sentry/wizard` flags, with the target first like other commands. - The integration is a positional, one at a time. A bare integration id is never read as a target, and a single bare word is always read as an integration, so a project or org spelled like one is written `my-org/nextjs`, `nextjs/` or `/nextjs`. - The target parses with the CLI's org/project grammar and resolves after login with `resolveOrgOptionalTarget`, like other commands. Without one the org and project pickers run, with no detection. - `-f/--force` is the only flag. It sets both `forceInstall` and `ignoreGitChanges`. - The instance comes from `SENTRY_URL` or the stored login, so the SaaS/self-hosted prompt, `--url`, `--saas` and `skipRcUrlCheck` go. - Spotlight mode follows `SENTRY_SPOTLIGHT`, telemetry follows `isTelemetryEnabled()`, and debug output goes through the CLI logger (`--verbose`, `--log-level`). - Every other `@sentry/wizard` flag and `SENTRY_WIZARD_*` variable is gone, hidden ones included, with `disableTelemetryForRun` and `rejectRemovedFlags`. A test pins the wizard's own flags to `force`, and `check:env-coverage` (part of `ci:policy`) fails when any file under `src/` names `SENTRY_WIZARD_`. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Re-export buildProjectIssuesUrl from lib/sentry-web-urls.ts through withSentryBaseUrl(getApiBaseUrl()), like the other user-facing link builders, so self-hosted and regional logins get links on the host they are authenticated against. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Port the `ios`, `appleSnapshots` and `reactNative` flows of @sentry/wizard 9.1.0 into `sentry wizard`, with their tests and Xcode fixtures, and register them in WIZARD_RUNNERS. The command gains the Apple flags of the old wizard (`--app-target`, `--hosted-test-target`, `--non-interactive`, hidden `--xcode-project-dir`), so existing `npx @sentry/wizard -i ios ...` command lines keep parsing. The flows no longer depend on the `sentry-cli` binary, because sentry.io/get-cli installs `sentry` once v4 ships: - The Xcode build phase runs `sentry debug-files upload` with SENTRY_ORG and SENTRY_PROJECT exported, checks for a v4 `sentry` with `sentry debug-files --help`, and turns failures into Xcode warnings with v4 install instructions. - The wizard checks only that `sentry` is on the PATH Xcode build phases see, and prints the Homebrew, curl and npm install commands when it is not. It no longer installs a CLI itself. - `.sentryclirc` gets `[defaults]` org and project next to the token, since v4 reads both. - The Apple Snapshots hint and preflight use `sentry snapshots upload`. - Existing-script detection recognizes both the v2 and v4 command forms, in the Apple and React Native Xcode code. xml-js is replaced by a small scanner for the two XML shapes the Snapshots flow reads (scheme TestAction blueprints and xcschememanagement.plist keys). xcode stays as a devDependency until the init/wizard unification.
…rs' into feat/cli-wizard-apple-react-native Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…eat/cli-wizard-apple-react-native Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> # Conflicts: # packages/cli/plugins/sentry-cli/skills/sentry-cli/references/wizard.md # packages/cli/src/commands/wizard.ts
`sentry wizard` takes `[<org>/<project>] [<integration>]` and `-f/--force` only, so the Apple flags this port added (`--app-target`, `--hosted-test-target`, `--non-interactive`, hidden `--xcode-project-dir`) go away. - The Apple wizards look for the Xcode project in the current directory and prompt for the project, app target and hosted XCTest target, as `@sentry/wizard` does without those flags. - Apple Snapshots runs non-interactively when stdin is not a terminal (`isatty(0)`, the CLI's auto-login check): it picks the only target or fails with the choices instead of prompting. - React Native links to the project's issues with `buildProjectIssuesUrl` from `lib/sentry-web-urls.ts`, now that `wizard/utils/url.ts` is gone. - `Array#forEach` loops become `for…of` for `unicorn/no-array-for-each`. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
📊 MCP Server Token Cost ReportSummary
Per-Tool Breakdown
Note: This measures the static overhead of tool definitions sent to LLM clients with every request. Lower is better. MCP Apps viewsEach
The budget applies to raw bytes, and the view's generator fails over it. |
`tsc -p script` follows script imports into the wizard's Xcode code but did not include `src/lib/wizard/xcode.d.ts`, so `xcode` had no types there and `pnpm run typecheck` failed. List it next to `global.d.ts`, as test/tsconfig.json already does.
BYK
left a comment
There was a problem hiding this comment.
Token source in Xcode: the build phase authenticates with the project's .sentryclirc token. Should it prefer a stored sentry auth login (or SENTRY_FORCE_ENV_TOKEN) instead?
If it can, yes?
When sentry isn't on the PATH Xcode sees (for example, the wizard ran via npx sentry wizard), we only print install commands. Should the wizard offer to install sentry?
Yes, maybe? Or the commands can also use npx which sounds better?
Should fastlane-plugin-sentry and the React Native SDK's upload scripts get v4 follow-ups, and who owns them?
Yes.
Is test/fixtures/wizard/apple/ the right place for the fixtures?
Yes
When no v4 `sentry` is on the PATH an Xcode build phase sees, the generated upload phase now runs `npx --yes sentry debug-files upload`, so a project set up with `npx sentry wizard` uploads debug symbols without installing the CLI first. It only warns when neither `sentry` nor `npx` is found. The wizard's preflight matches: it notes that builds will use `npx sentry` (and how to install the CLI for faster builds) when only `npx` is in reach, and warns as before when neither is. Existing-phase detection keys on `debug-files upload`, since the command now runs through `"$@"`.
|
Thanks. Here's where the four answers landed:
|
#2519 and #2520 were squash-merged, so this PR's base is now main. Resolved the add/add conflicts: run.ts keeps this branch's runner registrations (main's copy equals the old base), and project-data.ts and its test take main's copy, with the #2559 context-scoped origin trust fix (this branch didn't change them). Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…e wizard CodeQL flagged two patterns in the Apple wizard port: - xml-scan stripped comments, CDATA and declarations in one pass, so removing one span could leave another behind (`<<!-- x -->!-- … -->`). It now strips until nothing changes. - The pbxproj shell-script quoting escaped `"` but not `\`, so a backslash in a script could break out of the quoted string. One `quotePbxString` helper now escapes backslashes first, for both the add and update paths. Today's template has no backslashes, so the generated build phase is unchanged. dependency-review flagged uuid@7.0.3 (GHSA-w5hq-g745-h8pq), which xcode@3 pins. xcode only calls `uuid.v4()`, but a scoped `xcode@3>uuid` override moves it to the patched 11.1.1, which still ships CommonJS. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…d RN wizards Warden flagged these in code ported unchanged from sentry-wizard 9.1.0: - readXcodeBuildSettings ran `xcodebuild -project "<path>"` through execSync, so a `.xcodeproj` named with `$(…)` ran commands on the wizard host. It now uses execFileSync with an argument list. - configureFastlane didn't wrap its confirm in abortIfCancelled, so Ctrl+C returned a truthy symbol and the wizard edited the Fastfile. - The manual metro.config.js snippet had a stray `"` after the `@react-native/metro-config` require.
…ative wizard When the app file has no import to anchor on, show the copy-paste snippet instead of reporting that Sentry.init was added.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b53a30f. Configure here.
| ): string { | ||
| return js.replace( | ||
| // The last import statement, with or without a trailing semicolon. | ||
| /^([^]*)(import\s+[^;]*?(?:;|['"])[ \t]*$)/m, |
There was a problem hiding this comment.
Import regex matches non-import quotes
Medium Severity
The ASI import regex treats a trailing quote as the end of an import. Because the prefix is greedy, the last line in the file that contains import and then a quote or semicolon at end of line wins. Comments, string literals, and quoted words inside a multiline import all match, so Sentry.init can be injected inside a function or in the middle of an import and the wizard still reports success.
Reviewed by Cursor Bugbot for commit b53a30f. Configure here.
| // The default is '<group>' | ||
| const fileRefSourceTree = fileRef.obj.sourceTree?.replace(/"/g, "") ?? ""; | ||
| switch (fileRefSourceTree) { | ||
| case "<absolute>": | ||
| return fileRef.obj.path.replace(/"/g, ""); | ||
| case "<group>": | ||
| return this.resolveAbsoluteFilePathRelativeToGroup(fileRef); | ||
| case "BUILT_PRODUCTS_DIR": | ||
| return this.resolveAbsoluteFilePathRelativeToBuiltProductsDir(fileRef); | ||
| case "SOURCE_ROOT": | ||
| return this.resolveAbsoluteFilePathRelativeToSourceRoot(fileRef); | ||
| case "SDKROOT": | ||
| return this.resolveAbsoluteFilePathRelativeToSdkRoot(fileRef); | ||
| case "DEVELOPER_DIR": | ||
| return this.resolveAbsoluteFilePathRelativeToDeveloperDir(fileRef); | ||
| default: | ||
| debug( | ||
| `Unknown source tree '${fileRef.obj.sourceTree}' for build file: ${fileRef.obj.path}`, | ||
| ); | ||
| return undefined; | ||
| } |
There was a problem hiding this comment.
Missing sourceTree on a PBXFileReference drops its default <group> file
When a PBXFileReference omits sourceTree, the resolver treats the valid <group> default as unknown and drops the file path, so the iOS wizard can miss that Swift source and fail to inject the Sentry initialization snippet.
Evidence
resolveAbsolutePathOfFileReferencesays the default is<group>, but converts a missingsourceTreeto""and returnsundefinedfrom the default branch.resolveAbsolutePathOfGrouphandles a missingsourceTreeby defaulting it to<group>, confirming the intended resolution behavior for omitted values.findFilesInSourceBuildPhaseskips references whose path resolves toundefined;getSourceFilesForTargetpasses that file list toinjectCodeSnippet, which cannot inject into a file it did not discover.
Identified by Warden · code-review · QYR-4J8
| if (hasSentryContent(mod.$ast as t.Program)) { | ||
| const shouldContinue = await confirmPathMetroConfig(); | ||
| if (!shouldContinue) { | ||
| await showInstructions(); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| const configExpression = getModuleExportsAssignmentRight( | ||
| mod.$ast as t.Program, | ||
| ); | ||
| if (!configExpression) { | ||
| clack.log.warn( | ||
| "Could not find Metro config, please follow the manual steps.", | ||
| ); | ||
| reportCliError(new Error("Could not find Metro config.")); | ||
| await showInstructions(); | ||
| return false; | ||
| } | ||
|
|
||
| const wrappedConfig = wrapWithSentryConfig(configExpression); | ||
|
|
||
| const replacedModuleExportsRight = replaceModuleExportsRight( | ||
| mod.$ast as t.Program, | ||
| wrappedConfig, | ||
| ); | ||
| if (!replacedModuleExportsRight) { | ||
| clack.log.warn( | ||
| "Could not automatically wrap the config export, please follow the manual steps.", | ||
| ); | ||
| reportCliError( | ||
| new Error("Could not automatically wrap the config export."), | ||
| ); | ||
| await showInstructions(); | ||
| return false; | ||
| } | ||
|
|
||
| const addedSentryMetroImport = addSentryMetroRequireToMetroConfig( | ||
| mod.$ast as t.Program, | ||
| ); | ||
| if (!addedSentryMetroImport) { | ||
| clack.log.warn( | ||
| "Could not add `@sentry/react-native/metro` import to Metro config, please follow the manual steps.", | ||
| ); | ||
| reportCliError( | ||
| new Error( | ||
| "Could not add `@sentry/react-native/metro` import to Metro config.", | ||
| ), | ||
| ); | ||
| await showInstructions(); | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Confirming a Metro config re-patch duplicates the Sentry binding
If a bare React Native Metro config already contains Sentry setup and the user confirms modification, the wizard wraps the existing export and unconditionally inserts another const { withSentryConfig } declaration. The saved file then fails JavaScript parsing with a duplicate lexical binding, preventing Metro from loading.
Evidence
- The bare React Native wizard calls
patchMetroWithSentryConfig; whenhasSentryContentdetects an@sentry/string, the user can confirm modification and the function continues without removing existing Sentry setup. - The export lookup accepts an existing
withSentryConfig(...)call, which is wrapped again;addSentryMetroRequireToMetroConfigunconditionally inserts anotherconst { withSentryConfig } = require(...)declaration. patchMetroWithSentryConfigwrites the modified AST after this path succeeds, so an already-patched config is saved with duplicate top-levelconstbindings and cannot be parsed by Metro.
Identified by Warden · code-review · 89L-WE8


Part of #2511. Stacked on #2520.
This ports the
ios,appleSnapshotsandreactNativeflows of@sentry/wizard9.1.0 (src/apple/,src/apple/snapshots/,src/react-native/) and their tests topackages/cli/src/lib/wizard/andpackages/cli/test/lib/wizard/. All three are registered inWIZARD_RUNNERSand run assentry wizard [<org>/<project>] ios|appleSnapshots|reactNative. They add no flags. The upstream Apple flags (--app-target,--hosted-test-target,--non-interactive,--xcode-project-dir) are not carried over. The wizards look for the Xcode project in the current directory and prompt for the project, app target and hosted XCTest target. When stdin is not a terminal (isatty(0), the same check as auto-login), Apple Snapshots picks the only target or fails with the choices instead of prompting.No
sentry-clibinary. After v4, sentry.io/get-cli installssentry(getsentry/sentry#132672), so these flows use only v4 commands:sentrywithsentry debug-files --help, then runssentry debug-files upload [--include-sources] "$DWARF_DSYM_FOLDER_PATH".sentry, it runsnpx --yes sentry debug-files upload. Failures show up as Xcode warnings, and it warns with the v4 install command only when neithersentrynornpxis found. There is nosentry-clifallback.installSentryCLI/hasSentryCLIare not ported.check-installed-cli.tsonly checks thatsentryis on the PATH that Xcode build phases see. If it isn't butnpxis, the wizard notes that builds will usenpx sentry. If neither is, it prints the Homebrew, curl (cli.sentry.dev/install) and npm install commands..sentryclircstays, because v4 reads it. It now gets[defaults] org/projectnext to[auth] token. The CI hint names SENTRY_AUTH_TOKEN, SENTRY_ORG, SENTRY_PROJECT and SENTRY_URL.sentry snapshots upload … --app-id. v4 has no--org/--projectflags there, so the hint uses env vars.xcode-manager, React Nativexcode.ts) recognizes both the v2 and the v4 command forms.buildProjectIssuesUrl, so it points at the host you're logged in to.Dependencies.
apple/snapshots/xml-scan.tsis a small scanner, with tests, for the two shapes the Snapshots flow reads: schemeTestActionBlueprintNames andxcschememanagement.plistkeys.xcodestays as a devDependency, with local typings insrc/lib/wizard/xcode.d.ts. It goes away with the post-v4init/wizardunification (Unify thesentry initandsentry wizardsetup flows #2510).Overlap with sibling ports. These shared helpers are ported at upstream's paths, since other flows may port them too:
utils/files.tsandutils/find-files-with-extension.ts. Upstream has twofindFilesWithExtensions, and both are kept as they are.utils/abort-if-sportlight-not-supported.ts.utils/bash.ts, with onlyexecute, whichpod installneeds.React Native needs nothing from
src/android/orsrc/sourcemaps/.Fixtures. The Xcode project fixtures are in
test/fixtures/wizard/apple/.Not ported, or different from sentry-wizard.
sentry-clifallback in the build phase. Install CLI nightlies from Toolkit GHCR #1403 keeps one.sentry_debug_files_upload/sentry_upload_snapshotsactions are left as they are. They come from fastlane-plugin-sentry, which still runs sentry-cli.sentry.propertiesand uses the SDK's bundled@sentry/cliscripts for Xcode and Gradle uploads. Those scripts belong to the SDK.SENTRY_SPOTLIGHT) is still not supported for iOS or React Native, same as upstream.Resolved in review: v4 already prefers a stored
sentry auth loginover the.sentryclirctoken; the build phase falls back tonpx sentry; fastlane and RN SDK v4 follow-ups get their own issues; the fixtures stay intest/fixtures/wizard/apple/.via @BYK.
--
View Session [Sentry]