Reputation: 6552
Before '@sentry/node' was released, I used the raven module. Including tags with all of my errors was as simple as including a tags property in the options object when configuring Raven.
Raven.config(DSN, {
tags: {...}
})
How do I include tags when using the new API? So far I've tried:
Sentry.init({
dsn: DSN,
tags: {
process_name: 'webserver',
},
})
and
Sentry.configureScope(scope => {
scope.setTag('process_name', 'webserver')
})
but neither attempt works.
Upvotes: 3
Views: 4155
Reputation: 129
According to docs
You can use Sentry.configureScope
to configure scope, which including tag, of a Sentry instance.
Sentry.configureScope((scope) => {
scope.setTag("my-tag", "my value");
scope.setUser({
id: 42,
email: "[email protected]"
});
});
Or you can use Sentry.withScope
if you only want to send data with one specific event.
Sentry.withScope(scope => {
scope.setTag("my-tag", "my value");
scope.setLevel('warning');
// will be tagged with my-tag="my value"
Sentry.captureException(new Error('my error'));
});
// will not be tagged with my-tag
Sentry.captureException(new Error('my other error'));
Upvotes: 3
Reputation: 4815
You've to use Sentry.configureScope
, but as mentioned in the sdk docs Note that these functions will not perform any action before you have called init()
.
This should work, otherwise you would have to contact sentry:
const Sentry = require('@sentry/node');
Sentry.init({
dsn: '__DSN__',
// ...
});
Sentry.configureScope(scope => {
scope.setExtra('battery', 0.7);
scope.setTag('user_mode', 'admin');
scope.setUser({ id: '4711' });
// scope.clear();
});
Upvotes: 0