Repository navigation
feat(cli): add Android and Flutter to sentry wizard - #2528
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>
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
…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>
- 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>
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
left a comment
There was a problem hiding this comment.
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.
… 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.
|
Moved the reader to |
…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.
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 0f7b03a. Configure here.

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) topackages/cli/src/lib/wizard/{android,flutter}. Both are registered inWIZARD_RUNNERSthrough the entry points upstreamsrc/run.tscalled, sosentry wizard -i android/-i flutterwork and the picker lists them.What changed vs. sentry-wizard
No xml-js / js-yaml.
AndroidManifest.xml: it finds theMAINactivity and the manifestpackage. That's nowwizard/utils/xml.ts, a small element/attribute reader.getMainActivitythen falls back to "verify the setup by hand".pubspec.yamlandmain.dart.pubspec.yamlwas already patched with string edits, and none of the helpers it imports touch YAML.No
sentry-clibinary.sentry-cli../gradlewruns throughutils/bash.ts, which ports onlyexecute.sentry_dart_pluginbundle their own CLI, so they still readsentry.propertiesas upstream wrote it.docs.sentry.io/cli/configurationpage. They now name the Dart plugin and link its auth-token docs.Other port changes
Sentry.captureException("…")becomesreportCliError(new Error("…")), likeutils/clack/index.ts.promoCodeis gone fromprintWelcome.abort()throwsWizardExitError.getMainActivityno longer crashes on a lone<activity>without an<intent-filter>. Upstream dereferencedundefinedthere.sentry-properties-addedtag now reports thesentry.propertiesresult. Upstream reported the pubspec result.release-registry.tsusesfetchinstead of axios.sentrycommandsThese flows don't generate or print any
sentryCLI commands. The only CLI configuration they write is what the Gradle and Dart plugins read (sentry.properties, thepubspec.yamlsentry:block), and that stays as upstream wrote it.Overlap with parallel ports
test/commands/wizard.test.tsno longer hard-codes an integration for the "not available in this version yet" case. It picks any id without a runner through the newhasWizardRunner()inrun.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 toflutter) don't break it. When that conflicts, keep this version.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.tsutils/line-endings.tsutils/abort-if-sportlight-not-supported.ts(keeps upstream's file name)utils/bash.ts(executeonly;installSentryCLI/hasSentryCLIare intentionally left out)Kept as upstream (possible follow-ups)
build/and.gradle/.via @BYK.
--
View Session [Sentry]