If you want to move to the new sentry-javascript SDK we provided a short guide here of the most common patterns:
Migration
Here are some examples of how the new SDKs work. Please note that the API for all JavaScript SDKs is the same.
Installation
Old :
Raven.config('___PUBLIC_DSN___', { release: '1.3.0', }).install();
New :
Sentry.init({ dsn: '___PUBLIC_DSN___', release: '1.3.0', });
Set a global tag
Old :
Raven.setTagsContext({ key: 'value' });
New :
Sentry.configureScope(scope => scope.setTag('key', 'value'));
Capture custom exception
Old
try {
throwingFunction();
} catch (e) {
Raven.captureException(e, {
extra: {
debug: false
}
});
}
New :
try {
throwingFunction();
} catch (e) {
Sentry.withScope(scope => {
scope.setExtra('debug', false);
Sentry.captureException(e);
});
}
Capture a message
Old :
Raven.captureMessage('test', 'info', {
extra: {
debug: false
}
});
New :
Sentry.withScope(scope => {
scope.setExtra('debug', false);
Sentry.captureMessage('test', 'info');
});
Breadcrumbs
Old :
Raven.captureBreadcrumb({
message: 'Item added to shopping cart',
category: 'action',
data: {
isbn: '978-1617290541',
cartSize: '3'
}
});
New :
Sentry.addBreadcrumb({
message: 'Item added to shopping cart',
category: 'action',
data: {
isbn: '978-1617290541',
cartSize: '3'
}
});