Sentry/V8/Removal Of AddGlobalEventProcessor

/icons/calendar.svg

Last update

Dec 27, 2024

This codemod facilitates the migration from Sentry v7.x to v8.x by replacing the deprecated addGlobalEventProcessor function with the new getGlobalScope().addEventProcessor method.

codemod Registry

Example

Before

Sentry.addGlobalEventProcessor((event) => {
delete event.extra;
return event;
});

After

Sentry.getGlobalScope().addEventProcessor((event) => {
delete event.extra;
return event;
});

,

Before

Sentry.addGlobalEventProcessor((event) => {
delete event.extra;
return event;
});
Sentry.addGlobalEventProcessor((event) => {
delete event.tags;
return event;
});

After

Sentry.getGlobalScope().addEventProcessor((event) => {
delete event.extra;
return event;
});
Sentry.getGlobalScope().addEventProcessor((event) => {
delete event.tags;
return event;
});

,

Before

function processEvent(event) {
delete event.extra;
return event;
}
Sentry.addGlobalEventProcessor(processEvent);

After

function processEvent(event) {
delete event.extra;
return event;
}
Sentry.getGlobalScope().addEventProcessor(processEvent);

,

Before

Sentry.addGlobalEventProcessor((event) => {
if (event.level === 'error') {
delete event.extra;
}
return event;
});

After

Sentry.getGlobalScope().addEventProcessor((event) => {
if (event.level === 'error') {
delete event.extra;
}
return event;
});

Build custom codemods

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

background illustrationGet Started Now