diff --git a/package.json b/package.json index 1d86322dc..982898cd4 100644 --- a/package.json +++ b/package.json @@ -52,8 +52,8 @@ "@material-ui/icons": "^4.11.2", "@material-ui/lab": "^4.0.0-alpha.60", "@material-ui/styles": "^4.11.4", - "@sentry/react": "^6.18.2", - "@sentry/tracing": "^6.18.2", + "@sentry/react": "^6.19.7", + "@sentry/tracing": "^6.19.7", "@turf/boolean-point-in-polygon": "^6.5.0", "@turf/center": "^6.3.0", "@turf/destination": "^6.5.0", diff --git a/server/src/configs/custom-environment-variables.json b/server/src/configs/custom-environment-variables.json index 36b4896e8..763dbb187 100644 --- a/server/src/configs/custom-environment-variables.json +++ b/server/src/configs/custom-environment-variables.json @@ -18,7 +18,11 @@ "__name": "DEV_OPTIONS_QUERY_DEBUG", "__format": "boolean" }, - "clientPath": "DEV_OPTIONS_CLIENT_PATH" + "clientPath": "DEV_OPTIONS_CLIENT_PATH", + "clientErrors": { + "__name": "DEV_OPTIONS_CLIENT_ERRORS", + "__format": "boolean" + } }, "api": { "sessionSecret": "API_SESSION_SECRET", diff --git a/server/src/configs/default.json b/server/src/configs/default.json index 9581167d9..f7e4e6005 100644 --- a/server/src/configs/default.json +++ b/server/src/configs/default.json @@ -6,7 +6,8 @@ "enabled": false, "graphiql": false, "queryDebug": false, - "clientPath": "../../dist" + "clientPath": "../../dist", + "clientErrors": false }, "api": { "sessionSecret": "98ki^e72~!@#(85o3kXLI*#c9wu5l!Z", diff --git a/server/src/routes/rootRouter.js b/server/src/routes/rootRouter.js index ac4e2a07a..048de4f54 100644 --- a/server/src/routes/rootRouter.js +++ b/server/src/routes/rootRouter.js @@ -10,6 +10,7 @@ const Utility = require('../services/Utility') const Fetch = require('../services/Fetch') const { User } = require('../models/index') const { Event, Db } = require('../services/initialization') +const { version } = require('../../../package.json') const rootRouter = new express.Router() @@ -24,6 +25,16 @@ rootRouter.get('/logout', (req, res) => { res.redirect('/') }) +rootRouter.post('/clientError', (req) => { + if (req.headers.version === version && req.isAuthenticated()) { + const { body: { error }, user } = req + const userName = user?.username || user?.discordId || user?.telegramId || user?.id || 'Unknown' + if (error && config.devOptions.clientErrors) { + console.error('[CLIENT]', error, `- User: ${userName}`) + } + } +}) + rootRouter.get('/area/:area/:zoom?', (req, res) => { const { area, zoom } = req.params try { diff --git a/src/components/layout/dialogs/webhooks/Manage.jsx b/src/components/layout/dialogs/webhooks/Manage.jsx index 3290d0330..b0c1edfc0 100644 --- a/src/components/layout/dialogs/webhooks/Manage.jsx +++ b/src/components/layout/dialogs/webhooks/Manage.jsx @@ -70,7 +70,7 @@ export default function Manage({ action: () => setAddNew(true), icon: tabValue ? 'Add' : 'People', key: 'addNew', - disabled: !webhookData[selectedWebhook].human, + disabled: !webhookData[selectedWebhook]?.human, }, { name: 'close', action: handleWebhookClose, icon: 'Close', color: 'primary' }, ] diff --git a/src/index.jsx b/src/index.jsx index b4b727930..abf3a41c0 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -25,8 +25,23 @@ if (inject) { release: VERSION, environment: DEVELOPMENT ? 'development' : 'production', debug: SENTRY_DEBUG, - beforeSend(event) { - return CUSTOM ? null : event + beforeSend: async (event) => { + const errors = event.exception.values + const isLibrary = errors.find(e => e?.value?.includes('_')) + const fetchError = errors.find(e => e?.value?.includes('<')) + + if (!isLibrary) { + const error = errors[0] ? `${errors[0].type}: ${errors[0].value}` : 'Unknown error' + await fetch('/clientError', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + version: VERSION, + }, + body: JSON.stringify({ error }), + }) + } + return CUSTOM || isLibrary || fetchError ? null : event }, }) // eslint-disable-next-line no-console diff --git a/yarn.lock b/yarn.lock index 71128da84..922310473 100644 --- a/yarn.lock +++ b/yarn.lock @@ -351,14 +351,14 @@ resolved "https://registry.yarnpkg.com/@react-leaflet/core/-/core-1.1.1.tgz#827fd05bb542cf874116176d8ef48d5b12163f81" integrity sha512-7PGLWa9MZ5x/cWy8EH2VzI4T8q5WpuHbixzCDXqixP/WyqwIrg5NDUPgYuFnB4IEIZF+6nA265mYzswFo/h1Pw== -"@sentry/browser@6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.18.2.tgz#f980add635c242420a7f0c4dd3ed5668f1f39513" - integrity sha512-EsqKSNboi2gOiMuEwQranLucxrARi00y2vgUnaPXcqTKTlVlHDetoWHvq8/r29idA1JHGka5tDrwrmWccWIkrg== - dependencies: - "@sentry/core" "6.18.2" - "@sentry/types" "6.18.2" - "@sentry/utils" "6.18.2" +"@sentry/browser@6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.19.7.tgz#a40b6b72d911b5f1ed70ed3b4e7d4d4e625c0b5f" + integrity sha512-oDbklp4O3MtAM4mtuwyZLrgO1qDVYIujzNJQzXmi9YzymJCuzMLSRDvhY83NNDCRxf0pds4DShgYeZdbSyKraA== + dependencies: + "@sentry/core" "6.19.7" + "@sentry/types" "6.19.7" + "@sentry/utils" "6.19.7" tslib "^1.9.3" "@sentry/cli@^1.73.0": @@ -373,69 +373,69 @@ progress "^2.0.3" proxy-from-env "^1.1.0" -"@sentry/core@6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.18.2.tgz#d27619b7b4a4b90e2cfdc254d40ee9d630b251b9" - integrity sha512-r5ad/gq5S/JHc9sd5CUhZQT9ojQ+f+thk/AoGeGawX/8HURZYAgIqD565d6FK0VsZEDkdRMl58z1Qon20h3y1g== +"@sentry/core@6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.19.7.tgz#156aaa56dd7fad8c89c145be6ad7a4f7209f9785" + integrity sha512-tOfZ/umqB2AcHPGbIrsFLcvApdTm9ggpi/kQZFkej7kMphjT+SGBiQfYtjyg9jcRW+ilAR4JXC9BGKsdEQ+8Vw== dependencies: - "@sentry/hub" "6.18.2" - "@sentry/minimal" "6.18.2" - "@sentry/types" "6.18.2" - "@sentry/utils" "6.18.2" + "@sentry/hub" "6.19.7" + "@sentry/minimal" "6.19.7" + "@sentry/types" "6.19.7" + "@sentry/utils" "6.19.7" tslib "^1.9.3" -"@sentry/hub@6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.18.2.tgz#fdb8536f61899fd48f3d1b49a6957348ad729ec5" - integrity sha512-d0AugekMkbnN12b4EXMjseJxtLPc9S20DGobCPUb4oAQT6S2oDQEj1jwP6PQ5vtgyy+GMYWxBMgqAQ4pjVYISQ== +"@sentry/hub@6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.19.7.tgz#58ad7776bbd31e9596a8ec46365b45cd8b9cfd11" + integrity sha512-y3OtbYFAqKHCWezF0EGGr5lcyI2KbaXW2Ik7Xp8Mu9TxbSTuwTe4rTntwg8ngPjUQU3SUHzgjqVB8qjiGqFXCA== dependencies: - "@sentry/types" "6.18.2" - "@sentry/utils" "6.18.2" + "@sentry/types" "6.19.7" + "@sentry/utils" "6.19.7" tslib "^1.9.3" -"@sentry/minimal@6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.18.2.tgz#581c2fc030b9c89f1fcdc3e4855b91ce6c95db56" - integrity sha512-n7KYuo34W2LxE+3dnZ47of7XHuORINCnXq66XH72eoj67tf0XeWbIhEJrYGmoLRyRfoCYYrBLWiDl/uTjLzrzQ== +"@sentry/minimal@6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.19.7.tgz#b3ee46d6abef9ef3dd4837ebcb6bdfd01b9aa7b4" + integrity sha512-wcYmSJOdvk6VAPx8IcmZgN08XTXRwRtB1aOLZm+MVHjIZIhHoBGZJYTVQS/BWjldsamj2cX3YGbGXNunaCfYJQ== dependencies: - "@sentry/hub" "6.18.2" - "@sentry/types" "6.18.2" + "@sentry/hub" "6.19.7" + "@sentry/types" "6.19.7" tslib "^1.9.3" -"@sentry/react@^6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.18.2.tgz#9ba69862c1cf0bd9a47870c8836358db7200c421" - integrity sha512-TgCgoiduaPLq/YDh1urF+ZckIGiIzhMFPHs9tlMaqFkEwPOOENJTiPiwTs56x39/2B0tn3XNfY8Un8kG5hsINQ== +"@sentry/react@^6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.19.7.tgz#58cc2d6da20f7d3b0df40638dfbbbc86c9c85caf" + integrity sha512-VzJeBg/v41jfxUYPkH2WYrKjWc4YiMLzDX0f4Zf6WkJ4v3IlDDSkX6DfmWekjTKBho6wiMkSNy2hJ1dHfGZ9jA== dependencies: - "@sentry/browser" "6.18.2" - "@sentry/minimal" "6.18.2" - "@sentry/types" "6.18.2" - "@sentry/utils" "6.18.2" + "@sentry/browser" "6.19.7" + "@sentry/minimal" "6.19.7" + "@sentry/types" "6.19.7" + "@sentry/utils" "6.19.7" hoist-non-react-statics "^3.3.2" tslib "^1.9.3" -"@sentry/tracing@^6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.18.2.tgz#163ecf0042aeb300c12952a91784fda6630085ef" - integrity sha512-hg6NLqrqJ5sUPTyWEQ2RqdnhQVnyLtx8II0IyWxQLDWD8UCe3Mu6G7mroDtakPWcP+lWz6OnKfMEfuhMcxR8fw== +"@sentry/tracing@^6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.19.7.tgz#54bb99ed5705931cd33caf71da347af769f02a4c" + integrity sha512-ol4TupNnv9Zd+bZei7B6Ygnr9N3Gp1PUrNI761QSlHtPC25xXC5ssSD3GMhBgyQrcvpuRcCFHVNNM97tN5cZiA== dependencies: - "@sentry/hub" "6.18.2" - "@sentry/minimal" "6.18.2" - "@sentry/types" "6.18.2" - "@sentry/utils" "6.18.2" + "@sentry/hub" "6.19.7" + "@sentry/minimal" "6.19.7" + "@sentry/types" "6.19.7" + "@sentry/utils" "6.19.7" tslib "^1.9.3" -"@sentry/types@6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.18.2.tgz#f528fec8b75c19d5a6976004e71703184c6cf7be" - integrity sha512-WzpJf/Q5aORTzrSwer/As1NlO90dBAQpaHV2ikDDKqOyMWEgjKb5/4gh59p9gH8JMMnLetP1AvQel0fOj5UnUw== +"@sentry/types@6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.19.7.tgz#c6b337912e588083fc2896eb012526cf7cfec7c7" + integrity sha512-jH84pDYE+hHIbVnab3Hr+ZXr1v8QABfhx39KknxqKWr2l0oEItzepV0URvbEhB446lk/S/59230dlUUIBGsXbg== -"@sentry/utils@6.18.2": - version "6.18.2" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.18.2.tgz#c572a3ff49113e7dc4c97db1a18d117f199b9fff" - integrity sha512-EC619jesknyu4xpwud5WC/5odYLz6JUy7OSFy5405PpdGeh/m8XUvuJAx4zDx0Iz/Mlk0S1Md+ZcQwqkv39dkw== +"@sentry/utils@6.19.7": + version "6.19.7" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.19.7.tgz#6edd739f8185fd71afe49cbe351c1bbf5e7b7c79" + integrity sha512-z95ECmE3i9pbWoXQrD/7PgkBAzJYR+iXtPuTkpBjDKs86O3mT+PXOT3BAn79w2wkn7/i3vOGD2xVr1uiMl26dA== dependencies: - "@sentry/types" "6.18.2" + "@sentry/types" "6.19.7" tslib "^1.9.3" "@sindresorhus/is@^0.14.0":