Sentry/V8/Removal Sentry.ConfigureScope Method

1.0.2Last update Aug 25, 2024
by@akash-kumar-dev

This codemod facilitates the migration from Sentry version 7.x to 8.x by removing the deprecated Sentry.configureScope method. Instead, it transforms the code to utilize Sentry.getCurrentScope() for accessing and mutating the current scope. This change simplifies the API and aligns with the latest Sentry practices.

Example

Before

Sentry.configureScope((scope) => {
scope.setTag('key', 'value');
});

After

Sentry.getCurrentScope().setTag('key', 'value');

,

Before

Sentry.configureScope((scope) => {
scope.setTag('user', '123');
});

After

Sentry.getCurrentScope().setTag('user', '123');

,

Before

Sentry.configureScope((scope) => {
scope.setUser({ id: '456', email: 'user@example.com' });
});

After

Sentry.getCurrentScope().setUser({ id: '456', email: 'user@example.com' });

,

Before

Sentry.configureScope((scope) => {
scope.setExtra('key', 'value');
});

After

Sentry.getCurrentScope().setExtra('key', 'value');

,

Before

Sentry.configureScope((scope) => {
scope.setTag('level', 'info');
scope.setTag('action', 'click');
});

After

Sentry.getCurrentScope().setTag('action', 'click');
Sentry.getCurrentScope().setTag('level', 'info');

Build custom codemods

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

background illustrationGet Started Now