Skip to content

feat(cli): add Android and Flutter to sentry wizard - #2528

Merged
BYK merged 27 commits into
mainfrom
feat/cli-wizard-android-flutter
Nov 27, 2026
Merged

BYK merged 27 commits into
mainfrom
feat/cli-wizard-android-flutter

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of #2511. Stacked on #2520 (which is stacked on #2519).

Ports the Android and Flutter flows of sentry-wizard 9.1.0 (src/android/, src/flutter/ and their tests) to packages/cli/src/lib/wizard/{android,flutter}. Both are registered in WIZARD_RUNNERS through the entry points upstream src/run.ts called, so sentry wizard -i android / -i flutter work and the picker lists them.

What changed vs. sentry-wizard

No xml-js / js-yaml.

  • Android used xml-js only to read AndroidManifest.xml: it finds the MAIN activity and the manifest package. That's now wizard/utils/xml.ts, a small element/attribute reader.
    • It skips text, comments, CDATA, processing instructions and the doctype, and decodes character references in attribute values.
    • It throws on malformed markup. getMainActivity then falls back to "verify the setup by hand".
  • Every write is still a string edit, as upstream did it, so the user's formatting is kept. That covers the manifest, Gradle scripts, main activity, pubspec.yaml and main.dart.
  • Flutter never used js-yaml: pubspec.yaml was already patched with string edits, and none of the helpers it imports touch YAML.

No sentry-cli binary.

  • Nothing installs or checks for sentry-cli. ./gradlew runs through utils/bash.ts, which ports only execute.
  • The Android Gradle Plugin and sentry_dart_plugin bundle their own CLI, so they still read sentry.properties as upstream wrote it.
  • The Flutter auth-token hints used to say "auth token for Sentry CLI" and link the v3 docs.sentry.io/cli/configuration page. They now name the Dart plugin and link its auth-token docs.

Other port changes

  • Sentry.captureException("…") becomes reportCliError(new Error("…")), like utils/clack/index.ts.
  • promoCode is gone from printWelcome.
  • abort() throws WizardExitError.
  • getMainActivity no longer crashes on a lone <activity> without an <intent-filter>. Upstream dereferenced undefined there.
  • The sentry-properties-added tag now reports the sentry.properties result. Upstream reported the pubspec result.
  • release-registry.ts uses fetch instead of axios.

sentry commands

These flows don't generate or print any sentry CLI commands. The only CLI configuration they write is what the Gradle and Dart plugins read (sentry.properties, the pubspec.yaml sentry: block), and that stays as upstream wrote it.

Overlap with parallel ports

  • test/commands/wizard.test.ts no longer hard-codes an integration for the "not available in this version yet" case. It picks any id without a runner through the new hasWizardRunner() in run.ts, which the picker uses too. So sibling ports registering more integrations (feat(cli): add SvelteKit, Remix and React Router to sentry wizard #2526 switched it to flutter) don't break it. When that conflicts, keep this version.
  • Expect small additive conflicts in WIZARD_RUNNERS.

These shared helpers are ported at their upstream paths because these flows import them. Other flows may port the same files:

  • utils/release-registry.ts
  • utils/line-endings.ts
  • utils/abort-if-sportlight-not-supported.ts (keeps upstream's file name)
  • utils/bash.ts (execute only; installSentryCLI / hasSentryCLI are intentionally left out)

Kept as upstream (possible follow-ups)

  • Spotlight aborts for both flows ("only available for Next.js").
  • The search for Gradle files walks the whole tree, including build/ and .gradle/.

via @BYK.

--

View Session [Sentry]

sentry-junior Bot and others added 5 commits November 26, 2026 11:48
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>
Port the Android and Flutter flows of sentry-wizard 9.1.0 to
`sentry wizard -i android` and `-i flutter`, and register both in the
wizard's runner map so the picker lists them.

Android reads AndroidManifest.xml with a small element/attribute reader
(android/xml.ts) instead of xml-js; every write to the manifest, the
Gradle scripts, and main activity stays a string edit, as upstream did,
so user formatting is kept. Flutter already edited pubspec.yaml with
string edits and needs no YAML library.

Neither flow installs or checks for a sentry-cli binary: `./gradlew` runs
through a bash.ts that ports only `execute`. The Gradle plugin and the
Dart plugin bundle their own CLI and keep reading sentry.properties. The
Flutter auth-token hints now point at the Dart plugin docs instead of the
v3 sentry-cli configuration page.

The shared helpers these flows import (release-registry, line-endings,
abort-if-sportlight-not-supported) are ported at their upstream paths;
release-registry uses fetch instead of axios.

Refs #2511

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cli Ready Ready Preview Nov 27, 2026 10:45pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Nov 27, 2026 10:45pm UTC

Request Review

…e test

The test hard-coded an integration without a flow, which breaks each time
a sibling port registers that integration. Add `hasWizardRunner()` to
run.ts (the picker now uses it too) and let the test pick any integration
that has no runner yet, skipping once every integration has one.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
sentry-junior Bot and others added 3 commits November 26, 2026 18:10
- 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>
No Gradle project, no main activity (or package name), and a failed
Gradle sync are problems with the user's project, not CLI bugs. The
Android wizard now shows a message for each and exits non-zero via
abort(), without reporting them to Sentry. Unexpected failures still go
through reportCliError.

The sentry.properties step now says the token is for the Sentry Android
Gradle plugin.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
sentry-junior Bot and others added 6 commits November 26, 2026 19:01
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>
Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…eat/cli-wizard-shared-ast-helpers

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
Merge feat/cli-wizard-shared-ast-helpers (f0a48de), which brings the
positional `[<org>/<project>] [<integration>]` wizard command line and
removes findFile from wizard/utils/ast-utils.ts.

- The Android wizard finds the main activity source with the async
  findFile from lib/dsn/fs-utils.ts, so findActivitySourceFile is async
  and its caller awaits it.
- The wizard command test for an integration without a runner passes the
  integration as a positional argument.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
#2519 and #2520 were squash-merged into main, so this
branch's base is now main. The add/add conflicts came from the squashed
wizard files. main's copies of run.ts and test/commands/wizard.test.ts
equal f0a48de, which this branch already merged, so this branch's
Android and Flutter additions are kept. project-data.ts and its test take
main's copy, which has the #2559 fix for the origin trust check.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
- Android: treat only `import io.sentry.Sentry` itself as already
  patched, not imports such as `io.sentry.SentryOptions`.
- Flutter: skip an arrow `main` inside a comment or string.

Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>

@BYK BYK left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Android used xml-js only to read AndroidManifest.xml: it finds the MAIN activity and the manifest package. That's now android/xml.ts, a small element/attribute reader.

I think #2544 also adds something like this so these should be shared, not duplicated.

@BYK
BYK enabled auto-merge November 27, 2026 22:16
… wizard

- Only an uncommented `sentry_flutter:` or `sentry_dart_plugin:` key
  counts as already installed.
- Insert the Sentry import after the last import that isn't inside a
  comment or string.
The Android wizard's AndroidManifest.xml reader is a general element and
attribute parser, so move it to `wizard/utils/xml.ts` and export its
entity decoder for other wizards to reuse instead of adding their own.
@vercel
vercel Bot temporarily deployed to Preview – sentry-local November 27, 2026 22:20 Inactive
@sentry-junior

sentry-junior Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Moved the reader to packages/cli/src/lib/wizard/utils/xml.ts and exported decodeXmlEntities in 3f6cafd0. #2544 has its own copy: apple/snapshots/xml-scan.ts (a regex scanner and a second decodeXmlEntities). There is also a third entity decoder on main in react-native/xcode-env.ts. Once this lands, #2544 can build its Apple helpers on parseXml and drop its copy.

…id-flutter

# Conflicts:
#	packages/cli/src/lib/wizard/run.ts
#	packages/cli/src/lib/wizard/utils/abort-if-sportlight-not-supported.ts
#	packages/cli/src/lib/wizard/utils/bash.ts
`xml-scan.ts` had its own copy of the decoder in `wizard/utils/xml.ts`.
- Treat main.dart as set up only when `SentryFlutter.init(` appears in
  code, not when it just imports sentry_flutter; skip adding a second
  import.
- Make `main` async only where it is code, not in strings or comments.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0f7b03a. Configure here.

@vercel
vercel Bot temporarily deployed to Preview – sentry-local November 27, 2026 22:44 Inactive
@BYK
BYK added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit d5c9da8 Nov 27, 2026
30 checks passed
@BYK
BYK deleted the feat/cli-wizard-android-flutter branch November 27, 2026 23:03

This branch was successfully deployed

1 active and 1 inactive deployments
Preview – cli — 1ddc14e2 Deployed Nov 27, 2026 by vercel[bot]
Preview – sentry-local — 1ddc14e2 Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant