@sentry/migr8

0.0.5 • Public • Published

sentry-migr8

HACKWEEK PROJECT - Migrate to the next JS SDK version

This Package is highly experimental! Use with Caution!

Usage

Run @sentry/migr8 in your application directory:

npx @sentry/migr8

By default we run all transformations on all files in the directory, ignoring any gitignored files.

If you work in a monorepo, make sure to run @sentry/migr8 in each subpackage instead of the monorepo root, as otherwise we cannot update dependencies etc. correctly.

Options

You can run npx @sentry/migr8 --help to get a list of available options.

  • --filePatterns: Glob pattern(s) which files should be transformed. Defaults to **/*.{js,jsx,ts,tsx,mjs,cjs,mts,.vue,.svele}
  • --ignoreFilePatterns: Glob pattern(s) which files should be ignored. This overwrites files matched by --filePatterns.
  • --debug: Enable verbose logging
  • --sdk: We try to detect the used Sentry SDK package, e.g. @sentry/browser. You can overwrite this and provide the SDK package you're using.
  • --cwd: You can overwrite the cwd dir to run commands in.

Transformations

Replay Config v7>v8

This migrates deprecated replay configuration from v7 to v8. This includes:

  • blockSelectorblock
  • blockClassblock
  • ignoreClassignore
  • maskTextClassmask
  • maskTextSelectormask

It also migrates old sample rate config from new Replay() to Sentry.init():

Sentry.init({
  integrations: [
    new Replay({
      sessionSampleRate: 0.1,
      errorSampleRate: 0.8
    })
  ]
});
// Becomes...
Sentry.init({
  integrations: [
    new Replay({})
  ],
  replaysSessionSampleRate: 0.1,
  replaysOnErrorSampleRate: 0.8,
});

Remove deprecated packages

Removes deprecated packages (@sentry/hub, @sentry/tracing and @sentry/replay) from your application. These are not needed anymore, and their exports can just be imported from your main SDK package instead.

Update SDK to latest version

Updates your used SDK to the latest version, and ensures all packages have the same version.

Next.js Wrapper Methods v7>v8

This migrates deprecated Next.js methods from v7 to v8. This includes:

  • withSentryAPIwrapApiHandlerWithSentry
  • withSentryServerSideGetInitialPropswrapGetInitialPropsWithSentry
  • withSentryServerSideAppGetInitialPropswrapAppGetInitialPropsWithSentry
  • withSentryServerSideDocumentGetInitialPropswrapDocumentGetInitialPropsWithSentry
  • withSentryServerSideErrorGetInitialPropswrapErrorGetInitialPropsWithSentry
  • withSentryGetServerSidePropswrapGetServerSidePropsWithSentry
  • withSentryGetStaticPropswrapGetStaticPropsWithSentry
  • withSentrywrapApiWithSentry
  • withSentryServerSideAppGetInitialPropswrapAppGetInitialPropsWithSentry

Node Handler Utils v7>v8

Rewrite moved utility functions from Sentry.Handlers.xxx. Note that this does not migrate all methods on Handlers, but only a few that have been deprecated:

  • Handlers.ExpressRequestPolymorphicRequest (Type export)
  • Handlers.extractRequestDataextractRequestData

Use getCurrentScope() instead of configureScope()

Rewrites usages of configureScope() to use getCurrentScope() instead. Note that this will rewrite this to code blocks, which may not be the preferred syntax in all cases, but it's the only way to make this work somewhat reliably with avoiding variable clashes etc.

This will rewrite:

Sentry.configureScope(scope => {
  scope.setTag('ccc', 'ccc');
  scope.setExtra('ddd', { ddd: 'ddd' });
});

to

{
  const scope = Sentry.getCurrentScope();
  scope.setTag('ccc', 'ccc');
  scope.setExtra('ddd', { ddd: 'ddd' });
}

Tracing Config v7>v8

Rewrites tracePropagationTargets and tracingOrigins from Integration-level config to root config on Sentry.init().

Util Exports v7>v8

Rewrites some old exports from @sentry/utils to their newer formats:

  • severityFromStringseverityLevelFromString
  • getGlobalObject()GLOBAL_OBJ
  • timestampWithMstimestampInSeconds

Convert Enums to String Literals

Replaces the deprecated Sentry.Severity and Sentry.SpanStatus enums with their string literal values.

Remove @sentry/hub imports

Replaces imports from the deprecated @sentry/hub package with the newer imports.

Remove @sentry/replay imports

Replaces imports from the deprecated @sentry/replay package with the newer imports.

Remove @sentry/tracing imports

Replaces imports from the deprecated @sentry/tracing package with the newer imports.

Package Sidebar

Install

npm i @sentry/migr8

Weekly Downloads

15

Version

0.0.5

License

MIT

Unpacked Size

169 kB

Total Files

53

Last publish

Collaborators

  • benvinegar
  • billyvg
  • mitsuhiko
  • haza
  • jauer
  • sentry-bot
  • evanpurkhiser
  • lynnagara
  • leedongwei
  • markstory
  • zeeg