$npx -y skills add getsentry/sentry-for-ai --skill sentry-sdk-upgradesentry-sdk-upgrade is an agent skill published from getsentry/sentry-for-ai, installable through the skills CLI.
| 1 | > [All Skills](../../SKILL_TREE.md) > [Workflow](../sentry-workflow/SKILL.md) > SDK Upgrade |
| 2 | |
| 3 | # Sentry JavaScript SDK Upgrade |
| 4 | |
| 5 | Upgrade the Sentry JavaScript SDK across major versions with AI-guided migration. |
| 6 | |
| 7 | ## Invoke This Skill When |
| 8 | |
| 9 | - User asks to "upgrade Sentry" or "migrate Sentry SDK" |
| 10 | - User mentions deprecated Sentry APIs or breaking changes after a version bump |
| 11 | - User wants to move from v7 to v8, v8 to v9, or any major version jump |
| 12 | - User encounters errors after updating `@sentry/*` package versions |
| 13 | - User asks about Sentry migration guides or changelogs |
| 14 | |
| 15 | ## Phase 1: Detect |
| 16 | |
| 17 | Identify the current Sentry SDK version, target version, and framework. |
| 18 | |
| 19 | ### 1.1 Read package.json |
| 20 | |
| 21 | ```bash |
| 22 | cat package.json | grep -E '"@sentry/' | head -20 |
| 23 | ``` |
| 24 | |
| 25 | Extract: |
| 26 | - All `@sentry/*` packages and their current versions |
| 27 | - The current major version (e.g., `7.x`, `8.x`, `9.x`) |
| 28 | |
| 29 | ### 1.2 Detect Framework |
| 30 | |
| 31 | Check `package.json` dependencies for framework indicators: |
| 32 | |
| 33 | | Dependency | Framework | Sentry Package | |
| 34 | |---|---|---| |
| 35 | | `next` | Next.js | `@sentry/nextjs` | |
| 36 | | `nuxt` or `@nuxt/kit` | Nuxt | `@sentry/nuxt` | |
| 37 | | `@sveltejs/kit` | SvelteKit | `@sentry/sveltekit` | |
| 38 | | `@remix-run/node` | Remix | `@sentry/remix` | |
| 39 | | `react` (no Next/Remix) | React SPA | `@sentry/react` | |
| 40 | | `@angular/core` | Angular | `@sentry/angular` | |
| 41 | | `vue` (no Nuxt) | Vue | `@sentry/vue` | |
| 42 | | `express` | Express | `@sentry/node` | |
| 43 | | `@nestjs/core` | NestJS | `@sentry/nestjs` | |
| 44 | | `@solidjs/start` | SolidStart | `@sentry/solidstart` | |
| 45 | | `astro` | Astro | `@sentry/astro` | |
| 46 | | `bun` types or runtime | Bun | `@sentry/bun` | |
| 47 | | `@cloudflare/workers-types` | Cloudflare | `@sentry/cloudflare` | |
| 48 | | None of above (Node.js) | Node.js | `@sentry/node` | |
| 49 | |
| 50 | ### 1.3 Find Sentry Config Files |
| 51 | |
| 52 | ```bash |
| 53 | grep -rn "from '@sentry/\|require('@sentry/" --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" --include="*.mjs" --include="*.cjs" -l |
| 54 | ``` |
| 55 | |
| 56 | ```bash |
| 57 | find . -name "sentry.*" -o -name "*.sentry.*" -o -name "instrumentation.*" | grep -v node_modules | grep -v .next | grep -v .nuxt |
| 58 | ``` |
| 59 | |
| 60 | ### 1.4 Detect Deprecated Patterns |
| 61 | |
| 62 | Scan for patterns that indicate which migration steps are needed: |
| 63 | |
| 64 | ```bash |
| 65 | # v7 patterns (need v7→v8 migration) |
| 66 | grep -rn "from '@sentry/hub'\|from '@sentry/tracing'\|from '@sentry/integrations'\|from '@sentry/serverless'\|from '@sentry/replay'" --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" -l |
| 67 | grep -rn "new BrowserTracing\|new Replay\|startTransaction\|configureScope\|Handlers\.requestHandler\|Handlers\.errorHandler" --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" -l |
| 68 | |
| 69 | # v8 patterns (need v8→v9 migration) |
| 70 | grep -rn "from '@sentry/utils'\|from '@sentry/types'" --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" -l |
| 71 | grep -rn "getCurrentHub\|enableTracing\|captureUserFeedback\|@WithSentry\|autoSessionTracking" --include="*.ts" --include="*.js" --include="*.tsx" --include="*.jsx" -l |
| 72 | ``` |
| 73 | |
| 74 | ### 1.5 Determine Target Version |
| 75 | |
| 76 | If the user didn't specify a target version, recommend the latest major version (v9 as of this writing). If the user has already bumped package versions but has broken code, detect the target from `package.json`. |
| 77 | |
| 78 | ## Phase 2: Recommend |
| 79 | |
| 80 | Present a migration summary based on detected state. |
| 81 | |
| 82 | ### 2.1 Calculate Migration Path |
| 83 | |
| 84 | - **Single hop**: e.g., v8 to v9 |
| 85 | - **Multi-hop**: e.g., v7 to v9 (apply v7→v8 changes first, then v8→v9) |
| 86 | |
| 87 | For multi-hop migrations, apply code changes incrementally but update package versions once to the final target. |
| 88 | |
| 89 | ### 2.2 Present Breaking Changes Summary |
| 90 | |
| 91 | Load the appropriate version-specific reference: |
| 92 | - v7→v8: [references/v7-to-v8.md](references/v7-to-v8.md) |
| 93 | - v8→v9: [references/v8-to-v9.md](references/v8-to-v9.md) |
| 94 | - v9→v10: [references/v9-to-v10.md](references/v9-to-v10.md) |
| 95 | |
| 96 | Present a concrete summary of changes needed, categorized by complexity: |
| 97 | |
| 98 | **Auto-fixable** (apply directly): |
| 99 | - Package import renames (e.g., `@sentry/utils` to `@sentry/core`) |
| 100 | - Simple method renames (e.g., `@WithSentry` to `@SentryExceptionCaptured`) |
| 101 | - Config option swaps (e.g., `enableTracing` to `tracesSampleRate`) |
| 102 | |
| 103 | **AI-assisted** (explain and propose): |
| 104 | - Hub removal with variable storage patterns |
| 105 | - Performance API migration (transactions to spans) |
| 106 | - Complex config restructuring (Vue tracing options, Next.js config merging) |
| 107 | - Sampler `transactionContext` flattening |
| 108 | |
| 109 | **Manual review** (flag for user): |
| 110 | - Removed APIs with no equivalent |
| 111 | - Behavioral changes (sampling, source maps defaults) |
| 112 | - Custom transport modifications |
| 113 | |
| 114 | ### 2.3 Confirm Scope |
| 115 | |
| 116 | Ask the user: |
| 117 | - Confirm the migration path (e.g., "v8 to v9") |
| 118 | - Confirm whether to proceed with all |