Skip to content

fix(cli): Fix React Native wizard's Expo plugin setup - #2786

Merged
antonis merged 3 commits into
mainfrom
fix/rn-wizard-expo-app-config
Dec 2, 2026
Merged

antonis merged 3 commits into
mainfrom
fix/rn-wizard-expo-app-config

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Part of #2561

Fixes three bugs carried over from @sentry/wizard in how the React Native wizard adds the Sentry Expo plugin (packages/cli/src/lib/wizard/react-native/expo.ts).

  • Snippet shape. The copy-paste app.json snippet now nests name and plugins under "expo", where Expo reads them.
  • Already configured plugin. addWithSentryToAppConfigJson now returns patched, already-configured, or error instead of string | 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 the already-patched tag, and doesn't show the copy-paste instructions. A parse or write failure still logs "Unable to patch" and shows them.
  • File names and dynamic configs. Every message and the reported Sentry errors now name app.json, the file the wizard patches, not app.config.json. If the project has a dynamic config (app.config.ts, .mts, .cts, .mjs, .cjs, or .js, found with findFile in Expo's resolution order), Expo reads that file instead of app.json. In that case the wizard patches nothing, explains why, and shows a JS/TS snippet for that file: module.exports = for .js and .cjs, export default for the rest. It sets the new dynamic-config value of the app-config-file-status tag.

The node:fs mock in expo.test.ts now stubs only existsSync, so the patchExpoAppConfig tests read and write real files in a temp directory.

Open question: the wizard detects every extension Expo resolves, not only .js and .ts, because patching app.json has no effect next to any of them.

via Antonis Lilis.

--

View Session [Sentry]

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>
@vercel

vercel Bot commented Dec 2, 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 Dec 2, 2026 12:34pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 2, 2026 12:34pm UTC

Request Review

@antonis antonis 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.

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_EXTENSIONS matches Expo's DYNAMIC_CONFIG_EXTS, in the same order.
  • Expo reads config.expo ?? config, so the snippet's { expo: { ... } } shape works.
  • Expo's own modifyConfigAsync doesn't write plugins when 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:

  1. The dynamic config snippet reads like a whole new file. Many app.config.ts files are functions that spread app.json (({ config }) => ({ ...config, ... })), so a hint like "add this entry to plugins in your existing config" would keep people from replacing their file.
  2. Expo prefers app.config.json over app.json for the static config (getStaticConfigFilePath), and the wizard still only patches app.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.
@vercel
vercel Bot temporarily deployed to Preview – sentry-local December 2, 2026 12:26 Inactive
@antonis
antonis marked this pull request as ready for review December 2, 2026 12:30
@antonis
antonis enabled auto-merge December 2, 2026 12:30
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 2, 2026
@antonis
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.
@vercel
vercel Bot temporarily deployed to Preview – sentry-local December 2, 2026 12:34 Inactive
@antonis
antonis enabled auto-merge December 2, 2026 12:41
@antonis
antonis added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit f662000 Dec 2, 2026
31 checks passed
@antonis
antonis deleted the fix/rn-wizard-expo-app-config branch December 2, 2026 12:52
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

1 active and 1 inactive deployments
Preview – cli — defcdbf9 Deployed Dec 2, 2026 by vercel[bot]
Preview – sentry-local — defcdbf9 Deployed Dec 2, 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