From 4c88a4d4474cfc317897a2bbf803ead253f324af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 14 Dec 2020 00:59:12 +0100 Subject: [PATCH 01/40] Add Sentry plugin --- packages/strapi-plugin-sentry/.editorconfig | 7 ++ packages/strapi-plugin-sentry/.gitattributes | 103 ++++++++++++++++++ packages/strapi-plugin-sentry/.gitignore | 10 ++ packages/strapi-plugin-sentry/README.md | 3 + .../config/functions/bootstrap.js | 27 +++++ .../strapi-plugin-sentry/config/routes.json | 12 ++ .../strapi-plugin-sentry/config/settings.json | 6 + .../controllers/sentry.js | 24 ++++ packages/strapi-plugin-sentry/package.json | 30 +++++ .../strapi-plugin-sentry/services/sentry.js | 79 ++++++++++++++ yarn.lock | 68 ++++++++++++ 11 files changed, 369 insertions(+) create mode 100644 packages/strapi-plugin-sentry/.editorconfig create mode 100644 packages/strapi-plugin-sentry/.gitattributes create mode 100644 packages/strapi-plugin-sentry/.gitignore create mode 100644 packages/strapi-plugin-sentry/README.md create mode 100644 packages/strapi-plugin-sentry/config/functions/bootstrap.js create mode 100644 packages/strapi-plugin-sentry/config/routes.json create mode 100644 packages/strapi-plugin-sentry/config/settings.json create mode 100644 packages/strapi-plugin-sentry/controllers/sentry.js create mode 100644 packages/strapi-plugin-sentry/package.json create mode 100644 packages/strapi-plugin-sentry/services/sentry.js diff --git a/packages/strapi-plugin-sentry/.editorconfig b/packages/strapi-plugin-sentry/.editorconfig new file mode 100644 index 0000000000..d4eed8406b --- /dev/null +++ b/packages/strapi-plugin-sentry/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = false +indent_style = space +indent_size = 2 diff --git a/packages/strapi-plugin-sentry/.gitattributes b/packages/strapi-plugin-sentry/.gitattributes new file mode 100644 index 0000000000..065a11c71d --- /dev/null +++ b/packages/strapi-plugin-sentry/.gitattributes @@ -0,0 +1,103 @@ +# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes + +# Handle line endings automatically for files detected as text +# and leave all files detected as binary untouched. +* text=auto + +# +# The above will handle all files NOT found below +# + +# +## These files are text and should be normalized (Convert crlf => lf) +# + +# source code +*.php text +*.css text +*.sass text +*.scss text +*.less text +*.styl text +*.js text eol=lf +*.coffee text +*.json text +*.htm text +*.html text +*.xml text +*.svg text +*.txt text +*.ini text +*.inc text +*.pl text +*.rb text +*.py text +*.scm text +*.sql text +*.sh text +*.bat text + +# templates +*.ejs text +*.hbt text +*.jade text +*.haml text +*.hbs text +*.dot text +*.tmpl text +*.phtml text + +# git config +.gitattributes text +.gitignore text +.gitconfig text + +# code analysis config +.jshintrc text +.jscsrc text +.jshintignore text +.csslintrc text + +# misc config +*.yaml text +*.yml text +.editorconfig text + +# build config +*.npmignore text +*.bowerrc text + +# Heroku +Procfile text +.slugignore text + +# Documentation +*.md text +LICENSE text +AUTHORS text + + +# +## These files are binary and should be left untouched +# + +# (binary is a macro for -text -diff) +*.png binary +*.jpg binary +*.jpeg binary +*.gif binary +*.ico binary +*.mov binary +*.mp4 binary +*.mp3 binary +*.flv binary +*.fla binary +*.swf binary +*.gz binary +*.zip binary +*.7z binary +*.ttf binary +*.eot binary +*.woff binary +*.pyc binary +*.pdf binary diff --git a/packages/strapi-plugin-sentry/.gitignore b/packages/strapi-plugin-sentry/.gitignore new file mode 100644 index 0000000000..afe256bf30 --- /dev/null +++ b/packages/strapi-plugin-sentry/.gitignore @@ -0,0 +1,10 @@ +# Don't check auto-generated stuff into git +coverage +node_modules +stats.json +package-lock.json + +# Cruft +.DS_Store +npm-debug.log +.idea diff --git a/packages/strapi-plugin-sentry/README.md b/packages/strapi-plugin-sentry/README.md new file mode 100644 index 0000000000..14c6273075 --- /dev/null +++ b/packages/strapi-plugin-sentry/README.md @@ -0,0 +1,3 @@ +# Strapi plugin sentry + +A quick description of sentry. diff --git a/packages/strapi-plugin-sentry/config/functions/bootstrap.js b/packages/strapi-plugin-sentry/config/functions/bootstrap.js new file mode 100644 index 0000000000..17ff4d068f --- /dev/null +++ b/packages/strapi-plugin-sentry/config/functions/bootstrap.js @@ -0,0 +1,27 @@ +'use strict'; + +module.exports = async () => { + // Initialize the Sentry service exposed by this plugin + const { sentry } = strapi.plugins.sentry.services; + sentry.init(); + + // Only send errors to Sentry if a valid DSN was entered and the plugin isn't disabled + const shouldSendSentryEvents = sentry.isReady; + + // Create a middleware to intercept API errors + strapi.app.use(async (ctx, next) => { + try { + await next(); + } catch (error) { + if (shouldSendSentryEvents) { + sentry.sendError(error, (scope, sentryInstance) => { + scope.addEventProcessor(event => { + // Parse Koa context to add error metadata + return sentryInstance.Handlers.parseRequest(event, ctx.request); + }); + }); + } + throw error; + } + }); +}; diff --git a/packages/strapi-plugin-sentry/config/routes.json b/packages/strapi-plugin-sentry/config/routes.json new file mode 100644 index 0000000000..1665046d3f --- /dev/null +++ b/packages/strapi-plugin-sentry/config/routes.json @@ -0,0 +1,12 @@ +{ + "routes": [ + { + "method": "GET", + "path": "/", + "handler": "sentry.index", + "config": { + "policies": [] + } + } + ] +} diff --git a/packages/strapi-plugin-sentry/config/settings.json b/packages/strapi-plugin-sentry/config/settings.json new file mode 100644 index 0000000000..9661e53b57 --- /dev/null +++ b/packages/strapi-plugin-sentry/config/settings.json @@ -0,0 +1,6 @@ +{ + "disabled": false, + "config": { + "dsn": null + } +} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/controllers/sentry.js b/packages/strapi-plugin-sentry/controllers/sentry.js new file mode 100644 index 0000000000..9c6ab43d64 --- /dev/null +++ b/packages/strapi-plugin-sentry/controllers/sentry.js @@ -0,0 +1,24 @@ +'use strict'; + +/** + * sentry.js controller + * + * @description: A set of functions called "actions" of the `sentry` plugin. + */ + +module.exports = { + /** + * Default action. + * + * @return {Object} + */ + + index: async ctx => { + // Add your own logic here. + + // Send 200 `ok` + ctx.send({ + message: 'ok', + }); + }, +}; diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json new file mode 100644 index 0000000000..895c04bb64 --- /dev/null +++ b/packages/strapi-plugin-sentry/package.json @@ -0,0 +1,30 @@ +{ + "name": "strapi-plugin-sentry", + "version": "0.0.0", + "description": "This is the description of the plugin.", + "strapi": { + "name": "sentry", + "icon": "plug", + "description": "Description of sentry plugin." + }, + "dependencies": { + "@sentry/node": "5.29.0" + }, + "author": { + "name": "A Strapi developer", + "email": "", + "url": "" + }, + "maintainers": [ + { + "name": "A Strapi developer", + "email": "", + "url": "" + } + ], + "engines": { + "node": ">=10.16.0 <=14.x.x", + "npm": ">=6.0.0" + }, + "license": "MIT" +} diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js new file mode 100644 index 0000000000..0750cc6471 --- /dev/null +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -0,0 +1,79 @@ +'use strict'; + +const Sentry = require('@sentry/node'); +const defaultSettings = require('../config/settings.json'); + +module.exports = { + isReady: false, + _instance: null, + + /** + * Initialize Sentry service + */ + init() { + // Make sure there isn't a Sentry instance already running + if (this._instance != null) { + strapi.log.warn('Sentry has already been initialized'); + return; + } + + // Retrieve user settings and merge them with the default ones + const 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) { + Sentry.init({ + dsn: settings.config.dsn, + environment: strapi.config.environment, + }); + // Store the successfully initialized Sentry instance + this._instance = Sentry; + this.isReady = true; + } + } catch (error) { + strapi.log.warn('Could not set up Sentry, make sure you entered a valid DSN'); + } + }, + + /** + * Expose Sentry instance through a getter + * @returns {Sentry} + */ + getInstance() { + return this._instance; + }, + + /** + * Callback to [configure an instance of Sentry's scope]{@link https://docs.sentry.io/platforms/node/enriching-events/scopes/#configuring-the-scope} + * @callback configureScope + * @param {Sentry.scope} scope + * @param {Sentry=} instance An initialized Sentry instance + */ + + /** + * Higher level method to send exception events to Sentry + * @param {Error} error An error object + * @param {configureScope=} configureScope + */ + sendError(error, configureScope) { + // Make sure Sentry is ready + if (!this.isReady) { + strapi.log.warn("Sentry wasn't properly initialized, cannot send event"); + return; + } + + this._instance.withScope(scope => { + // Configure the Sentry scope using the provided callback + configureScope(scope, this._instance); + // Actually send the Error to Sentry + this._instance.captureException(error); + }); + + strapi.log.info('An error was sent to Sentry'); + }, +}; diff --git a/yarn.lock b/yarn.lock index 014508ef86..e0e0d75c3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2637,6 +2637,17 @@ "@sentry/utils" "5.27.3" tslib "^1.9.3" +"@sentry/core@5.29.0": + version "5.29.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.29.0.tgz#4410ca0dc5785abf3df02fa23c18e83ad90d7cda" + integrity sha512-a1sZBJ2u3NG0YDlGvOTwUCWiNjhfmDtAQiKK1o6RIIbcrWy9TlSps7CYDkBP239Y3A4pnvohjEEKEP3v3L3LZQ== + dependencies: + "@sentry/hub" "5.29.0" + "@sentry/minimal" "5.29.0" + "@sentry/types" "5.29.0" + "@sentry/utils" "5.29.0" + tslib "^1.9.3" + "@sentry/hub@5.27.3": version "5.27.3" resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.27.3.tgz#f509c2fd38f500afef6030504e82510dbd0649d6" @@ -2646,6 +2657,15 @@ "@sentry/utils" "5.27.3" tslib "^1.9.3" +"@sentry/hub@5.29.0": + version "5.29.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.29.0.tgz#d018b978fdffc6c8261744b0d08e8d25a3f4dc58" + integrity sha512-kcDPQsRG4cFdmqDh+TzjeO7lWYxU8s1dZYAbbl1J4uGKmhNB0J7I4ak4SGwTsXLY6fhbierxr6PRaoNojCxjPw== + dependencies: + "@sentry/types" "5.29.0" + "@sentry/utils" "5.29.0" + tslib "^1.9.3" + "@sentry/minimal@5.27.3": version "5.27.3" resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.27.3.tgz#c9263bdd6270bfeae64137177448911dff568e53" @@ -2655,6 +2675,30 @@ "@sentry/types" "5.27.3" tslib "^1.9.3" +"@sentry/minimal@5.29.0": + version "5.29.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.29.0.tgz#bd8b52f388abcec2234dbbc6d6721ff65aa30e35" + integrity sha512-nhXofdjtO41/caiF1wk1oT3p/QuhOZDYdF/b29DoD2MiAMK9IjhhOXI/gqaRpDKkXlDvd95fDTcx4t/MqqcKXA== + dependencies: + "@sentry/hub" "5.29.0" + "@sentry/types" "5.29.0" + tslib "^1.9.3" + +"@sentry/node@5.29.0": + version "5.29.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.29.0.tgz#409b5d8b8dc2be25c0c4ed20aadcf8a3bbe454bc" + integrity sha512-Jp32FsfkFSGVf81Hr26rGlgIwTg7Nx07mQ7rrnNuVasu6vD2aWBzUnohkkZDJ4gZRGjmk0MthukjX0RivDKcVQ== + dependencies: + "@sentry/core" "5.29.0" + "@sentry/hub" "5.29.0" + "@sentry/tracing" "5.29.0" + "@sentry/types" "5.29.0" + "@sentry/utils" "5.29.0" + cookie "^0.4.1" + https-proxy-agent "^5.0.0" + lru_map "^0.3.3" + tslib "^1.9.3" + "@sentry/node@^5.27.3": version "5.27.3" resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.27.3.tgz#174b81fbca8cadac12afe49910cbe9cc25b23f87" @@ -2681,11 +2725,27 @@ "@sentry/utils" "5.27.3" tslib "^1.9.3" +"@sentry/tracing@5.29.0": + version "5.29.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.29.0.tgz#8ed515b3f9d409137357c38c8622858f9e684e4a" + integrity sha512-2ZITUH7Eur7IkmRAd5gw8Xt2Sfc28btCnT7o2P2J8ZPD65e99ATqjxXPokx0+6zEkTsstIDD3mbyuwkpbuvuTA== + dependencies: + "@sentry/hub" "5.29.0" + "@sentry/minimal" "5.29.0" + "@sentry/types" "5.29.0" + "@sentry/utils" "5.29.0" + tslib "^1.9.3" + "@sentry/types@5.27.3": version "5.27.3" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.27.3.tgz#d377508769bc658d672c287166c7f6c5db45660c" integrity sha512-PkWhMArFMxBb1g3HtMEL8Ea9PYae2MU0z9CMIWiqzerFy2ZpKG98IU3pt8ic4JkmKQdwB8hDiZpRPMHhW0WYwQ== +"@sentry/types@5.29.0": + version "5.29.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.29.0.tgz#af5cec98cde54316c14df3121f0e8106e56b578e" + integrity sha512-iDkxT/9sT3UF+Xb+JyLjZ5caMXsgLfRyV9VXQEiR2J6mgpMielj184d9jeF3bm/VMuAf/VFFqrHlcVsVgmrrMw== + "@sentry/utils@5.27.3": version "5.27.3" resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.27.3.tgz#1fc45dfad1f1e4398bee58684d8947666d8d3003" @@ -2694,6 +2754,14 @@ "@sentry/types" "5.27.3" tslib "^1.9.3" +"@sentry/utils@5.29.0": + version "5.29.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.29.0.tgz#b4c1223ba362a94cf4850e9ca2cb24655b006b53" + integrity sha512-b2B1gshw2u3EHlAi84PuI5sfmLKXW1z9enMMhNuuNT/CoRp+g5kMAcUv/qYTws7UNnYSvTuVGuZG30v1e0hP9A== + dependencies: + "@sentry/types" "5.29.0" + tslib "^1.9.3" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" From c43e9b21bb05cbffbb2ed0c86db00e196a1f8c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 14 Dec 2020 16:15:35 +0100 Subject: [PATCH 02/40] Add option to avoid sending error metadata --- .../config/functions/bootstrap.js | 2 ++ .../strapi-plugin-sentry/config/settings.json | 6 ++---- packages/strapi-plugin-sentry/package.json | 4 ++-- packages/strapi-plugin-sentry/services/sentry.js | 16 ++++++++++------ 4 files changed, 16 insertions(+), 12 deletions(-) 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); }); From 5484afe8176bc29f6c0f95fcf5005b4a11a44691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 14 Dec 2020 17:50:19 +0100 Subject: [PATCH 03/40] Add readme and apply feedback --- packages/strapi-plugin-sentry/README.md | 71 ++++++++- .../config/functions/bootstrap.js | 19 +-- .../strapi-plugin-sentry/config/routes.json | 11 +- .../controllers/sentry.js | 17 +- .../strapi-plugin-sentry/services/sentry.js | 146 +++++++++--------- 5 files changed, 153 insertions(+), 111 deletions(-) diff --git a/packages/strapi-plugin-sentry/README.md b/packages/strapi-plugin-sentry/README.md index 14c6273075..a7439a3f7a 100644 --- a/packages/strapi-plugin-sentry/README.md +++ b/packages/strapi-plugin-sentry/README.md @@ -1,3 +1,70 @@ -# Strapi plugin sentry +# Strapi plugin Sentry -A quick description of sentry. +The official plugin to track Strapi errors with Sentry. + +## Features + +- Initialize a Sentry instance when your Strapi app starts +- Send errors encountered in your application's end API to Sentry +- Attach useful metadata to Sentry events, to help you with debugging +- Expose a global Sentry service + +## Configuration + +| property | type (default) | description | +| -------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | +| `dsn` | string (null) | Your Sentry data source name ([see Sentry docs](https://docs.sentry.io/product/sentry-basics/dsn-explainer/)). Omitting it will disable the plugin. | +| `sendMetadata` | boolean (true) | Whether the plugin should attach additional information (like OS, browser, etc.) to the events sent to Sentry. | + +**Example** + +`./config/plugins.js` + +```js +module.exports = ({ env }) => ({ + // ... + sentry: { + dsn: env('SENTRY_DSN'), + sendMetadata: true, + }, + // ... +}); +``` + +## Global Sentry service + +You can access a Sentry service throughout your app. + +```js +const sentryService = strapi.plugins.sentry.services.sentry; +``` + +This service exposes the following methods: + +### `sendError(error, configureScope)` + +Use it to manually send errors to Sentry. The `configureScope` is optional, it allows you to customize the error event. Read more about Sentry's scope system [on their docs](https://docs.sentry.io/platforms/node/enriching-events/scopes/#configuring-the-scope). + +**Example** + +```js +try { + // Your code here +} catch (error) { + strapi.plugins.sentry.services.sentry.sendError(error, (scope, sentryInstance) => { + // Customize the scope here + scope.setTag('my_custom_tag', 'Tag value'); + }); + throw error; +} +``` + +### `sendError(error, configureScope)` + +Use it if you need direct access to the Sentry instance, which should already already be initialized. It's useful if `sendError` doesn't suit your needs. + +**Example** + +```js +const sentryInstance = strapi.plugins.sentry.services.sentry.getInstance(); +``` diff --git a/packages/strapi-plugin-sentry/config/functions/bootstrap.js b/packages/strapi-plugin-sentry/config/functions/bootstrap.js index 9b2d3dde23..3253620f6d 100644 --- a/packages/strapi-plugin-sentry/config/functions/bootstrap.js +++ b/packages/strapi-plugin-sentry/config/functions/bootstrap.js @@ -5,24 +5,19 @@ module.exports = async () => { const { sentry } = strapi.plugins.sentry.services; sentry.init(); - // Only send errors to Sentry if a valid DSN was entered and the plugin isn't disabled - const shouldSendSentryEvents = sentry.isReady; - // Create a middleware to intercept API errors strapi.app.use(async (ctx, next) => { try { await next(); } catch (error) { - if (shouldSendSentryEvents) { - sentry.sendError(error, (scope, sentryInstance) => { - scope.addEventProcessor(event => { - // 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); + sentry.sendError(error, (scope, sentryInstance) => { + scope.addEventProcessor(event => { + // 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/routes.json b/packages/strapi-plugin-sentry/config/routes.json index 1665046d3f..9ade02d5d3 100644 --- a/packages/strapi-plugin-sentry/config/routes.json +++ b/packages/strapi-plugin-sentry/config/routes.json @@ -1,12 +1,3 @@ { - "routes": [ - { - "method": "GET", - "path": "/", - "handler": "sentry.index", - "config": { - "policies": [] - } - } - ] + "routes": [] } diff --git a/packages/strapi-plugin-sentry/controllers/sentry.js b/packages/strapi-plugin-sentry/controllers/sentry.js index 9c6ab43d64..3a6a590586 100644 --- a/packages/strapi-plugin-sentry/controllers/sentry.js +++ b/packages/strapi-plugin-sentry/controllers/sentry.js @@ -6,19 +6,4 @@ * @description: A set of functions called "actions" of the `sentry` plugin. */ -module.exports = { - /** - * Default action. - * - * @return {Object} - */ - - index: async ctx => { - // Add your own logic here. - - // Send 200 `ok` - ctx.send({ - message: 'ok', - }); - }, -}; +module.exports = {}; diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index d859be73c3..f926e31cc4 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -3,81 +3,85 @@ const Sentry = require('@sentry/node'); const defaultSettings = require('../config/settings.json'); -module.exports = { - isReady: false, - _instance: null, - settings: {}, +const createSentryService = () => { + let isReady = false; + let instance = null; + let settings = {}; - /** - * Initialize Sentry service - */ - init() { - // Make sure there isn't a Sentry instance already running - if (this._instance != null) { - strapi.log.warn('Sentry has already been initialized'); - return; - } - - // Retrieve user settings and merge them with the default ones - this.settings = { - ...defaultSettings, - ...strapi.plugins.sentry.config, - }; - - try { - // Don't init Sentry if no DSN was provided - if (this.settings.dsn) { - Sentry.init({ - 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'); + return { + /** + * Initialize Sentry service + */ + init() { + // Make sure there isn't a Sentry instance already running + if (instance != null) { + strapi.log.warn('Sentry has already been initialized'); + return; } - } catch (error) { - strapi.log.warn('Could not set up Sentry, make sure you entered a valid DSN'); - } - }, - /** - * Expose Sentry instance through a getter - * @returns {Sentry} - */ - getInstance() { - return this._instance; - }, + // Retrieve user settings and merge them with the default ones + settings = { + ...defaultSettings, + ...strapi.plugins.sentry.config, + }; - /** - * Callback to [configure an instance of Sentry's scope]{@link https://docs.sentry.io/platforms/node/enriching-events/scopes/#configuring-the-scope} - * @callback configureScope - * @param {Sentry.scope} scope - * @param {Sentry=} instance An initialized Sentry instance - */ - - /** - * Higher level method to send exception events to Sentry - * @param {Error} error An error object - * @param {configureScope=} configureScope - */ - sendError(error, configureScope) { - // Make sure Sentry is ready - if (!this.isReady) { - strapi.log.warn("Sentry wasn't properly initialized, cannot send event"); - return; - } - - this._instance.withScope(scope => { - // Configure the Sentry scope using the provided callback - if (this.settings.sendMetadata) { - configureScope(scope, this._instance); + try { + // Don't init Sentry if no DSN was provided + if (settings.dsn) { + Sentry.init({ + dsn: settings.dsn, + environment: strapi.config.environment, + }); + // Store the successfully initialized Sentry instance + instance = Sentry; + 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'); } - // Actually send the Error to Sentry - this._instance.captureException(error); - }); + }, - strapi.log.info('An error was sent to Sentry'); - }, + /** + * Expose Sentry instance through a getter + * @returns {Sentry} + */ + getInstance() { + return instance; + }, + + /** + * Callback to [configure an instance of Sentry's scope]{@link https://docs.sentry.io/platforms/node/enriching-events/scopes/#configuring-the-scope} + * @callback configureScope + * @param {Sentry.scope} scope + * @param {Sentry=} instance An initialized Sentry instance + */ + + /** + * Higher level method to send exception events to Sentry + * @param {Error} error An error object + * @param {configureScope=} configureScope + */ + sendError(error, configureScope) { + // Make sure Sentry is ready + if (!isReady) { + strapi.log.warn("Sentry wasn't properly initialized, cannot send event"); + return; + } + + instance.withScope(scope => { + // Configure the Sentry scope using the provided callback + if (settings.sendMetadata) { + configureScope(scope, instance); + } + // Actually send the Error to Sentry + instance.captureException(error); + }); + + strapi.log.info('An error was sent to Sentry'); + }, + }; }; + +module.exports = createSentryService(); From a0a70a39e2ae116ef95ee92330ace34602576478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 14 Dec 2020 17:54:42 +0100 Subject: [PATCH 04/40] Fix readme typo --- packages/strapi-plugin-sentry/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/strapi-plugin-sentry/README.md b/packages/strapi-plugin-sentry/README.md index a7439a3f7a..ef89952f05 100644 --- a/packages/strapi-plugin-sentry/README.md +++ b/packages/strapi-plugin-sentry/README.md @@ -59,7 +59,7 @@ try { } ``` -### `sendError(error, configureScope)` +### `getInstance()` Use it if you need direct access to the Sentry instance, which should already already be initialized. It's useful if `sendError` doesn't suit your needs. From c72349638ad952c310b9c17162f652ed7e0243c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Wed, 16 Dec 2020 12:35:36 +0100 Subject: [PATCH 05/40] Fix sendError() without configureScope param --- packages/strapi-plugin-sentry/README.md | 4 ++++ packages/strapi-plugin-sentry/services/sentry.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/strapi-plugin-sentry/README.md b/packages/strapi-plugin-sentry/README.md index ef89952f05..9118d2160c 100644 --- a/packages/strapi-plugin-sentry/README.md +++ b/packages/strapi-plugin-sentry/README.md @@ -51,6 +51,10 @@ Use it to manually send errors to Sentry. The `configureScope` is optional, it a try { // Your code here } catch (error) { + // Either send a simple error + strapi.plugins.sentry.services.sentry.sendError(error); + + // Or send an error with a customized Sentry scope strapi.plugins.sentry.services.sentry.sendError(error, (scope, sentryInstance) => { // Customize the scope here scope.setTag('my_custom_tag', 'Tag value'); diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index f926e31cc4..52fb2a5d70 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -72,7 +72,7 @@ const createSentryService = () => { instance.withScope(scope => { // Configure the Sentry scope using the provided callback - if (settings.sendMetadata) { + if (configureScope && settings.sendMetadata) { configureScope(scope, instance); } // Actually send the Error to Sentry From 6ee250a49ee22aadbf4920ff005d343a612e2cde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Wed, 16 Dec 2020 14:10:13 +0100 Subject: [PATCH 06/40] Add license and Sentry logo --- packages/strapi-plugin-sentry/LICENSE | 22 ++++++++++++ .../admin/src/assets/images/logo.svg | 1 + .../strapi-plugin-sentry/admin/src/index.js | 35 +++++++++++++++++++ .../admin/src/pluginId.js | 5 +++ packages/strapi-plugin-sentry/package.json | 2 +- 5 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 packages/strapi-plugin-sentry/LICENSE create mode 100644 packages/strapi-plugin-sentry/admin/src/assets/images/logo.svg create mode 100644 packages/strapi-plugin-sentry/admin/src/index.js create mode 100644 packages/strapi-plugin-sentry/admin/src/pluginId.js diff --git a/packages/strapi-plugin-sentry/LICENSE b/packages/strapi-plugin-sentry/LICENSE new file mode 100644 index 0000000000..db018546b5 --- /dev/null +++ b/packages/strapi-plugin-sentry/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2015-present Strapi Solutions SAS + +Portions of the Strapi software are licensed as follows: + +* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE". + +* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below. + +MIT Expat License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/strapi-plugin-sentry/admin/src/assets/images/logo.svg b/packages/strapi-plugin-sentry/admin/src/assets/images/logo.svg new file mode 100644 index 0000000000..9d9d1c787f --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/assets/images/logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/index.js b/packages/strapi-plugin-sentry/admin/src/index.js new file mode 100644 index 0000000000..5da039d64a --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/index.js @@ -0,0 +1,35 @@ +// NOTE TO PLUGINS DEVELOPERS: +// If you modify this file by adding new options to the plugin entry point +// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md +// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md +// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated +// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED + +import pluginPkg from '../../package.json'; +import pluginId from './pluginId'; +import pluginLogo from './assets/images/logo.svg'; + +export default strapi => { + const pluginDescription = pluginPkg.strapi.description || pluginPkg.description; + + const plugin = { + blockerComponent: null, + blockerComponentProps: {}, + description: pluginDescription, + icon: pluginPkg.strapi.icon, + id: pluginId, + isReady: true, + initializer: () => null, + injectedComponents: [], + isRequired: pluginPkg.strapi.required || false, + layout: null, + lifecycles: () => {}, + mainComponent: null, + name: pluginPkg.strapi.name, + pluginLogo, + preventComponentRendering: false, + trads: {}, + }; + + return strapi.registerPlugin(plugin); +}; diff --git a/packages/strapi-plugin-sentry/admin/src/pluginId.js b/packages/strapi-plugin-sentry/admin/src/pluginId.js new file mode 100644 index 0000000000..f5ad7de626 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/pluginId.js @@ -0,0 +1,5 @@ +import pluginPkg from '../../package.json'; + +const pluginId = pluginPkg.name.replace(/^strapi-plugin-/i, ''); + +export default pluginId; diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index 31a77bf9d5..c36177f46a 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -5,7 +5,7 @@ "strapi": { "name": "sentry", "icon": "plug", - "description": "Description of sentry plugin." + "description": "Send API errors to Sentry" }, "dependencies": { "@sentry/node": "5.29.0" From 4ab6d66364ea3571dc46db648235ab3ec881581c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Thu, 17 Dec 2020 11:43:39 +0100 Subject: [PATCH 07/40] WIP - add tests --- packages/strapi-plugin-sentry/package.json | 2 +- .../services/__tests__/sentry.test.js | 69 +++++++++++++++++++ .../strapi-plugin-sentry/services/sentry.js | 2 - 3 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 packages/strapi-plugin-sentry/services/__tests__/sentry.test.js diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index c36177f46a..93959ef864 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -26,5 +26,5 @@ "node": ">=10.16.0 <=14.x.x", "npm": ">=6.0.0" }, - "license": "MIT" + "license": "SEE LICENSE IN LICENSE" } diff --git a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js new file mode 100644 index 0000000000..172a01a1b9 --- /dev/null +++ b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js @@ -0,0 +1,69 @@ +const Sentry = require('@sentry/node'); +const sentryService = require('../sentry'); +const defaultConfig = require('../../config/settings.json'); + +describe('Check if runs', () => { + beforeEach(() => { + global.strapi = { + plugins: { + sentry: { + config: defaultConfig, + }, + }, + log: { + warn: jest.fn(), + info: jest.fn(), + }, + }; + }); + + it('disables Sentry when no DSN is provided', () => { + sentryService.init(); + expect(strapi.log.info).toHaveBeenCalledWith(expect.stringMatching(/disabled/i)); + + const instance = sentryService.getInstance(); + expect(instance).toBeNull(); + }); + + it('disables Sentry when an invalid DSN is provided', () => { + global.strapi.plugins.sentry.config = { + dsn: 'an_invalid_dsn', + }; + sentryService.init(); + expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/could not set up sentry/i)); + + const instance = sentryService.getInstance(); + expect(instance).toBeNull(); + }); + + it("doesn't send events before init", () => { + sentryService.sendError(Error()); + expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/cannot send event/i)); + }); + + it('initializes and sends errors', () => { + global.strapi.plugins.sentry.config = { + dsn: 'a_valid_dsn', + }; + + // Mock Sentry.init only for this test + Sentry.init = jest.fn(); + sentryService.init(); + expect(Sentry.init).toHaveBeenCalled(); + + // Saves the instance correctly + const instance = sentryService.getInstance(); + expect(instance).not.toBeNull(); + + // Doesn't allow re-init + sentryService.init(); + expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/already/i)); + + const error = Error('an error'); + const configureScope = jest.fn(); + sentryService.sendError(error, configureScope); + expect(configureScope).toHaveBeenCalled(); + }); + + it(''); +}); diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index 52fb2a5d70..3a5b72cbca 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -78,8 +78,6 @@ const createSentryService = () => { // Actually send the Error to Sentry instance.captureException(error); }); - - strapi.log.info('An error was sent to Sentry'); }, }; }; From db849d99baf14ac4cac15ba5aeebf00859ceca22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Fri, 22 Jan 2021 16:11:51 +0100 Subject: [PATCH 08/40] WIP- debug sentry mock --- packages/strapi-plugin-sentry/package.json | 3 +- .../services/__tests__/sentry.test.js | 138 +++++++++++------- .../strapi-plugin-sentry/services/sentry.js | 2 + yarn.lock | 19 +++ 4 files changed, 110 insertions(+), 52 deletions(-) diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index 93959ef864..8b1b057431 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -8,7 +8,8 @@ "description": "Send API errors to Sentry" }, "dependencies": { - "@sentry/node": "5.29.0" + "@sentry/node": "5.29.0", + "polygala": "4.0.0" }, "author": { "name": "A Strapi developer", diff --git a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js index 172a01a1b9..acd61f8685 100644 --- a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js +++ b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js @@ -1,13 +1,27 @@ -const Sentry = require('@sentry/node'); +'use strict'; + +jest.resetModules(); + +jest.mock('@sentry/node', () => { + return { + init() { + console.log('MOCKING SENTRY INIT'); + }, + }; +}); + const sentryService = require('../sentry'); const defaultConfig = require('../../config/settings.json'); -describe('Check if runs', () => { +describe('test', () => { beforeEach(() => { global.strapi = { plugins: { sentry: { - config: defaultConfig, + config: { + ...defaultConfig, + dsn: 'fakedsn', + }, }, }, log: { @@ -16,54 +30,76 @@ describe('Check if runs', () => { }, }; }); - - it('disables Sentry when no DSN is provided', () => { + it('init', async () => { sentryService.init(); - expect(strapi.log.info).toHaveBeenCalledWith(expect.stringMatching(/disabled/i)); - - const instance = sentryService.getInstance(); - expect(instance).toBeNull(); }); - - it('disables Sentry when an invalid DSN is provided', () => { - global.strapi.plugins.sentry.config = { - dsn: 'an_invalid_dsn', - }; - sentryService.init(); - expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/could not set up sentry/i)); - - const instance = sentryService.getInstance(); - expect(instance).toBeNull(); - }); - - it("doesn't send events before init", () => { - sentryService.sendError(Error()); - expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/cannot send event/i)); - }); - - it('initializes and sends errors', () => { - global.strapi.plugins.sentry.config = { - dsn: 'a_valid_dsn', - }; - - // Mock Sentry.init only for this test - Sentry.init = jest.fn(); - sentryService.init(); - expect(Sentry.init).toHaveBeenCalled(); - - // Saves the instance correctly - const instance = sentryService.getInstance(); - expect(instance).not.toBeNull(); - - // Doesn't allow re-init - sentryService.init(); - expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/already/i)); - - const error = Error('an error'); - const configureScope = jest.fn(); - sentryService.sendError(error, configureScope); - expect(configureScope).toHaveBeenCalled(); - }); - - it(''); }); + +// const Sentry = require('@sentry/node'); +// const sentryService = require('../sentry'); +// const defaultConfig = require('../../config/settings.json'); + +// const INVALID_DSN = 'an_invalid_dsn'; +// const VALID_DSN = 'a_valid_dsn'; + +// describe('strapi-plugin-sentry service', () => { +// beforeEach(() => { +// global.strapi = { +// plugins: { +// sentry: { +// config: defaultConfig, +// }, +// }, +// log: { +// warn: jest.fn(), +// info: jest.fn(), +// }, +// }; +// }); + +// it('disables Sentry when no DSN is provided', () => { +// // Sentry.init(); +// sentryService.init(); +// expect(strapi.log.info).toHaveBeenCalledWith(expect.stringMatching(/disabled/i)); + +// const instance = sentryService.getInstance(); +// expect(instance).toBeNull(); +// }); + +// it('disables Sentry when an invalid DSN is provided', () => { +// global.strapi.plugins.sentry.config = { +// dsn: INVALID_DSN, +// }; +// sentryService.init(); +// expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/could not set up sentry/i)); + +// const instance = sentryService.getInstance(); +// expect(instance).toBeNull(); +// }); + +// it("doesn't send events before init", () => { +// sentryService.sendError(Error()); +// expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/cannot send event/i)); +// }); + +// it('initializes and sends errors', () => { +// global.strapi.plugins.sentry.config = { +// dsn: VALID_DSN, +// }; + +// sentryService.init(); + +// // Saves the instance correctly +// const instance = sentryService.getInstance(); +// expect(instance).not.toBeNull(); + +// // Doesn't allow re-init +// sentryService.init(); +// expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/already/i)); + +// const error = Error('an error'); +// const configureScope = jest.fn(); +// sentryService.sendError(error, configureScope); +// expect(configureScope).toHaveBeenCalled(); +// }); +// }); diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index 3a5b72cbca..5b0b881f76 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -28,6 +28,7 @@ const createSentryService = () => { try { // Don't init Sentry if no DSN was provided if (settings.dsn) { + console.log('should call mock now'); Sentry.init({ dsn: settings.dsn, environment: strapi.config.environment, @@ -36,6 +37,7 @@ const createSentryService = () => { instance = Sentry; isReady = true; } else { + console.log('no dsn'); strapi.log.info('strapi-plugin-sentry is disabled because no Sentry DSN was provided'); } } catch (error) { diff --git a/yarn.lock b/yarn.lock index 6d5458562d..0e4ce371aa 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3230,6 +3230,11 @@ resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-1.8.0.tgz#682477dbbbd07cd032731cb3b0e7eaee3d026b69" integrity sha512-2aoSC4UUbHDj2uCsCxcG/vRMXey/m17bC7UwitVm5hn22nI8O8Y9iDpA76Orc+DWkQ4zZrOKEshCqR/jSuXAHA== +"@types/immediate@^3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@types/immediate/-/immediate-3.2.0.tgz#497e830a92aa4990aeba93c66a0f90ee790cb3f6" + integrity sha512-CojBxLEgxjdIXgoxSYrxvaydin6MmA94rCHg2AKmC+7FePBXNfFxhZ/1RRkUwyBnCi3YoVyg8PiM5iUQFku5pw== + "@types/invariant@^2.2.31": version "2.2.34" resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.34.tgz#05e4f79f465c2007884374d4795452f995720bbe" @@ -9743,6 +9748,11 @@ ignore@^5.0.6, ignore@^5.1.1: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== +immediate@^3.2.3: + version "3.3.0" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.3.0.tgz#1aef225517836bcdf7f2a2de2600c79ff0269266" + integrity sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q== + immediate@~3.0.5: version "3.0.6" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" @@ -14443,6 +14453,15 @@ pluralize@^8.0.0: resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1" integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA== +polygala@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/polygala/-/polygala-4.0.0.tgz#b408d4031c47d2b55b8c9dd0231c4b37ba24a775" + integrity sha512-NFCEozpfmK0wAymxrpdje2PP5laLfWJZsOHMwETbdooXc59LhfANZEqFtH5cokiMjd6sCpU0Vt0fnmHaF/Kn9A== + dependencies: + "@types/immediate" "^3.2.0" + immediate "^3.2.3" + tslib "^1.9.3" + popper.js@^1.14.4: version "1.16.1" resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b" From 7e070b0f655759f99b930f42e8cf7f5092393f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Fri, 22 Jan 2021 18:26:25 +0100 Subject: [PATCH 09/40] Fixed tests --- .../services/__tests__/sentry.test.js | 157 +++++++++--------- .../strapi-plugin-sentry/services/sentry.js | 2 - 2 files changed, 78 insertions(+), 81 deletions(-) diff --git a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js index acd61f8685..752152f511 100644 --- a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js +++ b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js @@ -1,27 +1,34 @@ 'use strict'; -jest.resetModules(); +const INVALID_DSN = 'an_invalid_dsn'; +const VALID_DSN = 'a_valid_dsn'; +const captureException = jest.fn(); jest.mock('@sentry/node', () => { return { - init() { - console.log('MOCKING SENTRY INIT'); + init(options = {}) { + if (options.dsn !== VALID_DSN) { + throw Error(); + } + }, + captureException, + withScope(configureScope) { + configureScope(); }, }; }); -const sentryService = require('../sentry'); +let sentryService = require('../sentry'); const defaultConfig = require('../../config/settings.json'); -describe('test', () => { +describe('strapi-plugin-sentry service', () => { beforeEach(() => { + // Reset Strapi state global.strapi = { + config: {}, plugins: { sentry: { - config: { - ...defaultConfig, - dsn: 'fakedsn', - }, + config: defaultConfig, }, }, log: { @@ -29,77 +36,69 @@ describe('test', () => { info: jest.fn(), }, }; + // Reset the plugin resource state + jest.resetModules(); + sentryService = require('../sentry'); }); - it('init', async () => { + + it('disables Sentry when no DSN is provided', () => { sentryService.init(); + expect(strapi.log.info).toHaveBeenCalledWith(expect.stringMatching(/disabled/i)); + + const instance = sentryService.getInstance(); + expect(instance).toBeNull(); + }); + + it('disables Sentry when an invalid DSN is provided', () => { + global.strapi.plugins.sentry.config = { + dsn: INVALID_DSN, + }; + sentryService.init(); + expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/could not set up sentry/i)); + + const instance = sentryService.getInstance(); + expect(instance).toBeNull(); + }); + + it("doesn't send events before init", () => { + sentryService.sendError(Error()); + expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/cannot send event/i)); + }); + + it('initializes and sends errors', () => { + global.strapi.plugins.sentry.config = { + dsn: VALID_DSN, + }; + sentryService.init(); + + // Saves the instance correctly + const instance = sentryService.getInstance(); + expect(instance).not.toBeNull(); + + // Doesn't allow re-init + sentryService.init(); + expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/already/i)); + + // Send error + const error = Error('an error'); + const configureScope = jest.fn(); + sentryService.sendError(error, configureScope); + expect(configureScope).toHaveBeenCalled(); + expect(captureException).toHaveBeenCalled(); + }); + + it('does not not send metadata when the option is disabled', () => { + // Init with metadata option disabled + global.strapi.plugins.sentry.config = { + dsn: VALID_DSN, + sendMetadata: false, + }; + sentryService.init(); + + // Send error + const error = Error('an error'); + const configureScope = jest.fn(); + sentryService.sendError(error, configureScope); + expect(configureScope).not.toHaveBeenCalled(); }); }); - -// const Sentry = require('@sentry/node'); -// const sentryService = require('../sentry'); -// const defaultConfig = require('../../config/settings.json'); - -// const INVALID_DSN = 'an_invalid_dsn'; -// const VALID_DSN = 'a_valid_dsn'; - -// describe('strapi-plugin-sentry service', () => { -// beforeEach(() => { -// global.strapi = { -// plugins: { -// sentry: { -// config: defaultConfig, -// }, -// }, -// log: { -// warn: jest.fn(), -// info: jest.fn(), -// }, -// }; -// }); - -// it('disables Sentry when no DSN is provided', () => { -// // Sentry.init(); -// sentryService.init(); -// expect(strapi.log.info).toHaveBeenCalledWith(expect.stringMatching(/disabled/i)); - -// const instance = sentryService.getInstance(); -// expect(instance).toBeNull(); -// }); - -// it('disables Sentry when an invalid DSN is provided', () => { -// global.strapi.plugins.sentry.config = { -// dsn: INVALID_DSN, -// }; -// sentryService.init(); -// expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/could not set up sentry/i)); - -// const instance = sentryService.getInstance(); -// expect(instance).toBeNull(); -// }); - -// it("doesn't send events before init", () => { -// sentryService.sendError(Error()); -// expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/cannot send event/i)); -// }); - -// it('initializes and sends errors', () => { -// global.strapi.plugins.sentry.config = { -// dsn: VALID_DSN, -// }; - -// sentryService.init(); - -// // Saves the instance correctly -// const instance = sentryService.getInstance(); -// expect(instance).not.toBeNull(); - -// // Doesn't allow re-init -// sentryService.init(); -// expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/already/i)); - -// const error = Error('an error'); -// const configureScope = jest.fn(); -// sentryService.sendError(error, configureScope); -// expect(configureScope).toHaveBeenCalled(); -// }); -// }); diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index 5b0b881f76..3a5b72cbca 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -28,7 +28,6 @@ const createSentryService = () => { try { // Don't init Sentry if no DSN was provided if (settings.dsn) { - console.log('should call mock now'); Sentry.init({ dsn: settings.dsn, environment: strapi.config.environment, @@ -37,7 +36,6 @@ const createSentryService = () => { instance = Sentry; isReady = true; } else { - console.log('no dsn'); strapi.log.info('strapi-plugin-sentry is disabled because no Sentry DSN was provided'); } } catch (error) { From ec769f39d9838a5f646ab9192a89ec826ae80a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Fri, 22 Jan 2021 18:47:12 +0100 Subject: [PATCH 10/40] Add npm ignore --- packages/strapi-plugin-sentry/.npmignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 packages/strapi-plugin-sentry/.npmignore diff --git a/packages/strapi-plugin-sentry/.npmignore b/packages/strapi-plugin-sentry/.npmignore new file mode 100644 index 0000000000..afe256bf30 --- /dev/null +++ b/packages/strapi-plugin-sentry/.npmignore @@ -0,0 +1,10 @@ +# Don't check auto-generated stuff into git +coverage +node_modules +stats.json +package-lock.json + +# Cruft +.DS_Store +npm-debug.log +.idea From 7b247791c0463e03b0d68d650227aa68504e324d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 25 Jan 2021 19:10:52 +0100 Subject: [PATCH 11/40] Finishing touches --- .../strapi-plugin-sentry/admin/src/index.js | 7 --- .../admin/src/translations/ar.json | 1 + .../admin/src/translations/cs.json | 1 + .../admin/src/translations/de.json | 1 + .../admin/src/translations/en.json | 5 ++ .../admin/src/translations/es.json | 1 + .../admin/src/translations/fr.json | 1 + .../admin/src/translations/id.json | 1 + .../admin/src/translations/index.js | 49 +++++++++++++++++++ .../admin/src/translations/it.json | 1 + .../admin/src/translations/ko.json | 1 + .../admin/src/translations/ms.json | 1 + .../admin/src/translations/nl.json | 1 + .../admin/src/translations/pl.json | 1 + .../admin/src/translations/pt-BR.json | 1 + .../admin/src/translations/pt.json | 1 + .../admin/src/translations/ru.json | 1 + .../admin/src/translations/sk.json | 1 + .../admin/src/translations/th.json | 1 + .../admin/src/translations/tr.json | 1 + .../admin/src/translations/uk.json | 1 + .../admin/src/translations/vi.json | 1 + .../admin/src/translations/zh-Hans.json | 1 + .../admin/src/translations/zh.json | 1 + packages/strapi-plugin-sentry/package.json | 7 ++- yarn.lock | 19 ------- 26 files changed, 78 insertions(+), 30 deletions(-) create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/ar.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/cs.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/de.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/en.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/es.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/fr.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/id.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/index.js create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/it.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/ko.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/ms.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/nl.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/pl.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/pt-BR.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/pt.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/ru.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/sk.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/th.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/tr.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/uk.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/vi.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/zh-Hans.json create mode 100644 packages/strapi-plugin-sentry/admin/src/translations/zh.json diff --git a/packages/strapi-plugin-sentry/admin/src/index.js b/packages/strapi-plugin-sentry/admin/src/index.js index 5da039d64a..683c3415f3 100644 --- a/packages/strapi-plugin-sentry/admin/src/index.js +++ b/packages/strapi-plugin-sentry/admin/src/index.js @@ -1,10 +1,3 @@ -// NOTE TO PLUGINS DEVELOPERS: -// If you modify this file by adding new options to the plugin entry point -// Here's the file: strapi/docs/3.0.0-beta.x/plugin-development/frontend-field-api.md -// Here's the file: strapi/docs/3.0.0-beta.x/guides/registering-a-field-in-admin.md -// Also the strapi-generate-plugins/files/admin/src/index.js needs to be updated -// IF THE DOC IS NOT UPDATED THE PULL REQUEST WILL NOT BE MERGED - import pluginPkg from '../../package.json'; import pluginId from './pluginId'; import pluginLogo from './assets/images/logo.svg'; diff --git a/packages/strapi-plugin-sentry/admin/src/translations/ar.json b/packages/strapi-plugin-sentry/admin/src/translations/ar.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/ar.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/cs.json b/packages/strapi-plugin-sentry/admin/src/translations/cs.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/cs.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/de.json b/packages/strapi-plugin-sentry/admin/src/translations/de.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/de.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-plugin-sentry/admin/src/translations/en.json b/packages/strapi-plugin-sentry/admin/src/translations/en.json new file mode 100644 index 0000000000..e79fc9d610 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/en.json @@ -0,0 +1,5 @@ +{ + "plugin.description.short": "Send Strapi error events to Sentry.", + "plugin.description.long": "Send Strapi error events to Sentry.", + "plugin.description": "Send Strapi error events to Sentry." +} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/es.json b/packages/strapi-plugin-sentry/admin/src/translations/es.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/es.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/fr.json b/packages/strapi-plugin-sentry/admin/src/translations/fr.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/fr.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/id.json b/packages/strapi-plugin-sentry/admin/src/translations/id.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/id.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/index.js b/packages/strapi-plugin-sentry/admin/src/translations/index.js new file mode 100644 index 0000000000..d990d5ae93 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/index.js @@ -0,0 +1,49 @@ +import ar from './ar.json'; +import cs from './cs.json'; +import de from './de.json'; +import en from './en.json'; +import es from './es.json'; +import fr from './fr.json'; +import id from './id.json'; +import it from './it.json'; +import ko from './ko.json'; +import ms from './ms.json'; +import nl from './nl.json'; +import pl from './pl.json'; +import ptBR from './pt-BR.json'; +import pt from './pt.json'; +import ru from './ru.json'; +import th from './th.json'; +import tr from './tr.json'; +import uk from './uk.json'; +import vi from './vi.json'; +import zhHans from './zh-Hans.json'; +import zh from './zh.json'; +import sk from './sk.json'; + +const trads = { + ar, + cs, + de, + en, + es, + fr, + id, + it, + ko, + ms, + nl, + pl, + 'pt-BR': ptBR, + pt, + ru, + th, + tr, + uk, + vi, + 'zh-Hans': zhHans, + zh, + sk, +}; + +export default trads; diff --git a/packages/strapi-plugin-sentry/admin/src/translations/it.json b/packages/strapi-plugin-sentry/admin/src/translations/it.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/it.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/ko.json b/packages/strapi-plugin-sentry/admin/src/translations/ko.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/ko.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/ms.json b/packages/strapi-plugin-sentry/admin/src/translations/ms.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/ms.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/nl.json b/packages/strapi-plugin-sentry/admin/src/translations/nl.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/nl.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/pl.json b/packages/strapi-plugin-sentry/admin/src/translations/pl.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/pl.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-plugin-sentry/admin/src/translations/pt-BR.json b/packages/strapi-plugin-sentry/admin/src/translations/pt-BR.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/pt-BR.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/pt.json b/packages/strapi-plugin-sentry/admin/src/translations/pt.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/pt.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/ru.json b/packages/strapi-plugin-sentry/admin/src/translations/ru.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/ru.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-plugin-sentry/admin/src/translations/sk.json b/packages/strapi-plugin-sentry/admin/src/translations/sk.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/sk.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/th.json b/packages/strapi-plugin-sentry/admin/src/translations/th.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/th.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/tr.json b/packages/strapi-plugin-sentry/admin/src/translations/tr.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/tr.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-plugin-sentry/admin/src/translations/uk.json b/packages/strapi-plugin-sentry/admin/src/translations/uk.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/uk.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-plugin-sentry/admin/src/translations/vi.json b/packages/strapi-plugin-sentry/admin/src/translations/vi.json new file mode 100644 index 0000000000..9e26dfeeb6 --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/vi.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/zh-Hans.json b/packages/strapi-plugin-sentry/admin/src/translations/zh-Hans.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/zh-Hans.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-plugin-sentry/admin/src/translations/zh.json b/packages/strapi-plugin-sentry/admin/src/translations/zh.json new file mode 100644 index 0000000000..0967ef424b --- /dev/null +++ b/packages/strapi-plugin-sentry/admin/src/translations/zh.json @@ -0,0 +1 @@ +{} diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index 8b1b057431..9690227085 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -3,13 +3,12 @@ "version": "3.3.4", "description": "Send Strapi error events to Sentry", "strapi": { - "name": "sentry", + "name": "Sentry", "icon": "plug", - "description": "Send API errors to Sentry" + "description": "sentry.plugin.description" }, "dependencies": { - "@sentry/node": "5.29.0", - "polygala": "4.0.0" + "@sentry/node": "5.29.0" }, "author": { "name": "A Strapi developer", diff --git a/yarn.lock b/yarn.lock index 0e4ce371aa..6d5458562d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3230,11 +3230,6 @@ resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-1.8.0.tgz#682477dbbbd07cd032731cb3b0e7eaee3d026b69" integrity sha512-2aoSC4UUbHDj2uCsCxcG/vRMXey/m17bC7UwitVm5hn22nI8O8Y9iDpA76Orc+DWkQ4zZrOKEshCqR/jSuXAHA== -"@types/immediate@^3.2.0": - version "3.2.0" - resolved "https://registry.yarnpkg.com/@types/immediate/-/immediate-3.2.0.tgz#497e830a92aa4990aeba93c66a0f90ee790cb3f6" - integrity sha512-CojBxLEgxjdIXgoxSYrxvaydin6MmA94rCHg2AKmC+7FePBXNfFxhZ/1RRkUwyBnCi3YoVyg8PiM5iUQFku5pw== - "@types/invariant@^2.2.31": version "2.2.34" resolved "https://registry.yarnpkg.com/@types/invariant/-/invariant-2.2.34.tgz#05e4f79f465c2007884374d4795452f995720bbe" @@ -9748,11 +9743,6 @@ ignore@^5.0.6, ignore@^5.1.1: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== -immediate@^3.2.3: - version "3.3.0" - resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.3.0.tgz#1aef225517836bcdf7f2a2de2600c79ff0269266" - integrity sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q== - immediate@~3.0.5: version "3.0.6" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" @@ -14453,15 +14443,6 @@ pluralize@^8.0.0: resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1" integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA== -polygala@4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/polygala/-/polygala-4.0.0.tgz#b408d4031c47d2b55b8c9dd0231c4b37ba24a775" - integrity sha512-NFCEozpfmK0wAymxrpdje2PP5laLfWJZsOHMwETbdooXc59LhfANZEqFtH5cokiMjd6sCpU0Vt0fnmHaF/Kn9A== - dependencies: - "@types/immediate" "^3.2.0" - immediate "^3.2.3" - tslib "^1.9.3" - popper.js@^1.14.4: version "1.16.1" resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b" From f3b362df1629a6f7a3e9c7cf96a9a7e3a3501dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 25 Jan 2021 19:35:21 +0100 Subject: [PATCH 12/40] Fixed description translations --- packages/strapi-plugin-sentry/admin/src/index.js | 3 ++- packages/strapi-plugin-sentry/admin/src/translations/en.json | 3 +-- packages/strapi-plugin-sentry/admin/src/translations/fr.json | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/strapi-plugin-sentry/admin/src/index.js b/packages/strapi-plugin-sentry/admin/src/index.js index 683c3415f3..a22453af33 100644 --- a/packages/strapi-plugin-sentry/admin/src/index.js +++ b/packages/strapi-plugin-sentry/admin/src/index.js @@ -1,6 +1,7 @@ import pluginPkg from '../../package.json'; import pluginId from './pluginId'; import pluginLogo from './assets/images/logo.svg'; +import trads from './translations'; export default strapi => { const pluginDescription = pluginPkg.strapi.description || pluginPkg.description; @@ -21,7 +22,7 @@ export default strapi => { name: pluginPkg.strapi.name, pluginLogo, preventComponentRendering: false, - trads: {}, + trads, }; return strapi.registerPlugin(plugin); diff --git a/packages/strapi-plugin-sentry/admin/src/translations/en.json b/packages/strapi-plugin-sentry/admin/src/translations/en.json index e79fc9d610..1fc4b05602 100644 --- a/packages/strapi-plugin-sentry/admin/src/translations/en.json +++ b/packages/strapi-plugin-sentry/admin/src/translations/en.json @@ -1,5 +1,4 @@ { "plugin.description.short": "Send Strapi error events to Sentry.", - "plugin.description.long": "Send Strapi error events to Sentry.", - "plugin.description": "Send Strapi error events to Sentry." + "plugin.description.long": "Send Strapi error events to Sentry." } \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/admin/src/translations/fr.json b/packages/strapi-plugin-sentry/admin/src/translations/fr.json index 9e26dfeeb6..ea4cc69ee2 100644 --- a/packages/strapi-plugin-sentry/admin/src/translations/fr.json +++ b/packages/strapi-plugin-sentry/admin/src/translations/fr.json @@ -1 +1,4 @@ -{} \ No newline at end of file +{ + "plugin.description.short": "Envoie vos erreurs Strapi à Sentry.", + "plugin.description.long": "Envoie vos erreurs Strapi à Sentry." +} \ No newline at end of file From 8fcc848f941baaea9c05c1f85733f56cfd8ad49d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Tue, 26 Jan 2021 10:58:28 +0100 Subject: [PATCH 13/40] Move jest reset modules --- .../strapi-plugin-sentry/services/__tests__/sentry.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js index 752152f511..99ecb4a797 100644 --- a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js +++ b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js @@ -36,6 +36,9 @@ describe('strapi-plugin-sentry service', () => { info: jest.fn(), }, }; + }); + + afterEach(() => { // Reset the plugin resource state jest.resetModules(); sentryService = require('../sentry'); From a82bc5f8649f3eea9817e0c8caec58d968192609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Tue, 26 Jan 2021 11:06:33 +0100 Subject: [PATCH 14/40] Move service require --- packages/strapi-plugin-sentry/services/__tests__/sentry.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js index 99ecb4a797..0375d17175 100644 --- a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js +++ b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js @@ -36,12 +36,12 @@ describe('strapi-plugin-sentry service', () => { info: jest.fn(), }, }; + sentryService = require('../sentry'); }); afterEach(() => { // Reset the plugin resource state jest.resetModules(); - sentryService = require('../sentry'); }); it('disables Sentry when no DSN is provided', () => { From e09f310639cd6a01fb3eeff7e66bc2fa6958b595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Thu, 28 Jan 2021 10:12:35 +0100 Subject: [PATCH 15/40] Fix undefined transaction tag --- packages/strapi-plugin-sentry/config/functions/bootstrap.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/strapi-plugin-sentry/config/functions/bootstrap.js b/packages/strapi-plugin-sentry/config/functions/bootstrap.js index 3253620f6d..31ecdb9581 100644 --- a/packages/strapi-plugin-sentry/config/functions/bootstrap.js +++ b/packages/strapi-plugin-sentry/config/functions/bootstrap.js @@ -13,10 +13,13 @@ module.exports = async () => { sentry.sendError(error, (scope, sentryInstance) => { scope.addEventProcessor(event => { // Parse Koa context to add error metadata - return sentryInstance.Handlers.parseRequest(event, ctx.request); + return sentryInstance.Handlers.parseRequest(event, ctx.request, { + transaction: false, + }); }); // Manually add Strapi version scope.setTag('strapi_version', strapi.config.info.strapi); + scope.setTag('method', ctx.method); }); throw error; } From 4fe9117229b7066c9e4dd34c4e8c1bab6fcc532d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Thu, 28 Jan 2021 16:47:35 +0100 Subject: [PATCH 16/40] Restore transaction name --- packages/strapi-plugin-sentry/config/functions/bootstrap.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/strapi-plugin-sentry/config/functions/bootstrap.js b/packages/strapi-plugin-sentry/config/functions/bootstrap.js index 31ecdb9581..90f915150c 100644 --- a/packages/strapi-plugin-sentry/config/functions/bootstrap.js +++ b/packages/strapi-plugin-sentry/config/functions/bootstrap.js @@ -14,9 +14,12 @@ module.exports = async () => { scope.addEventProcessor(event => { // Parse Koa context to add error metadata return sentryInstance.Handlers.parseRequest(event, ctx.request, { + // Don't parse the transaction name, we'll do it manually transaction: false, }); }); + // Manually add transaction name + scope.setTag('transaction', `${ctx.method} ${ctx.request.url}`); // Manually add Strapi version scope.setTag('strapi_version', strapi.config.info.strapi); scope.setTag('method', ctx.method); From 28f872a146d4ed44408323f8a5058935587c79ea Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Mon, 1 Feb 2021 18:29:49 +0100 Subject: [PATCH 17/40] Update sentry dep --- packages/strapi-plugin-sentry/package.json | 2 +- yarn.lock | 92 +++++++++++----------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index 9690227085..f68024ea3a 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -8,7 +8,7 @@ "description": "sentry.plugin.description" }, "dependencies": { - "@sentry/node": "5.29.0" + "@sentry/node": "6.0.3" }, "author": { "name": "A Strapi developer", diff --git a/yarn.lock b/yarn.lock index 6d5458562d..9b85d14861 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2637,15 +2637,15 @@ "@sentry/utils" "5.27.3" tslib "^1.9.3" -"@sentry/core@5.29.0": - version "5.29.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-5.29.0.tgz#4410ca0dc5785abf3df02fa23c18e83ad90d7cda" - integrity sha512-a1sZBJ2u3NG0YDlGvOTwUCWiNjhfmDtAQiKK1o6RIIbcrWy9TlSps7CYDkBP239Y3A4pnvohjEEKEP3v3L3LZQ== +"@sentry/core@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.0.3.tgz#620cb32365a11eac75497bed281bd52b9f0bb359" + integrity sha512-UykB/4/98y2DkNvwTiL2ofFPuK3KDHc7rIRNsdj6dg6D+Cf7FRexgmWUUkZrpC/y+QBj0TPqkcFDcZAuQDa3Ag== dependencies: - "@sentry/hub" "5.29.0" - "@sentry/minimal" "5.29.0" - "@sentry/types" "5.29.0" - "@sentry/utils" "5.29.0" + "@sentry/hub" "6.0.3" + "@sentry/minimal" "6.0.3" + "@sentry/types" "6.0.3" + "@sentry/utils" "6.0.3" tslib "^1.9.3" "@sentry/hub@5.27.3": @@ -2657,13 +2657,13 @@ "@sentry/utils" "5.27.3" tslib "^1.9.3" -"@sentry/hub@5.29.0": - version "5.29.0" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-5.29.0.tgz#d018b978fdffc6c8261744b0d08e8d25a3f4dc58" - integrity sha512-kcDPQsRG4cFdmqDh+TzjeO7lWYxU8s1dZYAbbl1J4uGKmhNB0J7I4ak4SGwTsXLY6fhbierxr6PRaoNojCxjPw== +"@sentry/hub@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.0.3.tgz#097f7b1e775a4c6c20c9bec60d7507d5ad2e8db0" + integrity sha512-BfV32tE09rjTWM9W0kk8gzxUC2k1h57Z5dNWJ35na79+LguNNtCcI6fHlFQ3PkJca6ITYof9FI8iQHUfsHFZnw== dependencies: - "@sentry/types" "5.29.0" - "@sentry/utils" "5.29.0" + "@sentry/types" "6.0.3" + "@sentry/utils" "6.0.3" tslib "^1.9.3" "@sentry/minimal@5.27.3": @@ -2675,25 +2675,25 @@ "@sentry/types" "5.27.3" tslib "^1.9.3" -"@sentry/minimal@5.29.0": - version "5.29.0" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-5.29.0.tgz#bd8b52f388abcec2234dbbc6d6721ff65aa30e35" - integrity sha512-nhXofdjtO41/caiF1wk1oT3p/QuhOZDYdF/b29DoD2MiAMK9IjhhOXI/gqaRpDKkXlDvd95fDTcx4t/MqqcKXA== +"@sentry/minimal@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.0.3.tgz#6eaaf78c479c49720df3e712d41518e7f4f0ffdf" + integrity sha512-YsW+nw0SMyyb7UQdjZeKlZjxbGsJFpXNLh9iIp6fHKnoLTTv17YPm2ej9sOikDsQuVotaPg/xn/Qt5wySGHIxw== dependencies: - "@sentry/hub" "5.29.0" - "@sentry/types" "5.29.0" + "@sentry/hub" "6.0.3" + "@sentry/types" "6.0.3" tslib "^1.9.3" -"@sentry/node@5.29.0": - version "5.29.0" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-5.29.0.tgz#409b5d8b8dc2be25c0c4ed20aadcf8a3bbe454bc" - integrity sha512-Jp32FsfkFSGVf81Hr26rGlgIwTg7Nx07mQ7rrnNuVasu6vD2aWBzUnohkkZDJ4gZRGjmk0MthukjX0RivDKcVQ== +"@sentry/node@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.0.3.tgz#f41e707db710fd7c48e3bffdf05c8edeec95cbe9" + integrity sha512-yvj/e91NPiTtkjUvQSdTqAlRkEw0f/jIC70abobtWH0ExUJOuLHOPWMCpAYST8Adv2QV7eGEhywseRrY1dxSsw== dependencies: - "@sentry/core" "5.29.0" - "@sentry/hub" "5.29.0" - "@sentry/tracing" "5.29.0" - "@sentry/types" "5.29.0" - "@sentry/utils" "5.29.0" + "@sentry/core" "6.0.3" + "@sentry/hub" "6.0.3" + "@sentry/tracing" "6.0.3" + "@sentry/types" "6.0.3" + "@sentry/utils" "6.0.3" cookie "^0.4.1" https-proxy-agent "^5.0.0" lru_map "^0.3.3" @@ -2725,15 +2725,15 @@ "@sentry/utils" "5.27.3" tslib "^1.9.3" -"@sentry/tracing@5.29.0": - version "5.29.0" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-5.29.0.tgz#8ed515b3f9d409137357c38c8622858f9e684e4a" - integrity sha512-2ZITUH7Eur7IkmRAd5gw8Xt2Sfc28btCnT7o2P2J8ZPD65e99ATqjxXPokx0+6zEkTsstIDD3mbyuwkpbuvuTA== +"@sentry/tracing@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.0.3.tgz#103f4942ddd546321e22ba20c011adf52b25b3f2" + integrity sha512-H7dnsvPz9cD1nuCNQM4MxcHxt2JdT9F8dQ/4+gp+eB9iBLy6staMrmKRLYuAcMU/M3MCDG4ISIip7KbTt74OLg== dependencies: - "@sentry/hub" "5.29.0" - "@sentry/minimal" "5.29.0" - "@sentry/types" "5.29.0" - "@sentry/utils" "5.29.0" + "@sentry/hub" "6.0.3" + "@sentry/minimal" "6.0.3" + "@sentry/types" "6.0.3" + "@sentry/utils" "6.0.3" tslib "^1.9.3" "@sentry/types@5.27.3": @@ -2741,10 +2741,10 @@ resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.27.3.tgz#d377508769bc658d672c287166c7f6c5db45660c" integrity sha512-PkWhMArFMxBb1g3HtMEL8Ea9PYae2MU0z9CMIWiqzerFy2ZpKG98IU3pt8ic4JkmKQdwB8hDiZpRPMHhW0WYwQ== -"@sentry/types@5.29.0": - version "5.29.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.29.0.tgz#af5cec98cde54316c14df3121f0e8106e56b578e" - integrity sha512-iDkxT/9sT3UF+Xb+JyLjZ5caMXsgLfRyV9VXQEiR2J6mgpMielj184d9jeF3bm/VMuAf/VFFqrHlcVsVgmrrMw== +"@sentry/types@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.0.3.tgz#a1ef6d6b2ac2a9201e3e4a894db6ecf7ceb5b27c" + integrity sha512-266aBQbk9AGedhG2dzXshWbn23LYLElXqlI74DLku48UrU2v7TGKdyik/8/nfOfquCoRSp0GFGYHbItwU124XQ== "@sentry/utils@5.27.3": version "5.27.3" @@ -2754,12 +2754,12 @@ "@sentry/types" "5.27.3" tslib "^1.9.3" -"@sentry/utils@5.29.0": - version "5.29.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.29.0.tgz#b4c1223ba362a94cf4850e9ca2cb24655b006b53" - integrity sha512-b2B1gshw2u3EHlAi84PuI5sfmLKXW1z9enMMhNuuNT/CoRp+g5kMAcUv/qYTws7UNnYSvTuVGuZG30v1e0hP9A== +"@sentry/utils@6.0.3": + version "6.0.3" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.0.3.tgz#114d9faa47f76416c3e140711465e76d2129dba8" + integrity sha512-lvuBFvZHYs1zYwI8dkC8Z8ryb0aYnwPFUl1rbZiMwJpYI2Dgl1jpqqZWv9luux2rSRYOMid74uGedV708rvEgA== dependencies: - "@sentry/types" "5.29.0" + "@sentry/types" "6.0.3" tslib "^1.9.3" "@sindresorhus/is@^0.14.0": From f0ebed1dc26fa2de8aee866b38b741a99df3865b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 8 Feb 2021 17:25:21 +0100 Subject: [PATCH 18/40] Update @sentry/node to 6.1.0 --- packages/strapi-plugin-sentry/package.json | 2 +- yarn.lock | 68 ++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index f68024ea3a..2c2ebdc46a 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -8,7 +8,7 @@ "description": "sentry.plugin.description" }, "dependencies": { - "@sentry/node": "6.0.3" + "@sentry/node": "6.1.0" }, "author": { "name": "A Strapi developer", diff --git a/yarn.lock b/yarn.lock index cef5f77230..e21e9746ff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2705,6 +2705,17 @@ "@sentry/utils" "6.0.3" tslib "^1.9.3" +"@sentry/core@6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.1.0.tgz#7dd4584dcaf2188a78b94b766068342e6ee65229" + integrity sha512-57mXkp3NoyxRycXrL+Ec6bYS6UYJZp9tYX0lUp5Ry2M0FxDZ3Q4drkjr8MIQOhBaQXP2ukSX4QTVLGMPm60zMw== + dependencies: + "@sentry/hub" "6.1.0" + "@sentry/minimal" "6.1.0" + "@sentry/types" "6.1.0" + "@sentry/utils" "6.1.0" + tslib "^1.9.3" + "@sentry/hub@6.0.3": version "6.0.3" resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.0.3.tgz#097f7b1e775a4c6c20c9bec60d7507d5ad2e8db0" @@ -2714,6 +2725,15 @@ "@sentry/utils" "6.0.3" tslib "^1.9.3" +"@sentry/hub@6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.1.0.tgz#fb22734c91c9d68564737996bf28b7e032e3d8ee" + integrity sha512-JnBSCgNg3VHiMojUl5tCHU8iWPVuE+qqENIzG9A722oJms1kKWBvWl+yQzhWBNdgk5qeAY3F5UzKWJZkbJ6xow== + dependencies: + "@sentry/types" "6.1.0" + "@sentry/utils" "6.1.0" + tslib "^1.9.3" + "@sentry/minimal@6.0.3": version "6.0.3" resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.0.3.tgz#6eaaf78c479c49720df3e712d41518e7f4f0ffdf" @@ -2723,6 +2743,15 @@ "@sentry/types" "6.0.3" tslib "^1.9.3" +"@sentry/minimal@6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.1.0.tgz#b3abf76d93b95477a3c1029db810818bdc56845f" + integrity sha512-g6sfNKenL7wnsr/tibp8nFiMv/XRH0s0Pt4p151npmNI+SmjuUz3GGYEXk8ChCyaKldYKilkNOFdVXJxUf5gZw== + dependencies: + "@sentry/hub" "6.1.0" + "@sentry/types" "6.1.0" + tslib "^1.9.3" + "@sentry/node@6.0.3": version "6.0.3" resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.0.3.tgz#f41e707db710fd7c48e3bffdf05c8edeec95cbe9" @@ -2738,6 +2767,21 @@ lru_map "^0.3.3" tslib "^1.9.3" +"@sentry/node@6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.1.0.tgz#9e20443fdfd15e508da5c0b674ef32960e8a6380" + integrity sha512-yOxYHoPxg8Br19QOsJbonP2uYirv1FFxdNkdeykfO2QBorRUkcirjET5qjRfz73jF1YYtUZBuxwR+f9ZOPqGTg== + dependencies: + "@sentry/core" "6.1.0" + "@sentry/hub" "6.1.0" + "@sentry/tracing" "6.1.0" + "@sentry/types" "6.1.0" + "@sentry/utils" "6.1.0" + cookie "^0.4.1" + https-proxy-agent "^5.0.0" + lru_map "^0.3.3" + tslib "^1.9.3" + "@sentry/tracing@6.0.3": version "6.0.3" resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.0.3.tgz#103f4942ddd546321e22ba20c011adf52b25b3f2" @@ -2749,11 +2793,27 @@ "@sentry/utils" "6.0.3" tslib "^1.9.3" +"@sentry/tracing@6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.1.0.tgz#cefabd0e4794fefb6a0a17478a8f09b2f1f3d889" + integrity sha512-s6a4Ra3hHn4awiNz4fOEK6TCV2w2iLcxdppijcYEB7S/1rJpmqZgHWDicqufbOmVMOLmyKLEQ7w+pZq3TR3WgQ== + dependencies: + "@sentry/hub" "6.1.0" + "@sentry/minimal" "6.1.0" + "@sentry/types" "6.1.0" + "@sentry/utils" "6.1.0" + tslib "^1.9.3" + "@sentry/types@6.0.3": version "6.0.3" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.0.3.tgz#a1ef6d6b2ac2a9201e3e4a894db6ecf7ceb5b27c" integrity sha512-266aBQbk9AGedhG2dzXshWbn23LYLElXqlI74DLku48UrU2v7TGKdyik/8/nfOfquCoRSp0GFGYHbItwU124XQ== +"@sentry/types@6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.1.0.tgz#5f9379229423ca1325acf6709e95687180f67132" + integrity sha512-kIaN52Fw5K+2mKRaHE2YluJ+F/qMGSUzZXIFDNdC6OUMXQ4TM8gZTrITXs8CLDm7cK8iCqFCtzKOjKK6KyOKAg== + "@sentry/utils@6.0.3": version "6.0.3" resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.0.3.tgz#114d9faa47f76416c3e140711465e76d2129dba8" @@ -2762,6 +2822,14 @@ "@sentry/types" "6.0.3" tslib "^1.9.3" +"@sentry/utils@6.1.0": + version "6.1.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.1.0.tgz#52e3d7050983e685d3a48f9d2efa1e6eb4ae3e6d" + integrity sha512-6JAplzUOS6bEwfX0PDRZBbYRvn9EN22kZfcL0qGHtM9L0QQ5ybjbbVwOpbXgRkiZx++dQbzLFtelxnDhsbFG+Q== + dependencies: + "@sentry/types" "6.1.0" + tslib "^1.9.3" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" From bd221816f36bce78b639e1e99fe422c6d9b1f7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Tue, 9 Feb 2021 10:48:06 +0100 Subject: [PATCH 19/40] Update strapi-generate-new's Sentry version --- packages/strapi-generate-new/package.json | 2 +- yarn.lock | 68 ----------------------- 2 files changed, 1 insertion(+), 69 deletions(-) diff --git a/packages/strapi-generate-new/package.json b/packages/strapi-generate-new/package.json index be8df579ef..ee85433cfd 100644 --- a/packages/strapi-generate-new/package.json +++ b/packages/strapi-generate-new/package.json @@ -13,7 +13,7 @@ "lib": "./lib" }, "dependencies": { - "@sentry/node": "6.0.3", + "@sentry/node": "6.1.0", "chalk": "^2.4.2", "execa": "^1.0.0", "fs-extra": "^9.0.1", diff --git a/yarn.lock b/yarn.lock index e21e9746ff..167ebb8eab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2694,17 +2694,6 @@ "@sendgrid/client" "^6.4.0" "@sendgrid/helpers" "^6.4.0" -"@sentry/core@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.0.3.tgz#620cb32365a11eac75497bed281bd52b9f0bb359" - integrity sha512-UykB/4/98y2DkNvwTiL2ofFPuK3KDHc7rIRNsdj6dg6D+Cf7FRexgmWUUkZrpC/y+QBj0TPqkcFDcZAuQDa3Ag== - dependencies: - "@sentry/hub" "6.0.3" - "@sentry/minimal" "6.0.3" - "@sentry/types" "6.0.3" - "@sentry/utils" "6.0.3" - tslib "^1.9.3" - "@sentry/core@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.1.0.tgz#7dd4584dcaf2188a78b94b766068342e6ee65229" @@ -2716,15 +2705,6 @@ "@sentry/utils" "6.1.0" tslib "^1.9.3" -"@sentry/hub@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.0.3.tgz#097f7b1e775a4c6c20c9bec60d7507d5ad2e8db0" - integrity sha512-BfV32tE09rjTWM9W0kk8gzxUC2k1h57Z5dNWJ35na79+LguNNtCcI6fHlFQ3PkJca6ITYof9FI8iQHUfsHFZnw== - dependencies: - "@sentry/types" "6.0.3" - "@sentry/utils" "6.0.3" - tslib "^1.9.3" - "@sentry/hub@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.1.0.tgz#fb22734c91c9d68564737996bf28b7e032e3d8ee" @@ -2734,15 +2714,6 @@ "@sentry/utils" "6.1.0" tslib "^1.9.3" -"@sentry/minimal@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.0.3.tgz#6eaaf78c479c49720df3e712d41518e7f4f0ffdf" - integrity sha512-YsW+nw0SMyyb7UQdjZeKlZjxbGsJFpXNLh9iIp6fHKnoLTTv17YPm2ej9sOikDsQuVotaPg/xn/Qt5wySGHIxw== - dependencies: - "@sentry/hub" "6.0.3" - "@sentry/types" "6.0.3" - tslib "^1.9.3" - "@sentry/minimal@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.1.0.tgz#b3abf76d93b95477a3c1029db810818bdc56845f" @@ -2752,21 +2723,6 @@ "@sentry/types" "6.1.0" tslib "^1.9.3" -"@sentry/node@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.0.3.tgz#f41e707db710fd7c48e3bffdf05c8edeec95cbe9" - integrity sha512-yvj/e91NPiTtkjUvQSdTqAlRkEw0f/jIC70abobtWH0ExUJOuLHOPWMCpAYST8Adv2QV7eGEhywseRrY1dxSsw== - dependencies: - "@sentry/core" "6.0.3" - "@sentry/hub" "6.0.3" - "@sentry/tracing" "6.0.3" - "@sentry/types" "6.0.3" - "@sentry/utils" "6.0.3" - cookie "^0.4.1" - https-proxy-agent "^5.0.0" - lru_map "^0.3.3" - tslib "^1.9.3" - "@sentry/node@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.1.0.tgz#9e20443fdfd15e508da5c0b674ef32960e8a6380" @@ -2782,17 +2738,6 @@ lru_map "^0.3.3" tslib "^1.9.3" -"@sentry/tracing@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.0.3.tgz#103f4942ddd546321e22ba20c011adf52b25b3f2" - integrity sha512-H7dnsvPz9cD1nuCNQM4MxcHxt2JdT9F8dQ/4+gp+eB9iBLy6staMrmKRLYuAcMU/M3MCDG4ISIip7KbTt74OLg== - dependencies: - "@sentry/hub" "6.0.3" - "@sentry/minimal" "6.0.3" - "@sentry/types" "6.0.3" - "@sentry/utils" "6.0.3" - tslib "^1.9.3" - "@sentry/tracing@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.1.0.tgz#cefabd0e4794fefb6a0a17478a8f09b2f1f3d889" @@ -2804,24 +2749,11 @@ "@sentry/utils" "6.1.0" tslib "^1.9.3" -"@sentry/types@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.0.3.tgz#a1ef6d6b2ac2a9201e3e4a894db6ecf7ceb5b27c" - integrity sha512-266aBQbk9AGedhG2dzXshWbn23LYLElXqlI74DLku48UrU2v7TGKdyik/8/nfOfquCoRSp0GFGYHbItwU124XQ== - "@sentry/types@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.1.0.tgz#5f9379229423ca1325acf6709e95687180f67132" integrity sha512-kIaN52Fw5K+2mKRaHE2YluJ+F/qMGSUzZXIFDNdC6OUMXQ4TM8gZTrITXs8CLDm7cK8iCqFCtzKOjKK6KyOKAg== -"@sentry/utils@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.0.3.tgz#114d9faa47f76416c3e140711465e76d2129dba8" - integrity sha512-lvuBFvZHYs1zYwI8dkC8Z8ryb0aYnwPFUl1rbZiMwJpYI2Dgl1jpqqZWv9luux2rSRYOMid74uGedV708rvEgA== - dependencies: - "@sentry/types" "6.0.3" - tslib "^1.9.3" - "@sentry/utils@6.1.0": version "6.1.0" resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.1.0.tgz#52e3d7050983e685d3a48f9d2efa1e6eb4ae3e6d" From a53d2dbacafee48d1ccd4c6817c404b6ee4a3459 Mon Sep 17 00:00:00 2001 From: Alexandre BODIN Date: Thu, 11 Feb 2021 15:52:59 +0100 Subject: [PATCH 20/40] Fix mongoose autopopulate recursively looping to infinity when cycles appear (#9367) --- .../strapi-connector-mongoose/lib/mount-models.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/strapi-connector-mongoose/lib/mount-models.js b/packages/strapi-connector-mongoose/lib/mount-models.js index 0fd55a6ef6..0b7aa7dae5 100644 --- a/packages/strapi-connector-mongoose/lib/mount-models.js +++ b/packages/strapi-connector-mongoose/lib/mount-models.js @@ -311,7 +311,9 @@ module.exports = async ({ models, target }, ctx) => { const createOnFetchPopulateFn = ({ morphAssociations, componentAttributes, definition }) => { return function() { const populatedPaths = this.getPopulatedPaths(); - const { publicationState } = this.getOptions(); + const { publicationState, _depth = 0 } = this.getOptions(); + + if (_depth > 2) return; const getMatchQuery = assoc => { const assocModel = strapi.db.getModelByAssoc(assoc); @@ -334,7 +336,10 @@ const createOnFetchPopulateFn = ({ morphAssociations, componentAttributes, defin this.populate({ path: alias, match: matchQuery, options: { publicationState } }); } else if (populatedPaths.includes(alias)) { _.set(this._mongooseOptions.populate, [alias, 'path'], `${alias}.ref`); - _.set(this._mongooseOptions.populate, [alias, 'options'], { publicationState }); + _.set(this._mongooseOptions.populate, [alias, 'options'], { + publicationState, + _depth: _depth + 1, + }); if (matchQuery !== undefined) { _.set(this._mongooseOptions.populate, [alias, 'match'], matchQuery); @@ -350,13 +355,13 @@ const createOnFetchPopulateFn = ({ morphAssociations, componentAttributes, defin this.populate({ path: ast.alias, match: getMatchQuery(ast), - options: { publicationState }, + options: { publicationState, _depth: _depth + 1 }, }); }); } componentAttributes.forEach(key => { - this.populate({ path: `${key}.ref`, options: { publicationState } }); + this.populate({ path: `${key}.ref`, options: { publicationState, _depth: _depth + 1 } }); }); }; }; From b42470e593c5be2987d886250e4af16aed3f032d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Feb 2021 09:20:09 +0100 Subject: [PATCH 21/40] Bump nodemailer from 6.4.17 to 6.4.18 (#9390) Bumps [nodemailer](https://github.com/nodemailer/nodemailer) from 6.4.17 to 6.4.18. - [Release notes](https://github.com/nodemailer/nodemailer/releases) - [Changelog](https://github.com/nodemailer/nodemailer/blob/master/CHANGELOG.md) - [Commits](https://github.com/nodemailer/nodemailer/compare/v6.4.17...v6.4.18) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/strapi-provider-email-nodemailer/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/strapi-provider-email-nodemailer/package.json b/packages/strapi-provider-email-nodemailer/package.json index ef7bd2918e..c40fc26996 100644 --- a/packages/strapi-provider-email-nodemailer/package.json +++ b/packages/strapi-provider-email-nodemailer/package.json @@ -15,7 +15,7 @@ }, "dependencies": { "lodash": "4.17.20", - "nodemailer": "6.4.17" + "nodemailer": "6.4.18" }, "repository": { "type": "git", diff --git a/yarn.lock b/yarn.lock index 6571c632c9..e82fe19d42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13708,10 +13708,10 @@ nodemailer-shared@1.1.0: dependencies: nodemailer-fetch "1.6.0" -nodemailer@6.4.17: - version "6.4.17" - resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.4.17.tgz#8de98618028953b80680775770f937243a7d7877" - integrity sha512-89ps+SBGpo0D4Bi5ZrxcrCiRFaMmkCt+gItMXQGzEtZVR3uAD3QAQIDoxTWnx3ky0Dwwy/dhFrQ+6NNGXpw/qQ== +nodemailer@6.4.18: + version "6.4.18" + resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.4.18.tgz#2788c85792844fc17befda019031609017f4b9a1" + integrity sha512-ht9cXxQ+lTC+t00vkSIpKHIyM4aXIsQ1tcbQCn5IOnxYHi81W2XOaU66EQBFFpbtzLEBTC94gmkbD4mGZQzVpA== noop-logger@^0.1.1: version "0.1.1" From 04d1ac3de5ebf7945ae7cc5642967e5326acce68 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Feb 2021 09:20:36 +0100 Subject: [PATCH 22/40] Bump sqlite3 from 5.0.0 to 5.0.1 (#9389) Bumps [sqlite3](https://github.com/mapbox/node-sqlite3) from 5.0.0 to 5.0.1. - [Release notes](https://github.com/mapbox/node-sqlite3/releases) - [Changelog](https://github.com/mapbox/node-sqlite3/blob/master/CHANGELOG.md) - [Commits](https://github.com/mapbox/node-sqlite3/compare/v5.0.0...v5.0.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- examples/getstarted/package.json | 2 +- yarn.lock | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/examples/getstarted/package.json b/examples/getstarted/package.json index 2dc3651319..86911e9391 100644 --- a/examples/getstarted/package.json +++ b/examples/getstarted/package.json @@ -16,7 +16,7 @@ "lodash": "4.17.19", "mysql": "^2.17.1", "pg": "8.5.1", - "sqlite3": "^5.0.0", + "sqlite3": "^5.0.1", "strapi": "3.4.6", "strapi-admin": "3.4.6", "strapi-connector-bookshelf": "3.4.6", diff --git a/yarn.lock b/yarn.lock index e82fe19d42..d394e8ef58 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13531,12 +13531,7 @@ node-abi@^2.7.0: dependencies: semver "^5.4.1" -node-addon-api@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-2.0.0.tgz#f9afb8d777a91525244b01775ea0ddbe1125483b" - integrity sha512-ASCL5U13as7HhOExbT6OlWJJUV/lLzL2voOSP1UVehpRD8FbSrSDjfScK/KwAvVTI5AS6r4VwbOMlIqtvRidnA== - -node-addon-api@^3.1.0: +node-addon-api@^3.0.0, node-addon-api@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.1.0.tgz#98b21931557466c6729e51cb77cd39c965f42239" integrity sha512-flmrDNB06LIl5lywUz7YlNGZH/5p0M7W28k8hzd9Lshtdh1wshD2Y+U4h9LD6KObOy1f+fEVdgprPrEymjM5uw== @@ -18212,12 +18207,12 @@ sprintf-js@~1.0.2: resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw= -sqlite3@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-5.0.0.tgz#1bfef2151c6bc48a3ab1a6c126088bb8dd233566" - integrity sha512-rjvqHFUaSGnzxDy2AHCwhHy6Zp6MNJzCPGYju4kD8yi6bze4d1/zMTg6C7JI49b7/EM7jKMTvyfN/4ylBKdwfw== +sqlite3@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/sqlite3/-/sqlite3-5.0.1.tgz#d5b58c8d1568bbaf13062eb9465982f36324f78a" + integrity sha512-kh2lTIcYNfmVcvhVJihsYuPj9U0xzBbh6bmqILO2hkryWSC9RRhzYmkIDtJkJ+d8Kg4wZRJ0T1reyHUEspICfg== dependencies: - node-addon-api "2.0.0" + node-addon-api "^3.0.0" node-pre-gyp "^0.11.0" optionalDependencies: node-gyp "3.x" From 1b5da26cca5af44b94306161b2ffbdaddb348bc0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 12 Feb 2021 15:26:28 +0100 Subject: [PATCH 23/40] Bump @babel/plugin-transform-runtime from 7.11.5 to 7.12.15 (#9363) Bumps [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-plugin-transform-runtime) from 7.11.5 to 7.12.15. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.15/packages/babel-plugin-transform-runtime) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/strapi-admin/package.json | 2 +- yarn.lock | 54 +++++++++++++++++------------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 222eea452e..27fbe6583d 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -19,7 +19,7 @@ "@babel/plugin-proposal-class-properties": "^7.12.1", "@babel/plugin-syntax-dynamic-import": "^7.2.0", "@babel/plugin-transform-modules-commonjs": "^7.12.1", - "@babel/plugin-transform-runtime": "^7.9.0", + "@babel/plugin-transform-runtime": "^7.12.15", "@babel/polyfill": "^7.12.1", "@babel/preset-env": "^7.9.5", "@babel/preset-react": "^7.9.4", diff --git a/yarn.lock b/yarn.lock index d394e8ef58..c8fca33512 100644 --- a/yarn.lock +++ b/yarn.lock @@ -215,19 +215,12 @@ dependencies: "@babel/types" "^7.12.1" -"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.10.4.tgz#4c5c54be04bd31670a7382797d75b9fa2e5b5620" - integrity sha512-nEQJHqYavI217oD9+s5MUBzk6x1IlvoS9WTPfgG43CbMEeStE0v+r+TucWdx8KFGowPGvyOkDT9+7DHedIDnVw== +"@babel/helper-module-imports@^7.0.0", "@babel/helper-module-imports@^7.10.4", "@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.12.13", "@babel/helper-module-imports@^7.7.0": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.13.tgz#ec67e4404f41750463e455cc3203f6a32e93fcb0" + integrity sha512-NGmfvRp9Rqxy0uHSSVP+SRIW1q31a7Ji10cLBcqSDUngGentY4FRiHOFZFE1CLU5eiL0oE8reH7Tg1y99TDM/g== dependencies: - "@babel/types" "^7.10.4" - -"@babel/helper-module-imports@^7.12.1", "@babel/helper-module-imports@^7.7.0": - version "7.12.5" - resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.12.5.tgz#1bfc0229f794988f76ed0a4d4e90860850b54dfb" - integrity sha512-SR713Ogqg6++uexFRORf/+nPXMmWIn80TALu0uaFb+iQIUoR7bOC7zBWyzBs5b3tBBJXuyD0cRu1F15GyzjOWA== - dependencies: - "@babel/types" "^7.12.5" + "@babel/types" "^7.12.13" "@babel/helper-module-transforms@^7.10.4", "@babel/helper-module-transforms@^7.10.5", "@babel/helper-module-transforms@^7.12.1": version "7.12.1" @@ -251,10 +244,10 @@ dependencies: "@babel/types" "^7.10.4" -"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": - version "7.10.4" - resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.10.4.tgz#2f75a831269d4f677de49986dff59927533cf375" - integrity sha512-O4KCvQA6lLiMU9l2eawBPMf1xPP8xPfB3iEQw150hOVTqj/rfXz0ThTb4HEzqQfs2Bmo5Ay8BzxfzVtBrr9dVg== +"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.12.13.tgz#174254d0f2424d8aefb4dd48057511247b0a9eeb" + integrity sha512-C+10MXCXJLiR6IeG9+Wiejt9jmtFpxUc3MQqCmPY8hfCjyUGl9kT+B2okzEZrtykiwrc4dbCPdDoz0A/HQbDaA== "@babel/helper-regex@^7.10.4": version "7.10.5" @@ -318,6 +311,11 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz#a78c7a7251e01f616512d31b10adcf52ada5e0d2" integrity sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw== +"@babel/helper-validator-identifier@^7.12.11": + version "7.12.11" + resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz#c9a1f021917dcb5ccf0d4e453e399022981fc9ed" + integrity sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw== + "@babel/helper-wrap-function@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.10.4.tgz#8a6f701eab0ff39f765b5a1cfef409990e624b87" @@ -825,14 +823,13 @@ dependencies: "@babel/helper-plugin-utils" "^7.10.4" -"@babel/plugin-transform-runtime@^7.9.0": - version "7.11.5" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.11.5.tgz#f108bc8e0cf33c37da031c097d1df470b3a293fc" - integrity sha512-9aIoee+EhjySZ6vY5hnLjigHzunBlscx9ANKutkeWTJTx6m5Rbq6Ic01tLvO54lSusR+BxV7u4UDdCmXv5aagg== +"@babel/plugin-transform-runtime@^7.12.15": + version "7.12.15" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.12.15.tgz#4337b2507288007c2b197059301aa0af8d90c085" + integrity sha512-OwptMSRnRWJo+tJ9v9wgAf72ydXWfYSXWhnQjZing8nGZSDFqU1MBleKM3+DriKkcbv7RagA8gVeB0A1PNlNow== dependencies: - "@babel/helper-module-imports" "^7.10.4" - "@babel/helper-plugin-utils" "^7.10.4" - resolve "^1.8.1" + "@babel/helper-module-imports" "^7.12.13" + "@babel/helper-plugin-utils" "^7.12.13" semver "^5.5.1" "@babel/plugin-transform-shorthand-properties@^7.10.4": @@ -1042,6 +1039,15 @@ lodash "^4.17.19" to-fast-properties "^2.0.0" +"@babel/types@^7.12.13": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.12.13.tgz#8be1aa8f2c876da11a9cf650c0ecf656913ad611" + integrity sha512-oKrdZTld2im1z8bDwTOQvUbxKwE+854zc16qWZQlcTqMN00pWxHQ4ZeOq0yDMnisOpRykH2/5Qqcrk/OlbAjiQ== + dependencies: + "@babel/helper-validator-identifier" "^7.12.11" + lodash "^4.17.19" + to-fast-properties "^2.0.0" + "@bcoe/v8-coverage@^0.2.3": version "0.2.3" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" @@ -16867,7 +16873,7 @@ resolve@1.1.x: resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= -resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.16.1, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2, resolve@^1.8.1: +resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.10.1, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.16.1, resolve@^1.17.0, resolve@^1.18.1, resolve@^1.3.2: version "1.18.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.18.1.tgz#018fcb2c5b207d2a6424aee361c5a266da8f4130" integrity sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA== From f8898b166266b2085275757ce157de6aceb77aec Mon Sep 17 00:00:00 2001 From: Tuna Sakar Date: Mon, 15 Feb 2021 10:49:44 +0300 Subject: [PATCH 24/40] Update README.md (#9380) fastandcomfy.io is down! --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index b17a7f5d4e..14a57b14d1 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,6 @@ - - - - From 92ba4efb2b239981579c494d375bdcd4df3cfd1a Mon Sep 17 00:00:00 2001 From: ngjoni <49320058+ngjoni@users.noreply.github.com> Date: Mon, 15 Feb 2021 09:21:10 +0100 Subject: [PATCH 25/40] Translation Update (german) (#9387) * update german translation * Additional german translation --- packages/strapi-admin/admin/src/translations/de.json | 12 +++++++++++- .../admin/src/translations/de.json | 6 +++++- .../admin/src/translations/de.json | 8 +++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/packages/strapi-admin/admin/src/translations/de.json b/packages/strapi-admin/admin/src/translations/de.json index f3efa62c14..b8ab0a1073 100644 --- a/packages/strapi-admin/admin/src/translations/de.json +++ b/packages/strapi-admin/admin/src/translations/de.json @@ -65,12 +65,20 @@ "Roles.ListPage.notification.delete-not-allowed": "Eine Rolle, die mit einem Benutzer verknüpft ist, kann nicht gelöscht werden", "Roles.RoleRow.user-count.plural": "{number} Benutzer", "Roles.RoleRow.user-count.singular": "{number} Benutzer", + "Settings.application.description": "Projektdetails ansehen", + "Settings.application.edition-title": "Aktuelle Planversion", + "Settings.application.link-pricing": "Alle Preisgestaltungen anzeigen", + "Settings.application.link-upgrade": "Dein Projekt upgraden", + "Settings.application.node-version": "NODE VERSION", + "Settings.application.strapi-version": "STRAPI VERSION", + "Settings.application.title": "Anwendung", "Roles.components.List.empty.withSearch": "Es gibt keine Rolle die der Suche ({search}) entspricht...", "Settings.PageTitle": "Einstellungen - {name}", "Settings.error": "Fehler", "Settings.global": "Globale Einstellungen", "Settings.permissions": "Administrationsoberfläche", "Settings.permissions.category": "Berechtigungseinstellungen für die {category}", + "Settings.permissions.category.plugins": "Berechtigungseinstellungen für das {category} Plugin", "Settings.permissions.conditions.anytime": "Jederzeit", "Settings.permissions.conditions.apply": "Anwenden", "Settings.permissions.conditions.can": "Kann", @@ -333,5 +341,7 @@ "notification.permission.not-allowed-read": "Keine Berechtigung dieses Dokument einzusehen", "notification.success.delete": "Eintrag wurde gelöscht", "notification.success.saved": "Gespeichert", + "notification.version.update.link": "Erfahre mehr", + "notification.version.update.message": "Eine neue Strapi Version ist verfügbar", "request.error.model.unknown": "Dieses Schema existiert nicht" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-content-type-builder/admin/src/translations/de.json b/packages/strapi-plugin-content-type-builder/admin/src/translations/de.json index 0889f65e09..6511aadaa5 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/translations/de.json +++ b/packages/strapi-plugin-content-type-builder/admin/src/translations/de.json @@ -16,6 +16,7 @@ "attribute.json.description": "Daten im JSON-Format", "attribute.media": "Medien", "attribute.media.description": "Dateien wie Bilder, Videos, etc", + "attribute.null": " ", "attribute.number": "Zahl", "attribute.number.description": "Zahlen (ganzzahlig, Gleitkommazahl, dezimal)", "attribute.password": "Passwort", @@ -65,6 +66,9 @@ "form.attribute.component.option.single.description": "Nützlich um Felder wie volle Addresse, Hauptinformationen, etc. zu grupppieren", "form.attribute.item.customColumnName": "Eigener Spaltenname", "form.attribute.item.customColumnName.description": "Dies ist nützlich, um Spalten in der Datenbank für Antworten der API umzubenennen", + "form.attribute.item.date.type.date": "Datum", + "form.attribute.item.date.type.datetime": "Datum und Uhrzeit", + "form.attribute.item.date.type.time": "Uhrzeit", "form.attribute.item.defineRelation.fieldName": "Feldname", "form.attribute.item.enumeration.graphql": "Namensüberschreibung für GraphQL", "form.attribute.item.enumeration.graphql.description": "Ermöglicht, den standardmäßig generierten Namen für GraphQL zu überschreiben", @@ -180,4 +184,4 @@ "relation.oneWay": "hat ein(-e/-en)", "table.attributes.title.plural": "{number} Felder", "table.attributes.title.singular": "{number} Feld" -} +} \ No newline at end of file diff --git a/packages/strapi-plugin-documentation/admin/src/translations/de.json b/packages/strapi-plugin-documentation/admin/src/translations/de.json index 6d7d8441bd..9aea5ac5f0 100755 --- a/packages/strapi-plugin-documentation/admin/src/translations/de.json +++ b/packages/strapi-plugin-documentation/admin/src/translations/de.json @@ -5,6 +5,9 @@ "containers.HomePage.Block.title": "Versionen", "containers.HomePage.Button.open": "Dokumentation öffnen", "containers.HomePage.Button.update": "Aktualisieren", + "containers.HomePage.copied": "Token in der Zwischenablage kopiert", + "containers.HomePage.form.jwtToken": "Jwt Token abrufen", + "containers.HomePage.form.jwtToken.description": "Kopieren Sie diesen Token und nutzen Sie es unter Swagger, um Anfragen zu stellen", "containers.HomePage.PluginHeader.description": "Einstellungen des Dokumentation-Plugins ändern", "containers.HomePage.PluginHeader.title": "Dokumentation - Einstellungen", "containers.HomePage.PopUpWarning.confirm": "Ich verstehe", @@ -16,9 +19,12 @@ "containers.HomePage.form.showGeneratedFiles": "Generierte Dateien anzeigen", "containers.HomePage.form.showGeneratedFiles.inputDescription": "Nützlich, wenn Sie die generierte Dokumentation überschreiben möchten. \nDas Plugin wird nach Modell und Plugin geteilte Dateien erzeugen. \nDurch die Aktivierung dieser Option wird es einfacher sein, Ihre Dokumentation anzupassen.", "error.deleteDoc.versionMissing": "Die Version, die Sie zu löschen versuchen, existiert nicht.", + "error.noVersion": "Eine Version wird benötigt", "error.regenerateDoc": "Ein Fehler ist während dem Neu-Erstellen der Dokumentation aufgetreten.", "error.regenerateDoc.versionMissing": "Die Version, die Sie zu generieren versuchen, existiert nicht", "notification.update.success": "Einstellungen wurden erfolgreich aktualisiert", + "notification.delete.success": "Dokument wurde erfolgreich gelöscht", + "notification.generate.success": "Dokument wurde erfolgreich generiert", "plugin.name": "Dokumentation" -} +} \ No newline at end of file From b2d73ccefc15567c31b01c504980829776f82e53 Mon Sep 17 00:00:00 2001 From: alexey Date: Mon, 15 Feb 2021 11:32:24 +0300 Subject: [PATCH 26/40] plugin-documentation: added enum for associations (#9381) --- packages/strapi-plugin-documentation/services/Documentation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/strapi-plugin-documentation/services/Documentation.js b/packages/strapi-plugin-documentation/services/Documentation.js index 5ad4b323cf..83963b07d3 100755 --- a/packages/strapi-plugin-documentation/services/Documentation.js +++ b/packages/strapi-plugin-documentation/services/Documentation.js @@ -348,7 +348,7 @@ module.exports = { } if (isField) { - acc.properties[curr] = { type: this.getType(attribute.type) }; + acc.properties[curr] = { type: this.getType(attribute.type), enum: attribute.enum }; } else { const newGetter = getter.slice(); newGetter.splice(newGetter.length - 1, 1, 'associations'); From e29483bb099b112489e96202db955e6cb8d516a7 Mon Sep 17 00:00:00 2001 From: alexey Date: Mon, 15 Feb 2021 11:34:12 +0300 Subject: [PATCH 27/40] plugin-documentation: added missed manyWay relation (#9379) --- packages/strapi-plugin-documentation/services/Documentation.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/strapi-plugin-documentation/services/Documentation.js b/packages/strapi-plugin-documentation/services/Documentation.js index 83963b07d3..df12cb4a18 100755 --- a/packages/strapi-plugin-documentation/services/Documentation.js +++ b/packages/strapi-plugin-documentation/services/Documentation.js @@ -359,6 +359,7 @@ module.exports = { switch (relationNature) { case 'manyToMany': case 'oneToMany': + case 'manyWay': case 'manyToManyMorph': acc.properties[curr] = { type: 'array', @@ -573,6 +574,7 @@ module.exports = { switch (relationNature) { case 'manyToMany': case 'oneToMany': + case 'manyWay': case 'manyToManyMorph': acc.properties[current] = { type: 'array', From 96516d5d7f21dcb11633a838fb1436574d38d89b Mon Sep 17 00:00:00 2001 From: Paul Weinsberg Date: Mon, 15 Feb 2021 14:34:44 +0100 Subject: [PATCH 28/40] Enable develop --poll flag to watch file changes in network directories (#8773) Co-authored-by: Alexandre BODIN --- packages/strapi/bin/strapi.js | 1 + packages/strapi/lib/commands/develop.js | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/strapi/bin/strapi.js b/packages/strapi/bin/strapi.js index cd477201f6..410929ef29 100755 --- a/packages/strapi/bin/strapi.js +++ b/packages/strapi/bin/strapi.js @@ -113,6 +113,7 @@ program .alias('dev') .option('--no-build', 'Disable build') .option('--watch-admin', 'Enable watch', false) + .option('--polling', 'Watching file changes in network directories', false) .option('--browser ', 'Open the browser', true) .description('Start your Strapi application in development mode') .action(getLocalScript('develop')); diff --git a/packages/strapi/lib/commands/develop.js b/packages/strapi/lib/commands/develop.js index 860380da9e..833f89347f 100644 --- a/packages/strapi/lib/commands/develop.js +++ b/packages/strapi/lib/commands/develop.js @@ -14,7 +14,7 @@ const strapi = require('../index'); * `$ strapi develop` * */ -module.exports = async function({ build, watchAdmin, browser }) { +module.exports = async function({ build, watchAdmin, polling, browser }) { const dir = process.cwd(); const config = loadConfiguration(dir); @@ -77,6 +77,7 @@ module.exports = async function({ build, watchAdmin, browser }) { dir, strapiInstance, watchIgnoreFiles: adminWatchIgnoreFiles, + polling, }); process.on('message', message => { @@ -106,7 +107,7 @@ module.exports = async function({ build, watchAdmin, browser }) { * @param {Strapi} options.strapi - Strapi instance * @param {array} options.watchIgnoreFiles - Array of custom file paths that should not be watched */ -function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles }) { +function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles, polling }) { const restart = () => { if (strapiInstance.reload.isWatching && !strapiInstance.reload.isReloading) { strapiInstance.reload.isReloading = true; @@ -116,6 +117,7 @@ function watchFileChanges({ dir, strapiInstance, watchIgnoreFiles }) { const watcher = chokidar.watch(dir, { ignoreInitial: true, + usePolling: polling, ignored: [ /(^|[/\\])\../, // dot files /tmp/, From 06ebbee16638d8715253d08632eb518a785a7191 Mon Sep 17 00:00:00 2001 From: Thew Dhanat <26767607+ThewBear@users.noreply.github.com> Date: Mon, 15 Feb 2021 20:58:59 +0700 Subject: [PATCH 29/40] strapi-plugin-upload accepts localServer configuration (#9191) * Update index.js * Update index.js * Update index.js * Update index.js --- packages/strapi-plugin-upload/middlewares/upload/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/strapi-plugin-upload/middlewares/upload/index.js b/packages/strapi-plugin-upload/middlewares/upload/index.js index ea8a06ac63..26eb5fcfc4 100644 --- a/packages/strapi-plugin-upload/middlewares/upload/index.js +++ b/packages/strapi-plugin-upload/middlewares/upload/index.js @@ -3,6 +3,7 @@ const { resolve } = require('path'); const range = require('koa-range'); const koaStatic = require('koa-static'); +const _ = require('lodash'); module.exports = strapi => ({ initialize() { @@ -23,6 +24,7 @@ module.exports = strapi => ({ strapi.app.onerror(err); }); - strapi.router.get('/uploads/(.*)', range, koaStatic(staticDir, { defer: true })); + const localServerConfig = _.get(strapi, 'plugins.upload.config.providerOptions.localServer') || {}; + strapi.router.get('/uploads/(.*)', range, koaStatic(staticDir, { defer: true, ...localServerConfig })); }, }); From 8d2ab6e1b05a2f78d1385b28aab4de2e2c7f60bf Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Mon, 15 Feb 2021 15:45:30 +0100 Subject: [PATCH 30/40] Move sentry middleware to middlewares folder --- .../config/functions/bootstrap.js | 23 ------------- .../middlewares/sentry/defaults.json | 5 +++ .../middlewares/sentry/index.js | 33 +++++++++++++++++++ .../strapi-plugin-sentry/services/sentry.js | 5 +-- 4 files changed, 41 insertions(+), 25 deletions(-) create mode 100644 packages/strapi-plugin-sentry/middlewares/sentry/defaults.json create mode 100644 packages/strapi-plugin-sentry/middlewares/sentry/index.js diff --git a/packages/strapi-plugin-sentry/config/functions/bootstrap.js b/packages/strapi-plugin-sentry/config/functions/bootstrap.js index 90f915150c..fe50250c6c 100644 --- a/packages/strapi-plugin-sentry/config/functions/bootstrap.js +++ b/packages/strapi-plugin-sentry/config/functions/bootstrap.js @@ -4,27 +4,4 @@ module.exports = async () => { // Initialize the Sentry service exposed by this plugin const { sentry } = strapi.plugins.sentry.services; sentry.init(); - - // Create a middleware to intercept API errors - strapi.app.use(async (ctx, next) => { - try { - await next(); - } catch (error) { - sentry.sendError(error, (scope, sentryInstance) => { - scope.addEventProcessor(event => { - // Parse Koa context to add error metadata - return sentryInstance.Handlers.parseRequest(event, ctx.request, { - // Don't parse the transaction name, we'll do it manually - transaction: false, - }); - }); - // Manually add transaction name - scope.setTag('transaction', `${ctx.method} ${ctx.request.url}`); - // Manually add Strapi version - scope.setTag('strapi_version', strapi.config.info.strapi); - scope.setTag('method', ctx.method); - }); - throw error; - } - }); }; diff --git a/packages/strapi-plugin-sentry/middlewares/sentry/defaults.json b/packages/strapi-plugin-sentry/middlewares/sentry/defaults.json new file mode 100644 index 0000000000..d3394f4839 --- /dev/null +++ b/packages/strapi-plugin-sentry/middlewares/sentry/defaults.json @@ -0,0 +1,5 @@ +{ + "sentry": { + "enabled": true + } +} diff --git a/packages/strapi-plugin-sentry/middlewares/sentry/index.js b/packages/strapi-plugin-sentry/middlewares/sentry/index.js new file mode 100644 index 0000000000..6d52b17151 --- /dev/null +++ b/packages/strapi-plugin-sentry/middlewares/sentry/index.js @@ -0,0 +1,33 @@ +'use strict'; + +module.exports = strapi => ({ + beforeInitialize() { + strapi.config.middleware.load.after.unshift('sentry'); + }, + initialize() { + const { sentry } = strapi.plugins.sentry.services; + sentry.init(); + + strapi.app.use(async (ctx, next) => { + try { + await next(); + } catch (error) { + sentry.sendError(error, (scope, sentryInstance) => { + scope.addEventProcessor(event => { + // Parse Koa context to add error metadata + return sentryInstance.Handlers.parseRequest(event, ctx.request, { + // Don't parse the transaction name, we'll do it manually + transaction: false, + }); + }); + // Manually add transaction name + scope.setTag('transaction', `${ctx.method} ${ctx.request.url}`); + // Manually add Strapi version + scope.setTag('strapi_version', strapi.config.info.strapi); + scope.setTag('method', ctx.method); + }); + throw error; + } + }); + }, +}); diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index 3a5b72cbca..42952a0d9e 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -15,8 +15,7 @@ const createSentryService = () => { init() { // Make sure there isn't a Sentry instance already running if (instance != null) { - strapi.log.warn('Sentry has already been initialized'); - return; + return this; } // Retrieve user settings and merge them with the default ones @@ -41,6 +40,8 @@ const createSentryService = () => { } catch (error) { strapi.log.warn('Could not set up Sentry, make sure you entered a valid DSN'); } + + return this; }, /** From 0aed8e18f55bfe747bea6aab2ef3b2b1241ba673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Mon, 15 Feb 2021 19:34:45 +0100 Subject: [PATCH 31/40] Improved docs to disable the plugin --- packages/strapi-plugin-sentry/README.md | 49 +++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/packages/strapi-plugin-sentry/README.md b/packages/strapi-plugin-sentry/README.md index 9118d2160c..57069b9b57 100644 --- a/packages/strapi-plugin-sentry/README.md +++ b/packages/strapi-plugin-sentry/README.md @@ -11,10 +11,10 @@ The official plugin to track Strapi errors with Sentry. ## Configuration -| property | type (default) | description | -| -------------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | -| `dsn` | string (null) | Your Sentry data source name ([see Sentry docs](https://docs.sentry.io/product/sentry-basics/dsn-explainer/)). Omitting it will disable the plugin. | -| `sendMetadata` | boolean (true) | Whether the plugin should attach additional information (like OS, browser, etc.) to the events sent to Sentry. | +| property | type (default) | description | +| -------------- | -------------- | -------------------------------------------------------------------------------------------------------------- | +| `dsn` | string (null) | Your Sentry data source name ([see Sentry docs](https://docs.sentry.io/product/sentry-basics/dsn-explainer/)). | +| `sendMetadata` | boolean (true) | Whether the plugin should attach additional information (like OS, browser, etc.) to the events sent to Sentry. | **Example** @@ -72,3 +72,44 @@ Use it if you need direct access to the Sentry instance, which should already al ```js const sentryInstance = strapi.plugins.sentry.services.sentry.getInstance(); ``` + +## Disabling + +### Disabling only the middleware + +By default, this plugin uses a middleware that logs all your unhandled API errors to Sentry. You can disable this feature by turning off the `sentry` middleware in your app's config. + +**Example** + +`./config/middleware.js` + +```js +module.exports = { + //... + settings: { + sentry: { + enabled: false, + }, + }, +}; +``` + +Only the middleware will be disabled. You will still have access to the Sentry service. + +### Disabling the plugin entirely + +You can also completely disable this plugin (both the middleware and the service). If you omit the `dsn` property of your plugin's settings, or if you give it a null value, the Sentry plugin will be ignored. You can use the `env` utility to disable it depending on the environment. + +**Example** + +`./config/plugins.js` + +```js +module.exports = ({ env }) => ({ + // ... + sentry: { + dsn: env('NODE_ENV') === 'development' ? null : env('SENTRY_DSN'), + }, + // ... +}); +``` From 321d7c136131349732ffd3babd232b13041e3e76 Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Tue, 16 Feb 2021 09:29:12 +0100 Subject: [PATCH 32/40] Fix unit tests --- packages/strapi-plugin-sentry/services/__tests__/sentry.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js index 0375d17175..84ffd14979 100644 --- a/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js +++ b/packages/strapi-plugin-sentry/services/__tests__/sentry.test.js @@ -80,7 +80,6 @@ describe('strapi-plugin-sentry service', () => { // Doesn't allow re-init sentryService.init(); - expect(strapi.log.warn).toHaveBeenCalledWith(expect.stringMatching(/already/i)); // Send error const error = Error('an error'); From 11005176ca7c82f444591b9a9a462bc24027df2c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Feb 2021 09:42:51 +0100 Subject: [PATCH 33/40] Bump swagger-ui-dist from 3.41.1 to 3.43.0 (#9413) Bumps [swagger-ui-dist](https://github.com/swagger-api/swagger-ui) from 3.41.1 to 3.43.0. - [Release notes](https://github.com/swagger-api/swagger-ui/releases) - [Commits](https://github.com/swagger-api/swagger-ui/compare/v3.41.1...v3.43.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/strapi-plugin-documentation/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/strapi-plugin-documentation/package.json b/packages/strapi-plugin-documentation/package.json index 70b108f718..629ef4c8ea 100644 --- a/packages/strapi-plugin-documentation/package.json +++ b/packages/strapi-plugin-documentation/package.json @@ -36,7 +36,7 @@ "redux-immutable": "^4.0.0", "reselect": "^4.0.0", "strapi-helper-plugin": "3.4.6", - "swagger-ui-dist": "3.41.1" + "swagger-ui-dist": "3.43.0" }, "author": { "name": "soupette", diff --git a/yarn.lock b/yarn.lock index c8fca33512..4628ed21fb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18878,10 +18878,10 @@ svgo@^1.0.0: unquote "~1.1.1" util.promisify "~1.0.0" -swagger-ui-dist@3.41.1: - version "3.41.1" - resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-3.41.1.tgz#1cb803fab9aef9bd45e1848068908887a23bf27f" - integrity sha512-Wg3RqMBp8dSYEwyvXOWuOTwh3fTxYxmtAvLjEbUwRlPXKEHcde3BG/v2zjswrDVcumUpPQ6Cp5RG3LMz6M0YIw== +swagger-ui-dist@3.43.0: + version "3.43.0" + resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-3.43.0.tgz#b064a2cec1d27776f9a124bc70423cfa0bbc0d3f" + integrity sha512-PtE+g23bNbYv8qqAVoPBqNQth8hU5Sl5ZsQ7gHXlO5jlCt31dVTiKI9ArHIT1b23ZzUYTnKsFgPYYFoiWyNCAw== switchback@^2.0.1: version "2.0.5" From 3bccd24bc4b8e3e01bd63633a26814133507e05c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Feb 2021 09:43:39 +0100 Subject: [PATCH 34/40] Bump markdown-it-ins from 3.0.0 to 3.0.1 (#9414) Bumps [markdown-it-ins](https://github.com/markdown-it/markdown-it-mark) from 3.0.0 to 3.0.1. - [Release notes](https://github.com/markdown-it/markdown-it-mark/releases) - [Changelog](https://github.com/markdown-it/markdown-it-mark/blob/master/CHANGELOG.md) - [Commits](https://github.com/markdown-it/markdown-it-mark/compare/3.0.0...3.0.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/strapi-plugin-content-manager/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/strapi-plugin-content-manager/package.json b/packages/strapi-plugin-content-manager/package.json index 376793577d..bc2958cbdb 100644 --- a/packages/strapi-plugin-content-manager/package.json +++ b/packages/strapi-plugin-content-manager/package.json @@ -28,7 +28,7 @@ "markdown-it-deflist": "^2.0.3", "markdown-it-emoji": "^2.0.0", "markdown-it-footnote": "^3.0.2", - "markdown-it-ins": "^3.0.0", + "markdown-it-ins": "^3.0.1", "markdown-it-mark": "^3.0.1", "markdown-it-sub": "^1.0.0", "markdown-it-sup": "^1.0.0", diff --git a/yarn.lock b/yarn.lock index 4628ed21fb..e010d780bf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12781,10 +12781,10 @@ markdown-it-footnote@^3.0.2: resolved "https://registry.yarnpkg.com/markdown-it-footnote/-/markdown-it-footnote-3.0.2.tgz#1575ee7a093648d4e096aa33386b058d92ac8bc1" integrity sha512-JVW6fCmZWjvMdDQSbOT3nnOQtd9iAXmw7hTSh26+v42BnvXeVyGMDBm5b/EZocMed2MbCAHiTX632vY0FyGB8A== -markdown-it-ins@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/markdown-it-ins/-/markdown-it-ins-3.0.0.tgz#b1b56824c78dc66e52b0fc97531b317cd78d79d2" - integrity sha512-+vyAdBuMGwmT2yMlAFJSx2VR/0QZ1onQ/Mkkmr4l9tDFOh5sVoAgRbkgbuSsk+sxJ9vaMH/IQ323ydfvQrPO/Q== +markdown-it-ins@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/markdown-it-ins/-/markdown-it-ins-3.0.1.tgz#c09356b917cf1dbf73add0b275d67ab8c73d4b4d" + integrity sha512-32SSfZqSzqyAmmQ4SHvhxbFqSzPDqsZgMHDwxqPzp+v+t8RsmqsBZRG+RfRQskJko9PfKC2/oxyOs4Yg/CfiRw== markdown-it-mark@^3.0.1: version "3.0.1" From 6dd67d5c7654447891db301413094029be5eadc9 Mon Sep 17 00:00:00 2001 From: Alexandre BODIN Date: Tue, 16 Feb 2021 10:16:49 +0100 Subject: [PATCH 35/40] Fix pool config (#9417) --- packages/strapi-connector-bookshelf/lib/knex.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/strapi-connector-bookshelf/lib/knex.js b/packages/strapi-connector-bookshelf/lib/knex.js index b1bcfa3bef..e8dd0dc04e 100644 --- a/packages/strapi-connector-bookshelf/lib/knex.js +++ b/packages/strapi-connector-bookshelf/lib/knex.js @@ -102,6 +102,7 @@ module.exports = strapi => { ...connection.options, debug: _.get(connection.options, 'debug', false), pool: { + ..._.get(connection.options, 'pool', {}), min: _.get(connection.options, 'pool.min', 0), }, }, From db3784ce32bfb10c2d8a4981e6afe18b12e9299d Mon Sep 17 00:00:00 2001 From: Marvin Frachet Date: Tue, 16 Feb 2021 12:00:24 +0100 Subject: [PATCH 36/40] Adding icons for Single Types and Collection type (#9416) --- .../admin/src/components/BooleanBox/CT.js | 21 +++ .../admin/src/components/BooleanBox/ST.js | 21 +++ .../components/BooleanBox/icons/CTSelected.js | 136 ++++++++++++++++++ .../BooleanBox/icons/CTUnselected.js | 136 ++++++++++++++++++ .../components/BooleanBox/icons/STSelected.js | 80 +++++++++++ .../BooleanBox/icons/STUnselected.js | 76 ++++++++++ .../admin/src/components/BooleanBox/index.js | 60 ++++++-- .../BooleanBox/tests/BooleanBox.test.js | 112 +++++++++++++++ 8 files changed, 631 insertions(+), 11 deletions(-) create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/CT.js create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/ST.js create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTSelected.js create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTUnselected.js create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STSelected.js create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STUnselected.js create mode 100644 packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/tests/BooleanBox.test.js diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/CT.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/CT.js new file mode 100644 index 0000000000..ea2cc34d3d --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/CT.js @@ -0,0 +1,21 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import CTSelected from './icons/CTSelected'; +import CTUnselected from './icons/CTUnselected'; + +const CT = ({ selected }) => + selected ? ( + + ) : ( + + ); + +CT.defaultProps = { + selected: false, +}; + +CT.propTypes = { + selected: PropTypes.bool, +}; + +export default CT; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/ST.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/ST.js new file mode 100644 index 0000000000..e3078eee4a --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/ST.js @@ -0,0 +1,21 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import STSelected from './icons/STSelected'; +import STUnselected from './icons/STUnselected'; + +const ST = ({ selected }) => + selected ? ( + + ) : ( + + ); + +ST.defaultProps = { + selected: false, +}; + +ST.propTypes = { + selected: PropTypes.bool, +}; + +export default ST; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTSelected.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTSelected.js new file mode 100644 index 0000000000..7eeb59b91b --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTSelected.js @@ -0,0 +1,136 @@ +/* eslint-disable */ +import React from 'react'; + +const CTSelected = props => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export default CTSelected; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTUnselected.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTUnselected.js new file mode 100644 index 0000000000..03c58bf8f0 --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/CTUnselected.js @@ -0,0 +1,136 @@ +/* eslint-disable */ +import React from 'react'; + +const CTUnSelected = props => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export default CTUnSelected; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STSelected.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STSelected.js new file mode 100644 index 0000000000..1ba2080d85 --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STSelected.js @@ -0,0 +1,80 @@ +/* eslint-disable */ +import React from 'react'; + +const STSelected = props => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export default STSelected; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STUnselected.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STUnselected.js new file mode 100644 index 0000000000..5433e92195 --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/icons/STUnselected.js @@ -0,0 +1,76 @@ +/* eslint-disable */ +import React from 'react'; + +const STUnselected = props => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + +); + +export default STUnselected; diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/index.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/index.js index d29e9e9029..da00027402 100644 --- a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/index.js +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/index.js @@ -1,11 +1,29 @@ import React from 'react'; import PropTypes from 'prop-types'; import { useGlobalContext } from 'strapi-helper-plugin'; +import { Flex } from '@buffetjs/core'; +import styled from 'styled-components'; +import CTIcon from './CT'; +import STIcon from './ST'; import CustomLabel from './Label'; import Enumeration from './Enumeration'; import EnumerationWrapper from './EnumerationWrapper'; import Wrapper from './Wrapper'; +/** + * TODO: Those should not exist, remove with design system + */ +const CTHackSpan = styled.span` + margin-left: -1rem; + margin-right: 1rem; + margin-top: -1.3rem; +`; +const STHackSpan = styled.span` + margin-left: -1rem; + margin-right: 1rem; + margin-top: -0.5rem; +`; + const BooleanBox = ({ label, name, onChange, onChangeCallback, options, value }) => { const { formatMessage } = useGlobalContext(); @@ -31,17 +49,37 @@ const BooleanBox = ({ label, name, onChange, onChangeCallback, options, value }) value={option.value} /> ))} - {options.map(option => ( - - - {formatMessage({ id: option.headerId })} -

{formatMessage({ id: option.descriptionId })}

-
- ))} + {options.map(option => { + const isST = option.value === 'singleType'; + const isCT = option.value === 'collectionType'; + + return ( + + + {isST && ( + + + + )} + {isCT && ( + + + + )} + +
+ + {formatMessage({ id: option.headerId })} +

{formatMessage({ id: option.descriptionId })}

+
+
+
+ ); + })} ); diff --git a/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/tests/BooleanBox.test.js b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/tests/BooleanBox.test.js new file mode 100644 index 0000000000..d14525950d --- /dev/null +++ b/packages/strapi-plugin-content-type-builder/admin/src/components/BooleanBox/tests/BooleanBox.test.js @@ -0,0 +1,112 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import { ThemeProvider } from 'styled-components'; +import defaultThemes from '../../../../../../strapi-admin/admin/src/themes'; +import BooleanBox from ".."; + +jest.mock('strapi-helper-plugin', () => ({ + useGlobalContext: () => ({ formatMessage: ({ id }) => id }), +})); + +describe('BooleanBox', () => { + it('has single type selected by default and verifies the other states', () => { + const options = [ + { + headerId: 'menu.section.models.name.singular', + descriptionId: 'form.button.collection-type.description', + value: 'collectionType', + }, + { + headerId: 'menu.section.single-types.name.singular', + descriptionId: 'form.button.single-type.description', + value: 'singleType', + }, + ]; + + render( + + null} + onChangeCallback={() => null} + options={options} + value="singleType" + /> + + ); + + expect(screen.getByTestId('st-selected')).toBeVisible(); + expect(screen.getByTestId('ct-unselected')).toBeVisible(); + + expect(screen.queryByTestId('ct-selected')).toBeFalsy(); + expect(screen.queryByTestId('st-unselected')).toBeFalsy(); + }); + + it('has collection type selected by default and verifies the other states', () => { + const options = [ + { + headerId: 'menu.section.models.name.singular', + descriptionId: 'form.button.collection-type.description', + value: 'collectionType', + }, + { + headerId: 'menu.section.single-types.name.singular', + descriptionId: 'form.button.single-type.description', + value: 'singleType', + }, + ]; + + render( + + null} + onChangeCallback={() => null} + options={options} + value="collectionType" + /> + + ); + + expect(screen.getByTestId('ct-selected')).toBeVisible(); + expect(screen.getByTestId('st-unselected')).toBeVisible(); + + expect(screen.queryByTestId('st-selected')).toBeFalsy(); + expect(screen.queryByTestId('ct-unselected')).toBeFalsy(); + }); + + it('does not show the ST and CT icons for other types', () => { + const options = [ + { + headerId: 'menu.section.models.name.singular', + descriptionId: 'form.button.collection-type.description', + value: 'text', + }, + { + headerId: 'menu.section.single-types.name.singular', + descriptionId: 'form.button.single-type.description', + value: 'string', + }, + ]; + + render( + + null} + onChangeCallback={() => null} + options={options} + value="collectionType" + /> + + ); + + expect(screen.queryByTestId('ct-selected')).toBeFalsy(); + expect(screen.queryByTestId('st-unselected')).toBeFalsy(); + expect(screen.queryByTestId('st-selected')).toBeFalsy(); + expect(screen.queryByTestId('ct-unselected')).toBeFalsy(); + }); +}); From 7a6432da735e22156c4cd6d33d6c63cf8e4ee100 Mon Sep 17 00:00:00 2001 From: jonmol <46555944+jonmol@users.noreply.github.com> Date: Tue, 16 Feb 2021 17:37:30 +0100 Subject: [PATCH 37/40] added a way to have a less expensive search (#9316) * added a way to have a less expensive search * renamed skipSearch to searchable * forgot to remove one skipSearch * skip non searchable fields on mongoose query * cleaned up the if statement * reverted change to strapi-plugin-upload/models Co-authored-by: Luis del Rio Co-authored-by: Alexandre BODIN --- packages/strapi-connector-bookshelf/lib/queries.js | 6 ++++-- packages/strapi-connector-mongoose/lib/buildQuery.js | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/strapi-connector-bookshelf/lib/queries.js b/packages/strapi-connector-bookshelf/lib/queries.js index 6c3d46091d..e93fa29ce3 100644 --- a/packages/strapi-connector-bookshelf/lib/queries.js +++ b/packages/strapi-connector-bookshelf/lib/queries.js @@ -700,12 +700,14 @@ const buildSearchQuery = ({ model, params }) => qb => { const searchColumns = Object.keys(model._attributes) .filter(attribute => !associations.includes(attribute)) - .filter(attribute => stringTypes.includes(model._attributes[attribute].type)); + .filter(attribute => stringTypes.includes(model._attributes[attribute].type)) + .filter(attribute => model._attributes[attribute].searchable !== false); if (!_.isNaN(_.toNumber(query))) { const numberColumns = Object.keys(model._attributes) .filter(attribute => !associations.includes(attribute)) - .filter(attribute => numberTypes.includes(model._attributes[attribute].type)); + .filter(attribute => numberTypes.includes(model._attributes[attribute].type)) + .filter(attribute => model._attributes[attribute].searchable !== false); searchColumns.push(...numberColumns); } diff --git a/packages/strapi-connector-mongoose/lib/buildQuery.js b/packages/strapi-connector-mongoose/lib/buildQuery.js index 7037621b0b..15b31929a0 100644 --- a/packages/strapi-connector-mongoose/lib/buildQuery.js +++ b/packages/strapi-connector-mongoose/lib/buildQuery.js @@ -36,6 +36,9 @@ const buildSearchOr = (model, query) => { } const searchOr = Object.keys(model.attributes).reduce((acc, curr) => { + if (model.attributes[curr].searchable === false) { + return acc + } switch (model.attributes[curr].type) { case 'biginteger': case 'integer': From ae29f535d780bf93da1e2878e1e591a817b2785f Mon Sep 17 00:00:00 2001 From: Alexandre Bodin Date: Tue, 16 Feb 2021 17:39:46 +0100 Subject: [PATCH 38/40] Update plugin sentry version --- packages/strapi-plugin-sentry/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/strapi-plugin-sentry/package.json b/packages/strapi-plugin-sentry/package.json index 2c2ebdc46a..fa6534d2a2 100644 --- a/packages/strapi-plugin-sentry/package.json +++ b/packages/strapi-plugin-sentry/package.json @@ -1,6 +1,6 @@ { "name": "strapi-plugin-sentry", - "version": "3.3.4", + "version": "3.4.6", "description": "Send Strapi error events to Sentry", "strapi": { "name": "Sentry", From 8359368477ff610257ec4bb937dc74b40e5ca3af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 17 Feb 2021 09:14:04 +0100 Subject: [PATCH 39/40] Bump @babel/runtime from 7.12.5 to 7.12.13 (#9427) Bumps [@babel/runtime](https://github.com/babel/babel/tree/HEAD/packages/babel-runtime) from 7.12.5 to 7.12.13. - [Release notes](https://github.com/babel/babel/releases) - [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) - [Commits](https://github.com/babel/babel/commits/v7.12.13/packages/babel-runtime) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/strapi-admin/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/strapi-admin/package.json b/packages/strapi-admin/package.json index 27fbe6583d..26a2b2ee87 100644 --- a/packages/strapi-admin/package.json +++ b/packages/strapi-admin/package.json @@ -23,7 +23,7 @@ "@babel/polyfill": "^7.12.1", "@babel/preset-env": "^7.9.5", "@babel/preset-react": "^7.9.4", - "@babel/runtime": "^7.9.2", + "@babel/runtime": "^7.12.13", "@buffetjs/core": "3.3.3-next.2", "@buffetjs/custom": "3.3.3-next.2", "@buffetjs/hooks": "3.3.3-next.2", diff --git a/yarn.lock b/yarn.lock index 53d51b8ee5..4e590354fe 100644 --- a/yarn.lock +++ b/yarn.lock @@ -999,10 +999,10 @@ core-js-pure "^3.0.0" regenerator-runtime "^0.13.4" -"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.10.5", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.2.0", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": - version "7.12.5" - resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.5.tgz#410e7e487441e1b360c29be715d870d9b985882e" - integrity sha512-plcc+hbExy3McchJCEQG3knOsuh3HH+Prx1P6cLIkET/0dLuQDEnrT+s27Axgc9bqfsmNUNHfscgMUdBpC9xfg== +"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.10.5", "@babel/runtime@^7.11.2", "@babel/runtime@^7.12.13", "@babel/runtime@^7.12.5", "@babel/runtime@^7.2.0", "@babel/runtime@^7.4.0", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2": + version "7.12.13" + resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.13.tgz#0a21452352b02542db0ffb928ac2d3ca7cb6d66d" + integrity sha512-8+3UMPBrjFa/6TtKi/7sehPKqfAm4g6K+YQjyyFOLUTxzOngcRZTlAVY8sc2CORJYqdHQY8gRPHmn+qo15rCBw== dependencies: regenerator-runtime "^0.13.4" From db0f437272a9892233b0fe67e55da22beebaf100 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20de=20Juvigny?= Date: Wed, 17 Feb 2021 09:15:32 +0100 Subject: [PATCH 40/40] Add init option to strapi-plugin-sentry (#9423) --- packages/strapi-plugin-sentry/README.md | 9 +++++---- packages/strapi-plugin-sentry/config/settings.json | 3 ++- packages/strapi-plugin-sentry/services/sentry.js | 1 + 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/strapi-plugin-sentry/README.md b/packages/strapi-plugin-sentry/README.md index 57069b9b57..368cef37bd 100644 --- a/packages/strapi-plugin-sentry/README.md +++ b/packages/strapi-plugin-sentry/README.md @@ -11,10 +11,11 @@ The official plugin to track Strapi errors with Sentry. ## Configuration -| property | type (default) | description | -| -------------- | -------------- | -------------------------------------------------------------------------------------------------------------- | -| `dsn` | string (null) | Your Sentry data source name ([see Sentry docs](https://docs.sentry.io/product/sentry-basics/dsn-explainer/)). | -| `sendMetadata` | boolean (true) | Whether the plugin should attach additional information (like OS, browser, etc.) to the events sent to Sentry. | +| property | type (default) | description | +| -------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `dsn` | string (`null`) | Your Sentry data source name ([see Sentry docs](https://docs.sentry.io/product/sentry-basics/dsn-explainer/)). | +| `sendMetadata` | boolean (`true`) | Whether the plugin should attach additional information (like OS, browser, etc.) to the events sent to Sentry. | +| `init` | object (`{}`) | A config object that is passed directly to Sentry during the `Sentry.init()`. See all available options [on Sentry's docs](https://docs.sentry.io/platforms/node/configuration/options/) | **Example** diff --git a/packages/strapi-plugin-sentry/config/settings.json b/packages/strapi-plugin-sentry/config/settings.json index d2e64c9018..c19e847bd7 100644 --- a/packages/strapi-plugin-sentry/config/settings.json +++ b/packages/strapi-plugin-sentry/config/settings.json @@ -1,4 +1,5 @@ { "dsn": null, - "sendMetadata": true + "sendMetadata": true, + "init": {} } \ No newline at end of file diff --git a/packages/strapi-plugin-sentry/services/sentry.js b/packages/strapi-plugin-sentry/services/sentry.js index 42952a0d9e..bb5f962530 100644 --- a/packages/strapi-plugin-sentry/services/sentry.js +++ b/packages/strapi-plugin-sentry/services/sentry.js @@ -30,6 +30,7 @@ const createSentryService = () => { Sentry.init({ dsn: settings.dsn, environment: strapi.config.environment, + ...settings.init, }); // Store the successfully initialized Sentry instance instance = Sentry;