diff --git a/packages/strapi-plugin-sentry/config/functions/bootstrap.js b/packages/strapi-plugin-sentry/config/functions/bootstrap.js index 17ff4d068f..9b2d3dde23 100644 --- a/packages/strapi-plugin-sentry/config/functions/bootstrap.js +++ b/packages/strapi-plugin-sentry/config/functions/bootstrap.js @@ -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; diff --git a/packages/strapi-plugin-sentry/config/settings.json b/packages/strapi-plugin-sentry/config/settings.json index 9661e53b57..d2e64c9018 100644 --- a/packages/strapi-plugin-sentry/config/settings.json +++ b/packages/strapi-plugin-sentry/config/settings.json @@ -1,6 +1,4 @@ { - "disabled": false, - "config": { - "dsn": null - } + "dsn": null, + "sendMetadata": true } \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index 895c04bb64..31a77bf9d5 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -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", diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index 0750cc6471..d859be73c3 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -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); });