From f86c19f086127eb8d47b238b4683fd2499af40ec Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 17:21:11 +0200 Subject: [PATCH 01/33] Configure @sentry/next using "npx @sentry/wizard -i nextjs" + removed auth.token from sentry.properties to avoid leaking sensitive token (need to find a way to configure it securely, probably through env var) --- next.config.js | 19 ++++- package.json | 1 + sentry.client.config.js | 14 ++++ sentry.properties | 4 + sentry.server.config.js | 14 ++++ yarn.lock | 165 +++++++++++++++++++++++++++++++++++++++- 6 files changed, 211 insertions(+), 6 deletions(-) create mode 100644 sentry.client.config.js create mode 100644 sentry.properties create mode 100644 sentry.server.config.js diff --git a/next.config.js b/next.config.js index f7055202..aaa25bb9 100644 --- a/next.config.js +++ b/next.config.js @@ -3,6 +3,7 @@ const nextSourceMaps = require('@zeit/next-source-maps'); const createNextPluginPreval = require('next-plugin-preval/config'); const packageJson = require('./package'); const i18nConfig = require('./src/modules/core/i18n/i18nConfig'); +const { withSentryConfig } = require('@sentry/nextjs'); const withNextPluginPreval = createNextPluginPreval(); const withSourceMaps = nextSourceMaps(); @@ -17,6 +18,16 @@ const publicBasePaths = ['robots', 'static', 'favicon.ico']; // All items (folde const noRedirectBasePaths = [...supportedLocales, ...publicBasePaths, ...noRedirectBlacklistedPaths]; // Will disable url rewrite for those items (should contain all supported languages and all public base paths) const date = new Date(); const GIT_COMMIT_SHA_SHORT = typeof process.env.GIT_COMMIT_SHA === 'string' && process.env.GIT_COMMIT_SHA.substring(0, 8); +const SentryWebpackPluginOptions = { + // Additional config options for the Sentry Webpack plugin. Keep in mind that + // the following options are set automatically, and overriding them is not + // recommended: + // release, url, org, project, authToken, configFile, stripPrefix, + // urlPrefix, include, ignore + // For all available options, see: + // https://github.com/getsentry/sentry-webpack-plugin#options. + debug: process.env.NODE_ENV === 'development', +}; console.debug(`Building Next with NODE_ENV="${process.env.NODE_ENV}" NEXT_PUBLIC_APP_STAGE="${process.env.NEXT_PUBLIC_APP_STAGE}" for NEXT_PUBLIC_CUSTOMER_REF="${process.env.NEXT_PUBLIC_CUSTOMER_REF}" using GIT_COMMIT_SHA=${process.env.GIT_COMMIT_SHA} and GIT_COMMIT_REF=${process.env.GIT_COMMIT_REF}`); @@ -35,14 +46,18 @@ console.debug(`Release version resolved from tags: "${APP_RELEASE_TAG}" (matchin * The below config applies to the whole application. * next.config.js gets used by the Next.js server and build phases, and it's not included in the browser build. * + * Make sure adding "withSentryConfig" is the last code to run before exporting, to ensure that your source maps include changes from all other Webpack plugins. + * * XXX Not all configuration options are listed below, we only kept those of most interest. * You'll need to dive into Next.js own documentation to find out about what's not included. * Basically, we focused on options that seemed important for a SSG/SSR app running on serverless mode (Vercel). * Also, we included some options by are not using them, this is mostly to help make you aware of those options, in case you'd need them. * * @see https://nextjs.org/docs/api-reference/next.config.js/introduction + * @see https://docs.sentry.io/platforms/javascript/guides/nextjs/ + * @see https://github.com/getsentry/sentry-webpack-plugin#options */ -module.exports = withNextPluginPreval(withBundleAnalyzer(withSourceMaps({ +module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSourceMaps({ // basepath: '', // If you want Next.js to cover only a subsection of the domain. See https://nextjs.org/docs/api-reference/next.config.js/basepath // target: 'serverless', // Automatically enabled on Vercel, you may need to manually opt-in if you're not using Vercel. See https://nextjs.org/docs/api-reference/next.config.js/build-target#serverless-target // trailingSlash: false, // By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. See https://nextjs.org/docs/api-reference/next.config.js/trailing-slash @@ -403,4 +418,4 @@ module.exports = withNextPluginPreval(withBundleAnalyzer(withSourceMaps({ // }, poweredByHeader: false, // See https://nextjs.org/docs/api-reference/next.config.js/disabling-x-powered-by -}))); +}))), SentryWebpackPluginOptions); diff --git a/package.json b/package.json index 28875f48..3a89ed5f 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "@fortawesome/free-solid-svg-icons": "5.15.3", "@fortawesome/react-fontawesome": "0.1.14", "@sentry/browser": "6.3.6", + "@sentry/nextjs": "6.6.0", "@sentry/node": "6.3.6", "@types/lodash.isequal": "4.5.5", "@unly/simple-logger": "1.0.0", diff --git a/sentry.client.config.js b/sentry.client.config.js new file mode 100644 index 00000000..98f9d7fa --- /dev/null +++ b/sentry.client.config.js @@ -0,0 +1,14 @@ +// This file configures the initialization of Sentry on the browser. +// The config you add here will be used whenever a page is visited. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from '@sentry/nextjs'; + +const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; + +Sentry.init({ + dsn: SENTRY_DSN, + // Note: if you want to override the automatic release value, do not set a + // `release` value here - use the environment variable `SENTRY_RELEASE`, so + // that it will also get attached to your source maps +}); diff --git a/sentry.properties b/sentry.properties new file mode 100644 index 00000000..3d1cd13d --- /dev/null +++ b/sentry.properties @@ -0,0 +1,4 @@ +defaults.url=https://sentry.io/ +defaults.org=unly +defaults.project=next-right-now +cli.executable=../../../.npm/_npx/a8388072043b4cbc/node_modules/@sentry/cli/bin/sentry-cli diff --git a/sentry.server.config.js b/sentry.server.config.js new file mode 100644 index 00000000..c4a9729b --- /dev/null +++ b/sentry.server.config.js @@ -0,0 +1,14 @@ +// This file configures the initialization of Sentry on the server. +// The config you add here will be used whenever the server handles a request. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from '@sentry/nextjs'; + +const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; + +Sentry.init({ + dsn: SENTRY_DSN, + // Note: if you want to override the automatic release value, do not set a + // `release` value here - use the environment variable `SENTRY_RELEASE`, so + // that it will also get attached to your source maps +}); diff --git a/yarn.lock b/yarn.lock index 424698c3..339985bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2580,6 +2580,28 @@ "@sentry/utils" "6.3.6" tslib "^1.9.3" +"@sentry/browser@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.6.0.tgz#1222c326593f0eecc68fb10e38bafce5fe4244f6" + integrity sha512-+FBGintTWlO/war3umfyHw2KoodWQFkMbMaudrkHfDgr2aRj8VAF7uWCW9V4XFT5Q7d1fMDvyUWG2C+SyPDBug== + dependencies: + "@sentry/core" "6.6.0" + "@sentry/types" "6.6.0" + "@sentry/utils" "6.6.0" + tslib "^1.9.3" + +"@sentry/cli@^1.63.1": + version "1.66.0" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.66.0.tgz#0526f1bc1c0570ce72ed817190af92f3b63a2e9a" + integrity sha512-2pZ+JHnvKqwyJWcGkKg/gCM/zURYronAnruBNllI+rH2g5IL0N90deMmjB1xcqXS66J222+MPTtWrGEK1Vl0/w== + dependencies: + https-proxy-agent "^5.0.0" + mkdirp "^0.5.5" + node-fetch "^2.6.0" + npmlog "^4.1.2" + progress "^2.0.3" + proxy-from-env "^1.1.0" + "@sentry/core@6.3.6": version "6.3.6" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.3.6.tgz#e2ec6ae7e456e61f28000bab2d8ce85f58c59c66" @@ -2591,6 +2613,17 @@ "@sentry/utils" "6.3.6" tslib "^1.9.3" +"@sentry/core@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.6.0.tgz#51661d2dd5023d6cd07467422de1854282ced7e5" + integrity sha512-EjdeT6paAdxAZgfsVCB8wneahQF3nAUt9GxOJxaOBUv8BSc3HQ/svcTU3RU7k8YsP26PseEOIsedaxsEVZ+7og== + dependencies: + "@sentry/hub" "6.6.0" + "@sentry/minimal" "6.6.0" + "@sentry/types" "6.6.0" + "@sentry/utils" "6.6.0" + tslib "^1.9.3" + "@sentry/hub@6.3.6": version "6.3.6" resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.3.6.tgz#e7bc6960e30d8731e23c6e77f31af0bfb1d5af3c" @@ -2600,6 +2633,25 @@ "@sentry/utils" "6.3.6" tslib "^1.9.3" +"@sentry/hub@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.6.0.tgz#1b9fa22ee104b7d6afd2dc4c40a1459fda259366" + integrity sha512-1Yw0kbxcvO7njZUDGvCKB6DxU5jQio7Be3Kx5qxwcx8ojpT9lo9p+IYZajgl6zQqkjjbVm/4SoYqU24ozu5vxw== + dependencies: + "@sentry/types" "6.6.0" + "@sentry/utils" "6.6.0" + tslib "^1.9.3" + +"@sentry/integrations@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-6.6.0.tgz#9c2c3ab77d9dd11d0159913e7250560f3e0ecadd" + integrity sha512-MStwI3yAjVCZ5BY7aUMpHFe9sdU9tIG2U95Jq9YGvYkdFIAAR1IEHlHIpsEpEPo0OFW0RIsDEhQg19a0D4Z9VQ== + dependencies: + "@sentry/types" "6.6.0" + "@sentry/utils" "6.6.0" + localforage "^1.8.1" + tslib "^1.9.3" + "@sentry/minimal@6.3.6": version "6.3.6" resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.3.6.tgz#aebcebd2ee9007b0ec505b9fcefd10f10fc5d43d" @@ -2609,6 +2661,29 @@ "@sentry/types" "6.3.6" tslib "^1.9.3" +"@sentry/minimal@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.6.0.tgz#48684734e3c380e5e63a9357d05f0c18bae84419" + integrity sha512-xVBlZIDxSvHvNdvD5KmjTf8Xgi78vLpT4xqJaDUkW7B+DqWMVJZe5aUdQmcp7X/zWxctBwyMKsdHO7oiHkpS+Q== + dependencies: + "@sentry/hub" "6.6.0" + "@sentry/types" "6.6.0" + tslib "^1.9.3" + +"@sentry/nextjs@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/nextjs/-/nextjs-6.6.0.tgz#c037a84f4bf2c813f981c066ccad05581f46c6e9" + integrity sha512-UFI9cfwUoNWXTzTNWvzi13o6qc6qQcdDRBaomyZq4H4fVz2Hy5DSMsoFqsjtwHWgnQphkJbtutE76YebaLZaKA== + dependencies: + "@sentry/core" "6.6.0" + "@sentry/integrations" "6.6.0" + "@sentry/node" "6.6.0" + "@sentry/react" "6.6.0" + "@sentry/tracing" "6.6.0" + "@sentry/utils" "6.6.0" + "@sentry/webpack-plugin" "1.15.0" + tslib "^1.9.3" + "@sentry/node@6.3.6": version "6.3.6" resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.3.6.tgz#e584500a10a9162d47fc8b55c9bf2ac3fec8d9f9" @@ -2624,6 +2699,33 @@ lru_map "^0.3.3" tslib "^1.9.3" +"@sentry/node@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.6.0.tgz#e535e1e679cf894752810529ffdee93cbfd078f0" + integrity sha512-heKie/AOanYq3mCsKR1igPn1sUIxBmGibBp79Xc0iSAgliPKnnLkqUjvAIKu6mcevL9UOUhpMDLzhilkaG+bAA== + dependencies: + "@sentry/core" "6.6.0" + "@sentry/hub" "6.6.0" + "@sentry/tracing" "6.6.0" + "@sentry/types" "6.6.0" + "@sentry/utils" "6.6.0" + cookie "^0.4.1" + https-proxy-agent "^5.0.0" + lru_map "^0.3.3" + tslib "^1.9.3" + +"@sentry/react@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.6.0.tgz#f451e075c276881d127c1c847952170b18fde9f3" + integrity sha512-8uB1dMLzhcnbEH/196tVQ1+fjZcF9h0M5JTg2P9ZUkMHoLxnHU1NqG+UrHxWlKcHm2Jajey85YxkX6KqZFhBBA== + dependencies: + "@sentry/browser" "6.6.0" + "@sentry/minimal" "6.6.0" + "@sentry/types" "6.6.0" + "@sentry/utils" "6.6.0" + hoist-non-react-statics "^3.3.2" + tslib "^1.9.3" + "@sentry/tracing@6.3.6": version "6.3.6" resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.3.6.tgz#dc2aced01cdc401f97d6027113f6313503ee9c91" @@ -2635,11 +2737,27 @@ "@sentry/utils" "6.3.6" tslib "^1.9.3" +"@sentry/tracing@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.6.0.tgz#ce62fcb951faa6447cf47889f91efe3617b9eed2" + integrity sha512-tjXrmAOFfVBfx+ZmgE5bkpDPs/euNj0xrUg8MowCWGfCRn01W679tTb+dyNeP6faxQTo2RcaD68xD8oLroJwwA== + dependencies: + "@sentry/hub" "6.6.0" + "@sentry/minimal" "6.6.0" + "@sentry/types" "6.6.0" + "@sentry/utils" "6.6.0" + tslib "^1.9.3" + "@sentry/types@6.3.6": version "6.3.6" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.3.6.tgz#aa3687051af1dc04ebc4eaf7f9562872da67aa5c" integrity sha512-93cFJdJkWyCfyZeWFARSU11qnoHVOS/R2h5WIsEf+jbQmkqG2C+TXVz/19s6nHVsfDrwpvYpwALPv4/nrxfU7g== +"@sentry/types@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.6.0.tgz#55cbca23859bad87411f0f32135a968e6e40a639" + integrity sha512-lZ1uFN0lSNftAohi0lciEoSL58Gk/Ib1lLKaj0FSOvB1PAUmvo5dPtLdd0qjtNdtoaM8zqhrAbwCTQ8XZCDRsg== + "@sentry/utils@6.3.6": version "6.3.6" resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.3.6.tgz#6f619a525f2a94fa6b160500f63f4bd5bd171055" @@ -2648,6 +2766,21 @@ "@sentry/types" "6.3.6" tslib "^1.9.3" +"@sentry/utils@6.6.0": + version "6.6.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.6.0.tgz#b34d342d05eefc25b7ddd3f27f41c050f1e7e1ef" + integrity sha512-FK9yqz2x+ef50B54tueeJ6mfb7Pf3lN75omx/YQBDL5cicyOV4j4kJDqn8/VKYhcSuX+ZaCZ/8bvOf0lxe0aHg== + dependencies: + "@sentry/types" "6.6.0" + tslib "^1.9.3" + +"@sentry/webpack-plugin@1.15.0": + version "1.15.0" + resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.15.0.tgz#c7f9eafbbace1929c3fb81bb720fc0d7e8b4f86d" + integrity sha512-KHVug+xI+KH/xCL7otWcRRszw0rt6i/BCH5F8+6/njz2gCBrYQOzdMvzWm4GeXZUuw5ekgycYaUhDs1/6enjuQ== + dependencies: + "@sentry/cli" "^1.63.1" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" @@ -9999,7 +10132,7 @@ hoist-non-react-statics@^2.3.1: resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.5.tgz#c5903cf409c0dfd908f388e619d86b9c1174cb47" integrity sha512-rqcy4pJo55FTTLWt+bU8ukscqHeE/e9KWvsOW2b/a3afxQZhwkQdT1rPPCJ0rYXdj4vNcasY8zHTH+jF/qStxw== -hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.1: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.1, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -10226,6 +10359,11 @@ ignore@^5.1.1, ignore@^5.1.4: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf" integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A== +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha1-nbHb0Pr43m++D13V5Wu2BigN5ps= + immer@8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656" @@ -11811,6 +11949,13 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +lie@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" + integrity sha1-mkNrLMd0bKWd56QfpGmz77dr2H4= + dependencies: + immediate "~3.0.5" + lines-and-columns@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" @@ -11892,6 +12037,13 @@ loader-utils@^1.0.0, loader-utils@^1.0.2, loader-utils@^1.2.3, loader-utils@^1.4 emojis-list "^3.0.0" json5 "^1.0.1" +localforage@^1.8.1: + version "1.9.0" + resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.9.0.tgz#f3e4d32a8300b362b4634cc4e066d9d00d2f09d1" + integrity sha512-rR1oyNrKulpe+VM9cYmcFn6tsHuokyVHFaCM3+osEmxaHTbEk8oQu6eGDfS6DQLWi/N67XRmB8ECG37OES368g== + dependencies: + lie "3.1.1" + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -12674,7 +12826,7 @@ mkdirp@^0.5.1, mkdirp@~0.5.1: dependencies: minimist "0.0.8" -mkdirp@^0.5.3: +mkdirp@^0.5.3, mkdirp@^0.5.5: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== @@ -12933,7 +13085,7 @@ node-ensure@^0.0.0: resolved "https://registry.yarnpkg.com/node-ensure/-/node-ensure-0.0.0.tgz#ecae764150de99861ec5c810fd5d096b183932a7" integrity sha1-7K52QVDemYYexcgQ/V0Jaxg5Mqc= -node-fetch@2.6.1, node-fetch@^2.6.1: +node-fetch@2.6.1, node-fetch@^2.6.0, node-fetch@^2.6.1: version "2.6.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== @@ -14078,7 +14230,7 @@ process@0.11.10, process@^0.11.10: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= -progress@^2.0.0: +progress@^2.0.0, progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== @@ -14162,6 +14314,11 @@ proxy-addr@~2.0.5: forwarded "~0.1.2" ipaddr.js "1.9.1" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" From 5d526cf916b727cb8b7e1cfd7b21edac4cb56e7f Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 17:25:47 +0200 Subject: [PATCH 02/33] Misc --- next.config.js | 4 ++-- src/app/components/MultiversalAppBootstrap.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/next.config.js b/next.config.js index aaa25bb9..fcdd5ffc 100644 --- a/next.config.js +++ b/next.config.js @@ -18,7 +18,7 @@ const publicBasePaths = ['robots', 'static', 'favicon.ico']; // All items (folde const noRedirectBasePaths = [...supportedLocales, ...publicBasePaths, ...noRedirectBlacklistedPaths]; // Will disable url rewrite for those items (should contain all supported languages and all public base paths) const date = new Date(); const GIT_COMMIT_SHA_SHORT = typeof process.env.GIT_COMMIT_SHA === 'string' && process.env.GIT_COMMIT_SHA.substring(0, 8); -const SentryWebpackPluginOptions = { +const sentryWebpackPluginOptions = { // Additional config options for the Sentry Webpack plugin. Keep in mind that // the following options are set automatically, and overriding them is not // recommended: @@ -418,4 +418,4 @@ module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSo // }, poweredByHeader: false, // See https://nextjs.org/docs/api-reference/next.config.js/disabling-x-powered-by -}))), SentryWebpackPluginOptions); +}))), sentryWebpackPluginOptions); diff --git a/src/app/components/MultiversalAppBootstrap.tsx b/src/app/components/MultiversalAppBootstrap.tsx index fd830726..daebb961 100644 --- a/src/app/components/MultiversalAppBootstrap.tsx +++ b/src/app/components/MultiversalAppBootstrap.tsx @@ -64,7 +64,7 @@ const MultiversalAppBootstrap: React.FunctionComponent = (props): JSX.Ele // When using SSG with "fallback: true" and the page hasn't been generated yet then isSSGFallbackInitialBuild is true const [isSSGFallbackInitialBuild] = useState(isEmpty(pageProps) && router?.isFallback === true); const pageComponentName = getComponentName(props.Component); - + logger.log('process.env.NEXT_PUBLIC_SENTRY_DSN', process.env.NEXT_PUBLIC_SENTRY_DSN); Sentry.addBreadcrumb({ // See https://docs.sentry.io/enriching-error-data/breadcrumbs category: fileLabel, message: `Rendering ${fileLabel}`, From 0cd0cd76dd0a10b1619e47570ee538d17bfd9353 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 20:43:42 +0200 Subject: [PATCH 03/33] Use @sentry/nextjs instead of @sentry/node --- .env.local.example | 6 ++ .storybook/webpack.config.js | 4 - next.config.js | 20 +---- package.json | 2 - src/app/components/BrowserPageBootstrap.tsx | 2 +- .../components/MultiversalAppBootstrap.tsx | 2 +- src/app/components/ServerPageBootstrap.tsx | 2 +- .../components/dataDisplay/Markdown.tsx | 2 +- src/common/utils/mobile.ts | 2 +- .../core/airtable/applyRecordFallback.ts | 2 +- .../core/airtable/fetchAirtableTable.ts | 2 +- .../core/airtable/sanitizeRawAirtableDS.ts | 2 +- src/modules/core/amplitude/amplitude.ts | 4 +- .../cookiesManager/UniversalCookiesManager.ts | 2 +- src/modules/core/css/css.ts | 2 +- src/modules/core/data/record.ts | 2 +- .../core/errorHandling/DefaultErrorLayout.tsx | 3 +- src/modules/core/i18n/i18n.ts | 2 +- src/modules/core/i18n/i18nextLocize.ts | 2 +- src/modules/core/js/url.ts | 2 +- src/modules/core/sentry/sentry.ts | 14 ++-- src/modules/core/userConsent/cookieConsent.ts | 2 +- .../core/vercelCache/diskCacheStorage.ts | 2 +- src/modules/core/vercelCache/hybridCache.ts | 2 +- .../demo/built-in-features/md-as-jsx.tsx | 2 +- src/pages/_document.tsx | 2 +- src/pages/_error.tsx | 2 +- yarn.lock | 78 ------------------- 28 files changed, 37 insertions(+), 134 deletions(-) diff --git a/.env.local.example b/.env.local.example index f3128e5c..1e0ac3f4 100644 --- a/.env.local.example +++ b/.env.local.example @@ -55,3 +55,9 @@ SENTRY_DSN= # Optional - If not set, the app will work anyway, it just won't be able to deploy new instances through the "startVercelDeployment" API # Example (fake value): 278c560c1314b8b032c1314b856072bdaaaaaaaa GITHUB_DISPATCH_TOKEN= + +# Sentry authentication token, can be found under "Settings => Account => API => Auth Tokens" at https://sentry.io/settings/account/api/auth-tokens/ +# Used to send soure maps to Sentry +# See https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#environment-variables +# Requires project:releases and org:read - See https://github.com/getsentry/sentry-webpack-plugin#options +SENTRY_AUTH_TOKEN= diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index 3e7ef366..ec7757d0 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -30,9 +30,5 @@ module.exports = async ({ console: true, }; - // XXX See https://github.com/vercel/next.js/blob/canary/examples/with-sentry-simple/next.config.js - // Because StoryBook only compiles for client and has no server runtime, we must replace backend-related libs like @sentry/node to their browser counterpart - config.resolve.alias['@sentry/node'] = '@sentry/browser'; - return config; }; diff --git a/next.config.js b/next.config.js index fcdd5ffc..dcda4795 100644 --- a/next.config.js +++ b/next.config.js @@ -27,6 +27,7 @@ const sentryWebpackPluginOptions = { // For all available options, see: // https://github.com/getsentry/sentry-webpack-plugin#options. debug: process.env.NODE_ENV === 'development', + // silent: true, // Suppresses all logs }; console.debug(`Building Next with NODE_ENV="${process.env.NODE_ENV}" NEXT_PUBLIC_APP_STAGE="${process.env.NEXT_PUBLIC_APP_STAGE}" for NEXT_PUBLIC_CUSTOMER_REF="${process.env.NEXT_PUBLIC_CUSTOMER_REF}" using GIT_COMMIT_SHA=${process.env.GIT_COMMIT_SHA} and GIT_COMMIT_REF=${process.env.GIT_COMMIT_REF}`); @@ -366,25 +367,6 @@ module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSo console.debug(`[webpack] Building release "${APP_VERSION_RELEASE}" using NODE_ENV="${process.env.NODE_ENV}" ${process.env.IS_SERVER_INITIAL_BUILD ? 'with IS_SERVER_INITIAL_BUILD="1"' : ''}`); } - // XXX See https://github.com/vercel/next.js/blob/canary/examples/with-sentry-simple/next.config.js - // In `pages/_app.js`, Sentry is imported from @sentry/node. While - // @sentry/browser will run in a Node.js environment, @sentry/node will use - // Node.js-only APIs to catch even more unhandled exceptions. - // - // This works well when Next.js is SSRing your page on a server with - // Node.js, but it is not what we want when your client-side bundle is being - // executed by a browser. - // - // Luckily, Next.js will call this webpack function twice, once for the - // server and once for the client. Read more: - // https://nextjs.org/docs#customizing-webpack-config - // - // So ask Webpack to replace @sentry/node imports with @sentry/browser when - // building the browser's bundle - if (!isServer) { - config.resolve.alias['@sentry/node'] = '@sentry/browser'; - } - return config; }, diff --git a/package.json b/package.json index 3a89ed5f..05591d6f 100644 --- a/package.json +++ b/package.json @@ -115,9 +115,7 @@ "@fortawesome/free-regular-svg-icons": "5.15.3", "@fortawesome/free-solid-svg-icons": "5.15.3", "@fortawesome/react-fontawesome": "0.1.14", - "@sentry/browser": "6.3.6", "@sentry/nextjs": "6.6.0", - "@sentry/node": "6.3.6", "@types/lodash.isequal": "4.5.5", "@unly/simple-logger": "1.0.0", "@unly/universal-language-detector": "2.0.3", diff --git a/src/app/components/BrowserPageBootstrap.tsx b/src/app/components/BrowserPageBootstrap.tsx index 4710c68c..128f709a 100644 --- a/src/app/components/BrowserPageBootstrap.tsx +++ b/src/app/components/BrowserPageBootstrap.tsx @@ -34,7 +34,7 @@ import { AmplitudeProvider, } from '@amplitude/react-amplitude'; import { useTheme } from '@emotion/react'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { AmplitudeClient } from 'amplitude-js'; import React from 'react'; import { useTranslation } from 'react-i18next'; diff --git a/src/app/components/MultiversalAppBootstrap.tsx b/src/app/components/MultiversalAppBootstrap.tsx index daebb961..162f8eea 100644 --- a/src/app/components/MultiversalAppBootstrap.tsx +++ b/src/app/components/MultiversalAppBootstrap.tsx @@ -29,7 +29,7 @@ import { NotFound404PageName } from '@/pages/404'; import ErrorPage from '@/pages/_error'; import { NO_AUTO_PREVIEW_MODE_KEY } from '@/pages/api/preview'; import { ThemeProvider } from '@emotion/react'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { isBrowser } from '@unly/utils'; import { i18n } from 'i18next'; import isEmpty from 'lodash.isempty'; diff --git a/src/app/components/ServerPageBootstrap.tsx b/src/app/components/ServerPageBootstrap.tsx index 4f5f06e0..0b5c2740 100644 --- a/src/app/components/ServerPageBootstrap.tsx +++ b/src/app/components/ServerPageBootstrap.tsx @@ -3,7 +3,7 @@ import { OnlyServerPageProps } from '@/layouts/core/types/OnlyServerPageProps'; import { createLogger } from '@/modules/core/logging/logger'; import { configureSentryUser } from '@/modules/core/sentry/sentry'; import { userSessionContext } from '@/modules/core/userSession/userSessionContext'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import React from 'react'; import { MultiversalAppBootstrapPageProps } from '../types/MultiversalAppBootstrapPageProps'; import { MultiversalAppBootstrapProps } from '../types/MultiversalAppBootstrapProps'; diff --git a/src/common/components/dataDisplay/Markdown.tsx b/src/common/components/dataDisplay/Markdown.tsx index bfaa9c96..c0a7d16a 100644 --- a/src/common/components/dataDisplay/Markdown.tsx +++ b/src/common/components/dataDisplay/Markdown.tsx @@ -3,7 +3,7 @@ import { Markdown as MarkdownType } from '@/modules/core/data/types/Markdown'; import I18nBtnChangeLocale from '@/modules/core/i18n/components/I18nBtnChangeLocale'; import I18nLink from '@/modules/core/i18n/components/I18nLink'; import { createLogger } from '@/modules/core/logging/logger'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import classnames from 'classnames'; import deepmerge from 'deepmerge'; import MarkdownToJSXLib, { MarkdownToJSX } from 'markdown-to-jsx'; diff --git a/src/common/utils/mobile.ts b/src/common/utils/mobile.ts index c9c538a3..735038ce 100644 --- a/src/common/utils/mobile.ts +++ b/src/common/utils/mobile.ts @@ -1,5 +1,5 @@ import { createLogger } from '@/modules/core/logging/logger'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { isBrowser } from '@unly/utils'; const fileLabel = 'common/utils/mobile'; diff --git a/src/modules/core/airtable/applyRecordFallback.ts b/src/modules/core/airtable/applyRecordFallback.ts index f078f6f8..d58cca5b 100644 --- a/src/modules/core/airtable/applyRecordFallback.ts +++ b/src/modules/core/airtable/applyRecordFallback.ts @@ -1,4 +1,4 @@ -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import map from 'lodash.map'; import { AirtableRecord } from '../data/types/AirtableRecord'; import { GenericObject } from '../data/types/GenericObject'; diff --git a/src/modules/core/airtable/fetchAirtableTable.ts b/src/modules/core/airtable/fetchAirtableTable.ts index b91e4366..3b879e89 100644 --- a/src/modules/core/airtable/fetchAirtableTable.ts +++ b/src/modules/core/airtable/fetchAirtableTable.ts @@ -1,5 +1,5 @@ import { createLogger } from '@/modules/core/logging/logger'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import deepmerge from 'deepmerge'; import map from 'lodash.map'; import size from 'lodash.size'; diff --git a/src/modules/core/airtable/sanitizeRawAirtableDS.ts b/src/modules/core/airtable/sanitizeRawAirtableDS.ts index 90622f06..e590bd34 100644 --- a/src/modules/core/airtable/sanitizeRawAirtableDS.ts +++ b/src/modules/core/airtable/sanitizeRawAirtableDS.ts @@ -1,4 +1,4 @@ -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import cloneDeep from 'lodash.clonedeep'; import filter from 'lodash.filter'; import find from 'lodash.find'; diff --git a/src/modules/core/amplitude/amplitude.ts b/src/modules/core/amplitude/amplitude.ts index 97e2abe8..4b1743a3 100644 --- a/src/modules/core/amplitude/amplitude.ts +++ b/src/modules/core/amplitude/amplitude.ts @@ -5,7 +5,7 @@ import { ClientNetworkConnectionType, getClientNetworkConnectionType, } from '@/modules/core/networkInformation/networkInformation'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { isBrowser } from '@unly/utils'; import { AmplitudeClient, @@ -85,7 +85,7 @@ export const getAmplitudeInstance = (props: GetAmplitudeInstanceProps): Amplitud hasUserGivenAnyCookieConsent, } = userConsent; - Sentry.configureScope((scope) => { // See https://www.npmjs.com/package/@sentry/node + Sentry.configureScope((scope) => { // See https://docs.sentry.io/platforms/javascript/guides/nextjs/usage/ scope.setTag('networkSpeed', networkSpeed); scope.setTag('networkConnectionType', networkConnectionType); scope.setTag('iframe', `${isInIframe}`); diff --git a/src/modules/core/cookiesManager/UniversalCookiesManager.ts b/src/modules/core/cookiesManager/UniversalCookiesManager.ts index 4836bfa6..e73cc4d6 100644 --- a/src/modules/core/cookiesManager/UniversalCookiesManager.ts +++ b/src/modules/core/cookiesManager/UniversalCookiesManager.ts @@ -1,4 +1,4 @@ -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { COOKIE_LOOKUP_KEY_LANG } from '@unly/universal-language-detector/lib'; import { isBrowser } from '@unly/utils'; import ServerCookies, { diff --git a/src/modules/core/css/css.ts b/src/modules/core/css/css.ts index eac606e5..b109c4c9 100644 --- a/src/modules/core/css/css.ts +++ b/src/modules/core/css/css.ts @@ -1,5 +1,5 @@ import { createLogger } from '@/modules/core/logging/logger'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { getPropertyName } from 'css-to-react-native'; import isPlainObject from 'lodash.isplainobject'; import map from 'lodash.map'; diff --git a/src/modules/core/data/record.ts b/src/modules/core/data/record.ts index 216ae691..95e91622 100644 --- a/src/modules/core/data/record.ts +++ b/src/modules/core/data/record.ts @@ -1,5 +1,5 @@ import { createLogger } from '@/modules/core/logging/logger'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import cloneDeep from 'lodash.clonedeep'; import find from 'lodash.find'; import get from 'lodash.get'; diff --git a/src/modules/core/errorHandling/DefaultErrorLayout.tsx b/src/modules/core/errorHandling/DefaultErrorLayout.tsx index f349bb19..ef8f12f4 100644 --- a/src/modules/core/errorHandling/DefaultErrorLayout.tsx +++ b/src/modules/core/errorHandling/DefaultErrorLayout.tsx @@ -1,5 +1,5 @@ import { css } from '@emotion/react'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import * as React from 'react'; import { Button } from 'reactstrap'; import { GenericObject } from '../data/types/GenericObject'; @@ -48,7 +48,6 @@ const DefaultErrorLayout: React.FunctionComponent = (props): JSX.Element `} /> + +
+ +
+ +
); }; From 8389f3a473d59bb2f70376689fadff342f3d767b Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 21:21:14 +0200 Subject: [PATCH 06/33] Reorder env vars --- .env.local.example | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.env.local.example b/.env.local.example index 1e0ac3f4..97910702 100644 --- a/.env.local.example +++ b/.env.local.example @@ -47,6 +47,12 @@ LOCIZE_API_KEY= # Example (fake value): https://14fa1cae05079675b18cd05403ae5c48@sentry.io/1234567 SENTRY_DSN= +# Sentry authentication token, can be found under "Settings => Account => API => Auth Tokens" at https://sentry.io/settings/account/api/auth-tokens/ +# Used to send soure maps to Sentry +# See https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#environment-variables +# Requires project:releases and org:read - See https://github.com/getsentry/sentry-webpack-plugin#options +SENTRY_AUTH_TOKEN= + # Github "personal access token", can be generated at "Settings > Developer settings > Personal access tokens" at https://github.com/settings/tokens # Used by "Workflow Dispatch" GitHub Actions # Needs the following scopes: @@ -55,9 +61,3 @@ SENTRY_DSN= # Optional - If not set, the app will work anyway, it just won't be able to deploy new instances through the "startVercelDeployment" API # Example (fake value): 278c560c1314b8b032c1314b856072bdaaaaaaaa GITHUB_DISPATCH_TOKEN= - -# Sentry authentication token, can be found under "Settings => Account => API => Auth Tokens" at https://sentry.io/settings/account/api/auth-tokens/ -# Used to send soure maps to Sentry -# See https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#environment-variables -# Requires project:releases and org:read - See https://github.com/getsentry/sentry-webpack-plugin#options -SENTRY_AUTH_TOKEN= From 17db210a466b74f50fdad8a757670e699323530a Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 22:05:14 +0200 Subject: [PATCH 07/33] Add NEXT_PUBLIC_SENTRY_DSN --- next.config.js | 8 ++- process.env.d.ts | 2 + sentry.client.config.js | 10 ++-- sentry.server.config.js | 10 ++-- src/modules/core/sentry/sentry.ts | 86 +++++++++++++++---------------- 5 files changed, 65 insertions(+), 51 deletions(-) diff --git a/next.config.js b/next.config.js index dcda4795..050df8dc 100644 --- a/next.config.js +++ b/next.config.js @@ -26,7 +26,8 @@ const sentryWebpackPluginOptions = { // urlPrefix, include, ignore // For all available options, see: // https://github.com/getsentry/sentry-webpack-plugin#options. - debug: process.env.NODE_ENV === 'development', + + // debug: process.env.NODE_ENV === 'development', // silent: true, // Suppresses all logs }; @@ -77,7 +78,7 @@ module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSo reactStrictMode: true, /** - * Environment variables added to JS bundle + * Environment variables added to JS bundle. * * XXX All env variables defined in ".env*" files that aren't public (those that don't start with "NEXT_PUBLIC_") MUST manually be made available at build time below. * They're necessary on Vercel for runtime execution (SSR, SSG with revalidate, everything that happens server-side will need those). @@ -89,11 +90,13 @@ module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSo * @see https://nextjs.org/docs/api-reference/next.config.js/environment-variables */ env: { + // Most sensitive env variables GITHUB_DISPATCH_TOKEN: process.env.GITHUB_DISPATCH_TOKEN, AIRTABLE_API_KEY: process.env.AIRTABLE_API_KEY, AIRTABLE_BASE_ID: process.env.AIRTABLE_BASE_ID, LOCIZE_API_KEY: process.env.LOCIZE_API_KEY, SENTRY_DSN: process.env.SENTRY_DSN, + NEXT_PUBLIC_SENTRY_DSN: process.env.SENTRY_DSN, // Sentry DSN must be provided to the browser for error reporting to work there // Vercel env variables - See https://vercel.com/docs/environment-variables#system-environment-variables VERCEL: process.env.VERCEL, @@ -360,6 +363,7 @@ module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSo // Those variables are considered public because they are available at build time and at run time (they'll be replaced during initial build, by their value) plugin.definitions['process.env.NEXT_PUBLIC_APP_BUILD_ID'] = JSON.stringify(buildId); plugin.definitions['process.env.NEXT_PUBLIC_APP_VERSION_RELEASE'] = JSON.stringify(APP_VERSION_RELEASE); + plugin.definitions['process.env.SENTRY_RELEASE'] = JSON.stringify(APP_VERSION_RELEASE); // Necessary to forward it automatically to source maps } }); diff --git a/process.env.d.ts b/process.env.d.ts index 6871621a..5b2086cc 100644 --- a/process.env.d.ts +++ b/process.env.d.ts @@ -31,6 +31,8 @@ declare global { NEXT_PUBLIC_LOCIZE_PROJECT_ID: string; NEXT_PUBLIC_NRN_PRESET: string; SENTRY_DSN: string; + NEXT_PUBLIC_SENTRY_DSN: string; // Public version of SENTRY_DSN made available to the browser (value is identical to SENTRY_DSN) + SENTRY_RELEASE: string; // Git env variables GIT_COMMIT_SHA_SHORT: string; diff --git a/sentry.client.config.js b/sentry.client.config.js index 98f9d7fa..75cb5ec1 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -3,12 +3,16 @@ // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import * as Sentry from '@sentry/nextjs'; - -const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; +import { configureSentry } from './src/modules/core/sentry/sentry'; Sentry.init({ - dsn: SENTRY_DSN, + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + enabled: process.env.NODE_ENV !== 'test', + environment: process.env.NEXT_PUBLIC_APP_STAGE, + // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps }); + +configureSentry(); diff --git a/sentry.server.config.js b/sentry.server.config.js index c4a9729b..87da27df 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -3,12 +3,16 @@ // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import * as Sentry from '@sentry/nextjs'; - -const SENTRY_DSN = process.env.SENTRY_DSN || process.env.NEXT_PUBLIC_SENTRY_DSN; +import { configureSentry } from './src/modules/core/sentry/sentry'; Sentry.init({ - dsn: SENTRY_DSN, + dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, + enabled: process.env.NODE_ENV !== 'test', + environment: process.env.NEXT_PUBLIC_APP_STAGE, + // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so // that it will also get attached to your source maps }); + +configureSentry(); diff --git a/src/modules/core/sentry/sentry.ts b/src/modules/core/sentry/sentry.ts index c30cd8c8..709aa32a 100644 --- a/src/modules/core/sentry/sentry.ts +++ b/src/modules/core/sentry/sentry.ts @@ -6,47 +6,6 @@ import { convertRequestBodyToJSObject } from '../api/convertRequestBodyToJSObjec import { GenericObject } from '../data/types/GenericObject'; import { UserSession } from '../userSession/useUserSession'; -/** - * Initialize Sentry and export it. - * - * Helper to avoid duplicating the init() call in every /pages/api file. - * Also used in pages/_app for the client side, which automatically applies it for all frontend pages. - * - * Doesn't initialise Sentry if SENTRY_DSN isn't defined - * - * @see https://www.npmjs.com/package/@sentry/nextjs - */ -if (process.env.SENTRY_DSN) { - Sentry.init({ - dsn: process.env.SENTRY_DSN, - enabled: process.env.NODE_ENV !== 'test', - environment: process.env.NEXT_PUBLIC_APP_STAGE, - release: process.env.NEXT_PUBLIC_APP_VERSION_RELEASE, - }); - - if (!process.env.SENTRY_DSN && process.env.NODE_ENV !== 'test') { - // eslint-disable-next-line no-console - console.error('Sentry DSN not defined'); - } - - // Scope configured by default, subsequent calls to "configureScope" will add additional data - Sentry.configureScope((scope) => { // See https://www.npmjs.com/package/@sentry/nextjs - scope.setTag('customerRef', process.env.NEXT_PUBLIC_CUSTOMER_REF); - scope.setTag('appStage', process.env.NEXT_PUBLIC_APP_STAGE); - scope.setTag('appName', process.env.NEXT_PUBLIC_APP_NAME); - scope.setTag('appBaseUrl', process.env.NEXT_PUBLIC_APP_BASE_URL); - scope.setTag('appVersion', process.env.NEXT_PUBLIC_APP_VERSION); - scope.setTag('appNameVersion', process.env.NEXT_PUBLIC_APP_NAME_VERSION); - scope.setTag('appBuildTime', process.env.NEXT_PUBLIC_APP_BUILD_TIME); - scope.setTag('buildTimeISO', (new Date(process.env.NEXT_PUBLIC_APP_BUILD_TIME || null)).toISOString()); - scope.setTag('appBuildId', process.env.NEXT_PUBLIC_APP_BUILD_ID); - scope.setTag('nodejs', process.version); - scope.setTag('nodejsAWS', process.env.AWS_EXECUTION_ENV || null); // Optional - Available on production environment only - scope.setTag('memory', process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || null); // Optional - Available on production environment only - scope.setTag('runtimeEngine', isBrowser() ? 'browser' : 'server'); - }); -} - /** * Alert types, meant to be assigned to "alertType" tag when reporting a message/exception/event to Sentry. * @@ -63,6 +22,45 @@ export const ALERT_TYPES = { VERCEL_DEPLOYMENT_COMPLETED: 'vercel-deployment-completed', }; +/** + * Configure Sentry default scope. + * + * Used by both sentry config files (client/server). + * Doesn't configure Sentry if NEXT_PUBLIC_SENTRY_DSN isn't defined. + * + * Automatically applied on the browser, thanks to @sentry/nextjs. + * Automatically applied on the server, thanks to @sentry/nextjs when "withSentry" HOC is used. + * + * @see https://www.npmjs.com/package/@sentry/nextjs + * @see https://docs.sentry.io/platforms/javascript/guides/nextjs/ + * @see https://docs.sentry.io/platforms/javascript/guides/nextjs/usage + */ +export const configureSentry = (): void => { + if (!process.env.NEXT_PUBLIC_SENTRY_DSN && process.env.NODE_ENV !== 'test') { + // eslint-disable-next-line no-console + console.warn(`Sentry DSN not defined, Sentry won't be configured and there won't be any error reporting.`); + } + + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { + // Scope configured by default, subsequent calls to "configureScope" will add additional data + Sentry.configureScope((scope) => { + scope.setTag('customerRef', process.env.NEXT_PUBLIC_CUSTOMER_REF); + scope.setTag('appStage', process.env.NEXT_PUBLIC_APP_STAGE); + scope.setTag('appName', process.env.NEXT_PUBLIC_APP_NAME); + scope.setTag('appBaseUrl', process.env.NEXT_PUBLIC_APP_BASE_URL); + scope.setTag('appVersion', process.env.NEXT_PUBLIC_APP_VERSION); + scope.setTag('appNameVersion', process.env.NEXT_PUBLIC_APP_NAME_VERSION); + scope.setTag('appBuildTime', process.env.NEXT_PUBLIC_APP_BUILD_TIME); + scope.setTag('buildTimeISO', (new Date(process.env.NEXT_PUBLIC_APP_BUILD_TIME || null)).toISOString()); + scope.setTag('appBuildId', process.env.NEXT_PUBLIC_APP_BUILD_ID); + scope.setTag('nodejs', process.version); + scope.setTag('nodejsAWS', process.env.AWS_EXECUTION_ENV || null); // Optional - Available on production environment only + scope.setTag('memory', process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || null); // Optional - Available on production environment only + scope.setTag('runtimeEngine', isBrowser() ? 'browser' : 'server'); + }); + } +}; + /** * Configure Sentry tags for the current user. * @@ -73,7 +71,7 @@ export const ALERT_TYPES = { * @see https://www.npmjs.com/package/@sentry/nextjs */ export const configureSentryUser = (userSession: UserSession): void => { - if (process.env.SENTRY_DSN) { + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { Sentry.configureScope((scope) => { scope.setTag('userId', userSession?.id); scope.setTag('userDeviceId', userSession?.deviceId); @@ -90,7 +88,7 @@ export const configureSentryUser = (userSession: UserSession): void => { * @see https://www.npmjs.com/package/@sentry/nextjs */ export const configureSentryI18n = (lang: string, locale: string): void => { - if (process.env.SENTRY_DSN) { + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { Sentry.configureScope((scope) => { // See https://www.npmjs.com/package/@sentry/nextjs scope.setTag('lang', lang); scope.setTag('locale', locale); @@ -104,7 +102,9 @@ export const configureSentryI18n = (lang: string, locale: string): void => { * @param req * @param tags * @param contexts + * * @see https://www.npmjs.com/package/@sentry/nextjs + * @deprecated Not necessary anymore with @sentry/nextjs, API endpoints should use "withSentry" HOC instead. Kept until API endpoints are migrated. */ export const configureReq = (req: NextApiRequest, tags?: { [key: string]: string }, contexts?: { [key: string]: any }): void => { let parsedBody: GenericObject = {}; From 814c6b1af8f951e093ae3be744799e2299cb5d03 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 22:16:20 +0200 Subject: [PATCH 08/33] Move withSentryConfig webpack plugin AFTER withNextPluginPreval, otherwise it makes a MESS and all env vars are undefined! --- .env | 4 ++++ next.config.js | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 70010fd7..0ef26760 100644 --- a/.env +++ b/.env @@ -40,3 +40,7 @@ NEXT_PUBLIC_LOCIZE_PROJECT_ID=658fc999-dfa8-4307-b9d7-b4870ad5b968 # Used to send analytics usage # Tip: The value being used below is valid, so that you can run the demo locally without having to create your own Amplitude account, but you cannot access the data NEXT_PUBLIC_AMPLITUDE_API_KEY=5ea02d86a6840c165fcc01377131fa13 + +# Tells webpack how to bundle the code for sentry.server.config.js. +# See https://github.com/getsentry/sentry-docs/issues/3721#issuecomment-858987529 +SENTRY_SERVER_INIT_PATH=.next/server/sentry/initServerSDK.js diff --git a/next.config.js b/next.config.js index 050df8dc..22fd6d82 100644 --- a/next.config.js +++ b/next.config.js @@ -59,7 +59,7 @@ console.debug(`Release version resolved from tags: "${APP_RELEASE_TAG}" (matchin * @see https://docs.sentry.io/platforms/javascript/guides/nextjs/ * @see https://github.com/getsentry/sentry-webpack-plugin#options */ -module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSourceMaps({ +module.exports = withNextPluginPreval(withSentryConfig(withBundleAnalyzer(withSourceMaps({ // basepath: '', // If you want Next.js to cover only a subsection of the domain. See https://nextjs.org/docs/api-reference/next.config.js/basepath // target: 'serverless', // Automatically enabled on Vercel, you may need to manually opt-in if you're not using Vercel. See https://nextjs.org/docs/api-reference/next.config.js/build-target#serverless-target // trailingSlash: false, // By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. See https://nextjs.org/docs/api-reference/next.config.js/trailing-slash @@ -404,4 +404,4 @@ module.exports = withSentryConfig(withNextPluginPreval(withBundleAnalyzer(withSo // }, poweredByHeader: false, // See https://nextjs.org/docs/api-reference/next.config.js/disabling-x-powered-by -}))), sentryWebpackPluginOptions); +})), sentryWebpackPluginOptions)); From 0018b8055282086ce447102c599e0d5adf369bce Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 22:19:29 +0200 Subject: [PATCH 09/33] Remove log --- src/app/components/MultiversalAppBootstrap.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/MultiversalAppBootstrap.tsx b/src/app/components/MultiversalAppBootstrap.tsx index 162f8eea..36e160e6 100644 --- a/src/app/components/MultiversalAppBootstrap.tsx +++ b/src/app/components/MultiversalAppBootstrap.tsx @@ -64,7 +64,7 @@ const MultiversalAppBootstrap: React.FunctionComponent = (props): JSX.Ele // When using SSG with "fallback: true" and the page hasn't been generated yet then isSSGFallbackInitialBuild is true const [isSSGFallbackInitialBuild] = useState(isEmpty(pageProps) && router?.isFallback === true); const pageComponentName = getComponentName(props.Component); - logger.log('process.env.NEXT_PUBLIC_SENTRY_DSN', process.env.NEXT_PUBLIC_SENTRY_DSN); + Sentry.addBreadcrumb({ // See https://docs.sentry.io/enriching-error-data/breadcrumbs category: fileLabel, message: `Rendering ${fileLabel}`, From 7a35307d330f34b7d80452444291be6a357a63c2 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 22:30:14 +0200 Subject: [PATCH 10/33] Adapt doc for other people not to fall in the same trap --- next.config.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 22fd6d82..459b7bb6 100644 --- a/next.config.js +++ b/next.config.js @@ -48,7 +48,11 @@ console.debug(`Release version resolved from tags: "${APP_RELEASE_TAG}" (matchin * The below config applies to the whole application. * next.config.js gets used by the Next.js server and build phases, and it's not included in the browser build. * - * Make sure adding "withSentryConfig" is the last code to run before exporting, to ensure that your source maps include changes from all other Webpack plugins. + * The Sentry doc states: + * "Make sure adding "withSentryConfig" is the last code to run before exporting, to ensure that your source maps include changes from all other Webpack plugins." + * XXX DO NOT follow that guideline blindly! "withNextPluginPreval" must be the last code to run when exporting. + * See https://github.com/getsentry/sentry-docs/issues/3723 + * See https://github.com/ricokahler/next-plugin-preval/issues/42 * * XXX Not all configuration options are listed below, we only kept those of most interest. * You'll need to dive into Next.js own documentation to find out about what's not included. From be57969e8652fab3811ae27e6af7b70d0d074577 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 22:40:27 +0200 Subject: [PATCH 11/33] Improve interactive error demo + fix TS errors --- .../core/errorHandling/DefaultErrorLayout.tsx | 1 + .../built-in-utilities/interactive-error.tsx | 37 ++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/modules/core/errorHandling/DefaultErrorLayout.tsx b/src/modules/core/errorHandling/DefaultErrorLayout.tsx index ef8f12f4..3b94b49f 100644 --- a/src/modules/core/errorHandling/DefaultErrorLayout.tsx +++ b/src/modules/core/errorHandling/DefaultErrorLayout.tsx @@ -48,6 +48,7 @@ const DefaultErrorLayout: React.FunctionComponent = (props): JSX.Element + +
+ +

+ Play around with custom error messages +

+ + + Generate your own errors dynamically! + + +
+ +
); }; From 5c82a99b3f079b7c19c79619b51405bc78347231 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 22:55:36 +0200 Subject: [PATCH 12/33] Add vercel secret nrn-sentry-auth-token --- .env | 1 + src/pages/api/status.ts | 3 ++- vercel.customer1.production.json | 1 + vercel.customer1.staging.json | 1 + vercel.customer2.production.json | 1 + vercel.customer2.staging.json | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 0ef26760..da0243c2 100644 --- a/.env +++ b/.env @@ -43,4 +43,5 @@ NEXT_PUBLIC_AMPLITUDE_API_KEY=5ea02d86a6840c165fcc01377131fa13 # Tells webpack how to bundle the code for sentry.server.config.js. # See https://github.com/getsentry/sentry-docs/issues/3721#issuecomment-858987529 +# Will be injected automatically by "@sentry/nextjs" into ".env.local" SENTRY_SERVER_INIT_PATH=.next/server/sentry/initServerSDK.js diff --git a/src/pages/api/status.ts b/src/pages/api/status.ts index 39b01005..47ee89b7 100644 --- a/src/pages/api/status.ts +++ b/src/pages/api/status.ts @@ -4,6 +4,7 @@ import { NextApiRequest, NextApiResponse, } from 'next'; +import { withSentry } from '@sentry/nextjs'; const fileLabel = 'api/status'; const logger = createLogger({ @@ -59,4 +60,4 @@ export const status = async (req: NextApiRequest, res: NextApiResponse): Promise } }; -export default status; +export default withSentry(status); diff --git a/vercel.customer1.production.json b/vercel.customer1.production.json index d33c7658..312c70b0 100644 --- a/vercel.customer1.production.json +++ b/vercel.customer1.production.json @@ -14,6 +14,7 @@ "AIRTABLE_BASE_ID": "@nrn-airtable-base-id", "LOCIZE_API_KEY": "The Locize API Key shouldn't be used in production (see https://github.com/locize/i18next-locize-backend#backend-options) because it's related to development-only features, and it's sensitive.", "SENTRY_DSN": "@nrn-sentry-dsn", + "SENTRY_AUTH_TOKEN": "@nrn-sentry-auth-token", "GITHUB_DISPATCH_TOKEN": "@nrn-github-dispatch-token", "VERCEL_DEPLOYMENT_COMPLETED_WEBHOOK": "https://nrn-v2-mst-aptd-at-lcz-sty-c1.vercel.app/api/webhooks/deploymentCompleted" } diff --git a/vercel.customer1.staging.json b/vercel.customer1.staging.json index 0b93270d..f45c4061 100644 --- a/vercel.customer1.staging.json +++ b/vercel.customer1.staging.json @@ -14,6 +14,7 @@ "AIRTABLE_BASE_ID": "@nrn-airtable-base-id", "LOCIZE_API_KEY": "@nrn-locize-api-key-staging", "SENTRY_DSN": "@nrn-sentry-dsn", + "SENTRY_AUTH_TOKEN": "@nrn-sentry-auth-token", "GITHUB_DISPATCH_TOKEN": "@nrn-github-dispatch-token", "VERCEL_DEPLOYMENT_COMPLETED_WEBHOOK": "https://nrn-v2-mst-aptd-at-lcz-sty-c1-preview.vercel.app/api/webhooks/deploymentCompleted" } diff --git a/vercel.customer2.production.json b/vercel.customer2.production.json index e0271e26..69c0bec1 100644 --- a/vercel.customer2.production.json +++ b/vercel.customer2.production.json @@ -14,6 +14,7 @@ "AIRTABLE_BASE_ID": "@nrn-airtable-base-id", "LOCIZE_API_KEY": "The Locize API Key shouldn't be used in production (see https://github.com/locize/i18next-locize-backend#backend-options) because it's related to development-only features, and it's sensitive.", "SENTRY_DSN": "@nrn-sentry-dsn", + "SENTRY_AUTH_TOKEN": "@nrn-sentry-auth-token", "GITHUB_DISPATCH_TOKEN": "@nrn-github-dispatch-token", "VERCEL_DEPLOYMENT_COMPLETED_WEBHOOK": "https://nrn-v2-mst-aptd-at-lcz-sty-c2.vercel.app/api/webhooks/deploymentCompleted" } diff --git a/vercel.customer2.staging.json b/vercel.customer2.staging.json index ff255154..b476479e 100644 --- a/vercel.customer2.staging.json +++ b/vercel.customer2.staging.json @@ -14,6 +14,7 @@ "AIRTABLE_BASE_ID": "@nrn-airtable-base-id", "LOCIZE_API_KEY": "@nrn-locize-api-key-staging", "SENTRY_DSN": "@nrn-sentry-dsn", + "SENTRY_AUTH_TOKEN": "@nrn-sentry-auth-token", "GITHUB_DISPATCH_TOKEN": "@nrn-github-dispatch-token", "VERCEL_DEPLOYMENT_COMPLETED_WEBHOOK": "https://nrn-v2-mst-aptd-at-lcz-sty-c2-preview.vercel.app/api/webhooks/deploymentCompleted" } From 8cc7c3a4ebc4edfc9a4de8f45ed603b1105a0481 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 10 Jun 2021 23:08:50 +0200 Subject: [PATCH 13/33] Use withSentry HOC for error, too --- src/pages/api/error.ts | 3 ++- src/pages/api/status.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/api/error.ts b/src/pages/api/error.ts index 30ae2083..0e091ab6 100644 --- a/src/pages/api/error.ts +++ b/src/pages/api/error.ts @@ -1,5 +1,6 @@ import { createLogger } from '@/modules/core/logging/logger'; import Sentry, { configureReq } from '@/modules/core/sentry/sentry'; +import { withSentry } from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, @@ -36,4 +37,4 @@ export const error = async (req: NextApiRequest, res: NextApiResponse): Promise< } }; -export default error; +export default withSentry(error); diff --git a/src/pages/api/status.ts b/src/pages/api/status.ts index 47ee89b7..16325b2b 100644 --- a/src/pages/api/status.ts +++ b/src/pages/api/status.ts @@ -1,10 +1,10 @@ import { createLogger } from '@/modules/core/logging/logger'; import Sentry, { configureReq } from '@/modules/core/sentry/sentry'; +import { withSentry } from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, } from 'next'; -import { withSentry } from '@sentry/nextjs'; const fileLabel = 'api/status'; const logger = createLogger({ From 0940f3cd53fb6c93d3cc03741462f5ae0c87ba26 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Mon, 14 Jun 2021 23:42:27 +0200 Subject: [PATCH 14/33] Enable debug mode --- next.config.js | 2 +- sentry.client.config.js | 1 + sentry.server.config.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 459b7bb6..68adcf25 100644 --- a/next.config.js +++ b/next.config.js @@ -27,7 +27,7 @@ const sentryWebpackPluginOptions = { // For all available options, see: // https://github.com/getsentry/sentry-webpack-plugin#options. - // debug: process.env.NODE_ENV === 'development', + debug: process.env.NODE_ENV === 'development', // silent: true, // Suppresses all logs }; diff --git a/sentry.client.config.js b/sentry.client.config.js index 75cb5ec1..d0d69c1f 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -9,6 +9,7 @@ Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV !== 'test', environment: process.env.NEXT_PUBLIC_APP_STAGE, + debug: process.env.NODE_ENV === 'development', // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so diff --git a/sentry.server.config.js b/sentry.server.config.js index 87da27df..8e8d906e 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -9,6 +9,7 @@ Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV !== 'test', environment: process.env.NEXT_PUBLIC_APP_STAGE, + debug: process.env.NODE_ENV === 'development', // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so From c3d1553b078e43841b2edee6da8bd4577c15ae03 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 14:03:48 +0200 Subject: [PATCH 15/33] Fix issues --- sentry.client.config.js | 2 +- sentry.server.config.js | 2 +- .../core/amplitude/amplitudeBrowserClient.ts | 2 +- .../core/amplitude/amplitudeServerClient.ts | 2 +- src/modules/core/sentry/browser.ts | 2 +- src/modules/core/sentry/init.ts | 64 ++- src/modules/core/sentry/server.ts | 4 +- src/modules/core/sentry/universal.ts | 14 +- yarn.lock | 505 +++++++++++++++--- 9 files changed, 478 insertions(+), 119 deletions(-) diff --git a/sentry.client.config.js b/sentry.client.config.js index d0d69c1f..5036c015 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -3,7 +3,7 @@ // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import * as Sentry from '@sentry/nextjs'; -import { configureSentry } from './src/modules/core/sentry/sentry'; +import { configureSentry } from './src/modules/core/sentry/init'; Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, diff --git a/sentry.server.config.js b/sentry.server.config.js index 8e8d906e..f9f1c896 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -3,7 +3,7 @@ // https://docs.sentry.io/platforms/javascript/guides/nextjs/ import * as Sentry from '@sentry/nextjs'; -import { configureSentry } from './src/modules/core/sentry/sentry'; +import { configureSentry } from './src/modules/core/sentry/init'; Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, diff --git a/src/modules/core/amplitude/amplitudeBrowserClient.ts b/src/modules/core/amplitude/amplitudeBrowserClient.ts index e592d373..d2dd3fa2 100644 --- a/src/modules/core/amplitude/amplitudeBrowserClient.ts +++ b/src/modules/core/amplitude/amplitudeBrowserClient.ts @@ -11,7 +11,7 @@ import { getClientNetworkConnectionType, getClientNetworkInformationSpeed, } from '@/modules/core/networkInformation/networkInformation'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { isBrowser } from '@unly/utils'; import { AmplitudeClient, diff --git a/src/modules/core/amplitude/amplitudeServerClient.ts b/src/modules/core/amplitude/amplitudeServerClient.ts index a3154738..34125f15 100644 --- a/src/modules/core/amplitude/amplitudeServerClient.ts +++ b/src/modules/core/amplitude/amplitudeServerClient.ts @@ -5,7 +5,7 @@ import { init } from '@amplitude/node'; import { Event } from '@amplitude/types'; import { LogLevel } from '@amplitude/types/dist/src/logger'; import { Response } from '@amplitude/types/dist/src/response'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { Context } from '@sentry/types'; import startsWith from 'lodash.startswith'; import { v1 as uuid } from 'uuid'; // XXX Use v1 for uniqueness - See https://www.sohamkamani.com/blog/2016/10/05/uuid1-vs-uuid4/ diff --git a/src/modules/core/sentry/browser.ts b/src/modules/core/sentry/browser.ts index c550dcee..fa2df500 100644 --- a/src/modules/core/sentry/browser.ts +++ b/src/modules/core/sentry/browser.ts @@ -2,7 +2,7 @@ import { ClientNetworkConnectionType, ClientNetworkInformationSpeed, } from '@/modules/core/networkInformation/networkInformation'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; /** * Configure Sentry tags related to the browser metadata. diff --git a/src/modules/core/sentry/init.ts b/src/modules/core/sentry/init.ts index 46ff83c9..7d766fd8 100644 --- a/src/modules/core/sentry/init.ts +++ b/src/modules/core/sentry/init.ts @@ -1,45 +1,43 @@ -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { isBrowser } from '@unly/utils'; /** - * Initialize Sentry and export it. + * Configure Sentry default scope. * - * Helper to avoid duplicating the init() call in every /pages/api file. - * Also used in pages/_app for the client side, which automatically applies it for all frontend pages. + * Used by both sentry config files (client/server). + * Doesn't configure Sentry if NEXT_PUBLIC_SENTRY_DSN isn't defined. * - * Doesn't initialise Sentry if SENTRY_DSN isn't defined + * Automatically applied on the browser, thanks to @sentry/nextjs. + * Automatically applied on the server, thanks to @sentry/nextjs, when "withSentry" HOC is used. * - * @see https://www.npmjs.com/package/@sentry/node + * @see https://www.npmjs.com/package/@sentry/nextjs + * @see https://docs.sentry.io/platforms/javascript/guides/nextjs/ + * @see https://docs.sentry.io/platforms/javascript/guides/nextjs/usage */ -if (process.env.SENTRY_DSN) { - Sentry.init({ - dsn: process.env.SENTRY_DSN, - enabled: process.env.NODE_ENV !== 'test', - environment: process.env.NEXT_PUBLIC_APP_STAGE, - release: process.env.NEXT_PUBLIC_APP_VERSION_RELEASE, - }); - - if (!process.env.SENTRY_DSN && process.env.NODE_ENV !== 'test') { +export const configureSentry = (): void => { + if (!process.env.NEXT_PUBLIC_SENTRY_DSN && process.env.NODE_ENV !== 'test') { // eslint-disable-next-line no-console - console.error('Sentry DSN not defined'); + console.warn(`Sentry DSN not defined, Sentry won't be configured and there won't be any error reporting.`); } - // Scope configured by default, subsequent calls to "configureScope" will add additional data - Sentry.configureScope((scope) => { // See https://www.npmjs.com/package/@sentry/node - scope.setTag('customerRef', process.env.NEXT_PUBLIC_CUSTOMER_REF); - scope.setTag('appStage', process.env.NEXT_PUBLIC_APP_STAGE); - scope.setTag('appName', process.env.NEXT_PUBLIC_APP_NAME); - scope.setTag('appBaseUrl', process.env.NEXT_PUBLIC_APP_BASE_URL); - scope.setTag('appVersion', process.env.NEXT_PUBLIC_APP_VERSION); - scope.setTag('appNameVersion', process.env.NEXT_PUBLIC_APP_NAME_VERSION); - scope.setTag('appBuildTime', process.env.NEXT_PUBLIC_APP_BUILD_TIME); - scope.setTag('buildTimeISO', (new Date(process.env.NEXT_PUBLIC_APP_BUILD_TIME || null)).toISOString()); - scope.setTag('appBuildId', process.env.NEXT_PUBLIC_APP_BUILD_ID); - scope.setTag('nodejs', process.version); - scope.setTag('nodejsAWS', process.env.AWS_EXECUTION_ENV || null); // Optional - Available on production environment only - scope.setTag('memory', process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || null); // Optional - Available on production environment only - scope.setTag('runtimeEngine', isBrowser() ? 'browser' : 'server'); - }); -} + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { + // Scope configured by default, subsequent calls to "configureScope" will add additional data + Sentry.configureScope((scope) => { + scope.setTag('customerRef', process.env.NEXT_PUBLIC_CUSTOMER_REF); + scope.setTag('appStage', process.env.NEXT_PUBLIC_APP_STAGE); + scope.setTag('appName', process.env.NEXT_PUBLIC_APP_NAME); + scope.setTag('appBaseUrl', process.env.NEXT_PUBLIC_APP_BASE_URL); + scope.setTag('appVersion', process.env.NEXT_PUBLIC_APP_VERSION); + scope.setTag('appNameVersion', process.env.NEXT_PUBLIC_APP_NAME_VERSION); + scope.setTag('appBuildTime', process.env.NEXT_PUBLIC_APP_BUILD_TIME); + scope.setTag('buildTimeISO', (new Date(process.env.NEXT_PUBLIC_APP_BUILD_TIME || null)).toISOString()); + scope.setTag('appBuildId', process.env.NEXT_PUBLIC_APP_BUILD_ID); + scope.setTag('nodejs', process.version); + scope.setTag('nodejsAWS', process.env.AWS_EXECUTION_ENV || null); // Optional - Available on production environment only + scope.setTag('memory', process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || null); // Optional - Available on production environment only + scope.setTag('runtimeEngine', isBrowser() ? 'browser' : 'server'); + }); + } +}; export default Sentry; diff --git a/src/modules/core/sentry/server.ts b/src/modules/core/sentry/server.ts index 1818b295..2abae337 100644 --- a/src/modules/core/sentry/server.ts +++ b/src/modules/core/sentry/server.ts @@ -1,6 +1,6 @@ import { convertRequestBodyToJSObject } from '@/modules/core/api/convertRequestBodyToJSObject'; import { GenericObject } from '@/modules/core/data/types/GenericObject'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import map from 'lodash.map'; import { NextApiRequest } from 'next'; @@ -10,7 +10,7 @@ import { NextApiRequest } from 'next'; * @param req * @param tags * @param contexts - * @see https://www.npmjs.com/package/@sentry/node + * @see https://www.npmjs.com/package/@sentry/nextjs */ export const configureReq = (req: NextApiRequest, tags?: { [key: string]: string }, contexts?: { [key: string]: any }): void => { let parsedBody: GenericObject = {}; diff --git a/src/modules/core/sentry/universal.ts b/src/modules/core/sentry/universal.ts index 8b9dc832..089138b0 100644 --- a/src/modules/core/sentry/universal.ts +++ b/src/modules/core/sentry/universal.ts @@ -1,5 +1,5 @@ import { UserSession } from '@/modules/core/userSession/useUserSession'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; /** * Configure Sentry tags related to the current user. @@ -8,10 +8,11 @@ import * as Sentry from '@sentry/node'; * The tracking remains anonymous, there are no personal information being tracked, only internal ids. * * @param userSession - * @see https://www.npmjs.com/package/@sentry/node + * + * @see https://www.npmjs.com/package/@sentry/nextjs */ export const configureSentryUserMetadata = (userSession: UserSession): void => { - if (process.env.SENTRY_DSN) { + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { Sentry.configureScope((scope) => { scope.setTag('userId', userSession?.id); scope.setTag('userDeviceId', userSession?.deviceId); @@ -25,11 +26,12 @@ export const configureSentryUserMetadata = (userSession: UserSession): void => { * * @param lang * @param locale - * @see https://www.npmjs.com/package/@sentry/node + * + * @see https://www.npmjs.com/package/@sentry/nextjs */ export const configureSentryI18n = (lang: string, locale: string): void => { - if (process.env.SENTRY_DSN) { - Sentry.configureScope((scope) => { // See https://www.npmjs.com/package/@sentry/node + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { + Sentry.configureScope((scope) => { scope.setTag('lang', lang); scope.setTag('locale', locale); }); diff --git a/yarn.lock b/yarn.lock index 0d06ed78..0f501fc3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7,6 +7,25 @@ resolved "https://registry.yarnpkg.com/@amplitude/eslint-config-typescript/-/eslint-config-typescript-1.1.0.tgz#f6d876febda6f4470564e806576e43750d60a094" integrity sha512-N8sKkwtFakPD2/cSOrBnM5Wudjp4qeDD69U1cG7dZ6DDczxBhUEqnJDJ0wiYmKMPXqr+bmFOsDdbCcOmb/CLYA== +"@amplitude/identify@^1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@amplitude/identify/-/identify-1.6.1.tgz#11bd423b4fb330a4a7b0adfb7075753b1c8d0235" + integrity sha512-+iT7e+Iw6XJCUvqgJRy/73bCbW6XO1j1EXtfBJ6XefGSeDpKJL651DtS848+qaf5SGji0vE934K1gShuTrouOA== + dependencies: + "@amplitude/types" "^1.6.1" + "@amplitude/utils" "^1.6.1" + tslib "^1.9.3" + +"@amplitude/node@1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@amplitude/node/-/node-1.6.1.tgz#d5dc1f40c1ffa24c3ab3a52cc4d35f0db4ce49f2" + integrity sha512-6mTVLJ4g7usNIMBKAkbBAIn3y2Y7rrI0DGHg8IFL0zLYaeYVJjvaOixqpGgPTFmiu1PO+NfHba8gk6/SWs879A== + dependencies: + "@amplitude/identify" "^1.6.1" + "@amplitude/types" "^1.6.1" + "@amplitude/utils" "^1.6.1" + tslib "^1.9.3" + "@amplitude/react-amplitude@1.0.0": version "1.0.0" resolved "https://registry.yarnpkg.com/@amplitude/react-amplitude/-/react-amplitude-1.0.0.tgz#60145d02de035fc457e28e173f90aa33af2d149a" @@ -22,6 +41,11 @@ dependencies: "@amplitude/eslint-config-typescript" "^1.1.0" +"@amplitude/types@^1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@amplitude/types/-/types-1.6.1.tgz#ed15be42746526d6f7087bedc916734e13be56fd" + integrity sha512-GSaNbROpG5gaoLQPo9crpCkB+BgfN7ZtK6SPJaQC2IX2xNqvfq/RZwYLhMZyNfZw/Nce0Z6lKYXCoNPyhdL26Q== + "@amplitude/ua-parser-js@0.7.24": version "0.7.24" resolved "https://registry.yarnpkg.com/@amplitude/ua-parser-js/-/ua-parser-js-0.7.24.tgz#2ce605af7d2c38d4a01313fb2385df55fbbd69aa" @@ -35,6 +59,14 @@ "@amplitude/types" "^1.1.1" tslib "^1.9.3" +"@amplitude/utils@^1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@amplitude/utils/-/utils-1.6.1.tgz#fb6833bca5a35af01468e0317363520ff2377259" + integrity sha512-lzmjvKOkg2tbr5YvLuxBAOoCvnmAJ5mvuLYy9hth5j4dzeVfE8aoZp9PYpxOGAuonVEPJas3BH0XGTVBDn1zNA== + dependencies: + "@amplitude/types" "^1.6.1" + tslib "^1.9.3" + "@babel/code-frame@7.10.4", "@babel/code-frame@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.10.4.tgz#168da1a36e90da68ae8d49c0f1b48c7c6249213a" @@ -2144,10 +2176,10 @@ dependencies: prop-types "^15.7.2" -"@hapi/accept@5.0.1": - version "5.0.1" - resolved "https://registry.yarnpkg.com/@hapi/accept/-/accept-5.0.1.tgz#068553e867f0f63225a506ed74e899441af53e10" - integrity sha512-fMr4d7zLzsAXo28PRRQPXR1o2Wmu+6z+VY1UzDp0iFo13Twj8WePakwXBiqn3E1aAlTpSNzCXdnnQXFhst8h8Q== +"@hapi/accept@5.0.2": + version "5.0.2" + resolved "https://registry.yarnpkg.com/@hapi/accept/-/accept-5.0.2.tgz#ab7043b037e68b722f93f376afb05e85c0699523" + integrity sha512-CmzBx/bXUR8451fnZRuZAJRlzgm0Jgu5dltTX/bszmR2lheb9BpyN47Q1RbaGTsvFzn0PXAEs+lXDKfshccYZw== dependencies: "@hapi/boom" "9.x.x" "@hapi/hoek" "9.x.x" @@ -2460,20 +2492,25 @@ dependencies: webpack-bundle-analyzer "4.3.0" -"@next/env@10.2.0": - version "10.2.0" - resolved "https://registry.yarnpkg.com/@next/env/-/env-10.2.0.tgz#154dbce2efa3ad067ebd20b7d0aa9aed775e7c97" - integrity sha512-tsWBsn1Rb6hXRaHc/pWMCpZ4Ipkf3OCbZ54ef5ukgIyEvzzGdGFXQshPP2AF7yb+8yMpunWs7vOMZW3e8oPF6A== +"@next/env@11.0.0": + version "11.0.0" + resolved "https://registry.yarnpkg.com/@next/env/-/env-11.0.0.tgz#bdd306a45e88ba3e4e7a36aa91806f6486bb61d0" + integrity sha512-VKpmDvTYeCpEQjREg3J4pCmVs/QjEzoLmkM8shGFK6e9AmFd0G9QXOL8HGA8qKhy/XmNb7dHeMqrcMiBua4OgA== -"@next/polyfill-module@10.2.0": - version "10.2.0" - resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-10.2.0.tgz#61f41110c4b465cc26d113e2054e205df61c3594" - integrity sha512-Nl3GexIUXsmuggkUqrRFyE/2k7UI44JaVzSywtXEyHzxpZm2a5bdMaWuC89pgLiFDDOqmbqyLAbtwm5lNxa7Eg== +"@next/eslint-plugin-next@11.0.0": + version "11.0.0" + resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-11.0.0.tgz#e6fb93a00bdaba371904f2b2698b184e6278d369" + integrity sha512-fPZ0904yY1box6bRpR9rJqIkNxJdvzzxH7doXS+cdjyBAdptMR7wj3mcx1hEikBHzWduU8BOXBvRg2hWc09YDQ== -"@next/react-dev-overlay@10.2.0": - version "10.2.0" - resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-10.2.0.tgz#4220121abac7e3404cbaf467784aeecca8be46cf" - integrity sha512-PRIAoWog41hLN4iJ8dChKp4ysOX0Q8yiNQ/cwzyqEd3EjugkDV5OiKl3mumGKaApJaIra1MX6j1wgQRuLhuWMA== +"@next/polyfill-module@11.0.0": + version "11.0.0" + resolved "https://registry.yarnpkg.com/@next/polyfill-module/-/polyfill-module-11.0.0.tgz#cb2f46b323bbe7f8a337ccd80fb82314d4039403" + integrity sha512-gydtFzRqsT549U8+sY8382I/f4HFcelD8gdUGnAofQJa/jEU1jkxmjCHC8tmEiyeMLidl7iDZgchfSCpmMzzUg== + +"@next/react-dev-overlay@11.0.0": + version "11.0.0" + resolved "https://registry.yarnpkg.com/@next/react-dev-overlay/-/react-dev-overlay-11.0.0.tgz#6befb4d00d952551db1b3909023074eb5778ac5d" + integrity sha512-q+Wp+eStEMThe77zxdeJ/nbuODkHR6P+/dfUqYXZSqbLf6x5c5xwLBauwwVbkCYFZpAlDuL8Jk8QSAH1OsqC2w== dependencies: "@babel/code-frame" "7.12.11" anser "1.4.9" @@ -2487,10 +2524,10 @@ stacktrace-parser "0.1.10" strip-ansi "6.0.0" -"@next/react-refresh-utils@10.2.0": - version "10.2.0" - resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-10.2.0.tgz#55953b697769c6647f371bc6bcd865a24e1a22e9" - integrity sha512-3I31K9B4hEQRl7yQ44Umyz+szHtuMJrNdwsgJGhoEnUCXSBRHp5wv5Zv8eDa2NewSbe53b2C0oOpivrzmdBakw== +"@next/react-refresh-utils@11.0.0": + version "11.0.0" + resolved "https://registry.yarnpkg.com/@next/react-refresh-utils/-/react-refresh-utils-11.0.0.tgz#cb671723c50b904eaa44b4b45c0845476ecd8825" + integrity sha512-hi5eY+KBn4QGtUv7VL2OptdM33fI2hxhd7+omOFmAK+S0hDWhg1uqHqqGJk0W1IfqlWEzzL10WvTJDPRAtDugQ== "@nodelib/fs.scandir@2.1.3": version "2.1.3" @@ -2525,18 +2562,6 @@ dependencies: mkdirp "^1.0.4" -"@opentelemetry/api@0.14.0": - version "0.14.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-0.14.0.tgz#4e17d8d2f1da72b19374efa7b6526aa001267cae" - integrity sha512-L7RMuZr5LzMmZiQSQDy9O1jo0q+DaLy6XpYJfIGfYSfoJA5qzYwUP3sP1uMIQ549DvxAgM3ng85EaPTM/hUHwQ== - dependencies: - "@opentelemetry/context-base" "^0.14.0" - -"@opentelemetry/context-base@^0.14.0": - version "0.14.0" - resolved "https://registry.yarnpkg.com/@opentelemetry/context-base/-/context-base-0.14.0.tgz#c67fc20a4d891447ca1a855d7d70fa79a3533001" - integrity sha512-sDOAZcYwynHFTbLo6n8kIbLiVF3a3BLkrmehJUyEbT9F+Smbi47kLGS2gG2g0fjBLR/Lr1InPD7kXL7FaTqEkw== - "@pmmmwh/react-refresh-webpack-plugin@^0.4.3": version "0.4.3" resolved "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.4.3.tgz#1eec460596d200c0236bf195b078a5d1df89b766" @@ -2574,6 +2599,11 @@ prop-types "^15.6.1" react-lifecycles-compat "^3.0.4" +"@rushstack/eslint-patch@^1.0.6": + version "1.0.6" + resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.0.6.tgz#023d72a5c4531b4ce204528971700a78a85a0c50" + integrity sha512-Myxw//kzromB9yWgS8qYGuGVf91oBUUJpNvy5eM50sqvmKLbKjwLxohJnkWGTeeI9v9IBMtPLxz5Gc60FIfvCA== + "@samverschueren/stream-to-observable@^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f" @@ -4471,10 +4501,10 @@ "@types/react" "*" "@types/reactcss" "*" -"@types/react-dom@17.0.4": - version "17.0.4" - resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.4.tgz#d65159a847aca2a0fc87a7544a2f8fece8754d04" - integrity sha512-Wb6rlnPJfqbhpkvYN39y1NM/pOGGPzzIRquu0RdUMvTwgXNvASFO7pdtrtvyxGTQNb9wzBaQxXAWDdEqegZw2A== +"@types/react-dom@17.0.7": + version "17.0.7" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.7.tgz#b8ee15ead9e5d6c2c858b44949fdf2ebe5212232" + integrity sha512-Wd5xvZRlccOrCTej8jZkoFZuZRKHzanDDv1xglI33oBNFMWrqOSzrvWFw7ngSiZjrpJAzPKFtX7JvuXpkNmQHA== dependencies: "@types/react" "*" @@ -4514,10 +4544,10 @@ "@types/prop-types" "*" csstype "^2.2.0" -"@types/react@17.0.5": - version "17.0.5" - resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.5.tgz#3d887570c4489011f75a3fc8f965bf87d09a1bea" - integrity sha512-bj4biDB9ZJmGAYTWSKJly6bMr4BLUiBrx9ujiJEoP9XIDY9CTaPGxE5QWN/1WjpPLzYF7/jRNnV2nNxNe970sw== +"@types/react@17.0.11": + version "17.0.11" + resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.11.tgz#67fcd0ddbf5a0b083a0f94e926c7d63f3b836451" + integrity sha512-yFRQbD+whVonItSk7ZzP/L+gPTJVBkL/7shLEF+i9GC/1cV3JmUxEQz6+9ylhUpWSDuqo1N9qEvqS6vTj4USUA== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -4728,6 +4758,16 @@ "@typescript-eslint/typescript-estree" "4.23.0" debug "^4.1.1" +"@typescript-eslint/parser@^4.20.0": + version "4.28.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-4.28.0.tgz#2404c16751a28616ef3abab77c8e51d680a12caa" + integrity sha512-7x4D22oPY8fDaOCvkuXtYYTQ6mTMmkivwEzS+7iml9F9VkHGbbZ3x4fHRwxAb5KeuSkLqfnYjs46tGx2Nour4A== + dependencies: + "@typescript-eslint/scope-manager" "4.28.0" + "@typescript-eslint/types" "4.28.0" + "@typescript-eslint/typescript-estree" "4.28.0" + debug "^4.3.1" + "@typescript-eslint/scope-manager@4.23.0": version "4.23.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.23.0.tgz#8792ef7eacac122e2ec8fa2d30a59b8d9a1f1ce4" @@ -4736,6 +4776,14 @@ "@typescript-eslint/types" "4.23.0" "@typescript-eslint/visitor-keys" "4.23.0" +"@typescript-eslint/scope-manager@4.28.0": + version "4.28.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.28.0.tgz#6a3009d2ab64a30fc8a1e257a1a320067f36a0ce" + integrity sha512-eCALCeScs5P/EYjwo6se9bdjtrh8ByWjtHzOkC4Tia6QQWtQr3PHovxh3TdYTuFcurkYI4rmFsRFpucADIkseg== + dependencies: + "@typescript-eslint/types" "4.28.0" + "@typescript-eslint/visitor-keys" "4.28.0" + "@typescript-eslint/scope-manager@4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.4.0.tgz#2f3dd27692a12cc9a046a90ba6a9d8cb7731190a" @@ -4754,6 +4802,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.23.0.tgz#da1654c8a5332f4d1645b2d9a1c64193cae3aa3b" integrity sha512-oqkNWyG2SLS7uTWLZf6Sr7Dm02gA5yxiz1RP87tvsmDsguVATdpVguHr4HoGOcFOpCvx9vtCSCyQUGfzq28YCw== +"@typescript-eslint/types@4.28.0": + version "4.28.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.28.0.tgz#a33504e1ce7ac51fc39035f5fe6f15079d4dafb0" + integrity sha512-p16xMNKKoiJCVZY5PW/AfILw2xe1LfruTcfAKBj3a+wgNYP5I9ZEKNDOItoRt53p4EiPV6iRSICy8EPanG9ZVA== + "@typescript-eslint/types@4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.4.0.tgz#63440ef87a54da7399a13bdd4b82060776e9e621" @@ -4772,6 +4825,19 @@ semver "^7.3.2" tsutils "^3.17.1" +"@typescript-eslint/typescript-estree@4.28.0": + version "4.28.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.28.0.tgz#e66d4e5aa2ede66fec8af434898fe61af10c71cf" + integrity sha512-m19UQTRtxMzKAm8QxfKpvh6OwQSXaW1CdZPoCaQuLwAq7VZMNuhJmZR4g5281s2ECt658sldnJfdpSZZaxUGMQ== + dependencies: + "@typescript-eslint/types" "4.28.0" + "@typescript-eslint/visitor-keys" "4.28.0" + debug "^4.3.1" + globby "^11.0.3" + is-glob "^4.0.1" + semver "^7.3.5" + tsutils "^3.21.0" + "@typescript-eslint/typescript-estree@4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.4.0.tgz#16a2df7c16710ddd5406b32b86b9c1124b1ca526" @@ -4815,6 +4881,14 @@ "@typescript-eslint/types" "4.23.0" eslint-visitor-keys "^2.0.0" +"@typescript-eslint/visitor-keys@4.28.0": + version "4.28.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.28.0.tgz#255c67c966ec294104169a6939d96f91c8a89434" + integrity sha512-PjJyTWwrlrvM5jazxYF5ZPs/nl0kHDZMVbuIcbpawVXaDPelp3+S9zpOz5RmVUfS/fD5l5+ZXNKnWhNYjPzCvw== + dependencies: + "@typescript-eslint/types" "4.28.0" + eslint-visitor-keys "^2.0.0" + "@typescript-eslint/visitor-keys@4.4.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.4.0.tgz#0a9118344082f14c0f051342a74b42dfdb012640" @@ -5488,7 +5562,7 @@ array-unique@^0.3.2: resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= -array.prototype.flat@^1.2.1: +array.prototype.flat@^1.2.1, array.prototype.flat@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.2.4.tgz#6ef638b43312bd401b4c6199fdec7e2dc9e9a123" integrity sha512-4470Xi3GAPAjZqFcljX2xzckv1qeKPizoNkiS0+O4IoPR2ZNpcjE0pkhdihlDouK+x6QOast26B4Q/O9DJnwSg== @@ -6146,7 +6220,18 @@ browserslist@4.14.2: escalade "^3.0.2" node-releases "^1.1.61" -browserslist@4.16.1, browserslist@^4.12.0, browserslist@^4.14.5: +browserslist@4.16.6: + version "4.16.6" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.6.tgz#d7901277a5a88e554ed305b183ec9b0c08f66fa2" + integrity sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ== + dependencies: + caniuse-lite "^1.0.30001219" + colorette "^1.2.2" + electron-to-chromium "^1.3.723" + escalade "^3.1.1" + node-releases "^1.1.71" + +browserslist@^4.12.0, browserslist@^4.14.5: version "4.16.1" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.16.1.tgz#bf757a2da376b3447b800a16f0f1c96358138766" integrity sha512-UXhDrwqsNcpTYJBTZsbGATDxZbiVDsx6UjpmRUmtnP10pr8wAYr5LgFoEFw9ixriQH2mv/NX2SfGzE/o8GndLA== @@ -6410,7 +6495,7 @@ caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001173: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001174.tgz#0f2aca2153fd88ceb07a2bb982fc2acb787623c4" integrity sha512-tqClL/4ThQq6cfFXH3oJL4rifFBeM6gTkphjao5kgwMaW9yn0tKgQLAEfKzDwj6HQWCB/aWo8kTFlSvIN8geEA== -caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001179, caniuse-lite@^1.0.30001181: +caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001181: version "1.0.30001205" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001205.tgz#d79bf6a6fb13196b4bb46e5143a22ca0242e0ef8" integrity sha512-TL1GrS5V6LElbitPazidkBMD9sa448bQDDLrumDqaggmKFcuU2JW1wTOHJPukAcOMtEmLcmDJEzfRrf+GjM0Og== @@ -6420,6 +6505,11 @@ caniuse-lite@^1.0.30001202: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001223.tgz#39b49ff0bfb3ee3587000d2f66c47addc6e14443" integrity sha512-k/RYs6zc/fjbxTjaWZemeSmOjO0JJV+KguOBA3NwPup8uzxM1cMhR2BD9XmO86GuqaqTCO8CgkgH9Rz//vdDiA== +caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001228: + version "1.0.30001239" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001239.tgz#66e8669985bb2cb84ccb10f68c25ce6dd3e4d2b8" + integrity sha512-cyBkXJDMeI4wthy8xJ2FvDU6+0dtcZSJW3voUF8+e9f1bBeuvyZfc3PNbkOETyhbR+dGCPzn9E7MA3iwzusOhQ== + capture-exit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4" @@ -7477,7 +7567,7 @@ dayjs@^1.10.4: resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.5.tgz#5600df4548fc2453b3f163ebb2abbe965ccfb986" integrity sha512-BUFis41ikLz+65iH6LHQCDm4YPMj5r1YFLdupPIyM4SGcXMmtiLQ7U37i+hGS8urIuqe7I/ou3IS1jVc4nbN4g== -debug@2, debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0: +debug@2, debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -7498,7 +7588,7 @@ debug@4.3.2: dependencies: ms "2.1.2" -debug@^3.0.0: +debug@^3.0.0, debug@^3.2.7: version "3.2.7" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== @@ -8100,6 +8190,11 @@ electron-to-chromium@^1.3.634: resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.635.tgz#8d1591eeca6b257d380061a2c04f0b3cc6c9e33b" integrity sha512-RRriZOLs9CpW6KTLmgBqyUdnY0QNqqWs0HOtuQGGEMizOTNNn1P7sGRBxARnUeLejOsgwjDyRqT3E/CSst02ZQ== +electron-to-chromium@^1.3.723: + version "1.3.756" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.756.tgz#942cee59cd64d19f576d8d5804eef09cb423740c" + integrity sha512-WsmJym1TMeHVndjPjczTFbnRR/c4sbzg8fBFtuhlb2Sru3i/S1VGpzDSrv/It8ctMU2bj8G7g7/O3FzYMGw6eA== + elegant-spinner@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/elegant-spinner/-/elegant-spinner-1.0.1.tgz#db043521c95d7e303fd8f345bedc3349cfb0729e" @@ -8352,6 +8447,28 @@ es-abstract@^1.18.0-next.2: string.prototype.trimstart "^1.0.4" unbox-primitive "^1.0.0" +es-abstract@^1.18.2: + version "1.18.3" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.3.tgz#25c4c3380a27aa203c44b2b685bba94da31b63e0" + integrity sha512-nQIr12dxV7SSxE6r6f1l3DtAeEYdsGpps13dR0TwJg1S8gyp4ZPgy3FZcHBgbiQqnoqSTb+oC+kO4UQ0C/J8vw== + dependencies: + call-bind "^1.0.2" + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + get-intrinsic "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.2" + is-callable "^1.2.3" + is-negative-zero "^2.0.1" + is-regex "^1.1.3" + is-string "^1.0.6" + object-inspect "^1.10.3" + object-keys "^1.1.1" + object.assign "^4.1.2" + string.prototype.trimend "^1.0.4" + string.prototype.trimstart "^1.0.4" + unbox-primitive "^1.0.1" + es-array-method-boxes-properly@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz#873f3e84418de4ee19c5be752990b2e44718d09e" @@ -8449,6 +8566,57 @@ escodegen@^2.0.0: optionalDependencies: source-map "~0.6.1" +eslint-config-next@11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/eslint-config-next/-/eslint-config-next-11.0.0.tgz#0638a839dd46bbf5391076b13c48b6c0cc92ec2f" + integrity sha512-pmatg4zqb5Vygu2HrSPxbsCBudXO9OZQUMKQCyrPKRvfL8PJ3lOIOzzwsiW68eMPXOZwOc1yxTRZWKNY8OJT0w== + dependencies: + "@next/eslint-plugin-next" "11.0.0" + "@rushstack/eslint-patch" "^1.0.6" + "@typescript-eslint/parser" "^4.20.0" + eslint-import-resolver-node "^0.3.4" + eslint-plugin-import "^2.22.1" + eslint-plugin-jsx-a11y "^6.4.1" + eslint-plugin-react "^7.23.1" + eslint-plugin-react-hooks "^4.2.0" + +eslint-import-resolver-node@^0.3.4: + version "0.3.4" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz#85ffa81942c25012d8231096ddf679c03042c717" + integrity sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA== + dependencies: + debug "^2.6.9" + resolve "^1.13.1" + +eslint-module-utils@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.6.1.tgz#b51be1e473dd0de1c5ea638e22429c2490ea8233" + integrity sha512-ZXI9B8cxAJIH4nfkhTwcRTEAnrVfobYqwjWy/QMCZ8rHkZHFjf9yO4BzpiF9kCSfNlMG54eKigISHpX0+AaT4A== + dependencies: + debug "^3.2.7" + pkg-dir "^2.0.0" + +eslint-plugin-import@^2.22.1: + version "2.23.4" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.23.4.tgz#8dceb1ed6b73e46e50ec9a5bb2411b645e7d3d97" + integrity sha512-6/wP8zZRsnQFiR3iaPFgh5ImVRM1WN5NUWfTIRqwOdeiGJlBcSk82o1FEVq8yXmy4lkIzTo7YhHCIxlU/2HyEQ== + dependencies: + array-includes "^3.1.3" + array.prototype.flat "^1.2.4" + debug "^2.6.9" + doctrine "^2.1.0" + eslint-import-resolver-node "^0.3.4" + eslint-module-utils "^2.6.1" + find-up "^2.0.0" + has "^1.0.3" + is-core-module "^2.4.0" + minimatch "^3.0.4" + object.values "^1.1.3" + pkg-up "^2.0.0" + read-pkg-up "^3.0.0" + resolve "^1.20.0" + tsconfig-paths "^3.9.0" + eslint-plugin-jest@24.3.6: version "24.3.6" resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-24.3.6.tgz#5f0ca019183c3188c5ad3af8e80b41de6c8e9173" @@ -8456,7 +8624,7 @@ eslint-plugin-jest@24.3.6: dependencies: "@typescript-eslint/experimental-utils" "^4.0.1" -eslint-plugin-jsx-a11y@6.4.1: +eslint-plugin-jsx-a11y@6.4.1, eslint-plugin-jsx-a11y@^6.4.1: version "6.4.1" resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.4.1.tgz#a2d84caa49756942f42f1ffab9002436391718fd" integrity sha512-0rGPJBbwHoGNPU73/QCLP/vveMlM1b1Z9PponxO87jfr6tuH5ligXbDT6nHSSzBC8ovX2Z+BQu7Bk5D/Xgq9zg== @@ -8473,7 +8641,7 @@ eslint-plugin-jsx-a11y@6.4.1: jsx-ast-utils "^3.1.0" language-tags "^1.0.5" -eslint-plugin-react-hooks@4.2.0: +eslint-plugin-react-hooks@4.2.0, eslint-plugin-react-hooks@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.2.0.tgz#8c229c268d468956334c943bb45fc860280f5556" integrity sha512-623WEiZJqxR7VdxFCKLI6d6LLpwJkGPYKODnkH3D7WpOG5KM8yWueBd8TLsNAetEJNF5iJmolaAKO3F8yzyVBQ== @@ -8496,6 +8664,24 @@ eslint-plugin-react@7.23.2: resolve "^2.0.0-next.3" string.prototype.matchall "^4.0.4" +eslint-plugin-react@^7.23.1: + version "7.24.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.24.0.tgz#eadedfa351a6f36b490aa17f4fa9b14e842b9eb4" + integrity sha512-KJJIx2SYx7PBx3ONe/mEeMz4YE0Lcr7feJTCMyyKb/341NcjuAgim3Acgan89GfPv7nxXK2+0slu0CWXYM4x+Q== + dependencies: + array-includes "^3.1.3" + array.prototype.flatmap "^1.2.4" + doctrine "^2.1.0" + has "^1.0.3" + jsx-ast-utils "^2.4.1 || ^3.0.0" + minimatch "^3.0.4" + object.entries "^1.1.4" + object.fromentries "^2.0.4" + object.values "^1.1.4" + prop-types "^15.7.2" + resolve "^2.0.0-next.3" + string.prototype.matchall "^4.0.5" + eslint-scope@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" @@ -9170,6 +9356,13 @@ find-up@4.1.0, find-up@^4.0.0, find-up@^4.1.0: locate-path "^5.0.0" path-exists "^4.0.0" +find-up@^2.0.0, find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= + dependencies: + locate-path "^2.0.0" + find-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" @@ -9729,6 +9922,18 @@ globby@^10.0.1: merge2 "^1.2.3" slash "^3.0.0" +globby@^11.0.3: + version "11.0.4" + resolved "https://registry.yarnpkg.com/globby/-/globby-11.0.4.tgz#2cbaff77c2f2a62e71e9b2813a67b97a3a3001a5" + integrity sha512-9O4MVG9ioZJ08ffbcyVYyLOJLk5JQ688pJ4eMGLpdWLHq/Wr1D9BlriLQyL0E+jbkuePVZXYFj47QM/v093wHg== + dependencies: + array-union "^2.1.0" + dir-glob "^3.0.1" + fast-glob "^3.1.1" + ignore "^5.1.4" + merge2 "^1.3.0" + slash "^3.0.0" + globby@^9.2.0: version "9.2.0" resolved "https://registry.yarnpkg.com/globby/-/globby-9.2.0.tgz#fd029a706c703d29bdd170f4b6db3a3f7a7cb63d" @@ -10301,6 +10506,13 @@ ignore@^5.1.1, ignore@^5.1.4: resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf" integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A== +image-size@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/image-size/-/image-size-1.0.0.tgz#58b31fe4743b1cec0a0ac26f5c914d3c5b2f0750" + integrity sha512-JLJ6OwBfO1KcA+TvJT+v8gbE6iWbj24LyDNFgFEN0lzegn6cC6a/p3NIDaepMsJjQjlUWqIC7wJv8lBFxPNjcw== + dependencies: + queue "6.0.2" + immediate@~3.0.5: version "3.0.6" resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" @@ -10559,6 +10771,13 @@ is-core-module@^2.1.0, is-core-module@^2.2.0: dependencies: has "^1.0.3" +is-core-module@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1" + integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A== + dependencies: + has "^1.0.3" + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -10859,6 +11078,14 @@ is-regex@^1.1.2: call-bind "^1.0.2" has-symbols "^1.0.1" +is-regex@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.3.tgz#d029f9aff6448b93ebbe3f33dac71511fdcbef9f" + integrity sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ== + dependencies: + call-bind "^1.0.2" + has-symbols "^1.0.2" + is-regexp@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-regexp/-/is-regexp-1.0.0.tgz#fd2d883545c46bac5a633e7b9a09e87fa2cb5069" @@ -10894,6 +11121,11 @@ is-string@^1.0.5: resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== +is-string@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.6.tgz#3fe5d5992fb0d93404f32584d4b0179a71b54a5f" + integrity sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w== + is-symbol@^1.0.2, is-symbol@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" @@ -11947,6 +12179,16 @@ listr@^0.14.3: p-map "^2.0.0" rxjs "^6.3.3" +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + loader-runner@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357" @@ -11986,6 +12228,14 @@ localforage@^1.8.1: dependencies: lie "3.1.1" +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -12932,24 +13182,23 @@ next-unused@0.0.6: ts-loader "^7.0.0" typescript "^4.2.3" -next@10.2.0: - version "10.2.0" - resolved "https://registry.yarnpkg.com/next/-/next-10.2.0.tgz#6654cc925d8abcb15474fa062fc6b3ee527dd6dc" - integrity sha512-PKDKCSF7s82xudu3kQhOEaokxggpbLEWouEUtzP6OqV0YqKYHF+Ff+BFLycEem8ixtTM2M6ElN0VRJcskJfxPQ== +next@11.0.0: + version "11.0.0" + resolved "https://registry.yarnpkg.com/next/-/next-11.0.0.tgz#866b833f192f5a94ddb3267d5cc0f4b0ce405ac7" + integrity sha512-1OA0ccCTwVtdLats/1v7ReiBVx+Akya0UVhHo9IBr8ZkpDI3/SGNcaruJBp5agy8ROF97VDKkZamoUXxRB9NUA== dependencies: "@babel/runtime" "7.12.5" - "@hapi/accept" "5.0.1" - "@next/env" "10.2.0" - "@next/polyfill-module" "10.2.0" - "@next/react-dev-overlay" "10.2.0" - "@next/react-refresh-utils" "10.2.0" - "@opentelemetry/api" "0.14.0" + "@hapi/accept" "5.0.2" + "@next/env" "11.0.0" + "@next/polyfill-module" "11.0.0" + "@next/react-dev-overlay" "11.0.0" + "@next/react-refresh-utils" "11.0.0" assert "2.0.0" ast-types "0.13.2" browserify-zlib "0.2.0" - browserslist "4.16.1" + browserslist "4.16.6" buffer "5.6.0" - caniuse-lite "^1.0.30001179" + caniuse-lite "^1.0.30001228" chalk "2.4.2" chokidar "3.5.1" constants-browserify "1.0.0" @@ -12961,6 +13210,7 @@ next@10.2.0: find-cache-dir "3.3.1" get-orientation "1.1.2" https-browserify "1.0.0" + image-size "1.0.0" jest-worker "27.0.0-next.5" native-url "0.3.4" node-fetch "2.6.1" @@ -12975,7 +13225,7 @@ next@10.2.0: prop-types "15.7.2" querystring-es3 "0.2.1" raw-body "2.4.1" - react-is "16.13.1" + react-is "17.0.2" react-refresh "0.8.3" stream-browserify "3.0.0" stream-http "3.1.1" @@ -13122,6 +13372,11 @@ node-releases@^1.1.69: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.69.tgz#3149dbde53b781610cd8b486d62d86e26c3725f6" integrity sha512-DGIjo79VDEyAnRlfSqYTsy+yoHd2IOjJiKUozD2MV2D85Vso6Bug56mb9tT/fY5Urt0iqk01H7x+llAruDR2zA== +node-releases@^1.1.71: + version "1.1.73" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.73.tgz#dd4e81ddd5277ff846b80b52bb40c49edf7a7b20" + integrity sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg== + node-source-walk@^4.0.0, node-source-walk@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/node-source-walk/-/node-source-walk-4.2.0.tgz#c2efe731ea8ba9c03c562aa0a9d984e54f27bc2c" @@ -13143,7 +13398,7 @@ nopt@~1.0.10: dependencies: abbrev "1" -normalize-package-data@^2.5.0: +normalize-package-data@^2.3.2, normalize-package-data@^2.5.0: version "2.5.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.5.0.tgz#e66db1838b200c1dfc233225d12cb36520e234a8" integrity sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA== @@ -13240,6 +13495,11 @@ object-copy@^0.1.0: define-property "^0.2.5" kind-of "^3.0.3" +object-inspect@^1.10.3: + version "1.10.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369" + integrity sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw== + object-inspect@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" @@ -13312,6 +13572,15 @@ object.entries@^1.1.0, object.entries@^1.1.3: es-abstract "^1.18.0-next.1" has "^1.0.3" +object.entries@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.4.tgz#43ccf9a50bc5fd5b649d45ab1a579f24e088cafd" + integrity sha512-h4LWKWE+wKQGhtMjZEBud7uLGhqyLwj8fpHOarZhD2uY3C9cRtk57VQ89ke3moByLXMedqs3XCHzyb4AmA2DjA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.2" + "object.fromentries@^2.0.0 || ^1.0.0": version "2.0.3" resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.3.tgz#13cefcffa702dc67750314a3305e8cb3fad1d072" @@ -13376,6 +13645,15 @@ object.values@^1.1.3: es-abstract "^1.18.0-next.2" has "^1.0.3" +object.values@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.4.tgz#0d273762833e816b693a637d30073e7051535b30" + integrity sha512-TnGo7j4XSnKQoK3MfvkzqKCi0nVe/D9I9IjwTNYdb/fxYHpjrluHVOgw0AF6jrRFGMPHdfuidR09tIDiIvnaSg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.2" + objectorarray@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/objectorarray/-/objectorarray-1.0.4.tgz#d69b2f0ff7dc2701903d308bb85882f4ddb49483" @@ -13540,6 +13818,13 @@ p-limit@3.1.0, p-limit@^3.0.2: dependencies: yocto-queue "^0.1.0" +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== + dependencies: + p-try "^1.0.0" + p-limit@^2.0.0, p-limit@^2.2.0: version "2.2.2" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.2.2.tgz#61279b67721f5287aa1c13a9a7fbbc48c9291b1e" @@ -13547,6 +13832,13 @@ p-limit@^2.0.0, p-limit@^2.2.0: dependencies: p-try "^2.0.0" +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= + dependencies: + p-limit "^1.1.0" + p-locate@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" @@ -13594,6 +13886,11 @@ p-timeout@^3.1.0: dependencies: p-finally "^1.0.0" +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= + p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" @@ -13674,6 +13971,14 @@ parse-entities@^2.0.0: is-decimal "^1.0.0" is-hexadecimal "^1.0.0" +parse-json@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" + integrity sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA= + dependencies: + error-ex "^1.3.1" + json-parse-better-errors "^1.0.1" + parse-json@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-5.0.0.tgz#73e5114c986d143efa3712d4ea24db9a4266f60f" @@ -13840,6 +14145,13 @@ pirates@^4.0.0, pirates@^4.0.1: dependencies: node-modules-regexp "^1.0.0" +pkg-dir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" + integrity sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s= + dependencies: + find-up "^2.1.0" + pkg-dir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" @@ -13868,6 +14180,13 @@ pkg-up@3.1.0, pkg-up@^3.1.0: dependencies: find-up "^3.0.0" +pkg-up@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-up/-/pkg-up-2.0.0.tgz#c819ac728059a461cab1c3889a2be3c49a004d7f" + integrity sha1-yBmscoBZpGHKscOImivjxJoATX8= + dependencies: + find-up "^2.1.0" + platform@1.3.6: version "1.3.6" resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.6.tgz#48b4ce983164b209c2d45a107adb31f473a6e7a7" @@ -14380,6 +14699,13 @@ querystring@0.2.0, querystring@^0.2.0: resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= +queue@6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/queue/-/queue-6.0.2.tgz#b91525283e2315c7553d2efa18d83e76432fed65" + integrity sha512-iHZWu+q3IdFZFX36ro/lKBkSvfkztY5Y7HMiPlOUjhupPcG2JMfst2KKEpu5XndviX/3UhFbRngUPNKtgvtZiA== + dependencies: + inherits "~2.0.3" + quick-lru@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f" @@ -14707,10 +15033,10 @@ react-inspector@^5.1.0: is-dom "^1.0.0" prop-types "^15.0.0" -react-is@16.13.1: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" - integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== +react-is@17.0.2, react-is@^17.0.2: + version "17.0.2" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" + integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== react-is@^16.12.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4: version "16.13.0" @@ -14722,11 +15048,6 @@ react-is@^16.12.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.1.tgz#5b3531bd76a645a4c9fb6e693ed36419e3301339" integrity sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA== -react-is@^17.0.2: - version "17.0.2" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0" - integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w== - react-lifecycles-compat@^3.0.2, react-lifecycles-compat@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" @@ -14930,6 +15251,14 @@ reactstrap@8.9.0: react-popper "^1.3.6" react-transition-group "^2.3.1" +read-pkg-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-3.0.0.tgz#3ed496685dba0f8fe118d0691dc51f4a1ff96f07" + integrity sha1-PtSWaF26D4/hGNBpHcUfSh/5bwc= + dependencies: + find-up "^2.0.0" + read-pkg "^3.0.0" + read-pkg-up@^7.0.1: version "7.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-7.0.1.tgz#f3a6135758459733ae2b95638056e1854e7ef507" @@ -14939,6 +15268,15 @@ read-pkg-up@^7.0.1: read-pkg "^5.2.0" type-fest "^0.8.1" +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + integrity sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" + read-pkg@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-5.2.0.tgz#7bf295438ca5a33e56cd30e053b34ee7250c93cc" @@ -15431,7 +15769,7 @@ resolve@^1.10.0, resolve@^1.12.0, resolve@^1.3.2: dependencies: path-parse "^1.0.6" -resolve@^1.13.1, resolve@^1.14.2, resolve@^1.19.0: +resolve@^1.13.1, resolve@^1.14.2, resolve@^1.19.0, resolve@^1.20.0: version "1.20.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.20.0.tgz#629a013fb3f70755d6f0b7935cc1c2c5378b1975" integrity sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A== @@ -15717,7 +16055,7 @@ semver@^6.0.0, semver@^6.1.1, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.3.4: +semver@^7.3.4, semver@^7.3.5: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== @@ -16362,6 +16700,20 @@ string.prototype.matchall@^4.0.4: regexp.prototype.flags "^1.3.1" side-channel "^1.0.4" +string.prototype.matchall@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.5.tgz#59370644e1db7e4c0c045277690cf7b01203c4da" + integrity sha512-Z5ZaXO0svs0M2xd/6By3qpeKpLKd9mO4v4q3oMEQrk8Ck4xOD5d5XeBOOjGrmVZZ/AHB1S0CgG4N5r1G9N3E2Q== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.2" + get-intrinsic "^1.1.1" + has-symbols "^1.0.2" + internal-slot "^1.0.3" + regexp.prototype.flags "^1.3.1" + side-channel "^1.0.4" + string.prototype.padend@^3.0.0: version "3.1.1" resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.1.tgz#824c84265dbac46cade2b957b38b6a5d8d1683c5" @@ -17157,6 +17509,13 @@ tsutils@^3.17.1: dependencies: tslib "^1.8.1" +tsutils@^3.21.0: + version "3.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623" + integrity sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA== + dependencies: + tslib "^1.8.1" + tty-browserify@0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" @@ -17288,7 +17647,7 @@ ua-parser-js@^0.7.18: resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777" integrity sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ== -unbox-primitive@^1.0.0: +unbox-primitive@^1.0.0, unbox-primitive@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471" integrity sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw== From 002c54e9fb1667d4e4ecf017c4d93c7e27b2b15c Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 16:14:45 +0200 Subject: [PATCH 16/33] Import sentry from @sentry/nextjs --- src/layouts/core/components/CoreLayout.tsx | 7 +++++-- src/layouts/demo/components/DemoLayout.tsx | 2 +- src/layouts/quickPreview/components/QuickPreviewLayout.tsx | 2 +- src/modules/core/githubActions/dispatchWorkflow.ts | 2 +- src/modules/core/githubActions/dispatchWorkflowByPath.ts | 2 +- src/modules/core/sentry/init.ts | 2 -- src/pages/_app.tsx | 1 - src/pages/api/error.ts | 2 +- src/pages/api/preview.ts | 2 +- src/pages/api/startVercelDeployment.ts | 2 +- src/pages/api/status.ts | 2 +- src/pages/api/webhooks/deploymentCompleted.ts | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/layouts/core/components/CoreLayout.tsx b/src/layouts/core/components/CoreLayout.tsx index ac90cd23..03fb2d68 100644 --- a/src/layouts/core/components/CoreLayout.tsx +++ b/src/layouts/core/components/CoreLayout.tsx @@ -3,13 +3,16 @@ import { GenericObject } from '@/modules/core/data/types/GenericObject'; import DefaultErrorLayout from '@/modules/core/errorHandling/DefaultErrorLayout'; import { createLogger } from '@/modules/core/logging/logger'; import PreviewModeBanner from '@/modules/core/previewMode/components/PreviewModeBanner'; -import Sentry from '@/modules/core/sentry/init'; import ErrorPage from '@/pages/_error'; import { Amplitude, LogOnMount, } from '@amplitude/react-amplitude'; -import { css, SerializedStyles } from '@emotion/react'; +import { + css, + SerializedStyles, +} from '@emotion/react'; +import * as Sentry from '@sentry/nextjs'; import classnames from 'classnames'; import { NextRouter, diff --git a/src/layouts/demo/components/DemoLayout.tsx b/src/layouts/demo/components/DemoLayout.tsx index 6d5dc758..01ac79e7 100644 --- a/src/layouts/demo/components/DemoLayout.tsx +++ b/src/layouts/demo/components/DemoLayout.tsx @@ -3,12 +3,12 @@ import { GenericObject } from '@/modules/core/data/types/GenericObject'; import DefaultErrorLayout from '@/modules/core/errorHandling/DefaultErrorLayout'; import { createLogger } from '@/modules/core/logging/logger'; import PreviewModeBanner from '@/modules/core/previewMode/components/PreviewModeBanner'; -import Sentry from '@/modules/core/sentry/init'; import ErrorPage from '@/pages/_error'; import { Amplitude, LogOnMount, } from '@amplitude/react-amplitude'; +import * as Sentry from '@sentry/nextjs'; import classnames from 'classnames'; import { NextRouter, diff --git a/src/layouts/quickPreview/components/QuickPreviewLayout.tsx b/src/layouts/quickPreview/components/QuickPreviewLayout.tsx index db65c883..abfc8d5f 100644 --- a/src/layouts/quickPreview/components/QuickPreviewLayout.tsx +++ b/src/layouts/quickPreview/components/QuickPreviewLayout.tsx @@ -2,12 +2,12 @@ import Head, { HeadProps } from '@/layouts/core/components/CoreHead'; import { SoftPageProps } from '@/layouts/core/types/SoftPageProps'; import { GenericObject } from '@/modules/core/data/types/GenericObject'; import { createLogger } from '@/modules/core/logging/logger'; -import Sentry from '@/modules/core/sentry/init'; import { Amplitude, LogOnMount, } from '@amplitude/react-amplitude'; import { css } from '@emotion/react'; +import * as Sentry from '@sentry/nextjs'; import React from 'react'; import { Container } from 'reactstrap'; import QuickPreviewBanner from './QuickPreviewBanner'; diff --git a/src/modules/core/githubActions/dispatchWorkflow.ts b/src/modules/core/githubActions/dispatchWorkflow.ts index ca7ea837..f3711b30 100644 --- a/src/modules/core/githubActions/dispatchWorkflow.ts +++ b/src/modules/core/githubActions/dispatchWorkflow.ts @@ -1,6 +1,6 @@ import { createLogger } from '@/modules/core/logging/logger'; import { ALERT_TYPES } from '@/modules/core/sentry/config'; -import Sentry from '../sentry/init'; +import * as Sentry from '@sentry/nextjs'; import { WorkflowsAPIResponse } from './types/WorkflowsAPIResponse'; const fileLabel = 'modules/core/githubActions/dispatchWorkflow'; diff --git a/src/modules/core/githubActions/dispatchWorkflowByPath.ts b/src/modules/core/githubActions/dispatchWorkflowByPath.ts index 2212bd3c..acc2317d 100644 --- a/src/modules/core/githubActions/dispatchWorkflowByPath.ts +++ b/src/modules/core/githubActions/dispatchWorkflowByPath.ts @@ -4,7 +4,7 @@ import { GITHUB_REPO_NAME, } from '@/app/constants'; import { createLogger } from '@/modules/core/logging/logger'; -import Sentry from '../sentry/init'; +import * as Sentry from '@sentry/nextjs'; import dispatchWorkflow from './dispatchWorkflow'; import { WorkflowsAPIResponse } from './types/WorkflowsAPIResponse'; diff --git a/src/modules/core/sentry/init.ts b/src/modules/core/sentry/init.ts index 7d766fd8..783ca16d 100644 --- a/src/modules/core/sentry/init.ts +++ b/src/modules/core/sentry/init.ts @@ -39,5 +39,3 @@ export const configureSentry = (): void => { }); } }; - -export default Sentry; diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index d88e99ba..db67f9c8 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -6,7 +6,6 @@ import { SSGPageProps } from '@/layouts/core/types/SSGPageProps'; import { SSRPageProps } from '@/layouts/core/types/SSRPageProps'; import { sendWebVitals } from '@/modules/core/amplitude/amplitudeBrowserClient'; import '@/modules/core/fontAwesome/fontAwesome'; -import '@/modules/core/sentry/init'; import { NextWebVitalsMetrics } from '@/modules/core/webVitals/types/NextWebVitalsMetrics'; import { NextWebVitalsMetricsReport } from '@/modules/core/webVitals/types/NextWebVitalsMetricsReport'; import size from 'lodash.size'; diff --git a/src/pages/api/error.ts b/src/pages/api/error.ts index 2fcb4be0..0fb8a996 100644 --- a/src/pages/api/error.ts +++ b/src/pages/api/error.ts @@ -5,8 +5,8 @@ import { } from '@/modules/core/amplitude/events'; import { createLogger } from '@/modules/core/logging/logger'; import { FLUSH_TIMEOUT } from '@/modules/core/sentry/config'; -import Sentry from '@/modules/core/sentry/init'; import { configureReq } from '@/modules/core/sentry/server'; +import * as Sentry from '@sentry/nextjs'; import { withSentry } from '@sentry/nextjs'; import { NextApiRequest, diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts index da506394..6566fec1 100644 --- a/src/pages/api/preview.ts +++ b/src/pages/api/preview.ts @@ -6,8 +6,8 @@ import { import { filterExternalAbsoluteUrl } from '@/modules/core/js/url'; import { createLogger } from '@/modules/core/logging/logger'; import { FLUSH_TIMEOUT } from '@/modules/core/sentry/config'; -import Sentry from '@/modules/core/sentry/init'; import { configureReq } from '@/modules/core/sentry/server'; +import * as Sentry from '@sentry/nextjs'; import appendQueryParameter from 'append-query'; import { NextApiRequest, diff --git a/src/pages/api/startVercelDeployment.ts b/src/pages/api/startVercelDeployment.ts index 38f4ddd3..ba0dee10 100644 --- a/src/pages/api/startVercelDeployment.ts +++ b/src/pages/api/startVercelDeployment.ts @@ -7,8 +7,8 @@ import { import dispatchWorkflowByPath from '@/modules/core/githubActions/dispatchWorkflowByPath'; import { createLogger } from '@/modules/core/logging/logger'; import { ALERT_TYPES } from '@/modules/core/sentry/config'; -import Sentry from '@/modules/core/sentry/init'; import { configureReq } from '@/modules/core/sentry/server'; +import * as Sentry from '@sentry/nextjs'; import size from 'lodash.size'; import { NextApiRequest, diff --git a/src/pages/api/status.ts b/src/pages/api/status.ts index 6b5da88a..3fd60847 100644 --- a/src/pages/api/status.ts +++ b/src/pages/api/status.ts @@ -5,8 +5,8 @@ import { } from '@/modules/core/amplitude/events'; import { createLogger } from '@/modules/core/logging/logger'; import { FLUSH_TIMEOUT } from '@/modules/core/sentry/config'; -import Sentry from '@/modules/core/sentry/init'; import { configureReq } from '@/modules/core/sentry/server'; +import * as Sentry from '@sentry/nextjs'; import { withSentry } from '@sentry/nextjs'; import { NextApiRequest, diff --git a/src/pages/api/webhooks/deploymentCompleted.ts b/src/pages/api/webhooks/deploymentCompleted.ts index f5891cd0..156356d7 100644 --- a/src/pages/api/webhooks/deploymentCompleted.ts +++ b/src/pages/api/webhooks/deploymentCompleted.ts @@ -9,8 +9,8 @@ import { ALERT_TYPES, FLUSH_TIMEOUT, } from '@/modules/core/sentry/config'; -import Sentry from '@/modules/core/sentry/init'; import { configureReq } from '@/modules/core/sentry/server'; +import * as Sentry from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, From dc67f66c15085b7ccea1028958d541e8ceb065f0 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 16:19:33 +0200 Subject: [PATCH 17/33] Log full error --- src/pages/api/preview.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts index 6566fec1..c5f8b835 100644 --- a/src/pages/api/preview.ts +++ b/src/pages/api/preview.ts @@ -110,7 +110,7 @@ export const preview = async (req: EndpointRequest, res: NextApiResponse): Promi res.end(); } catch (e) { Sentry.captureException(e); - logger.error(e.message); + logger.error(e); // It's necessary to flush all events because Vercel runs on AWS Lambda, see https://vercel.com/docs/platform/limits#streaming-responses await Sentry.flush(FLUSH_TIMEOUT); From 84e45741a4b147d45f16276bf152cb4f8c28b608 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 16:25:48 +0200 Subject: [PATCH 18/33] Attempt try/catch flushing --- src/pages/api/preview.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts index c5f8b835..1d15dde9 100644 --- a/src/pages/api/preview.ts +++ b/src/pages/api/preview.ts @@ -103,8 +103,13 @@ export const preview = async (req: EndpointRequest, res: NextApiResponse): Promi Sentry.captureMessage('Preview mode is not allowed in production', Sentry.Severity.Warning); } - // It's necessary to flush all events because Vercel runs on AWS Lambda, see https://vercel.com/docs/platform/limits#streaming-responses - await Sentry.flush(FLUSH_TIMEOUT); + try { + // It's necessary to flush all events because Vercel runs on AWS Lambda, see https://vercel.com/docs/platform/limits#streaming-responses + await Sentry.flush(FLUSH_TIMEOUT); + } catch (e) { + Sentry.captureException(e); + logger.error(e); + } res.writeHead(307, { Location: safeRedirectUrl }); res.end(); From fbc700284793a6ae4ab2d7ede72c0dded8a9dcaf Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 16:55:39 +0200 Subject: [PATCH 19/33] Use withSentry for all API endpoints + remove try/catch --- package.json | 2 +- src/pages/api/autoRedirectToLocalisedPage.ts | 3 +- src/pages/api/preview.ts | 12 +- src/pages/api/startVercelDeployment.ts | 3 +- src/pages/api/webhooks/deploymentCompleted.ts | 3 +- yarn.lock | 172 +++++++++--------- 6 files changed, 97 insertions(+), 98 deletions(-) diff --git a/package.json b/package.json index 710a3f0a..6baf3d75 100644 --- a/package.json +++ b/package.json @@ -116,7 +116,7 @@ "@fortawesome/free-regular-svg-icons": "5.15.3", "@fortawesome/free-solid-svg-icons": "5.15.3", "@fortawesome/react-fontawesome": "0.1.14", - "@sentry/nextjs": "6.6.0", + "@sentry/nextjs": "6.7.2", "@types/lodash.isequal": "4.5.5", "@unly/simple-logger": "1.0.0", "@unly/universal-language-detector": "2.0.3", diff --git a/src/pages/api/autoRedirectToLocalisedPage.ts b/src/pages/api/autoRedirectToLocalisedPage.ts index f184e236..c8fd0e64 100644 --- a/src/pages/api/autoRedirectToLocalisedPage.ts +++ b/src/pages/api/autoRedirectToLocalisedPage.ts @@ -4,6 +4,7 @@ import { AMPLITUDE_EVENTS, } from '@/modules/core/amplitude/events'; import localeMiddleware from '@/modules/core/i18n/middlewares/localeMiddleware'; +import { withSentry } from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, @@ -27,5 +28,5 @@ const autoRedirectToLocalisedPage = async (req: NextApiRequest, res: NextApiResp return await localeMiddleware(req, res); }; -export default autoRedirectToLocalisedPage; +export default withSentry(autoRedirectToLocalisedPage); diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts index 1d15dde9..4b97eb30 100644 --- a/src/pages/api/preview.ts +++ b/src/pages/api/preview.ts @@ -8,6 +8,7 @@ import { createLogger } from '@/modules/core/logging/logger'; import { FLUSH_TIMEOUT } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; import * as Sentry from '@sentry/nextjs'; +import { withSentry } from '@sentry/nextjs'; import appendQueryParameter from 'append-query'; import { NextApiRequest, @@ -103,13 +104,8 @@ export const preview = async (req: EndpointRequest, res: NextApiResponse): Promi Sentry.captureMessage('Preview mode is not allowed in production', Sentry.Severity.Warning); } - try { - // It's necessary to flush all events because Vercel runs on AWS Lambda, see https://vercel.com/docs/platform/limits#streaming-responses - await Sentry.flush(FLUSH_TIMEOUT); - } catch (e) { - Sentry.captureException(e); - logger.error(e); - } + // It's necessary to flush all events because Vercel runs on AWS Lambda, see https://vercel.com/docs/platform/limits#streaming-responses + await Sentry.flush(FLUSH_TIMEOUT); res.writeHead(307, { Location: safeRedirectUrl }); res.end(); @@ -127,4 +123,4 @@ export const preview = async (req: EndpointRequest, res: NextApiResponse): Promi } }; -export default preview; +export default withSentry(preview); diff --git a/src/pages/api/startVercelDeployment.ts b/src/pages/api/startVercelDeployment.ts index ba0dee10..4e594d43 100644 --- a/src/pages/api/startVercelDeployment.ts +++ b/src/pages/api/startVercelDeployment.ts @@ -8,6 +8,7 @@ import dispatchWorkflowByPath from '@/modules/core/githubActions/dispatchWorkflo import { createLogger } from '@/modules/core/logging/logger'; import { ALERT_TYPES } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; +import { withSentry } from '@sentry/nextjs'; import * as Sentry from '@sentry/nextjs'; import size from 'lodash.size'; import { @@ -186,4 +187,4 @@ const startVercelDeployment = async (req: EndpointRequest, res: NextApiResponse) } }; -export default startVercelDeployment; +export default withSentry(startVercelDeployment); diff --git a/src/pages/api/webhooks/deploymentCompleted.ts b/src/pages/api/webhooks/deploymentCompleted.ts index 156356d7..ea9f5ec2 100644 --- a/src/pages/api/webhooks/deploymentCompleted.ts +++ b/src/pages/api/webhooks/deploymentCompleted.ts @@ -10,6 +10,7 @@ import { FLUSH_TIMEOUT, } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; +import { withSentry } from '@sentry/nextjs'; import * as Sentry from '@sentry/nextjs'; import { NextApiRequest, @@ -137,4 +138,4 @@ export const deploymentCompleted = async (req: EndpointRequest, res: NextApiResp } }; -export default deploymentCompleted; +export default withSentry(deploymentCompleted); diff --git a/yarn.lock b/yarn.lock index 0f501fc3..652600b6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2611,17 +2611,17 @@ dependencies: any-observable "^0.3.0" -"@sentry/browser@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.6.0.tgz#1222c326593f0eecc68fb10e38bafce5fe4244f6" - integrity sha512-+FBGintTWlO/war3umfyHw2KoodWQFkMbMaudrkHfDgr2aRj8VAF7uWCW9V4XFT5Q7d1fMDvyUWG2C+SyPDBug== - dependencies: - "@sentry/core" "6.6.0" - "@sentry/types" "6.6.0" - "@sentry/utils" "6.6.0" +"@sentry/browser@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.7.2.tgz#cfbe060de5a9694617f175a6bde469e5e266792e" + integrity sha512-Lv0Ne1QcesyGAhVcQDfQa3hDPR/MhPSDTMg3xFi+LxqztchVc4w/ynzR0wCZFb8KIHpTj5SpJHfxpDhXYMtS9g== + dependencies: + "@sentry/core" "6.7.2" + "@sentry/types" "6.7.2" + "@sentry/utils" "6.7.2" tslib "^1.9.3" -"@sentry/cli@^1.63.1": +"@sentry/cli@^1.64.1": version "1.66.0" resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.66.0.tgz#0526f1bc1c0570ce72ed817190af92f3b63a2e9a" integrity sha512-2pZ+JHnvKqwyJWcGkKg/gCM/zURYronAnruBNllI+rH2g5IL0N90deMmjB1xcqXS66J222+MPTtWrGEK1Vl0/w== @@ -2633,116 +2633,116 @@ progress "^2.0.3" proxy-from-env "^1.1.0" -"@sentry/core@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.6.0.tgz#51661d2dd5023d6cd07467422de1854282ced7e5" - integrity sha512-EjdeT6paAdxAZgfsVCB8wneahQF3nAUt9GxOJxaOBUv8BSc3HQ/svcTU3RU7k8YsP26PseEOIsedaxsEVZ+7og== +"@sentry/core@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.7.2.tgz#1d294fac6e62744bce3b9dfbcd90b14e93620480" + integrity sha512-NTZqwN5nR94yrXmSfekoPs1mIFuKvf8esdIW/DadwSKWAdLJwQTJY9xK/8PQv+SEzd7wiitPAx+mCw2By1xiNQ== dependencies: - "@sentry/hub" "6.6.0" - "@sentry/minimal" "6.6.0" - "@sentry/types" "6.6.0" - "@sentry/utils" "6.6.0" + "@sentry/hub" "6.7.2" + "@sentry/minimal" "6.7.2" + "@sentry/types" "6.7.2" + "@sentry/utils" "6.7.2" tslib "^1.9.3" -"@sentry/hub@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.6.0.tgz#1b9fa22ee104b7d6afd2dc4c40a1459fda259366" - integrity sha512-1Yw0kbxcvO7njZUDGvCKB6DxU5jQio7Be3Kx5qxwcx8ojpT9lo9p+IYZajgl6zQqkjjbVm/4SoYqU24ozu5vxw== +"@sentry/hub@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.7.2.tgz#31b250e74aa303877620dfa500aa89e4411e2dec" + integrity sha512-05qVW6ymChJsXag4+fYCQokW3AcABIgcqrVYZUBf6GMU/Gbz5SJqpV7y1+njwWvnPZydMncP9LaDVpMKbE7UYQ== dependencies: - "@sentry/types" "6.6.0" - "@sentry/utils" "6.6.0" + "@sentry/types" "6.7.2" + "@sentry/utils" "6.7.2" tslib "^1.9.3" -"@sentry/integrations@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-6.6.0.tgz#9c2c3ab77d9dd11d0159913e7250560f3e0ecadd" - integrity sha512-MStwI3yAjVCZ5BY7aUMpHFe9sdU9tIG2U95Jq9YGvYkdFIAAR1IEHlHIpsEpEPo0OFW0RIsDEhQg19a0D4Z9VQ== +"@sentry/integrations@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-6.7.2.tgz#1ddfb165b4aee42d0e9d9ef531c5ded8a73cbd61" + integrity sha512-IvOLqKVTxPxSJLbKVEe15BjvotnWBs86h5MJx3DLA/1HLP4xtUOvFsdmuMLJij5PtFG10HuUpRn8acEh5h9PTw== dependencies: - "@sentry/types" "6.6.0" - "@sentry/utils" "6.6.0" + "@sentry/types" "6.7.2" + "@sentry/utils" "6.7.2" localforage "^1.8.1" tslib "^1.9.3" -"@sentry/minimal@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.6.0.tgz#48684734e3c380e5e63a9357d05f0c18bae84419" - integrity sha512-xVBlZIDxSvHvNdvD5KmjTf8Xgi78vLpT4xqJaDUkW7B+DqWMVJZe5aUdQmcp7X/zWxctBwyMKsdHO7oiHkpS+Q== +"@sentry/minimal@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.7.2.tgz#9e6c0c587daea64a9042041694a4ad5d559d16cd" + integrity sha512-jkpwFv2GFHoVl5vnK+9/Q+Ea8eVdbJ3hn3/Dqq9MOLFnVK7ED6MhdHKLT79puGSFj+85OuhM5m2Q44mIhyS5mw== dependencies: - "@sentry/hub" "6.6.0" - "@sentry/types" "6.6.0" + "@sentry/hub" "6.7.2" + "@sentry/types" "6.7.2" tslib "^1.9.3" -"@sentry/nextjs@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/nextjs/-/nextjs-6.6.0.tgz#c037a84f4bf2c813f981c066ccad05581f46c6e9" - integrity sha512-UFI9cfwUoNWXTzTNWvzi13o6qc6qQcdDRBaomyZq4H4fVz2Hy5DSMsoFqsjtwHWgnQphkJbtutE76YebaLZaKA== - dependencies: - "@sentry/core" "6.6.0" - "@sentry/integrations" "6.6.0" - "@sentry/node" "6.6.0" - "@sentry/react" "6.6.0" - "@sentry/tracing" "6.6.0" - "@sentry/utils" "6.6.0" - "@sentry/webpack-plugin" "1.15.0" +"@sentry/nextjs@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/nextjs/-/nextjs-6.7.2.tgz#bb689aa75222ae899abbc2307cd6e676ca61946c" + integrity sha512-O891EUf9wTSDU+n1GH/ibPblOZVbWfWe8HTnH/BvsPjLjzumJ1IFSpQhQtyiYpmewbEDuR1F2hmqD+CoiTAtTg== + dependencies: + "@sentry/core" "6.7.2" + "@sentry/integrations" "6.7.2" + "@sentry/node" "6.7.2" + "@sentry/react" "6.7.2" + "@sentry/tracing" "6.7.2" + "@sentry/utils" "6.7.2" + "@sentry/webpack-plugin" "1.15.1" tslib "^1.9.3" -"@sentry/node@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.6.0.tgz#e535e1e679cf894752810529ffdee93cbfd078f0" - integrity sha512-heKie/AOanYq3mCsKR1igPn1sUIxBmGibBp79Xc0iSAgliPKnnLkqUjvAIKu6mcevL9UOUhpMDLzhilkaG+bAA== +"@sentry/node@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.7.2.tgz#ef2b865af2c37d83966db7fbd031179aa8c82cc0" + integrity sha512-vfNTmxBbHthAKPDBo0gVk/aNHdgUfXLzmaK7FgWO7cISiI2soCfvKEIP61XqIFZru06teqcRuDsYlR4wSeyWpg== dependencies: - "@sentry/core" "6.6.0" - "@sentry/hub" "6.6.0" - "@sentry/tracing" "6.6.0" - "@sentry/types" "6.6.0" - "@sentry/utils" "6.6.0" + "@sentry/core" "6.7.2" + "@sentry/hub" "6.7.2" + "@sentry/tracing" "6.7.2" + "@sentry/types" "6.7.2" + "@sentry/utils" "6.7.2" cookie "^0.4.1" https-proxy-agent "^5.0.0" lru_map "^0.3.3" tslib "^1.9.3" -"@sentry/react@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.6.0.tgz#f451e075c276881d127c1c847952170b18fde9f3" - integrity sha512-8uB1dMLzhcnbEH/196tVQ1+fjZcF9h0M5JTg2P9ZUkMHoLxnHU1NqG+UrHxWlKcHm2Jajey85YxkX6KqZFhBBA== +"@sentry/react@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.7.2.tgz#68edb082ea42cabcf86939f254457436b82b4a0a" + integrity sha512-gjXRuhgd3l2s18Y4dw9ZMWCiFKyeAU79fBiYdv8lqu9EFPFquU0qkZbgep8D37Xq2GWjQM0qEBmD758L6bUwvQ== dependencies: - "@sentry/browser" "6.6.0" - "@sentry/minimal" "6.6.0" - "@sentry/types" "6.6.0" - "@sentry/utils" "6.6.0" + "@sentry/browser" "6.7.2" + "@sentry/minimal" "6.7.2" + "@sentry/types" "6.7.2" + "@sentry/utils" "6.7.2" hoist-non-react-statics "^3.3.2" tslib "^1.9.3" -"@sentry/tracing@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.6.0.tgz#ce62fcb951faa6447cf47889f91efe3617b9eed2" - integrity sha512-tjXrmAOFfVBfx+ZmgE5bkpDPs/euNj0xrUg8MowCWGfCRn01W679tTb+dyNeP6faxQTo2RcaD68xD8oLroJwwA== +"@sentry/tracing@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.7.2.tgz#78a6934837143ae5e200b49bd256bc8a917477bc" + integrity sha512-juKlI7FICKONWJFJxDxerj0A+8mNRhmtrdR+OXFqOkqSAy/QXlSFZcA/j//O19k2CfwK1BrvoMcQ/4gnffUOVg== dependencies: - "@sentry/hub" "6.6.0" - "@sentry/minimal" "6.6.0" - "@sentry/types" "6.6.0" - "@sentry/utils" "6.6.0" + "@sentry/hub" "6.7.2" + "@sentry/minimal" "6.7.2" + "@sentry/types" "6.7.2" + "@sentry/utils" "6.7.2" tslib "^1.9.3" -"@sentry/types@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.6.0.tgz#55cbca23859bad87411f0f32135a968e6e40a639" - integrity sha512-lZ1uFN0lSNftAohi0lciEoSL58Gk/Ib1lLKaj0FSOvB1PAUmvo5dPtLdd0qjtNdtoaM8zqhrAbwCTQ8XZCDRsg== +"@sentry/types@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.7.2.tgz#8108272c98ad7784ddf9ddda0b7bdc6880ed6e50" + integrity sha512-h21Go/PfstUN+ZV6SbwRSZVg9GXRJWdLfHoO5PSVb3TVEMckuxk8tAE57/u+UZDwX8wu+Xyon2TgsKpiWKxqUg== -"@sentry/utils@6.6.0": - version "6.6.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.6.0.tgz#b34d342d05eefc25b7ddd3f27f41c050f1e7e1ef" - integrity sha512-FK9yqz2x+ef50B54tueeJ6mfb7Pf3lN75omx/YQBDL5cicyOV4j4kJDqn8/VKYhcSuX+ZaCZ/8bvOf0lxe0aHg== +"@sentry/utils@6.7.2": + version "6.7.2" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.7.2.tgz#c7f957ebe16de3e701a0c5477ac2dba04e7b4b68" + integrity sha512-9COL7aaBbe61Hp5BlArtXZ1o/cxli1NGONLPrVT4fMyeQFmLonhUiy77NdsW19XnvhvaA+2IoV5dg3dnFiF/og== dependencies: - "@sentry/types" "6.6.0" + "@sentry/types" "6.7.2" tslib "^1.9.3" -"@sentry/webpack-plugin@1.15.0": - version "1.15.0" - resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.15.0.tgz#c7f9eafbbace1929c3fb81bb720fc0d7e8b4f86d" - integrity sha512-KHVug+xI+KH/xCL7otWcRRszw0rt6i/BCH5F8+6/njz2gCBrYQOzdMvzWm4GeXZUuw5ekgycYaUhDs1/6enjuQ== +"@sentry/webpack-plugin@1.15.1": + version "1.15.1" + resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.15.1.tgz#deb014fce8c1b51811100f25ec9050dd03addd9b" + integrity sha512-/Z06MJDXyWcN2+CbeDTMDwVzySjgZWQajOke773TvpkgqdtkeT1eYBsA+pfsje+ZE1prEgrZdlH/L9HdM1odnQ== dependencies: - "@sentry/cli" "^1.63.1" + "@sentry/cli" "^1.64.1" "@sindresorhus/is@^0.14.0": version "0.14.0" From 1d01078c3ea662d65b05faaa7e5c1551867705b1 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 17:26:00 +0200 Subject: [PATCH 20/33] Refacto --- src/pages/api/error.ts | 3 +-- src/pages/api/preview.ts | 3 +-- src/pages/api/startVercelDeployment.ts | 3 +-- src/pages/api/status.ts | 3 +-- src/pages/api/webhooks/deploymentCompleted.ts | 3 +-- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/pages/api/error.ts b/src/pages/api/error.ts index 0fb8a996..a05c2c20 100644 --- a/src/pages/api/error.ts +++ b/src/pages/api/error.ts @@ -7,7 +7,6 @@ import { createLogger } from '@/modules/core/logging/logger'; import { FLUSH_TIMEOUT } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; import * as Sentry from '@sentry/nextjs'; -import { withSentry } from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, @@ -51,4 +50,4 @@ export const error = async (req: NextApiRequest, res: NextApiResponse): Promise< } }; -export default withSentry(error); +export default Sentry.withSentry(error); diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts index 4b97eb30..63c7515e 100644 --- a/src/pages/api/preview.ts +++ b/src/pages/api/preview.ts @@ -8,7 +8,6 @@ import { createLogger } from '@/modules/core/logging/logger'; import { FLUSH_TIMEOUT } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; import * as Sentry from '@sentry/nextjs'; -import { withSentry } from '@sentry/nextjs'; import appendQueryParameter from 'append-query'; import { NextApiRequest, @@ -123,4 +122,4 @@ export const preview = async (req: EndpointRequest, res: NextApiResponse): Promi } }; -export default withSentry(preview); +export default Sentry.withSentry(preview); diff --git a/src/pages/api/startVercelDeployment.ts b/src/pages/api/startVercelDeployment.ts index 4e594d43..118f86a3 100644 --- a/src/pages/api/startVercelDeployment.ts +++ b/src/pages/api/startVercelDeployment.ts @@ -8,7 +8,6 @@ import dispatchWorkflowByPath from '@/modules/core/githubActions/dispatchWorkflo import { createLogger } from '@/modules/core/logging/logger'; import { ALERT_TYPES } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; -import { withSentry } from '@sentry/nextjs'; import * as Sentry from '@sentry/nextjs'; import size from 'lodash.size'; import { @@ -187,4 +186,4 @@ const startVercelDeployment = async (req: EndpointRequest, res: NextApiResponse) } }; -export default withSentry(startVercelDeployment); +export default Sentry.withSentry(startVercelDeployment); diff --git a/src/pages/api/status.ts b/src/pages/api/status.ts index 3fd60847..211f4e39 100644 --- a/src/pages/api/status.ts +++ b/src/pages/api/status.ts @@ -7,7 +7,6 @@ import { createLogger } from '@/modules/core/logging/logger'; import { FLUSH_TIMEOUT } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; import * as Sentry from '@sentry/nextjs'; -import { withSentry } from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, @@ -74,4 +73,4 @@ export const status = async (req: NextApiRequest, res: NextApiResponse): Promise } }; -export default withSentry(status); +export default Sentry.withSentry(status); diff --git a/src/pages/api/webhooks/deploymentCompleted.ts b/src/pages/api/webhooks/deploymentCompleted.ts index ea9f5ec2..0e0c55fb 100644 --- a/src/pages/api/webhooks/deploymentCompleted.ts +++ b/src/pages/api/webhooks/deploymentCompleted.ts @@ -10,7 +10,6 @@ import { FLUSH_TIMEOUT, } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; -import { withSentry } from '@sentry/nextjs'; import * as Sentry from '@sentry/nextjs'; import { NextApiRequest, @@ -138,4 +137,4 @@ export const deploymentCompleted = async (req: EndpointRequest, res: NextApiResp } }; -export default withSentry(deploymentCompleted); +export default Sentry.withSentry(deploymentCompleted); From 12bfda6cc1afab0249a18afeb38a95ffb150b540 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 17:34:25 +0200 Subject: [PATCH 21/33] Add tracesSampleRate --- sentry.client.config.js | 1 + sentry.server.config.js | 1 + 2 files changed, 2 insertions(+) diff --git a/sentry.client.config.js b/sentry.client.config.js index 5036c015..dfb4b7b4 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -10,6 +10,7 @@ Sentry.init({ enabled: process.env.NODE_ENV !== 'test', environment: process.env.NEXT_PUBLIC_APP_STAGE, debug: process.env.NODE_ENV === 'development', + tracesSampleRate: 1.0, // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so diff --git a/sentry.server.config.js b/sentry.server.config.js index f9f1c896..a8c42a1e 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -10,6 +10,7 @@ Sentry.init({ enabled: process.env.NODE_ENV !== 'test', environment: process.env.NEXT_PUBLIC_APP_STAGE, debug: process.env.NODE_ENV === 'development', + tracesSampleRate: 1.0, // Note: if you want to override the automatic release value, do not set a // `release` value here - use the environment variable `SENTRY_RELEASE`, so From 204d53f5b875d8e07f5b071ec985cbb99a7e6c42 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 18:03:16 +0200 Subject: [PATCH 22/33] Use '@sentry/nextjs' instead of @sentry/node' --- src/pages/_error.tsx | 2 +- src/pages/api/error.ts | 2 +- src/pages/api/preview.ts | 2 +- src/pages/api/status.ts | 2 +- src/pages/api/webhooks/deploymentCompleted.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/_error.tsx b/src/pages/_error.tsx index 960ba810..485d44c1 100644 --- a/src/pages/_error.tsx +++ b/src/pages/_error.tsx @@ -1,5 +1,5 @@ import { flushSafe } from '@/modules/core/sentry/universal'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { NextPageContext } from 'next'; import NextError, { ErrorProps as NextErrorProps } from 'next/error'; import React, { Fragment } from 'react'; diff --git a/src/pages/api/error.ts b/src/pages/api/error.ts index 1632b18d..c49401e2 100644 --- a/src/pages/api/error.ts +++ b/src/pages/api/error.ts @@ -6,7 +6,7 @@ import { import { createLogger } from '@/modules/core/logging/logger'; import { configureReq } from '@/modules/core/sentry/server'; import { flushSafe } from '@/modules/core/sentry/universal'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts index c346a041..561ee2fc 100644 --- a/src/pages/api/preview.ts +++ b/src/pages/api/preview.ts @@ -7,7 +7,7 @@ import { filterExternalAbsoluteUrl } from '@/modules/core/js/url'; import { createLogger } from '@/modules/core/logging/logger'; import { configureReq } from '@/modules/core/sentry/server'; import { flushSafe } from '@/modules/core/sentry/universal'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import appendQueryParameter from 'append-query'; import { NextApiRequest, diff --git a/src/pages/api/status.ts b/src/pages/api/status.ts index 8661757a..309297a9 100644 --- a/src/pages/api/status.ts +++ b/src/pages/api/status.ts @@ -6,7 +6,7 @@ import { import { createLogger } from '@/modules/core/logging/logger'; import { configureReq } from '@/modules/core/sentry/server'; import { flushSafe } from '@/modules/core/sentry/universal'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, diff --git a/src/pages/api/webhooks/deploymentCompleted.ts b/src/pages/api/webhooks/deploymentCompleted.ts index 0ad5a75e..fb9e3c14 100644 --- a/src/pages/api/webhooks/deploymentCompleted.ts +++ b/src/pages/api/webhooks/deploymentCompleted.ts @@ -8,7 +8,7 @@ import { createLogger } from '@/modules/core/logging/logger'; import { ALERT_TYPES } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; import { flushSafe } from '@/modules/core/sentry/universal'; -import * as Sentry from '@sentry/node'; +import * as Sentry from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, From 599f5ed911716921a714e09f57cedd0e88a01a90 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Thu, 24 Jun 2021 19:09:37 +0200 Subject: [PATCH 23/33] Add more doc + make Sentry silent --- next.config.js | 7 +++++-- sentry.client.config.js | 2 +- sentry.server.config.js | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/next.config.js b/next.config.js index e4a88f2d..1492e495 100644 --- a/next.config.js +++ b/next.config.js @@ -27,8 +27,11 @@ const sentryWebpackPluginOptions = { // For all available options, see: // https://github.com/getsentry/sentry-webpack-plugin#options. - debug: process.env.NODE_ENV === 'development', - // silent: true, // Suppresses all logs + // XXX The error "Error: Cannot find module '/.next/server/sentry/initServerSDK.js'" in the console is a false-positive error + // See https://github.com/getsentry/sentry-docs/issues/3721 + + debug: process.env.NODE_ENV !== 'development', // You'll need to configure "debug" in sentry.x.config.js files as well + silent: true, // Suppresses all logs, because "[Sentry Webpack Plugin]" logs are too noisy }; console.debug(`Building Next with NODE_ENV="${process.env.NODE_ENV}" NEXT_PUBLIC_APP_STAGE="${process.env.NEXT_PUBLIC_APP_STAGE}" for NEXT_PUBLIC_CUSTOMER_REF="${process.env.NEXT_PUBLIC_CUSTOMER_REF}" using GIT_COMMIT_SHA=${process.env.GIT_COMMIT_SHA} and GIT_COMMIT_REF=${process.env.GIT_COMMIT_REF}`); diff --git a/sentry.client.config.js b/sentry.client.config.js index dfb4b7b4..cf82b163 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -9,7 +9,7 @@ Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV !== 'test', environment: process.env.NEXT_PUBLIC_APP_STAGE, - debug: process.env.NODE_ENV === 'development', + debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well as next.config.js tracesSampleRate: 1.0, // Note: if you want to override the automatic release value, do not set a diff --git a/sentry.server.config.js b/sentry.server.config.js index a8c42a1e..2b401e35 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -9,7 +9,7 @@ Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV !== 'test', environment: process.env.NEXT_PUBLIC_APP_STAGE, - debug: process.env.NODE_ENV === 'development', + debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well as next.config.js tracesSampleRate: 1.0, // Note: if you want to override the automatic release value, do not set a From 5ba6c1b316e90b426878a42d95b0f43c1ee1eca9 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 10:59:06 +0200 Subject: [PATCH 24/33] Avoid duplicating config between browser/server --- sentry.client.config.js | 17 +---------------- sentry.server.config.js | 17 +---------------- src/modules/core/sentry/init.ts | 4 +++- 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/sentry.client.config.js b/sentry.client.config.js index cf82b163..d0c4393f 100644 --- a/sentry.client.config.js +++ b/sentry.client.config.js @@ -2,19 +2,4 @@ // The config you add here will be used whenever a page is visited. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import * as Sentry from '@sentry/nextjs'; -import { configureSentry } from './src/modules/core/sentry/init'; - -Sentry.init({ - dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - enabled: process.env.NODE_ENV !== 'test', - environment: process.env.NEXT_PUBLIC_APP_STAGE, - debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well as next.config.js - tracesSampleRate: 1.0, - - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps -}); - -configureSentry(); +import './src/modules/core/sentry/init'; diff --git a/sentry.server.config.js b/sentry.server.config.js index 2b401e35..d1763c02 100644 --- a/sentry.server.config.js +++ b/sentry.server.config.js @@ -2,19 +2,4 @@ // The config you add here will be used whenever the server handles a request. // https://docs.sentry.io/platforms/javascript/guides/nextjs/ -import * as Sentry from '@sentry/nextjs'; -import { configureSentry } from './src/modules/core/sentry/init'; - -Sentry.init({ - dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, - enabled: process.env.NODE_ENV !== 'test', - environment: process.env.NEXT_PUBLIC_APP_STAGE, - debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well as next.config.js - tracesSampleRate: 1.0, - - // Note: if you want to override the automatic release value, do not set a - // `release` value here - use the environment variable `SENTRY_RELEASE`, so - // that it will also get attached to your source maps -}); - -configureSentry(); +import './src/modules/core/sentry/init'; diff --git a/src/modules/core/sentry/init.ts b/src/modules/core/sentry/init.ts index 5feb2e6e..725222e9 100644 --- a/src/modules/core/sentry/init.ts +++ b/src/modules/core/sentry/init.ts @@ -30,7 +30,9 @@ if (process.env.NEXT_PUBLIC_SENTRY_DSN) { dsn: process.env.NEXT_PUBLIC_SENTRY_DSN, enabled: process.env.NODE_ENV !== 'test', environment: process.env.NEXT_PUBLIC_APP_STAGE, - release: process.env.NEXT_PUBLIC_APP_VERSION_RELEASE, + // release: process.env.NEXT_PUBLIC_APP_VERSION_RELEASE, // Uses the environment variable `SENTRY_RELEASE`, which is also attached to the source maps + debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well as next.config.js + tracesSampleRate: 1.0, }); Sentry.configureScope((scope) => { From f9571d8d2dca9e7ac7e4b090658110a20e0f4f92 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:07:17 +0200 Subject: [PATCH 25/33] Use NEXT_PUBLIC_SENTRY_DSN + add test --- src/modules/core/sentry/browser.ts | 2 +- src/modules/core/testing/tests/env.test.ts | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/core/sentry/browser.ts b/src/modules/core/sentry/browser.ts index fa2df500..f64de3ca 100644 --- a/src/modules/core/sentry/browser.ts +++ b/src/modules/core/sentry/browser.ts @@ -13,7 +13,7 @@ import * as Sentry from '@sentry/nextjs'; * @param iframeReferrer */ export const configureSentryBrowserMetadata = (networkSpeed: ClientNetworkInformationSpeed, networkConnectionType: ClientNetworkConnectionType, isInIframe: boolean, iframeReferrer: string): void => { - if (process.env.SENTRY_DSN) { + if (process.env.NEXT_PUBLIC_SENTRY_DSN) { Sentry.configureScope((scope) => { scope.setTag('networkSpeed', networkSpeed); scope.setTag('networkConnectionType', networkConnectionType); diff --git a/src/modules/core/testing/tests/env.test.ts b/src/modules/core/testing/tests/env.test.ts index f2aa3297..dd618de0 100644 --- a/src/modules/core/testing/tests/env.test.ts +++ b/src/modules/core/testing/tests/env.test.ts @@ -117,5 +117,12 @@ describe(`utils/env/env.ts`, () => { } expect(1).toEqual(1); }); + + test(`NEXT_PUBLIC_SENTRY_DSN`, async () => { + if (typeof process.env.SENTRY_DSN === 'undefined') { + console.warn(`[warning] NEXT_PUBLIC_SENTRY_DSN environment variable isn't defined. This is not critical and the app will still function normally, but you may want to look into this. \nThis variable is automatically inherited from SENTRY_DSN. You may also disable this warning in "src/utils/env/env.test.ts".`); + } + expect(1).toEqual(1); + }); }); }); From d285b72a2c40ea0e86ce1a74952e6ce12efdbc75 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:09:52 +0200 Subject: [PATCH 26/33] Wrap all API endpoint with Sentry.withSentry --- src/pages/api/autoRedirectToLocalisedPage.ts | 4 ++-- src/pages/api/error.ts | 2 +- src/pages/api/preview.ts | 2 +- src/pages/api/startVercelDeployment.ts | 1 + src/pages/api/status.ts | 2 +- src/pages/api/webhooks/deploymentCompleted.ts | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/api/autoRedirectToLocalisedPage.ts b/src/pages/api/autoRedirectToLocalisedPage.ts index c8fd0e64..9f73a713 100644 --- a/src/pages/api/autoRedirectToLocalisedPage.ts +++ b/src/pages/api/autoRedirectToLocalisedPage.ts @@ -4,7 +4,7 @@ import { AMPLITUDE_EVENTS, } from '@/modules/core/amplitude/events'; import localeMiddleware from '@/modules/core/i18n/middlewares/localeMiddleware'; -import { withSentry } from '@sentry/nextjs'; +import * as Sentry from '@sentry/nextjs'; import { NextApiRequest, NextApiResponse, @@ -28,5 +28,5 @@ const autoRedirectToLocalisedPage = async (req: NextApiRequest, res: NextApiResp return await localeMiddleware(req, res); }; -export default withSentry(autoRedirectToLocalisedPage); +export default Sentry.withSentry(autoRedirectToLocalisedPage); diff --git a/src/pages/api/error.ts b/src/pages/api/error.ts index c49401e2..5ce2032a 100644 --- a/src/pages/api/error.ts +++ b/src/pages/api/error.ts @@ -49,4 +49,4 @@ export const error = async (req: NextApiRequest, res: NextApiResponse): Promise< } }; -export default error; +export default Sentry.withSentry(error); diff --git a/src/pages/api/preview.ts b/src/pages/api/preview.ts index 561ee2fc..d6086567 100644 --- a/src/pages/api/preview.ts +++ b/src/pages/api/preview.ts @@ -120,4 +120,4 @@ export const preview = async (req: EndpointRequest, res: NextApiResponse): Promi } }; -export default preview; +export default Sentry.withSentry(preview); diff --git a/src/pages/api/startVercelDeployment.ts b/src/pages/api/startVercelDeployment.ts index b04d3dc1..3e3e05fb 100644 --- a/src/pages/api/startVercelDeployment.ts +++ b/src/pages/api/startVercelDeployment.ts @@ -8,6 +8,7 @@ import dispatchWorkflowByPath from '@/modules/core/githubActions/dispatchWorkflo import { createLogger } from '@/modules/core/logging/logger'; import { ALERT_TYPES } from '@/modules/core/sentry/config'; import { configureReq } from '@/modules/core/sentry/server'; +import { flushSafe } from '@/modules/core/sentry/universal'; import * as Sentry from '@sentry/nextjs'; import size from 'lodash.size'; import { diff --git a/src/pages/api/status.ts b/src/pages/api/status.ts index 309297a9..690f9c0c 100644 --- a/src/pages/api/status.ts +++ b/src/pages/api/status.ts @@ -72,4 +72,4 @@ export const status = async (req: NextApiRequest, res: NextApiResponse): Promise } }; -export default status; +export default Sentry.withSentry(status); diff --git a/src/pages/api/webhooks/deploymentCompleted.ts b/src/pages/api/webhooks/deploymentCompleted.ts index fb9e3c14..f13ca422 100644 --- a/src/pages/api/webhooks/deploymentCompleted.ts +++ b/src/pages/api/webhooks/deploymentCompleted.ts @@ -133,4 +133,4 @@ export const deploymentCompleted = async (req: EndpointRequest, res: NextApiResp } }; -export default deploymentCompleted; +export default Sentry.withSentry(deploymentCompleted); From dbe23254018b8bb96897f7f9482a4b1c00bf99b5 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:14:34 +0200 Subject: [PATCH 27/33] Test Vercel ENV (unrelated) --- scripts/populate-git-env.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/populate-git-env.sh b/scripts/populate-git-env.sh index 40bc2bde..ab92d1c0 100755 --- a/scripts/populate-git-env.sh +++ b/scripts/populate-git-env.sh @@ -6,3 +6,4 @@ export "GIT_COMMIT_SHA=${GIT_COMMIT_SHA:-$(yarn --silent git:getCommitSHA)}" export "GIT_COMMIT_REF=${GIT_COMMIT_REF:-$(yarn --silent git:getCommitRef)}" export "GIT_COMMIT_TAGS=${GIT_COMMIT_TAGS:-$(yarn --silent git:getReleasesAndTags)}" +export "VERCEL_GIT_COMMIT_MESSAGE=Fake commit for testing Vercel" From 6e4b9b4c2a39570d5769f79fc75dd6a75d52238d Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:21:06 +0200 Subject: [PATCH 28/33] Test Vercel ENV (unrelated) --- package.json | 2 +- scripts/populate-git-env.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 6baf3d75..423bdd02 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "deploy:customer2:production:simple": "yarn vercel:cleanup && yarn vercel:deploy --local-config=vercel.customer2.production.json --prod", "deploy:fake": "git commit --allow-empty -m \"Fake empty commit (force CI trigger)\"", "vercel:cleanup": "npx del-cli .vercel/", - "vercel:deploy": ". ./scripts/populate-git-env.sh && vercel --build-env GIT_COMMIT_TAGS=$GIT_COMMIT_TAGS --build-env GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env GIT_COMMIT_SHA=$GIT_COMMIT_SHA --confirm --debug --force", + "vercel:deploy": ". ./scripts/populate-git-env.sh && vercel --build-env GIT_COMMIT_TAGS=$GIT_COMMIT_TAGS --build-env GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env GIT_COMMIT_SHA=$GIT_COMMIT_SHA --env VERCEL_GIT_COMMIT_REF=$GIT_COMMIT_REF --env VERCEL_GIT_COMMIT_SHA=$GIT_COMMIT_SHA --confirm --debug --force", "script:populate-git-env:print": ". ./scripts/populate-git-env.sh && echo 'SHA: '${GIT_COMMIT_SHA} && echo 'REF (current branch/tag): '${GIT_COMMIT_REF} && echo 'TAGS: '${GIT_COMMIT_TAGS}", "git:getReleasesAndTags": "git tag --points-at HEAD | tr '\\r\\n' ' '", "git:getCommitSHA": "git rev-parse HEAD", diff --git a/scripts/populate-git-env.sh b/scripts/populate-git-env.sh index ab92d1c0..40bc2bde 100755 --- a/scripts/populate-git-env.sh +++ b/scripts/populate-git-env.sh @@ -6,4 +6,3 @@ export "GIT_COMMIT_SHA=${GIT_COMMIT_SHA:-$(yarn --silent git:getCommitSHA)}" export "GIT_COMMIT_REF=${GIT_COMMIT_REF:-$(yarn --silent git:getCommitRef)}" export "GIT_COMMIT_TAGS=${GIT_COMMIT_TAGS:-$(yarn --silent git:getReleasesAndTags)}" -export "VERCEL_GIT_COMMIT_MESSAGE=Fake commit for testing Vercel" From fbd279f329148dd62e870db008200538e7caa667 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:26:22 +0200 Subject: [PATCH 29/33] Avoids capturing false-positive 404 pages when building the 404 page --- src/app/components/MultiversalAppBootstrap.tsx | 10 ++++++---- src/modules/core/sentry/init.ts | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/components/MultiversalAppBootstrap.tsx b/src/app/components/MultiversalAppBootstrap.tsx index 1baa6428..e01e7937 100644 --- a/src/app/components/MultiversalAppBootstrap.tsx +++ b/src/app/components/MultiversalAppBootstrap.tsx @@ -301,11 +301,13 @@ const MultiversalAppBootstrap: React.FunctionComponent = (props): JSX.Ele }); } } else { - // XXX Opinionated: Record an exception in Sentry for 404, if you don't want this then uncomment the below code - const err = new Error(`Page not found (404) for "${router?.asPath}"`); + if (!process.env.IS_SERVER_INITIAL_BUILD) { // Avoids capturing false-positive 404 pages when building the 404 page + // XXX Opinionated: Record an exception in Sentry for 404, if you don't want this then uncomment the below code + const err = new Error(`Page not found (404) for "${router?.asPath}"`); - logger.warn(err); - Sentry.captureException(err); + logger.warn(err); + Sentry.captureException(err); + } } const i18nextInstance: i18n = i18nextLocize(lang, i18nTranslations); // Apply i18next configuration with Locize backend diff --git a/src/modules/core/sentry/init.ts b/src/modules/core/sentry/init.ts index 725222e9..dcf96957 100644 --- a/src/modules/core/sentry/init.ts +++ b/src/modules/core/sentry/init.ts @@ -49,6 +49,7 @@ if (process.env.NEXT_PUBLIC_SENTRY_DSN) { scope.setTag('nodejsAWS', process.env.AWS_EXECUTION_ENV || null); // Optional - Available on production environment only scope.setTag('memory', process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || null); // Optional - Available on production environment only scope.setTag('runtimeEngine', isBrowser() ? 'browser' : 'server'); + scope.setTag('isServerInitialBuild', process.env.IS_SERVER_INITIAL_BUILD || '0'); }); } else { if (process.env.NODE_ENV !== 'test') { From 8fdc4cef4ec3e6df749b48023c4373770d50628d Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:27:48 +0200 Subject: [PATCH 30/33] Use build-env --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 423bdd02..1c6b7fe0 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "deploy:customer2:production:simple": "yarn vercel:cleanup && yarn vercel:deploy --local-config=vercel.customer2.production.json --prod", "deploy:fake": "git commit --allow-empty -m \"Fake empty commit (force CI trigger)\"", "vercel:cleanup": "npx del-cli .vercel/", - "vercel:deploy": ". ./scripts/populate-git-env.sh && vercel --build-env GIT_COMMIT_TAGS=$GIT_COMMIT_TAGS --build-env GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env GIT_COMMIT_SHA=$GIT_COMMIT_SHA --env VERCEL_GIT_COMMIT_REF=$GIT_COMMIT_REF --env VERCEL_GIT_COMMIT_SHA=$GIT_COMMIT_SHA --confirm --debug --force", + "vercel:deploy": ". ./scripts/populate-git-env.sh && vercel --build-env GIT_COMMIT_TAGS=$GIT_COMMIT_TAGS --build-env GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env GIT_COMMIT_SHA=$GIT_COMMIT_SHA --build-env VERCEL_GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env VERCEL_GIT_COMMIT_SHA=$GIT_COMMIT_SHA --confirm --debug --force", "script:populate-git-env:print": ". ./scripts/populate-git-env.sh && echo 'SHA: '${GIT_COMMIT_SHA} && echo 'REF (current branch/tag): '${GIT_COMMIT_REF} && echo 'TAGS: '${GIT_COMMIT_TAGS}", "git:getReleasesAndTags": "git tag --points-at HEAD | tr '\\r\\n' ' '", "git:getCommitSHA": "git rev-parse HEAD", From 3df28092159a60ebd83e01ae016363c32d5a90c5 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:38:11 +0200 Subject: [PATCH 31/33] Fix debug mode --- next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 1492e495..7030a394 100644 --- a/next.config.js +++ b/next.config.js @@ -30,7 +30,7 @@ const sentryWebpackPluginOptions = { // XXX The error "Error: Cannot find module '/.next/server/sentry/initServerSDK.js'" in the console is a false-positive error // See https://github.com/getsentry/sentry-docs/issues/3721 - debug: process.env.NODE_ENV !== 'development', // You'll need to configure "debug" in sentry.x.config.js files as well + debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well silent: true, // Suppresses all logs, because "[Sentry Webpack Plugin]" logs are too noisy }; From c0f84e2634c421e6d32e66178496c94f8f650d72 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:38:32 +0200 Subject: [PATCH 32/33] Reset deploy env vars --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1c6b7fe0..6baf3d75 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "deploy:customer2:production:simple": "yarn vercel:cleanup && yarn vercel:deploy --local-config=vercel.customer2.production.json --prod", "deploy:fake": "git commit --allow-empty -m \"Fake empty commit (force CI trigger)\"", "vercel:cleanup": "npx del-cli .vercel/", - "vercel:deploy": ". ./scripts/populate-git-env.sh && vercel --build-env GIT_COMMIT_TAGS=$GIT_COMMIT_TAGS --build-env GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env GIT_COMMIT_SHA=$GIT_COMMIT_SHA --build-env VERCEL_GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env VERCEL_GIT_COMMIT_SHA=$GIT_COMMIT_SHA --confirm --debug --force", + "vercel:deploy": ". ./scripts/populate-git-env.sh && vercel --build-env GIT_COMMIT_TAGS=$GIT_COMMIT_TAGS --build-env GIT_COMMIT_REF=$GIT_COMMIT_REF --build-env GIT_COMMIT_SHA=$GIT_COMMIT_SHA --confirm --debug --force", "script:populate-git-env:print": ". ./scripts/populate-git-env.sh && echo 'SHA: '${GIT_COMMIT_SHA} && echo 'REF (current branch/tag): '${GIT_COMMIT_REF} && echo 'TAGS: '${GIT_COMMIT_TAGS}", "git:getReleasesAndTags": "git tag --points-at HEAD | tr '\\r\\n' ' '", "git:getCommitSHA": "git rev-parse HEAD", From f681da09955336ad0d97ddb611f75482d1db4f02 Mon Sep 17 00:00:00 2001 From: Dhenain Ambroise Date: Fri, 25 Jun 2021 11:58:47 +0200 Subject: [PATCH 33/33] Use dryRun in development mode --- next.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/next.config.js b/next.config.js index 7030a394..1d65128d 100644 --- a/next.config.js +++ b/next.config.js @@ -31,6 +31,7 @@ const sentryWebpackPluginOptions = { // See https://github.com/getsentry/sentry-docs/issues/3721 debug: process.env.NODE_ENV === 'development', // You'll need to configure "debug" in sentry.x.config.js files as well + dryRun: process.env.NODE_ENV === 'development', // Don't upload source maps during dev (doesn't work anyway) silent: true, // Suppresses all logs, because "[Sentry Webpack Plugin]" logs are too noisy };