diff --git a/package.json b/package.json index f0d486a..c3a3aa7 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "@hookform/resolvers": "^2.6.0", "@mdx-js/loader": "^1.6.22", "@next/mdx": "^11.0.1", - "@sentry/react": "^6.8.0", - "@sentry/tracing": "^6.8.0", + "@sentry/nextjs": "^6.9.0", "@welldone-software/why-did-you-render": "^6.2.0", "@xstyled/styled-components": "^3.0.3", "@xstyled/system": "^3.0.2", diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index a82a98a..03111ee 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { AppProps as NextAppProps } from 'next/app' import { Preflight } from '@xstyled/styled-components' @@ -16,7 +15,7 @@ import 'sanitize.css/typography.css' initSentry() interface AppProps extends NextAppProps { - err: any + err: unknown } // Workaround for https://github.com/vercel/next.js/issues/8592 diff --git a/src/pages/cats.tsx b/src/pages/cats.tsx new file mode 100644 index 0000000..1eb74c5 --- /dev/null +++ b/src/pages/cats.tsx @@ -0,0 +1,32 @@ +type HomeProps = { catFacts: string[] | undefined } + +const Home = ({ catFacts }: HomeProps) => ( +
+ +
+) + +export const getStaticProps = async () => { + // const response = await fetch('https://cat-fact.herokuapp.com/facts') + // const parsedData = await response.json() + + // const formattedData = parsedData?.map((cat) => cat.text) + + const formattedData = [ + 'Cats make about 100 different sounds. Dogs make only about 10.', + 'Domestic cats spend about 70 percent of the day sleeping and 15 percent of the day grooming.', + 'I do not know anything about cats.', + 'The technical term for a cat’s hairball is a bezoar.', + 'Cats are the most popular pet in the United States.', + ] + + return { + props: { catFacts: formattedData }, + } +} + +export default Home diff --git a/src/utils/sentry.ts b/src/utils/sentry.ts index 10ece75..87897ce 100644 --- a/src/utils/sentry.ts +++ b/src/utils/sentry.ts @@ -1,5 +1,10 @@ -import * as SentryEngine from '@sentry/react' -import { Integrations } from '@sentry/tracing' +/* eslint-disable no-console */ +import { + init, + captureException as sentryCaptureException, + flush, + Exception, +} from '@sentry/nextjs' import { getPublicEnvironmentConfig, isProductionMode } from 'utils/environment' @@ -7,14 +12,12 @@ const { NEXT_PUBLIC_SENTRY_DSN } = getPublicEnvironmentConfig() export const initSentry = () => { if (!isProductionMode()) { - // eslint-disable-next-line no-console console.debug('[MONITORING] Sentry skipped.') return } if (!NEXT_PUBLIC_SENTRY_DSN) { - // eslint-disable-next-line no-console console.error( '[MONITORING] Sentry not loaded. A valid DSN config could not be found.' ) @@ -23,31 +26,33 @@ export const initSentry = () => { } try { - SentryEngine.init({ + init({ enabled: isProductionMode(), - integrations: [new Integrations.BrowserTracing()], dsn: NEXT_PUBLIC_SENTRY_DSN, }) } catch (error) { - // eslint-disable-next-line no-console console.error( - '[MONITORING] Sentry not loaded. An error was encountered when starting Sentry.' + '[MONITORING] Sentry not loaded. An error was encountered when starting Sentry.', + error ) } } -export const captureException = async (error: Error) => { +export const captureException = async (error: Error | Exception) => { if (isProductionMode()) { try { - SentryEngine.captureException(error) + sentryCaptureException(error) - const success = await SentryEngine.flush(5000) + const success = await flush(5000) if (!success) { - throw new Error() + throw new Error( + `Flush pass: false. It may not have been possible to send exception data to Nexpy servers. Please report this bug! ${String( + error + )}` + ) } - // eslint-disable-next-line no-console console.error( `Flush pass: ${success}`, 'This exception was caught automatically and will be debugged.', @@ -55,16 +60,12 @@ export const captureException = async (error: Error) => { error ) } catch { - // eslint-disable-next-line no-console console.error( - '[MONITORING] It was not possible to send exception data for Nexpy servers. Please report this bug!', + '[MONITORING] It was not possible to send exception data for Nexpy servers. Please report this bug! ', error ) } } else { - // eslint-disable-next-line no-console - console.error('[TRACKED_ERROR] ', error) + console.error('[DEV_ERROR] ', error) } } - -export default SentryEngine diff --git a/yarn.lock b/yarn.lock index 6cd81ea..c8e574c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1863,81 +1863,144 @@ resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.0.6.tgz#023d72a5c4531b4ce204528971700a78a85a0c50" integrity sha512-Myxw//kzromB9yWgS8qYGuGVf91oBUUJpNvy5eM50sqvmKLbKjwLxohJnkWGTeeI9v9IBMtPLxz5Gc60FIfvCA== -"@sentry/browser@6.8.0": - version "6.8.0" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.8.0.tgz#023707cd2302f6818014e9a7e124856b2d064178" - integrity sha512-nxa71csHlG5sMHUxI4e4xxuCWtbCv/QbBfMsYw7ncJSfCKG3yNlCVh8NJ7NS0rZW/MJUT6S6+r93zw0HetNDOA== +"@sentry/browser@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.9.0.tgz#b75ac1a6ff8fe60d451b14aea94d66f9dcd5570f" + integrity sha512-4JnEPcwoNs6JqeEd4wscBq+hxpotEJ0DJ4eOIsaNZIMyqEHXBHTXCk/gfrSsiZFrkHM4PgvUHOxaC0HcZ92oBA== + dependencies: + "@sentry/core" "6.9.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" + tslib "^1.9.3" + +"@sentry/cli@^1.64.1": + version "1.67.2" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.67.2.tgz#dbb5631cb3637e10298f67915013592cb22f04ff" + integrity sha512-lPn0Sffbjg2UmCkHl2iw8pKlqpPhy85mW0za5kz3LEqC9JGUXHo9eSyyCkiRktlemMXKk+DeS/nyFy/LTRUG2Q== dependencies: - "@sentry/core" "6.8.0" - "@sentry/types" "6.8.0" - "@sentry/utils" "6.8.0" + 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.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.9.0.tgz#43b25290f3b1eb2c23f665e1c0fcbadd06d06012" + integrity sha512-oFX2qQcMLujCeIuCQGlhpTUIOXiU5n6V2lqDnvMXUV8gKpplBPalwdlR9bgbSi+VO8u7LjHR1IKM0RAPWgNHWw== + dependencies: + "@sentry/hub" "6.9.0" + "@sentry/minimal" "6.9.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" tslib "^1.9.3" -"@sentry/core@6.8.0": - version "6.8.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.8.0.tgz#bfac76844deee9126460c18dc6166015992efdc3" - integrity sha512-vJzWt/znEB+JqVwtwfjkRrAYRN+ep+l070Ti8GhJnvwU4IDtVlV3T/jVNrj6rl6UChcczaJQMxVxtG5x0crlAA== +"@sentry/hub@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.9.0.tgz#21068e12769cc745825e8d122c7e81858f609708" + integrity sha512-5mors7ojbo7G85ZmoVPQBgFBMONAJwyZfV0LNLy14GenoaVNuxTPyvAQiJb1FYq+x6YZ3CvqGX6r74KRKQU87w== dependencies: - "@sentry/hub" "6.8.0" - "@sentry/minimal" "6.8.0" - "@sentry/types" "6.8.0" - "@sentry/utils" "6.8.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" tslib "^1.9.3" -"@sentry/hub@6.8.0": - version "6.8.0" - resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.8.0.tgz#cb0f8509093919ed3c1ef98ef8cf63dc102a6524" - integrity sha512-hFrI2Ss1fTov7CH64FJpigqRxH7YvSnGeqxT9Jc1BL7nzW/vgCK+Oh2mOZbosTcrzoDv+lE8ViOnSN3w/fo+rg== +"@sentry/integrations@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-6.9.0.tgz#40efd6dd933f7b9589da0c53ac19a52560f17a26" + integrity sha512-p4z+PsPhimoII1iiT55Favjd0wxeXVio/oHEGivaYd7Al4G2CYLVsDu25OAejxizwNn6rJE8A3WIhXC3DXN84g== dependencies: - "@sentry/types" "6.8.0" - "@sentry/utils" "6.8.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" + localforage "^1.8.1" tslib "^1.9.3" -"@sentry/minimal@6.8.0": - version "6.8.0" - resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.8.0.tgz#d6c3e4c96f231367aeb2b8a87a83b53d28e7c6db" - integrity sha512-MRxUKXiiYwKjp8mOQMpTpEuIby1Jh3zRTU0cmGZtfsZ38BC1JOle8xlwC4FdtOH+VvjSYnPBMya5lgNHNPUJDQ== +"@sentry/minimal@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.9.0.tgz#e6201eb237753994be83ec33866e3fdae9a79bf3" + integrity sha512-GBZ6wG2Rc1wInYEl2BZTZc/t57O1Da876ifLsSPpEQAEnGWbqZWb8RLjZskH09ZIL/K4XCIDDi5ySzN8kFUWJw== dependencies: - "@sentry/hub" "6.8.0" - "@sentry/types" "6.8.0" + "@sentry/hub" "6.9.0" + "@sentry/types" "6.9.0" tslib "^1.9.3" -"@sentry/react@^6.8.0": - version "6.8.0" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.8.0.tgz#3cf4a2e1ef042ee227836e268e702e9cb3b67e41" - integrity sha512-yXNnDaVw8kIacbwQjA27w8DA74WxmDVw4RlUTJGtq35SDmWsaGN1mwvU+mE1u3zEg927QTCBYig2Zqk8Tdt/fQ== +"@sentry/nextjs@^6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/nextjs/-/nextjs-6.9.0.tgz#7d3743ff2363620ec9eeb581a6f9018db13eaeba" + integrity sha512-PNnUai1nXs2I9Fe621Gwgnhjf2WzeR1ws7JxEdEnad+xmPfWKPu763dDcWSirg42PFOU+uYkE1bqcRaMXqaPGQ== + dependencies: + "@sentry/core" "6.9.0" + "@sentry/integrations" "6.9.0" + "@sentry/node" "6.9.0" + "@sentry/react" "6.9.0" + "@sentry/tracing" "6.9.0" + "@sentry/utils" "6.9.0" + "@sentry/webpack-plugin" "1.15.1" + tslib "^1.9.3" + +"@sentry/node@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-6.9.0.tgz#653c4386a1984b208eb0ff41379b33d178cbe731" + integrity sha512-hYb5NFS/3piGzGyV7V0pe7Z7ijEiFJb3Ey3iPbbje0aREUD8aUI7OVSJBctRLqEBQNCX9wX8fCHf5QNxRTUeqA== + dependencies: + "@sentry/core" "6.9.0" + "@sentry/hub" "6.9.0" + "@sentry/tracing" "6.9.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" + cookie "^0.4.1" + https-proxy-agent "^5.0.0" + lru_map "^0.3.3" + tslib "^1.9.3" + +"@sentry/react@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.9.0.tgz#2db02de48481f3680e21e52a0821fd28e90f8347" + integrity sha512-ccMhpL+YHcq171EhSHU02IYh476mBjPfK1zq+vW2fJkaigg+mEqbOHnQV0Uu3zFYHGqVg4CZKZc6v92cvbBwEg== dependencies: - "@sentry/browser" "6.8.0" - "@sentry/minimal" "6.8.0" - "@sentry/types" "6.8.0" - "@sentry/utils" "6.8.0" + "@sentry/browser" "6.9.0" + "@sentry/minimal" "6.9.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" hoist-non-react-statics "^3.3.2" tslib "^1.9.3" -"@sentry/tracing@^6.8.0": - version "6.8.0" - resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.8.0.tgz#5baa4f2e66cd2e6851c213213017850f67e65f4b" - integrity sha512-3gDkQnmOuOjHz5rY7BOatLEUksANU3efR8wuBa2ujsPQvoLSLFuyZpRjPPsxuUHQOqAYIbSNAoDloXECvQeHjw== +"@sentry/tracing@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.9.0.tgz#5dff993af253ee31e62c5f84ab21b008df7d0841" + integrity sha512-gogVTypolhPazXr3Lue8HgzBg5Sy1cQpEp5Iq9LtECs+TlOlxJ+S+P+EIjEZ0f1AHVu706jr5cY2G2Shluli9g== dependencies: - "@sentry/hub" "6.8.0" - "@sentry/minimal" "6.8.0" - "@sentry/types" "6.8.0" - "@sentry/utils" "6.8.0" + "@sentry/hub" "6.9.0" + "@sentry/minimal" "6.9.0" + "@sentry/types" "6.9.0" + "@sentry/utils" "6.9.0" tslib "^1.9.3" -"@sentry/types@6.8.0", "@sentry/types@^6.8.0": +"@sentry/types@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.9.0.tgz#ef1a541c4240df6a7c6f5f31d7cdddd7d92c15f1" + integrity sha512-v52HJqLoLapEnqS2NdVtUXPvT+aezQgNXQkp8hiQ3RUdTm5cffwBVG7wlbpE6OsOOIZxd6p1zKylFkwCypiIIA== + +"@sentry/types@^6.8.0": version "6.8.0" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.8.0.tgz#97fd531a0ed1e75e65b4a24b26509fb7c15eb7b8" integrity sha512-PbSxqlh6Fd5thNU5f8EVYBVvX+G7XdPA+ThNb2QvSK8yv3rIf0McHTyF6sIebgJ38OYN7ZFK7vvhC/RgSAfYTA== -"@sentry/utils@6.8.0": - version "6.8.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.8.0.tgz#0ffafa5b69fe0cdeabad5c4a6cc68a426eaa6b37" - integrity sha512-OYlI2JNrcWKMdvYbWNdQwR4QBVv2V0y5wK0U6f53nArv6RsyO5TzwRu5rMVSIZofUUqjoE5hl27jqnR+vpUrsA== +"@sentry/utils@6.9.0": + version "6.9.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.9.0.tgz#6bf0bf290a6d37a27078b7c1331a06d8a7e313c5" + integrity sha512-PimDr6KAi4cCp5hQZ8Az2/pDcdfhTu7WAU30Dd9MZwknpHSTmD4G6QvkdrB5er6kMMnNQOC7rMo6w/Do3m6X3w== dependencies: - "@sentry/types" "6.8.0" + "@sentry/types" "6.9.0" tslib "^1.9.3" +"@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.64.1" + "@sinonjs/commons@^1.7.0": version "1.8.3" resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.8.3.tgz#3802ddd21a50a949b6721ddd72da36e67e7f1b2d" @@ -7537,6 +7600,11 @@ image-size@1.0.0: 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" + integrity sha1-nbHb0Pr43m++D13V5Wu2BigN5ps= + immer@8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/immer/-/immer-8.0.1.tgz#9c73db683e2b3975c424fb0572af5889877ae656" @@ -8904,6 +8972,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" @@ -8994,6 +9069,13 @@ loader-utils@^1.2.3, loader-utils@^1.4.0: 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@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -9133,6 +9215,11 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +lru_map@^0.3.3: + version "0.3.3" + resolved "https://registry.yarnpkg.com/lru_map/-/lru_map-0.3.3.tgz#b5c8351b9464cbd750335a79650a0ec0e56118dd" + integrity sha1-tcg1G5Rky9dQM1p5ZQoOwOVhGN0= + make-dir@^2.0.0, make-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" @@ -9558,7 +9645,7 @@ mixin-deep@^1.2.0: for-in "^1.0.2" is-extendable "^1.0.1" -mkdirp@^0.5.1, mkdirp@^0.5.3: +mkdirp@^0.5.1, 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== @@ -9761,7 +9848,7 @@ node-dir@^0.1.10: dependencies: minimatch "^3.0.2" -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== @@ -10681,7 +10768,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== @@ -10757,6 +10844,11 @@ proxy-addr@~2.0.5: forwarded "0.2.0" 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"