Skip to content

feat: Add SDK upgrade codemods (v8→v9)#1235

Closed
sergical wants to merge 3 commits intomasterfrom
feat/upgrade-codemods
Closed

feat: Add SDK upgrade codemods (v8→v9)#1235
sergical wants to merge 3 commits intomasterfrom
feat/upgrade-codemods

Conversation

@sergical
Copy link
Copy Markdown
Member

@sergical sergical commented Mar 2, 2026

Summary

  • Adds an upgrade wizard flow that applies AST codemods for breaking changes between major SDK versions
  • Currently supports v8→v9 with four transform modules:
    • package-remapping: @sentry/utils, @sentry/types@sentry/core
    • hub-removal: getCurrentHub() → direct API calls (captureException, getCurrentScope, etc.)
    • method-renames: captureUserFeedbackcaptureFeedback, WithSentrySentryExceptionCaptured, etc.
    • config-changes: enableTracing removal, transactionContext flattening, hideSourceMaps/autoInstrumentRemix removal
  • Complex patterns that can't be auto-migrated get TODO(sentry-upgrade): comments or manual review items
  • Wired up to CLI via npx @sentry/wizard -i upgrade or the interactive menu
  • Reuses existing recast infrastructure — no new dependencies

Test plan

  • 43 unit tests covering all four transform modules + version detection
  • 3 e2e tests (full project transform, manual review items, node_modules/dist exclusion)
  • Full test suite passes (870 tests, 0 regressions)
  • Type checks pass (tsc --noEmit)
  • Manual test: run yarn try -i upgrade against a sample v8 project

🤖 Generated with Claude Code

Adds an `upgrade` flow to the wizard that automatically applies codemods
for breaking changes when upgrading between major SDK versions. Currently
supports v8→v9 with four transform modules:

- package-remapping: @sentry/utils, @sentry/types → @sentry/core
- hub-removal: getCurrentHub() → direct API calls
- method-renames: captureUserFeedback → captureFeedback, etc.
- config-changes: enableTracing removal, transactionContext flattening

Includes 46 unit tests, 3 e2e tests, and CLI integration via `-i upgrade`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


Features

  • Add SDK upgrade codemods (v8→v9) by sergical in #1235

🤖 This preview updates automatically when you update the PR.

sergical and others added 2 commits March 2, 2026 18:47
- Add eslint-disable for recast parser require() calls
- Remove unnecessary async from synchronous runCodemodsOnFiles
- Fix non-null assertion in hub-removal
- Add assertTransform/assertNoChange to vitest expect-expect allowlist
- Update help-message e2e snapshot to include "upgrade" choice

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The function was changed from async to sync but callers still awaited it,
causing await-thenable lint errors. Also updates the help-message inline
snapshot to match actual yargs output whitespace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sergical
Copy link
Copy Markdown
Member Author

sergical commented Mar 5, 2026

Closing in favor of getsentry/sentry-for-ai#20

@sergical sergical closed this Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant