Sentry/V8/Remove Replay Package And Update Integration

/icons/calendar.svg

Last update

Aug 25, 2024

This codemod removes the import statement for the @sentry/replay package and replaces instances of new Replay() with Sentry.replayIntegration(), aligning with the latest Sentry SDK practices.

  • Import Removal: Eliminates the import statement for Replay from the @sentry/replay package.
  • Integration Replacement: Transforms all occurrences of new Replay() into Sentry.replayIntegration() to ensure compatibility with the latest Sentry SDK.

Example

Before

import { Replay } from '@sentry/replay';
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [new Replay()],
});

After

Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [Sentry.replayIntegration()],
});

,

Before

import { Replay } from '@sentry/replay';
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [
new Replay(),
// Other integrations
],
});

After

Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [
Sentry.replayIntegration(),
// Other integrations
],
});

,

Before

import { Replay } from '@sentry/replay';
Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [
new Replay({
maskAllText: true,
blockAllMedia: true,
}),
],
});

After

Sentry.init({
dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',
integrations: [
Sentry.replayIntegration({
maskAllText: true,
blockAllMedia: true,
}),
],
});

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now