Repository navigation
fix(cli): Fix React Native wizard's Expo plugin setup - #2786
Merged
Merged
Conversation
Nest the copy-paste app.json snippet under "expo", where Expo reads plugins. Report an already configured Sentry plugin as set up instead of as a patch failure, so the wizard no longer tells the user to add it again. Name app.json, the file the wizard patches, in every message and error. When the project has a dynamic config (app.config.ts, app.config.js, ...), which Expo reads instead of app.json, show the plugin entry to add there instead of patching app.json. Part of #2561 Co-Authored-By: Antonis Lilis <antonis.lilis@sentry.io>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
antonis
approved these changes
Dec 2, 2026
antonis
left a comment
Contributor
There was a problem hiding this comment.
Looks good. This covers the three Expo items from #2561, and it doesn't depend on any React Native SDK change.
I checked the dynamic config handling against @expo/config 58:
DYNAMIC_APP_CONFIG_EXTENSIONSmatches Expo'sDYNAMIC_CONFIG_EXTS, in the same order.- Expo reads
config.expo ?? config, so the snippet's{ expo: { ... } }shape works. - Expo's own
modifyConfigAsyncdoesn't writepluginswhen a dynamic config exists either ("We don't know what plugins are in dynamic configs"), so showing instructions instead of patching matches Expo. That answers the open question: detecting every extension Expo resolves is right.
Two optional nits for a follow-up, not blocking:
- The dynamic config snippet reads like a whole new file. Many
app.config.tsfiles are functions that spreadapp.json(({ config }) => ({ ...config, ... })), so a hint like "add this entry topluginsin your existing config" would keep people from replacing their file. - Expo prefers
app.config.jsonoverapp.jsonfor the static config (getStaticConfigFilePath), and the wizard still only patchesapp.json. This is rare and existed before this PR.
The dynamic config snippet reads like a whole file. Many app.config.ts files spread app.json, so the hint now says to add the entry to plugins in the existing config instead of replacing the file.
antonis
marked this pull request as ready for review
December 2, 2026 12:30
antonis
enabled auto-merge
December 2, 2026 12:30
antonis
disabled auto-merge
December 2, 2026 12:33
Match the configured plugin by name in expo.plugins instead of searching the whole app.json text, so a value such as an app name that mentions sentry-expo no longer counts as configured. Treat an ["@sentry/react-native"] entry without options like the bare string and configure it in place.
8 of 12 tasks
antonis
enabled auto-merge
December 2, 2026 12:41
This was referenced Dec 3, 2026
14 of 16 tasks
github-actions Bot
pushed a commit
to Fields-Education/sentry-mcp
that referenced
this pull request
Dec 4, 2026
…entry#2839) From the mobile re-test (getsentry/sentry-react-native#7172). Even with every feature flag (`--tracing --profiling --logs --replay --feedback --no-mcp < /dev/null`), `sentry wizard reactNative` exited 1 at a prompt: bare React Native at "Do you want to run `pod install` now?", Expo at "Have you successfully sent a test event?". This lets the React Native and Expo wizards finish without a terminal, which the wizard e2e tests in getsentry#2572 need. **`pod install`**: new `--pod-install`/`--no-pod-install` flag in `WIZARD_ANSWER_FLAGS` (reactNative only). `confirmPodInstall` asks through `askFlagQuestion` and keeps Yes as the default. **Closing question**: it only confirms a setup that is already done, so it is skipped when stdin is not a TTY (`isatty(0)`, as `guardNonInteractive` and auto-login check). Piped stdin that is still open counts as no terminal too. The run then ends with an outro that says Sentry is set up, tells the user to send a test event and check it in Sentry, and links the project's issues page and the sentry-react-native GitHub issues. `user-confirmed-first-error` is `"skipped"`. With a terminal, it is asked as before. **Expo second run**: a `metro.config.js` that already has Sentry is its own `"already-configured"` outcome of `patchMetroInMemory`. It is logged once, with no "Could not patch" error and no copy-paste instructions. Those instructions also asked "Did you apply the snippet above?", which would have stopped a run without a terminal too. Parse and write failures still show them, as getsentry#2786 does for `app.json`. **`.gitignore` duplicates**: Expo's `.env.local` (`addToGitignore`) and Flutter's `sentry.properties` (`addProperties`) are appended only when no line already is the entry, ignoring surrounding whitespace. The check is `gitignoreHasEntry` in `utils/git.ts`. `addCliConfigFileToGitIgnore` now uses it as well, so whitespace around the entry counts there too. getsentry#2796 also changes `addCliConfigFileToGitIgnore`, but in other lines. <!-- junior-request-attribution:start --> via **Antonis Lilis**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:slack%3AD0CAPGCFLSC%3A1796305761.291369 --> -- [View Session](https://junior-prod.sentry.dev/conversations/slack%3AD0CAPGCFLSC%3A1796305761.291369) [[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AD0CAPGCFLSC%3A1796305761.291369/?project=4510944073809921) <!-- junior-session-footer:end --> Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com> Co-authored-by: Antonis Lilis <antonis.lilis@sentry.io>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2561
Fixes three bugs carried over from
@sentry/wizardin how the React Native wizard adds the Sentry Expo plugin (packages/cli/src/lib/wizard/react-native/expo.ts).app.jsonsnippet now nestsnameandpluginsunder"expo", where Expo reads them.addWithSentryToAppConfigJsonnow returnspatched,already-configured, orerrorinstead ofstring | null. When@sentry/react-native/expo,sentry-expo, or an"@sentry/react-native"entry with options is already there, the wizard logs that the plugin is already set up, keeps thealready-patchedtag, and doesn't show the copy-paste instructions. A parse or write failure still logs "Unable to patch" and shows them.app.json, the file the wizard patches, notapp.config.json. If the project has a dynamic config (app.config.ts,.mts,.cts,.mjs,.cjs, or.js, found withfindFilein Expo's resolution order), Expo reads that file instead ofapp.json. In that case the wizard patches nothing, explains why, and shows a JS/TS snippet for that file:module.exports =for.jsand.cjs,export defaultfor the rest. It sets the newdynamic-configvalue of theapp-config-file-statustag.The
node:fsmock inexpo.test.tsnow stubs onlyexistsSync, so thepatchExpoAppConfigtests read and write real files in a temp directory.Open question: the wizard detects every extension Expo resolves, not only
.jsand.ts, because patchingapp.jsonhas no effect next to any of them.via Antonis Lilis.
--
View Session [Sentry]