Repository navigation
feat(cli): add SvelteKit, Remix and React Router to sentry wizard - #2526
sentry-junior[bot] wants to merge 18 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>
Port the SvelteKit, Remix and React Router flows of getsentry/sentry-wizard 9.1.0 into `src/lib/wizard/` with their tests, and register them as the `sveltekit`, `remix` and `reactRouter` runners of `sentry wizard`. The flows take the same options `@sentry/wizard` passed them, and like upstream they stop with a notice under `--spotlight` (`utils/abort-if-sportlight-not-supported.ts` comes over for that). Changes from upstream: - Remix with a Vite config used the source maps wizard's Vite setup, which isn't in the CLI yet. It now writes `.env.sentry-build-plugin` and points to the manual source map steps instead. - The AST code is typed with ast-types instead of `@babel/types`, which the CLI doesn't depend on; node printing that magicast's `generateCode` did on bare nodes goes through `recast.print`, which is what `generateCode` calls for them. - Failures that went to `Sentry.captureException` go through `reportCliError`. - The SvelteKit fallback for `instrumentation.server` named the file `.ts` even in JavaScript projects; it now uses the project's ending. The upstream test fixtures are kept byte for byte, so formatting, lint and type checks skip `test/lib/wizard/**/fixtures/`. 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
|
…rs' into feat/cli-wizard-sveltekit-remix-react-router Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…ith v4 CI failed on the SvelteKit, Remix and React Router flows: - They still passed `promoCode` to `printWelcome()`, which the scaffold removed with the sign-up and partner flags. - The sentry-wizard codemod fixtures under `test/lib/wizard/**/fixtures/` are excluded from the test tsconfig, so the tsconfig policy now lists them as unchecked on purpose, like the cli3to4 codemod fixtures. The Remix build script used `npx @sentry/remix --upload-sourcemaps`, which runs the legacy sentry-cli. The wizard must not depend on sentry-cli, so the script now runs `sentry sourcemap upload` on the same build path and URL prefix, and the wizard installs `sentry` as a dev dependency so the script works in CI. The org, project and self-hosted URL move from script flags into `.sentryclirc`, which v4 reads; the wizard tells the user to set the matching env vars in CI.
- 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>
Revert the Remix build script change from 07f26e0. For Remix without Vite the wizard again sets the build script to `npx @sentry/remix --upload-sourcemaps --org … --project …` and writes only the auth token to `.sentryclirc`, as sentry-wizard does. It no longer installs `sentry` as a dev dependency or prints the CI env var note. The promoCode removal from the welcome screen stays. 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>
…e new wizard base Merge feat/cli-wizard-shared-ast-helpers (f0a48de) and fix what it breaks: - `findFile` moved from `wizard/utils/ast-utils.ts` to the async `lib/dsn/fs-utils.ts`; the Remix and SvelteKit flows now await it. - `sentry wizard` takes `[<org>/<project>] [<integration>]` positionals, so the dispatch tests for the three flows pass them that way and check the `target` the flows get. - The base enables `unicorn/no-array-for-each`, so the ported `forEach` loops are `for…of` loops. Co-Authored-By: BYK <126780+BYK@users.noreply.github.com>
…ekit-remix-react-router Co-Authored-By: BYK <126780+BYK@users.noreply.github.com> # Conflicts: # packages/cli/src/lib/wizard/run.ts # packages/cli/src/lib/wizard/utils/project-data.ts # packages/cli/test/commands/wizard.test.ts # packages/cli/test/lib/wizard/utils/project-data.test.ts # scripts/tsconfig-policy.test.mjs
| }); | ||
| } | ||
|
|
||
| instrumentHandleError(serverEntryAst); |
There was a problem hiding this comment.
const/arrow handleError gets captureException after return
instrumentHandleError appends Sentry.captureException with body.push for variable-exported handlers, so any early return leaves capture unreachable and server errors are never reported. Insert with unshift like the function-declaration path (around line 435).
Evidence
instrumentServerEntrycallsinstrumentHandleErroron the entry AST before writing the file.- For
export const handleError = .../ arrow handlers, the sentryif (!request.signal.aborted) { Sentry.captureException(error); }node is added viaexistingBody.body.push(sentryCall)at the end of the block. - Fixture
variable-export.tsxand the variable-declaration tests use handlers thatreturn new Response(...)before the inserted call, so capture becomes dead code. - The
export function handleErrorpath correctly usesdeclaration.body.body.unshift(sentryCall)instead; tests only asserttoContain("captureException"), not statement order or reachability.
Identified by Warden · code-review · 6BK-CX9
| }); | ||
| } | ||
|
|
||
| instrumentHandleError(serverEntryAst); |
There was a problem hiding this comment.
Error-only function declarations get an unbound request reference
When an existing exported handleError declaration accepts only error, the codemod inserts request.signal.aborted without adding a request binding. The generated handler then throws on the error path before Sentry capture or the user's original handler runs.
Evidence
instrumentHandleErrorinserts this statement at the start of an exported function declaration's body but never changes that declaration's parameters.- The test at
server-entry.test.tslines 304–317 usesexport function handleError(error: unknown), then checks forcaptureExceptionwithout checking thatrequestis bound. - The variable-declaration branch explicitly adds
{ request }when onlyerrorexists, confirming that the inserted guard requires a request binding.
Identified by Warden · code-review · CC6-JTR
| b.identifier("config"), | ||
| ]); | ||
| } | ||
|
|
||
| /** Adds @sentry/react-router to optimizeDeps.exclude to prevent 504 errors during dev. */ | ||
| function addOptimizeDepsExclude(configObj: t.ObjectExpression): void { | ||
| const b = recast.types.builders; | ||
|
|
||
| const optimizeDeps = findProperty(configObj, "optimizeDeps"); | ||
| const optimizeDepsObj = | ||
| optimizeDeps?.type === "ObjectProperty" && | ||
| optimizeDeps.value.type === "ObjectExpression" | ||
| ? optimizeDeps.value | ||
| : null; | ||
|
|
||
| let targetDepsObj: t.ObjectExpression; | ||
| if (!optimizeDepsObj) { | ||
| if (optimizeDeps) { | ||
| debug("optimizeDeps is not a static object, skipping exclude"); | ||
| return; | ||
| } | ||
| targetDepsObj = b.objectExpression([]); | ||
| configObj.properties.push( | ||
| b.objectProperty(b.identifier("optimizeDeps"), targetDepsObj), | ||
| ); | ||
| } else { | ||
| targetDepsObj = optimizeDepsObj; | ||
| } | ||
|
|
||
| const excludeProp = findProperty(targetDepsObj, "exclude"); | ||
| const excludeArr = | ||
| excludeProp?.type === "ObjectProperty" && | ||
| excludeProp.value.type === "ArrayExpression" | ||
| ? excludeProp.value | ||
| : null; | ||
|
|
||
| let targetArr: t.ArrayExpression; | ||
| if (!excludeArr) { | ||
| if (excludeProp) { | ||
| debug("optimizeDeps.exclude is not a static array, skipping"); | ||
| return; | ||
| } | ||
| targetArr = b.arrayExpression([]); | ||
| targetDepsObj.properties.push( | ||
| b.objectProperty(b.identifier("exclude"), targetArr), | ||
| ); | ||
| } else { | ||
| targetArr = excludeArr; | ||
| } | ||
|
|
||
| const isAlreadyExcluded = targetArr.elements.some( | ||
| (el) => el?.type === "StringLiteral" && el.value === "@sentry/react-router", | ||
| ); | ||
| if (!isAlreadyExcluded) { | ||
| targetArr.elements.push(b.stringLiteral("@sentry/react-router")); | ||
| } | ||
| } | ||
|
|
||
| export function addReactRouterPluginToViteConfig( | ||
| program: t.Program, | ||
| orgSlug: string, | ||
| projectSlug: string, | ||
| ): { success: boolean; wasConverted: boolean } { | ||
| const b = recast.types.builders; | ||
| let wasConverted = false; | ||
|
|
||
| const defaultExport = program.body.find( | ||
| (node): node is t.ExportDefaultDeclaration => | ||
| node.type === "ExportDefaultDeclaration", | ||
| ); | ||
|
|
||
| if (!defaultExport) { | ||
| return { success: false, wasConverted: false }; | ||
| } | ||
|
|
||
| let configObj: t.ObjectExpression | undefined; | ||
| let defineConfigCall: t.CallExpression | undefined; | ||
|
|
||
| if ( | ||
| defaultExport.declaration.type === "CallExpression" && | ||
| defaultExport.declaration.callee.type === "Identifier" && | ||
| defaultExport.declaration.callee.name === "defineConfig" | ||
| ) { | ||
| defineConfigCall = defaultExport.declaration; | ||
|
|
||
| const arg = defineConfigCall.arguments[0]; | ||
|
|
||
| // Early exit if not single argument | ||
| if (defineConfigCall.arguments.length !== 1 || !arg) { | ||
| return { success: false, wasConverted: false }; | ||
| } | ||
|
|
||
| if (arg.type === "ObjectExpression") { | ||
| configObj = arg; | ||
| // Convert to function form | ||
| const arrowFunction = b.arrowFunctionExpression( | ||
| [b.identifier("config")], | ||
| configObj, | ||
| ); | ||
| defineConfigCall.arguments[0] = arrowFunction; | ||
| wasConverted = true; | ||
| } else if ( | ||
| arg.type === "ArrowFunctionExpression" || | ||
| arg.type === "FunctionExpression" | ||
| ) { | ||
| configObj = extractFromFunctionBody(arg.body); |
There was a problem hiding this comment.
sentryReactRouter call hardcodes config for any defineConfig callback
When an existing defineConfig callback is already a function whose parameter is not named config (e.g. env or ({ mode })), the wizard still emits sentryReactRouter(..., config), leaving a free identifier so Vite fails after a successful wizard run.
Evidence
createSentryPluginCall()always builds the second argument asb.identifier("config")(line 87).- For an existing
ArrowFunctionExpression/FunctionExpression,addReactRouterPluginToViteConfig()only callsextractFromFunctionBody(arg.body)and never readsarg.params(lines 188–192). - Object-form configs are rewritten to
(config) => …, so they match; function-form configs keep their original parameter name. - Tests only cover
config =>andfunction(config); Vite’s own docs commonly use({ command, mode })orenv.
Identified by Warden · code-review · NTK-WRA
| } else if (handleErrorFunctionVariableDeclarationExport) { | ||
| const implementation = recast.parse(HANDLE_ERROR_TEMPLATE).program.body[0]; | ||
|
|
||
| // If the current handleError function has a body, we need to merge the new implementation with the existing one | ||
| implementation.declarations[0].init.arguments[0].body.body.unshift( | ||
| // @ts-expect-error - declaration works here because the AST is proxified by magicast | ||
| ...handleErrorFunctionVariableDeclarationExport.declaration | ||
| .declarations[0].init.body.body, | ||
| ); |
There was a problem hiding this comment.
Variable handleError wrap crashes on non-block bodies
The variable-export branch reads init.body.body without checking that init is a block-bodied function, so expression-body or non-function initializers throw and skip server entry instrumentation.
Evidence
- For
export const handleError = ..., the merge path does...handleErrorFunctionVariableDeclarationExport.declaration.declarations[0].init.body.bodywith no type/guard checks. - An expression-body arrow (
export const handleError = (e) => console.error(e)) hasinit.bodyas an Expression, so.bodyis undefined and the spread throws. - The same throw occurs if
initis a CallExpression/Identifier rather than a function with a BlockStatement body. - React Router’s
instrumentHandleErrorin this PR guardsArrowFunctionExpression/FunctionExpression+BlockStatementbefore touching.body; this Remix path does not.
Identified by Warden · code-review · 484-EKL
| url: sentryUrl, | ||
| orgSlug: selectedProject.organization.slug, | ||
| projectId: selectedProject.id, | ||
| isUsingSvelte5: ["5.x", ">5.x"].includes(svelteVersionBucket), |
There was a problem hiding this comment.
Svelte 5 example page does not react to connectivity results
When Sentry is unreachable in a Svelte 5 project, the generated example page leaves isConnected as a plain variable in runes mode, so the button stays enabled and the blocked-network warning never appears. Declare it with $state so the connectivity result updates the UI.
Evidence
sveltekit-wizard.tspassesisUsingSvelte5: truefor Svelte version buckets5.xand>5.x.- In that case, the generated component uses
$stateforhasSentErrorbut leavesisConnectedas a plainlet; the rune opts the component into runes mode, where that plain variable is not reactive. - When
diagnoseSdkConnectivity()returnssentry-unreachable,onMountsetsisConnectedto false, but the button’sdisabledand the connectivity-warning branch do not update.
Also found at 1 additional location
packages/cli/src/lib/wizard/sveltekit/templates.ts:158-163
Identified by Warden · code-review · XYK-TL6
| ]), | ||
| b.identifier("config"), | ||
| ]); | ||
| } |
There was a problem hiding this comment.
Vite plugin ignores existing config param
Medium Severity
createSentryPluginCall always passes the identifier config as the second argument to sentryReactRouter. When the Vite config is already a function whose parameter is not named config — for example defineConfig(({ command, mode }) => ({ ... })) — the generated call references an undeclared config and the build fails.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e525c83. Configure here.
| return true; | ||
| } | ||
|
|
||
| originalExpressServerMod.$code = `import './${instrumentationFile}';\n${originalExpressServerMod.$code}`; |
There was a problem hiding this comment.
Express instrumentation import path is wrong
High Severity
The instrumentation file is written at the project root as instrumentation.server.mjs, but the Express server import is always ./instrumentation.server.mjs. findCustomExpressServerImplementation also looks in server/index, app/server, and app/server/index, where that relative path does not resolve to the root file, so the server fails to start with a missing module.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e525c83. Configure here.
| } | ||
|
|
||
| // Add the Sentry call to the function body | ||
| existingBody.body.push(sentryCall); |
There was a problem hiding this comment.
handleError capture runs too late
Medium Severity
For a handleError function declaration the capture call is inserted at the start of the body, but for a variable-declaration handleError it is appended at the end. If that function returns or rethrows, Sentry.captureException never runs and server errors are dropped.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e525c83. Configure here.
| `NODE_OPTIONS='--import ./${INSTRUMENTATION_FILE}' react-router-serve ./build/server/index.js`; | ||
| } else { | ||
| packageJson.scripts["start"] = mergeNodeOptions(startScript); | ||
| } |
There was a problem hiding this comment.
Start script replacement drops custom flags
Medium Severity
When the existing start script has no NODE_OPTIONS and no instrumentation file, it is replaced with a hardcoded react-router-serve ./build/server/index.js command. Extra flags, a custom server entry, or a different serve path are discarded. mergeNodeOptions already knows how to prepend --import while keeping the original command.
Reviewed by Cursor Bugbot for commit e525c83. Configure here.
| ); | ||
|
|
||
| // @ts-expect-error - declaration works here because the AST is proxified by magicast | ||
| handleErrorFunctionVariableDeclarationExport.declaration = implementation; |
There was a problem hiding this comment.
Remix handleError merge can throw
Medium Severity
When wrapping an existing variable-declaration handleError, the Remix codemod reads .init.body.body with no guard. An arrow or function expression that is not a block body has no .body.body, so the wizard throws instead of skipping. The React Router port of this same step logs and skips in that case.
Reviewed by Cursor Bugbot for commit e525c83. Configure here.
…r wizards Fixes carried over from sentry-wizard that keep its intended behaviour: - React Router: Ctrl+C at the `react-router reveal` prompt stops the wizard instead of running reveal. - React Router: `--force` reaches both SDK installs. - React Router: an existing react-router.config with the other extension is updated instead of shadowed by a new file. - React Router: `export default [...] as RouteConfig` gets the example routes, and an unsupported routes export now shows the manual steps. - React Router: the example routes are registered in `app/routes.js` too. - React Router: the package.json fallback snippet shows the real `react-router-serve` start script as the line to replace. - Remix: an unknown installed SDK version falls back to the `^11` the wizard installs, so the data collection prompt is offered. - SvelteKit: a failed vite.config edit no longer reports success. - SvelteKit: `kit.experimental.(tracing|instrumentation)` objects with `server: false` or no `server` key are rewritten instead of skipped, and the fallback snippet keeps server tracing off when it was declined.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
There are 6 total unresolved issues (including 5 from previous reviews).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit f0ece5c. Configure here.
| if (fileExistedBefore) { | ||
| clack.log.success(`Updated ${filename} with Sentry buildEnd hook.`); | ||
| } else { | ||
| clack.log.success(`Created ${filename} with Sentry buildEnd hook.`); |
There was a problem hiding this comment.
Config logs ignore existing extension
Medium Severity
configureReactRouterConfig still derives the config filename only from isTS, while instrumentReactRouterConfig now updates whichever of .js or .ts already exists. Success and error messages can name the wrong file, and the copy-paste fallback still points at a TypeScript config that would shadow the one that was actually edited.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit f0ece5c. Configure here.
| const buildEndProp = findProperty(configObj, "buildEnd"); | ||
|
|
||
| if (buildEndProp) { | ||
| throw new Error( | ||
| "A buildEnd hook already exists in your React Router config.", | ||
| ); | ||
| } |
There was a problem hiding this comment.
Method-style buildEnd hooks are not detected and get overwritten
findProperty only matches ObjectProperty, so an existing async buildEnd() { ... } is missed; the wizard appends another buildEnd and silently replaces the user's hook at runtime instead of throwing the intended merge error.
Evidence
findPropertyinast-utils.tsonly returns nodes withp.type === "ObjectProperty".- A method shorthand like
async buildEnd() { ... }is an ASTObjectMethod, sobuildEndPropis undefined and the throw on lines 77-81 never runs. - Lines 138-140 always
pusha newbuildEndObjectProperty after that check. - In a plain object literal the later duplicate key wins, so the original method body is dropped with no error.
- Tests only cover
buildEnd: async () => { ... }(ObjectProperty), not the method form.
Identified by Warden · code-review · 3E5-J5N
| 'Please manually add these routes to your routes.ts file: route("/sentry-example-page", "routes/sentry-example-page.tsx") and route("/api/sentry-example-api", "routes/api.sentry-example-api.ts")', | ||
| ); |
There was a problem hiding this comment.
Manual routes fallback always uses TypeScript paths
When updating routes config fails, the recovery message always tells users to edit routes.ts and register .tsx/.ts modules, even for JavaScript apps where this wizard wrote .jsx/.js files and may be using routes.js.
Evidence
- On codemod failure, the info string is hardcoded to
routes.ts,sentry-example-page.tsx, andapi.sentry-example-api.ts. createExamplePagewritessentry-example-page.jsx/api.sentry-example-api.jswhenisTSis false, and discovers eitherapp/routes.tsorapp/routes.js.addRoutesToConfigalready picks extensions fromisTSand can throw for non-array default exports, so this fallback is reachable.- The JS test expects the
.jsx/.jsroute module paths, confirming the intended contract.
Identified by Warden · code-review · HDQ-VH2
| const tracingServer = enableTracing || hasTracingEnabled; | ||
|
|
||
| try { | ||
| const configPath = path.join(process.cwd(), SVELTE_CONFIG_FILE); | ||
| const svelteConfigContent = await promises.readFile(configPath, "utf-8"); | ||
|
|
||
| const { error, result } = _enableTracingAndInstrumentationInConfig( | ||
| svelteConfigContent, | ||
| tracingServer, |
There was a problem hiding this comment.
Declined tracing can overwrite on-disk tracing.server true when originalSvelteConfig is empty
When originalSvelteConfig omits already-enabled tracing (e.g. loadSvelteConfig() failed and returned {}) and the user declines tracing, the file rewrite sets kit.experimental.tracing.server to false even if it was already true on disk.
Evidence
loadSvelteConfig()catches import/eval errors and returns{}while the wizard continues.hasTracingEnabledis taken only fromoriginalSvelteConfig.kit?.experimental?.tracing?.server === true, so a failed load makes itfalse.- With
enableTracing === false,tracingServerisfalseand is passed to_enableTracingAndInstrumentationInConfig, which writestracing.serverto that value. - The comment on this line says already-enabled server tracing must not be turned off; the file contents are never checked for an existing
truebefore that write.
Identified by Warden · code-review · ZZD-BCT


Part of #2511 (under #1965). Stacked on #2520 (shared AST helpers), which sits on #2519 (
sentry wizardscaffold and Next.js). magicast and recast stay until #2510 moves the config edits to a shared flow.What
Ports the SvelteKit, Remix and React Router flows of getsentry/sentry-wizard 9.1.0 (
src/sveltekit/,src/remix/,src/react-router/) intopackages/cli/src/lib/wizard/, with their upstream tests inpackages/cli/test/lib/wizard/.sveltekit,remixandreactRouterare registered inWIZARD_RUNNERS, callingrunSvelteKitWizard,runRemixWizardandrunReactRouterWizardwith the sameWizardOptionsthat upstreamsrc/run.tspasses, sosentry wizard -i <id>and the picker now offer them.The one shared helper these flows needed that the CLI didn't have yet,
utils/abort-if-sportlight-not-supported.ts, comes over with its upstream path and signature. As upstream, all three flows stop with a notice under--spotlight.Changes from upstream
configureVitePlugin(src/sourcemaps/tools/vite.ts), which belongs to the source maps port. For now this branch writes.env.sentry-build-pluginand prints a link to the manual Remix source map steps. When the source maps port lands, swap that call back in; it's one call inremix/remix-wizard.ts.remix build --sourcemap && npx @sentry/remix --upload-sourcemaps --org … --project …(shopify hydrogen buildand--buildPath ./distfor Hydrogen, plus--urlfor self-hosted), and.sentryclircgets the auth token. That is the Remix SDK's own upload script, which uses@sentry/cliinternally, so it stays as is. Self-hosted is detected with theselfHostedflag fromgetOrAskForProjectDatainstead of comparingsentryUrltoDEFAULT_URL.ast-typesnamedTypesinstead of@babel/types, which the CLI doesn't depend on. Where upstream called magicast'sgenerateCodeon a bare node, this branch callsrecast.print, which is whatgenerateCoderuns for a node that has no$code. A few defensive checks that the stricter types make redundant were removed. The React RouterhandleErrorcodemod now narrows the variable declaration properly instead of usingas any. When thehandleErrorvalue isn't a function with a block body, the codemod logs a debug message and skips the edit; upstream threw there.Sentry.captureException(...)calls go throughreportCliError. The SvelteKit Vite fallback snippet prints withclack.rawOutputinstead ofconsole.log.instrumentation.serverfallback always named the file.ts, because(fileEnding ?? isUsingTypeScript())is always truthy. It now uses the project's ending..tsxfiles undertest/lib/wizard/{remix,react-router}/**/fixtures/) are kept byte for byte, because the tests compare against their exact quoting. Oxfmt, Oxlint and the testtsconfig.jsonskippackages/cli/test/lib/wizard/**/fixtures/**, andscripts/tsconfig-policy.test.mjslists them as unchecked on purpose, like the cli3to4 codemod fixtures.max-paramsdisable comment, so that the upstream tests still call them unchanged.Not ported / follow-ups
test/commands/wizard.test.tsusedremixas its example of an integration that isn't available yet. It now usesflutter, so a sibling PR that ports Flutter will need to pick another one.via @BYK.
--
View Session [Sentry]