mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
Add option to avoid sending error metadata
This commit is contained in:
parent
4c88a4d447
commit
c43e9b21bb
@ -19,6 +19,8 @@ module.exports = async () => {
|
||||
// Parse Koa context to add error metadata
|
||||
return sentryInstance.Handlers.parseRequest(event, ctx.request);
|
||||
});
|
||||
// Manually add Strapi version
|
||||
scope.setTag('strapi_version', strapi.config.info.strapi);
|
||||
});
|
||||
}
|
||||
throw error;
|
||||
|
@ -1,6 +1,4 @@
|
||||
{
|
||||
"disabled": false,
|
||||
"config": {
|
||||
"dsn": null
|
||||
}
|
||||
"dsn": null,
|
||||
"sendMetadata": true
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "strapi-plugin-sentry",
|
||||
"version": "0.0.0",
|
||||
"description": "This is the description of the plugin.",
|
||||
"version": "3.3.4",
|
||||
"description": "Send Strapi error events to Sentry",
|
||||
"strapi": {
|
||||
"name": "sentry",
|
||||
"icon": "plug",
|
||||
|
@ -6,6 +6,7 @@ const defaultSettings = require('../config/settings.json');
|
||||
module.exports = {
|
||||
isReady: false,
|
||||
_instance: null,
|
||||
settings: {},
|
||||
|
||||
/**
|
||||
* Initialize Sentry service
|
||||
@ -18,22 +19,23 @@ module.exports = {
|
||||
}
|
||||
|
||||
// Retrieve user settings and merge them with the default ones
|
||||
const settings = {
|
||||
this.settings = {
|
||||
...defaultSettings,
|
||||
...strapi.plugins.sentry.config,
|
||||
};
|
||||
|
||||
// Try to initialize Sentry using the config's DSN
|
||||
try {
|
||||
// Don't init Sentry if the user has disabled it
|
||||
if (!settings.disabled) {
|
||||
// Don't init Sentry if no DSN was provided
|
||||
if (this.settings.dsn) {
|
||||
Sentry.init({
|
||||
dsn: settings.config.dsn,
|
||||
dsn: this.settings.dsn,
|
||||
environment: strapi.config.environment,
|
||||
});
|
||||
// Store the successfully initialized Sentry instance
|
||||
this._instance = Sentry;
|
||||
this.isReady = true;
|
||||
} else {
|
||||
strapi.log.info('strapi-plugin-sentry is disabled because no Sentry DSN was provided');
|
||||
}
|
||||
} catch (error) {
|
||||
strapi.log.warn('Could not set up Sentry, make sure you entered a valid DSN');
|
||||
@ -69,7 +71,9 @@ module.exports = {
|
||||
|
||||
this._instance.withScope(scope => {
|
||||
// Configure the Sentry scope using the provided callback
|
||||
configureScope(scope, this._instance);
|
||||
if (this.settings.sendMetadata) {
|
||||
configureScope(scope, this._instance);
|
||||
}
|
||||
// Actually send the Error to Sentry
|
||||
this._instance.captureException(error);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user