From 92d74c662d26486901f4b83c45b7c921ce0e1ff3 Mon Sep 17 00:00:00 2001 From: Kalil Smith-Nuevelle Date: Thu, 28 Sep 2023 12:56:29 -0500 Subject: [PATCH 1/5] Add sentry to core --- .gitignore | 5 +- core/app/api/sentry-example-api/route.js | 7 + core/app/sentry-example-page/page.jsx | 86 ++++++ core/next.config.js | 37 +++ core/package.json | 1 + core/sentry.client.config.ts | 30 ++ core/sentry.edge.config.ts | 16 + core/sentry.server.config.ts | 17 ++ pnpm-lock.yaml | 353 +++++++++++++++++++++-- 9 files changed, 526 insertions(+), 26 deletions(-) create mode 100644 core/app/api/sentry-example-api/route.js create mode 100644 core/app/sentry-example-page/page.jsx create mode 100644 core/sentry.client.config.ts create mode 100644 core/sentry.edge.config.ts create mode 100644 core/sentry.server.config.ts diff --git a/.gitignore b/.gitignore index 4829ea179d..df64c951eb 100644 --- a/.gitignore +++ b/.gitignore @@ -45,4 +45,7 @@ next-env.d.ts dump.rdb # turbo -.turbo \ No newline at end of file +.turbo + +# Sentry Auth Token +.sentryclirc diff --git a/core/app/api/sentry-example-api/route.js b/core/app/api/sentry-example-api/route.js new file mode 100644 index 0000000000..80dcc18d99 --- /dev/null +++ b/core/app/api/sentry-example-api/route.js @@ -0,0 +1,7 @@ +import { NextResponse } from "next/server"; + +// A faulty API route to test Sentry's error monitoring +export function GET() { + throw new Error("Sentry Example API Route Error"); + return NextResponse.json({ data: "Testing Sentry Error..." }); +} diff --git a/core/app/sentry-example-page/page.jsx b/core/app/sentry-example-page/page.jsx new file mode 100644 index 0000000000..c701d78e9d --- /dev/null +++ b/core/app/sentry-example-page/page.jsx @@ -0,0 +1,86 @@ +"use client"; + +import Head from "next/head"; +import * as Sentry from "@sentry/nextjs"; + +export default function Page() { + return ( +
+ + Sentry Onboarding + + + +
+

+ + + +

+ +

Get started by sending us a sample error:

+ + +

+ Next, look for the error on the{" "} + Issues Page. +

+

+ For more information, see{" "} + + https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +

+
+
+ ); +} diff --git a/core/next.config.js b/core/next.config.js index ae228fb121..9575e1d179 100644 --- a/core/next.config.js +++ b/core/next.config.js @@ -25,3 +25,40 @@ const nextConfig = { }; module.exports = withPreconstruct(nextConfig); + + +// Injected content via Sentry wizard below + +const { withSentryConfig } = require("@sentry/nextjs"); + +module.exports = withSentryConfig( + module.exports, + { + // For all available options, see: + // https://github.com/getsentry/sentry-webpack-plugin#options + + // Suppresses source map uploading logs during build + silent: true, + org: "kfg", + project: "v7-core", + }, + { + // For all available options, see: + // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ + + // Upload a larger set of source maps for prettier stack traces (increases build time) + widenClientFileUpload: true, + + // Transpiles SDK to be compatible with IE11 (increases bundle size) + transpileClientSDK: true, + + // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) + tunnelRoute: "/monitoring", + + // Hides source maps from generated client bundles + hideSourceMaps: true, + + // Automatically tree-shake Sentry logger statements to reduce bundle size + disableLogger: true, + } +); diff --git a/core/package.json b/core/package.json index 7d86882bde..328e18d5e5 100644 --- a/core/package.json +++ b/core/package.json @@ -20,6 +20,7 @@ "dependencies": { "@faker-js/faker": "^8.0.2", "@prisma/client": "^5.2.0", + "@sentry/nextjs": "^7.72.0", "@supabase/supabase-js": "^2.33.2", "@ts-rest/core": "^3.28.0", "@ts-rest/next": "^3.28.0", diff --git a/core/sentry.client.config.ts b/core/sentry.client.config.ts new file mode 100644 index 0000000000..27f29a1db7 --- /dev/null +++ b/core/sentry.client.config.ts @@ -0,0 +1,30 @@ +// This file configures the initialization of Sentry on the client. +// The config you add here will be used whenever a users loads a page in their browser. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "https://5012643b47ea6b2c8917f14442066f23@o31718.ingest.sentry.io/4505959187480576", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, + + replaysOnErrorSampleRate: 1.0, + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 1, + + // You can remove this option if you're not planning to use the Sentry Session Replay feature: + integrations: [ + new Sentry.Replay({ + // Additional Replay configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); diff --git a/core/sentry.edge.config.ts b/core/sentry.edge.config.ts new file mode 100644 index 0000000000..db88163525 --- /dev/null +++ b/core/sentry.edge.config.ts @@ -0,0 +1,16 @@ +// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on). +// The config you add here will be used whenever one of the edge features is loaded. +// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "https://5012643b47ea6b2c8917f14442066f23@o31718.ingest.sentry.io/4505959187480576", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, +}); diff --git a/core/sentry.server.config.ts b/core/sentry.server.config.ts new file mode 100644 index 0000000000..f1285d75fa --- /dev/null +++ b/core/sentry.server.config.ts @@ -0,0 +1,17 @@ +// 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"; +import prisma from "~/prisma/db"; + +Sentry.init({ + dsn: "https://5012643b47ea6b2c8917f14442066f23@o31718.ingest.sentry.io/4505959187480576", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, + integrations: [new Sentry.Integrations.Prisma({ client: prisma })], +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ddad9e564..9fbda3a8f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,7 +40,7 @@ importers: version: 0.1.11(prettier@2.8.8) turbo: specifier: latest - version: 1.10.14 + version: 1.10.13 core: dependencies: @@ -50,6 +50,9 @@ importers: '@prisma/client': specifier: ^5.2.0 version: 5.2.0(prisma@5.2.0) + '@sentry/nextjs': + specifier: ^7.72.0 + version: 7.72.0(next@13.5.2)(react@18.2.0) '@supabase/supabase-js': specifier: ^2.33.2 version: 2.33.2 @@ -3028,6 +3031,24 @@ packages: rollup: 2.79.1 dev: true + /@rollup/plugin-commonjs@24.0.0(rollup@2.78.0): + resolution: {integrity: sha512-0w0wyykzdyRRPHOb0cQt14mIBLujfAv6GgP6g8nvg/iBxEm112t3YPPq+Buqe2+imvElTka+bjNlJ/gB56TD8g==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.68.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.0.4(rollup@2.78.0) + commondir: 1.0.1 + estree-walker: 2.0.2 + glob: 8.1.0 + is-reference: 1.2.1 + magic-string: 0.27.0 + rollup: 2.78.0 + dev: false + /@rollup/plugin-json@4.1.0(rollup@2.79.1): resolution: {integrity: sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==} peerDependencies: @@ -3074,6 +3095,183 @@ packages: rollup: 2.79.1 dev: true + /@rollup/pluginutils@5.0.4(rollup@2.78.0): + resolution: {integrity: sha512-0KJnIoRI8A+a1dqOYLxH8vBf8bphDmty5QvIm2hqm7oFCFYKCAZWWd2hXgMibaPsNDhI0AtpYfQZJG47pt/k4g==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@types/estree': 1.0.1 + estree-walker: 2.0.2 + picomatch: 2.3.1 + rollup: 2.78.0 + dev: false + + /@sentry-internal/tracing@7.72.0: + resolution: {integrity: sha512-DToryaRSHk9R5RLgN4ktYEXZjQdqncOAWPqyyIurji8lIobXFRfmLtGL1wjoCK6sQNgWsjhSM9kXxwGnva1DNw==} + engines: {node: '>=8'} + dependencies: + '@sentry/core': 7.72.0 + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + tslib: 2.6.1 + dev: false + + /@sentry/browser@7.72.0: + resolution: {integrity: sha512-fcFDTzqhPd3VZAmmYW3KvBTBaEfrKjPmRhlAsfhkGWYLCHqVkNtzsFER4cmUNRGNxjyt9tcG3WlTTqgLRucycQ==} + engines: {node: '>=8'} + dependencies: + '@sentry-internal/tracing': 7.72.0 + '@sentry/core': 7.72.0 + '@sentry/replay': 7.72.0 + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + tslib: 2.6.1 + dev: false + + /@sentry/cli@1.75.2: + resolution: {integrity: sha512-CG0CKH4VCKWzEaegouWfCLQt9SFN+AieFESCatJ7zSuJmzF05ywpMusjxqRul6lMwfUhRKjGKOzcRJ1jLsfTBw==} + engines: {node: '>= 8'} + hasBin: true + requiresBuild: true + dependencies: + https-proxy-agent: 5.0.1 + mkdirp: 0.5.6 + node-fetch: 2.6.12 + progress: 2.0.3 + proxy-from-env: 1.1.0 + which: 2.0.2 + transitivePeerDependencies: + - encoding + - supports-color + dev: false + + /@sentry/core@7.72.0: + resolution: {integrity: sha512-G03JdQ5ZsFNRjcNNi+QvCjqOuBvYqU92Gs1T2iK3GE8dSBTu2khThydMpG4xrKZQLIpHOyiIhlFZiuPtZ66W8w==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + tslib: 2.6.1 + dev: false + + /@sentry/integrations@7.72.0: + resolution: {integrity: sha512-ay2WgLtjsr0WS8+N7i7VmKzondoZRh3ISx8rb91LjmVrDNu8baleZAB59jkKe/JSy0gYh99umJuptc2te/65+A==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + localforage: 1.10.0 + tslib: 2.6.1 + dev: false + + /@sentry/nextjs@7.72.0(next@13.5.2)(react@18.2.0): + resolution: {integrity: sha512-8S7OHPwFUwm2Ci9lC9lIwsXwNzxgq/lS84RDPma2ChPQv8rbxivVtDArQl/jgr4wn6WJ2UyDKsoic+TbgIumNw==} + engines: {node: '>=8'} + peerDependencies: + next: ^10.0.8 || ^11.0 || ^12.0 || ^13.0 + react: 16.x || 17.x || 18.x + webpack: '>= 4.0.0' + peerDependenciesMeta: + webpack: + optional: true + dependencies: + '@rollup/plugin-commonjs': 24.0.0(rollup@2.78.0) + '@sentry/core': 7.72.0 + '@sentry/integrations': 7.72.0 + '@sentry/node': 7.72.0 + '@sentry/react': 7.72.0(react@18.2.0) + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + '@sentry/vercel-edge': 7.72.0 + '@sentry/webpack-plugin': 1.20.0 + chalk: 3.0.0 + next: 13.5.2(@babel/core@7.22.17)(react-dom@18.2.0)(react@18.2.0) + react: 18.2.0 + rollup: 2.78.0 + stacktrace-parser: 0.1.10 + tslib: 2.6.1 + transitivePeerDependencies: + - encoding + - supports-color + dev: false + + /@sentry/node@7.72.0: + resolution: {integrity: sha512-R5kNCIdaDa92EN6oCLiGJehw5wxayOM53WF60Ap6EJHZb5U8dM2BnODmQ6SCRLNB677p+620oSV6CCU286IleQ==} + engines: {node: '>=8'} + dependencies: + '@sentry-internal/tracing': 7.72.0 + '@sentry/core': 7.72.0 + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + cookie: 0.5.0 + https-proxy-agent: 5.0.1 + lru_map: 0.3.3 + tslib: 2.6.1 + transitivePeerDependencies: + - supports-color + dev: false + + /@sentry/react@7.72.0(react@18.2.0): + resolution: {integrity: sha512-BYFO3uyB9FfdUq05NtsS+OfU636HMZ7avbSEALo24x+OPuaD+fCByTdgxYVpDRYrBPa7lALYzCge0PDcGnGiig==} + engines: {node: '>=8'} + peerDependencies: + react: 15.x || 16.x || 17.x || 18.x + dependencies: + '@sentry/browser': 7.72.0 + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + hoist-non-react-statics: 3.3.2 + react: 18.2.0 + tslib: 2.6.1 + dev: false + + /@sentry/replay@7.72.0: + resolution: {integrity: sha512-dHH/mYCFBwJ/kYmL9L5KihjwQKcefiuvcH0otHSwKSpbbeEoM/BV+SHQoYGd6OMSYnL9fq1dHfF7Zo26p5Yu0Q==} + engines: {node: '>=12'} + dependencies: + '@sentry/core': 7.72.0 + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + dev: false + + /@sentry/types@7.72.0: + resolution: {integrity: sha512-g6u0mk62yGshx02rfFADIfyR/S9VXcf3RG2qQPuvykrWtOfN/BOTrZypF7I+MiqKwRW76r3Pcu2C/AB+6z9XQA==} + engines: {node: '>=8'} + dev: false + + /@sentry/utils@7.72.0: + resolution: {integrity: sha512-o/MtqI7WJXuswidH0bSgBP40KN2lrnyQEIx5uoyJUJi/QEaboIsqbxU62vaFJpde8SYrbA+rTnP3J3ujF2gUag==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.72.0 + tslib: 2.6.1 + dev: false + + /@sentry/vercel-edge@7.72.0: + resolution: {integrity: sha512-H2A+59jVKgQ2E4EQh5nFBqfJ0foEGh+aGItdvbq7PcJSI1sosA4sDeY6pQzoFtdMLL23FC7dojOxOI5b3JTtmg==} + engines: {node: '>=8'} + dependencies: + '@sentry/core': 7.72.0 + '@sentry/types': 7.72.0 + '@sentry/utils': 7.72.0 + tslib: 2.6.1 + dev: false + + /@sentry/webpack-plugin@1.20.0: + resolution: {integrity: sha512-Ssj1mJVFsfU6vMCOM2d+h+KQR7QHSfeIP16t4l20Uq/neqWXZUQ2yvQfe4S3BjdbJXz/X4Rw8Hfy1Sd0ocunYw==} + engines: {node: '>= 8'} + dependencies: + '@sentry/cli': 1.75.2 + webpack-sources: 3.2.3 + transitivePeerDependencies: + - encoding + - supports-color + dev: false + /@supabase/functions-js@2.1.5: resolution: {integrity: sha512-BNzC5XhCzzCaggJ8s53DP+WeHHGT/NfTsx2wUSSGKR2/ikLFQTBCDzMvGz/PxYMqRko/LwncQtKXGOYp1PkPaw==} dependencies: @@ -3507,7 +3705,6 @@ packages: /@types/estree@1.0.1: resolution: {integrity: sha512-LG4opVs2ANWZ1TJoKc937iMmNstM/d0ae1vNbnBvBhqCSezgVUOzcLCqbI5elV8Vy6WKwKjaqR+zO9VKirBBCA==} - dev: true /@types/hast@2.3.5: resolution: {integrity: sha512-SvQi0L/lNpThgPoleH53cdjB3y9zpLlVjRbqB3rH8hx1jiRSBGAhyjV3H+URFjNVRqt2EdYNrbZE5IsGlNfpRg==} @@ -3645,6 +3842,15 @@ packages: engines: {node: '>=0.4.0'} hasBin: true + /agent-base@6.0.2: + resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} + engines: {node: '>= 6.0.0'} + dependencies: + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + dev: false + /aggregate-error@3.1.0: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} engines: {node: '>=8'} @@ -3997,6 +4203,14 @@ packages: escape-string-regexp: 1.0.5 supports-color: 5.5.0 + /chalk@3.0.0: + resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==} + engines: {node: '>=8'} + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + dev: false + /chalk@4.1.2: resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} engines: {node: '>=10'} @@ -4203,7 +4417,6 @@ packages: /commondir@1.0.1: resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} - dev: true /concat-map@0.0.1: resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} @@ -4617,7 +4830,6 @@ packages: /estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} - dev: true /esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} @@ -4947,6 +5159,17 @@ packages: once: 1.4.0 path-is-absolute: 1.0.1 + /glob@8.1.0: + resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} + engines: {node: '>=12'} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 + dev: false + /globals@11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} @@ -5055,6 +5278,16 @@ packages: resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} dev: true + /https-proxy-agent@5.0.1: + resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==} + engines: {node: '>= 6'} + dependencies: + agent-base: 6.0.2 + debug: 4.3.4 + transitivePeerDependencies: + - supports-color + dev: false + /human-id@1.0.2: resolution: {integrity: sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw==} dev: true @@ -5092,6 +5325,10 @@ packages: engines: {node: '>= 4'} dev: true + /immediate@3.0.6: + resolution: {integrity: sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==} + dev: false + /immutable@3.8.2: resolution: {integrity: sha512-15gZoQ38eYjEjxkorfbcgBKBL6R7T459OuK+CpcWt7O3KF4uPCx2tD0uFETlUDIyo+1789crbMhTvQBSR5yBMg==} engines: {node: '>=0.10.0'} @@ -5296,7 +5533,6 @@ packages: resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} dependencies: '@types/estree': 1.0.1 - dev: true /is-regex@1.1.4: resolution: {integrity: sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==} @@ -5481,6 +5717,12 @@ packages: engines: {node: '>=6'} dev: true + /lie@3.1.1: + resolution: {integrity: sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==} + dependencies: + immediate: 3.0.6 + dev: false + /lilconfig@2.1.0: resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==} engines: {node: '>=10'} @@ -5540,6 +5782,12 @@ packages: strip-bom: 3.0.0 dev: true + /localforage@1.10.0: + resolution: {integrity: sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==} + dependencies: + lie: 3.1.1 + dev: false + /locate-path@5.0.0: resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} engines: {node: '>=8'} @@ -5618,6 +5866,10 @@ packages: dependencies: yallist: 4.0.0 + /lru_map@0.3.3: + resolution: {integrity: sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==} + dev: false + /lucide-react@0.274.0(react@18.2.0): resolution: {integrity: sha512-qiWcojRXEwDiSimMX1+arnxha+ROJzZjJaVvCC0rsG6a9pUPjZePXSq7em4ZKMp0NDm1hyzPNkM7UaWC3LU2AA==} peerDependencies: @@ -5632,6 +5884,13 @@ packages: sourcemap-codec: 1.4.8 dev: true + /magic-string@0.27.0: + resolution: {integrity: sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 + dev: false + /magic-string@0.30.3: resolution: {integrity: sha512-B7xGbll2fG/VjP+SWg4sX3JynwIU0mjoTc6MPpKNuIvftk6u6vqhDnk1R80b8C2GBR6ywqy+1DcKBrevBg+bmw==} engines: {node: '>=12'} @@ -5752,6 +6011,13 @@ packages: dependencies: brace-expansion: 1.1.11 + /minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: false + /minimatch@7.4.6: resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} engines: {node: '>=10'} @@ -5802,6 +6068,13 @@ packages: dev: false optional: true + /mkdirp@0.5.6: + resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} + hasBin: true + dependencies: + minimist: 1.2.8 + dev: false + /mkdirp@1.0.4: resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} engines: {node: '>=10'} @@ -6402,6 +6675,11 @@ packages: engines: {node: '>= 0.6.0'} dev: false + /progress@2.0.3: + resolution: {integrity: sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==} + engines: {node: '>=0.4.0'} + dev: false + /prop-types@15.8.1: resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} dependencies: @@ -6902,6 +7180,14 @@ packages: glob: 7.1.6 dev: false + /rollup@2.78.0: + resolution: {integrity: sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg==} + engines: {node: '>=10.0.0'} + hasBin: true + optionalDependencies: + fsevents: 2.3.2 + dev: false + /rollup@2.79.1: resolution: {integrity: sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==} engines: {node: '>=10.0.0'} @@ -7157,6 +7443,13 @@ packages: /sprintf-js@1.0.3: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + /stacktrace-parser@0.1.10: + resolution: {integrity: sha512-KJP1OCML99+8fhOHxwwzyWrlUuVX5GQ0ZpJTd1DFXhdkrvg1szxfHhawXUZ3g9TkXORQd4/WG68jMlQZ2p8wlg==} + engines: {node: '>=6'} + dependencies: + type-fest: 0.7.1 + dev: false + /stampit@4.3.2: resolution: {integrity: sha512-pE2org1+ZWQBnIxRPrBM2gVupkuDD0TTNIo1H6GdT/vO82NXli2z8lRE8cu/nBIHrcOCXFBAHpb9ZldrB2/qOA==} dev: false @@ -7661,64 +7954,64 @@ packages: dev: false optional: true - /turbo-darwin-64@1.10.14: - resolution: {integrity: sha512-I8RtFk1b9UILAExPdG/XRgGQz95nmXPE7OiGb6ytjtNIR5/UZBS/xVX/7HYpCdmfriKdVwBKhalCoV4oDvAGEg==} + /turbo-darwin-64@1.10.13: + resolution: {integrity: sha512-vmngGfa2dlYvX7UFVncsNDMuT4X2KPyPJ2Jj+xvf5nvQnZR/3IeDEGleGVuMi/hRzdinoxwXqgk9flEmAYp0Xw==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-darwin-arm64@1.10.14: - resolution: {integrity: sha512-KAdUWryJi/XX7OD0alOuOa0aJ5TLyd4DNIYkHPHYcM6/d7YAovYvxRNwmx9iv6Vx6IkzTnLeTiUB8zy69QkG9Q==} + /turbo-darwin-arm64@1.10.13: + resolution: {integrity: sha512-eMoJC+k7gIS4i2qL6rKmrIQGP6Wr9nN4odzzgHFngLTMimok2cGLK3qbJs5O5F/XAtEeRAmuxeRnzQwTl/iuAw==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-linux-64@1.10.14: - resolution: {integrity: sha512-BOBzoREC2u4Vgpap/WDxM6wETVqVMRcM8OZw4hWzqCj2bqbQ6L0wxs1LCLWVrghQf93JBQtIGAdFFLyCSBXjWQ==} + /turbo-linux-64@1.10.13: + resolution: {integrity: sha512-0CyYmnKTs6kcx7+JRH3nPEqCnzWduM0hj8GP/aodhaIkLNSAGAa+RiYZz6C7IXN+xUVh5rrWTnU2f1SkIy7Gdg==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-linux-arm64@1.10.14: - resolution: {integrity: sha512-D8T6XxoTdN5D4V5qE2VZG+/lbZX/89BkAEHzXcsSUTRjrwfMepT3d2z8aT6hxv4yu8EDdooZq/2Bn/vjMI32xw==} + /turbo-linux-arm64@1.10.13: + resolution: {integrity: sha512-0iBKviSGQQlh2OjZgBsGjkPXoxvRIxrrLLbLObwJo3sOjIH0loGmVIimGS5E323soMfi/o+sidjk2wU1kFfD7Q==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-windows-64@1.10.14: - resolution: {integrity: sha512-zKNS3c1w4i6432N0cexZ20r/aIhV62g69opUn82FLVs/zk3Ie0GVkSB6h0rqIvMalCp7enIR87LkPSDGz9K4UA==} + /turbo-windows-64@1.10.13: + resolution: {integrity: sha512-S5XySRfW2AmnTeY1IT+Jdr6Goq7mxWganVFfrmqU+qqq3Om/nr0GkcUX+KTIo9mPrN0D3p5QViBRzulwB5iuUQ==} cpu: [x64] os: [win32] requiresBuild: true dev: true optional: true - /turbo-windows-arm64@1.10.14: - resolution: {integrity: sha512-rkBwrTPTxNSOUF7of8eVvvM+BkfkhA2OvpHM94if8tVsU+khrjglilp8MTVPHlyS9byfemPAmFN90oRIPB05BA==} + /turbo-windows-arm64@1.10.13: + resolution: {integrity: sha512-nKol6+CyiExJIuoIc3exUQPIBjP9nIq5SkMJgJuxsot2hkgGrafAg/izVDRDrRduQcXj2s8LdtxJHvvnbI8hEQ==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /turbo@1.10.14: - resolution: {integrity: sha512-hr9wDNYcsee+vLkCDIm8qTtwhJ6+UAMJc3nIY6+PNgUTtXcQgHxCq8BGoL7gbABvNWv76CNbK5qL4Lp9G3ZYRA==} + /turbo@1.10.13: + resolution: {integrity: sha512-vOF5IPytgQPIsgGtT0n2uGZizR2N3kKuPIn4b5p5DdeLoI0BV7uNiydT7eSzdkPRpdXNnO8UwS658VaI4+YSzQ==} hasBin: true optionalDependencies: - turbo-darwin-64: 1.10.14 - turbo-darwin-arm64: 1.10.14 - turbo-linux-64: 1.10.14 - turbo-linux-arm64: 1.10.14 - turbo-windows-64: 1.10.14 - turbo-windows-arm64: 1.10.14 + turbo-darwin-64: 1.10.13 + turbo-darwin-arm64: 1.10.13 + turbo-linux-64: 1.10.13 + turbo-linux-arm64: 1.10.13 + turbo-windows-64: 1.10.13 + turbo-windows-arm64: 1.10.13 dev: true /type-fest@0.13.1: @@ -7741,6 +8034,11 @@ packages: engines: {node: '>=8'} dev: true + /type-fest@0.7.1: + resolution: {integrity: sha512-Ne2YiiGN8bmrmJJEuTWTLJR32nh/JdL1+PSicowtNb0WFpn59GK8/lfD61bVtzguz7b3PBt74nxpv/Pw5po5Rg==} + engines: {node: '>=8'} + dev: false + /type-fest@0.8.1: resolution: {integrity: sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==} engines: {node: '>=8'} @@ -7996,6 +8294,11 @@ packages: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: false + /webpack-sources@3.2.3: + resolution: {integrity: sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==} + engines: {node: '>=10.13.0'} + dev: false + /websocket@1.0.34: resolution: {integrity: sha512-PRDso2sGwF6kM75QykIesBijKSVceR6jL2G8NGYyq2XrItNC2P5/qL5XeR056GhA+Ly7JMFvJb9I312mJfmqnQ==} engines: {node: '>=4.0.0'} From b5fd8a12c98a2a7def4ec5af5811667a3199ac05 Mon Sep 17 00:00:00 2001 From: Kalil Smith-Nuevelle Date: Thu, 28 Sep 2023 13:01:18 -0500 Subject: [PATCH 2/5] Update next config --- core/next.config.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/core/next.config.js b/core/next.config.js index 9575e1d179..5b50e47133 100644 --- a/core/next.config.js +++ b/core/next.config.js @@ -1,7 +1,8 @@ /** @type {import('next').NextConfig} */ const withPreconstruct = require("@preconstruct/next"); +const { withSentryConfig } = require("@sentry/nextjs"); -const nextConfig = { +const nextConfig = withPreconstruct({ reactStrictMode: true, images: { remotePatterns: [ @@ -22,17 +23,10 @@ const nextConfig = { experimental: { serverActions: true, }, -}; - -module.exports = withPreconstruct(nextConfig); - - -// Injected content via Sentry wizard below - -const { withSentryConfig } = require("@sentry/nextjs"); +}); module.exports = withSentryConfig( - module.exports, + nextConfig, { // For all available options, see: // https://github.com/getsentry/sentry-webpack-plugin#options @@ -53,7 +47,7 @@ module.exports = withSentryConfig( transpileClientSDK: true, // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) - tunnelRoute: "/monitoring", + // tunnelRoute: "/monitoring", // Hides source maps from generated client bundles hideSourceMaps: true, From 8d2e0f41ff18c589fb10e245983a5b3d6f4e2552 Mon Sep 17 00:00:00 2001 From: Kalil Smith-Nuevelle Date: Thu, 28 Sep 2023 13:02:30 -0500 Subject: [PATCH 3/5] Add sentry to submissions integration --- .../app/api/sentry-example-api/route.js | 7 ++ .../app/sentry-example-page/page.jsx | 86 +++++++++++++++++++ integrations/submissions/next.config.js | 37 +++++++- integrations/submissions/package.json | 1 + .../submissions/sentry.client.config.ts | 30 +++++++ .../submissions/sentry.edge.config.ts | 16 ++++ .../submissions/sentry.server.config.ts | 15 ++++ pnpm-lock.yaml | 3 + 8 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 integrations/submissions/app/api/sentry-example-api/route.js create mode 100644 integrations/submissions/app/sentry-example-page/page.jsx create mode 100644 integrations/submissions/sentry.client.config.ts create mode 100644 integrations/submissions/sentry.edge.config.ts create mode 100644 integrations/submissions/sentry.server.config.ts diff --git a/integrations/submissions/app/api/sentry-example-api/route.js b/integrations/submissions/app/api/sentry-example-api/route.js new file mode 100644 index 0000000000..80dcc18d99 --- /dev/null +++ b/integrations/submissions/app/api/sentry-example-api/route.js @@ -0,0 +1,7 @@ +import { NextResponse } from "next/server"; + +// A faulty API route to test Sentry's error monitoring +export function GET() { + throw new Error("Sentry Example API Route Error"); + return NextResponse.json({ data: "Testing Sentry Error..." }); +} diff --git a/integrations/submissions/app/sentry-example-page/page.jsx b/integrations/submissions/app/sentry-example-page/page.jsx new file mode 100644 index 0000000000..5dda4df362 --- /dev/null +++ b/integrations/submissions/app/sentry-example-page/page.jsx @@ -0,0 +1,86 @@ +"use client"; + +import Head from "next/head"; +import * as Sentry from "@sentry/nextjs"; + +export default function Page() { + return ( +
+ + Sentry Onboarding + + + +
+

+ + + +

+ +

Get started by sending us a sample error:

+ + +

+ Next, look for the error on the{" "} + Issues Page. +

+

+ For more information, see{" "} + + https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +

+
+
+ ); +} diff --git a/integrations/submissions/next.config.js b/integrations/submissions/next.config.js index e0c27db57c..853a84d750 100644 --- a/integrations/submissions/next.config.js +++ b/integrations/submissions/next.config.js @@ -1,11 +1,42 @@ /** @type {import('next').NextConfig} */ const withPreconstruct = require("@preconstruct/next"); +const { withSentryConfig } = require("@sentry/nextjs"); -const nextConfig = { +const nextConfig = withPreconstruct({ reactStrictMode: true, experimental: { serverActions: true, }, -}; +}); -module.exports = withPreconstruct(nextConfig); +module.exports = withSentryConfig( + nextConfig, + { + // For all available options, see: + // https://github.com/getsentry/sentry-webpack-plugin#options + + // Suppresses source map uploading logs during build + silent: true, + org: "kfg", + project: "v7-submissions", + }, + { + // For all available options, see: + // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ + + // Upload a larger set of source maps for prettier stack traces (increases build time) + widenClientFileUpload: true, + + // Transpiles SDK to be compatible with IE11 (increases bundle size) + transpileClientSDK: true, + + // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) + // tunnelRoute: "/monitoring", + + // Hides source maps from generated client bundles + hideSourceMaps: true, + + // Automatically tree-shake Sentry logger statements to reduce bundle size + disableLogger: true, + } +); diff --git a/integrations/submissions/package.json b/integrations/submissions/package.json index 4a1b81ed71..43497b5e6d 100644 --- a/integrations/submissions/package.json +++ b/integrations/submissions/package.json @@ -11,6 +11,7 @@ "dependencies": { "@hookform/resolvers": "^3.3.1", "@pubpub/sdk": "workspace:*", + "@sentry/nextjs": "^7.72.0", "clsx": "^2.0.0", "contracts": "workspace:*", "next": "13.5.2", diff --git a/integrations/submissions/sentry.client.config.ts b/integrations/submissions/sentry.client.config.ts new file mode 100644 index 0000000000..fdcb3cd613 --- /dev/null +++ b/integrations/submissions/sentry.client.config.ts @@ -0,0 +1,30 @@ +// This file configures the initialization of Sentry on the client. +// The config you add here will be used whenever a users loads a page in their browser. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "https://7c82e3153327133e3fd930edb146bd6e@o31718.ingest.sentry.io/4505959387430913", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, + + replaysOnErrorSampleRate: 1.0, + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // You can remove this option if you're not planning to use the Sentry Session Replay feature: + integrations: [ + new Sentry.Replay({ + // Additional Replay configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); diff --git a/integrations/submissions/sentry.edge.config.ts b/integrations/submissions/sentry.edge.config.ts new file mode 100644 index 0000000000..4d47b40119 --- /dev/null +++ b/integrations/submissions/sentry.edge.config.ts @@ -0,0 +1,16 @@ +// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on). +// The config you add here will be used whenever one of the edge features is loaded. +// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "https://7c82e3153327133e3fd930edb146bd6e@o31718.ingest.sentry.io/4505959387430913", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, +}); diff --git a/integrations/submissions/sentry.server.config.ts b/integrations/submissions/sentry.server.config.ts new file mode 100644 index 0000000000..dea2a71e8f --- /dev/null +++ b/integrations/submissions/sentry.server.config.ts @@ -0,0 +1,15 @@ +// 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"; + +Sentry.init({ + dsn: "https://7c82e3153327133e3fd930edb146bd6e@o31718.ingest.sentry.io/4505959387430913", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9fbda3a8f4..95fda6d3b4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -259,6 +259,9 @@ importers: '@pubpub/sdk': specifier: workspace:* version: link:../../packages/sdk + '@sentry/nextjs': + specifier: ^7.72.0 + version: 7.72.0(next@13.5.2)(react@18.2.0) clsx: specifier: ^2.0.0 version: 2.0.0 From 8c6fb3bb02212a0dbcd734a72be46f5681f5e9a6 Mon Sep 17 00:00:00 2001 From: Kalil Smith-Nuevelle Date: Thu, 28 Sep 2023 13:10:10 -0500 Subject: [PATCH 4/5] Add sentry to evaluations integration --- .../app/api/sentry-example-api/route.js | 7 ++ .../app/sentry-example-page/page.jsx | 86 +++++++++++++++++++ integrations/evaluations/next.config.js | 37 +++++++- integrations/evaluations/package.json | 1 + .../evaluations/sentry.client.config.ts | 30 +++++++ .../evaluations/sentry.edge.config.ts | 16 ++++ .../evaluations/sentry.server.config.ts | 15 ++++ pnpm-lock.yaml | 3 + 8 files changed, 192 insertions(+), 3 deletions(-) create mode 100644 integrations/evaluations/app/api/sentry-example-api/route.js create mode 100644 integrations/evaluations/app/sentry-example-page/page.jsx create mode 100644 integrations/evaluations/sentry.client.config.ts create mode 100644 integrations/evaluations/sentry.edge.config.ts create mode 100644 integrations/evaluations/sentry.server.config.ts diff --git a/integrations/evaluations/app/api/sentry-example-api/route.js b/integrations/evaluations/app/api/sentry-example-api/route.js new file mode 100644 index 0000000000..80dcc18d99 --- /dev/null +++ b/integrations/evaluations/app/api/sentry-example-api/route.js @@ -0,0 +1,7 @@ +import { NextResponse } from "next/server"; + +// A faulty API route to test Sentry's error monitoring +export function GET() { + throw new Error("Sentry Example API Route Error"); + return NextResponse.json({ data: "Testing Sentry Error..." }); +} diff --git a/integrations/evaluations/app/sentry-example-page/page.jsx b/integrations/evaluations/app/sentry-example-page/page.jsx new file mode 100644 index 0000000000..082985d1f4 --- /dev/null +++ b/integrations/evaluations/app/sentry-example-page/page.jsx @@ -0,0 +1,86 @@ +"use client"; + +import Head from "next/head"; +import * as Sentry from "@sentry/nextjs"; + +export default function Page() { + return ( +
+ + Sentry Onboarding + + + +
+

+ + + +

+ +

Get started by sending us a sample error:

+ + +

+ Next, look for the error on the{" "} + Issues Page. +

+

+ For more information, see{" "} + + https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +

+
+
+ ); +} diff --git a/integrations/evaluations/next.config.js b/integrations/evaluations/next.config.js index e0c27db57c..71ca79db23 100644 --- a/integrations/evaluations/next.config.js +++ b/integrations/evaluations/next.config.js @@ -1,11 +1,42 @@ /** @type {import('next').NextConfig} */ const withPreconstruct = require("@preconstruct/next"); +const { withSentryConfig } = require("@sentry/nextjs"); -const nextConfig = { +const nextConfig = withPreconstruct({ reactStrictMode: true, experimental: { serverActions: true, }, -}; +}); -module.exports = withPreconstruct(nextConfig); +module.exports = withSentryConfig( + nextConfig, + { + // For all available options, see: + // https://github.com/getsentry/sentry-webpack-plugin#options + + // Suppresses source map uploading logs during build + silent: true, + org: "kfg", + project: "v7-evaluations", + }, + { + // For all available options, see: + // https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/ + + // Upload a larger set of source maps for prettier stack traces (increases build time) + widenClientFileUpload: true, + + // Transpiles SDK to be compatible with IE11 (increases bundle size) + transpileClientSDK: true, + + // Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load) + // tunnelRoute: "/monitoring", + + // Hides source maps from generated client bundles + hideSourceMaps: true, + + // Automatically tree-shake Sentry logger statements to reduce bundle size + disableLogger: true, + } +); diff --git a/integrations/evaluations/package.json b/integrations/evaluations/package.json index 0300ddde15..d1a06059cd 100644 --- a/integrations/evaluations/package.json +++ b/integrations/evaluations/package.json @@ -11,6 +11,7 @@ "dependencies": { "@hookform/resolvers": "^3.3.1", "@pubpub/sdk": "workspace:*", + "@sentry/nextjs": "^7.72.0", "clsx": "^2.0.0", "next": "13.5.2", "parse5-sax-parser": "^7.0.0", diff --git a/integrations/evaluations/sentry.client.config.ts b/integrations/evaluations/sentry.client.config.ts new file mode 100644 index 0000000000..c53a52ab0d --- /dev/null +++ b/integrations/evaluations/sentry.client.config.ts @@ -0,0 +1,30 @@ +// This file configures the initialization of Sentry on the client. +// The config you add here will be used whenever a users loads a page in their browser. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "https://ccf8ee31961e83825bd7ab1f02f318a6@o31718.ingest.sentry.io/4505959424327680", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, + + replaysOnErrorSampleRate: 1.0, + + // This sets the sample rate to be 10%. You may want this to be 100% while + // in development and sample at a lower rate in production + replaysSessionSampleRate: 0.1, + + // You can remove this option if you're not planning to use the Sentry Session Replay feature: + integrations: [ + new Sentry.Replay({ + // Additional Replay configuration goes in here, for example: + maskAllText: true, + blockAllMedia: true, + }), + ], +}); diff --git a/integrations/evaluations/sentry.edge.config.ts b/integrations/evaluations/sentry.edge.config.ts new file mode 100644 index 0000000000..b9ca2fa0ba --- /dev/null +++ b/integrations/evaluations/sentry.edge.config.ts @@ -0,0 +1,16 @@ +// This file configures the initialization of Sentry for edge features (middleware, edge routes, and so on). +// The config you add here will be used whenever one of the edge features is loaded. +// Note that this config is unrelated to the Vercel Edge Runtime and is also required when running locally. +// https://docs.sentry.io/platforms/javascript/guides/nextjs/ + +import * as Sentry from "@sentry/nextjs"; + +Sentry.init({ + dsn: "https://ccf8ee31961e83825bd7ab1f02f318a6@o31718.ingest.sentry.io/4505959424327680", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, +}); diff --git a/integrations/evaluations/sentry.server.config.ts b/integrations/evaluations/sentry.server.config.ts new file mode 100644 index 0000000000..f8e07b6132 --- /dev/null +++ b/integrations/evaluations/sentry.server.config.ts @@ -0,0 +1,15 @@ +// 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"; + +Sentry.init({ + dsn: "https://ccf8ee31961e83825bd7ab1f02f318a6@o31718.ingest.sentry.io/4505959424327680", + + // Adjust this value in production, or use tracesSampler for greater control + tracesSampleRate: 1, + + // Setting this option to true will print useful information to the console while you're setting up Sentry. + debug: false, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 95fda6d3b4..ef6445c70d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -189,6 +189,9 @@ importers: '@pubpub/sdk': specifier: workspace:* version: link:../../packages/sdk + '@sentry/nextjs': + specifier: ^7.72.0 + version: 7.72.0(next@13.5.2)(react@18.2.0) clsx: specifier: ^2.0.0 version: 2.0.0 From b30dbf56b5698aadc92e4dfff1675b71c2cd3e3f Mon Sep 17 00:00:00 2001 From: Kalil Smith-Nuevelle Date: Thu, 28 Sep 2023 13:30:29 -0500 Subject: [PATCH 5/5] Remove example pages --- core/app/api/sentry-example-api/route.js | 7 -- core/app/sentry-example-page/page.jsx | 86 ------------------- .../app/api/sentry-example-api/route.js | 7 -- .../app/sentry-example-page/page.jsx | 86 ------------------- .../app/api/sentry-example-api/route.js | 7 -- .../app/sentry-example-page/page.jsx | 86 ------------------- 6 files changed, 279 deletions(-) delete mode 100644 core/app/api/sentry-example-api/route.js delete mode 100644 core/app/sentry-example-page/page.jsx delete mode 100644 integrations/evaluations/app/api/sentry-example-api/route.js delete mode 100644 integrations/evaluations/app/sentry-example-page/page.jsx delete mode 100644 integrations/submissions/app/api/sentry-example-api/route.js delete mode 100644 integrations/submissions/app/sentry-example-page/page.jsx diff --git a/core/app/api/sentry-example-api/route.js b/core/app/api/sentry-example-api/route.js deleted file mode 100644 index 80dcc18d99..0000000000 --- a/core/app/api/sentry-example-api/route.js +++ /dev/null @@ -1,7 +0,0 @@ -import { NextResponse } from "next/server"; - -// A faulty API route to test Sentry's error monitoring -export function GET() { - throw new Error("Sentry Example API Route Error"); - return NextResponse.json({ data: "Testing Sentry Error..." }); -} diff --git a/core/app/sentry-example-page/page.jsx b/core/app/sentry-example-page/page.jsx deleted file mode 100644 index c701d78e9d..0000000000 --- a/core/app/sentry-example-page/page.jsx +++ /dev/null @@ -1,86 +0,0 @@ -"use client"; - -import Head from "next/head"; -import * as Sentry from "@sentry/nextjs"; - -export default function Page() { - return ( -
- - Sentry Onboarding - - - -
-

- - - -

- -

Get started by sending us a sample error:

- - -

- Next, look for the error on the{" "} - Issues Page. -

-

- For more information, see{" "} - - https://docs.sentry.io/platforms/javascript/guides/nextjs/ - -

-
-
- ); -} diff --git a/integrations/evaluations/app/api/sentry-example-api/route.js b/integrations/evaluations/app/api/sentry-example-api/route.js deleted file mode 100644 index 80dcc18d99..0000000000 --- a/integrations/evaluations/app/api/sentry-example-api/route.js +++ /dev/null @@ -1,7 +0,0 @@ -import { NextResponse } from "next/server"; - -// A faulty API route to test Sentry's error monitoring -export function GET() { - throw new Error("Sentry Example API Route Error"); - return NextResponse.json({ data: "Testing Sentry Error..." }); -} diff --git a/integrations/evaluations/app/sentry-example-page/page.jsx b/integrations/evaluations/app/sentry-example-page/page.jsx deleted file mode 100644 index 082985d1f4..0000000000 --- a/integrations/evaluations/app/sentry-example-page/page.jsx +++ /dev/null @@ -1,86 +0,0 @@ -"use client"; - -import Head from "next/head"; -import * as Sentry from "@sentry/nextjs"; - -export default function Page() { - return ( -
- - Sentry Onboarding - - - -
-

- - - -

- -

Get started by sending us a sample error:

- - -

- Next, look for the error on the{" "} - Issues Page. -

-

- For more information, see{" "} - - https://docs.sentry.io/platforms/javascript/guides/nextjs/ - -

-
-
- ); -} diff --git a/integrations/submissions/app/api/sentry-example-api/route.js b/integrations/submissions/app/api/sentry-example-api/route.js deleted file mode 100644 index 80dcc18d99..0000000000 --- a/integrations/submissions/app/api/sentry-example-api/route.js +++ /dev/null @@ -1,7 +0,0 @@ -import { NextResponse } from "next/server"; - -// A faulty API route to test Sentry's error monitoring -export function GET() { - throw new Error("Sentry Example API Route Error"); - return NextResponse.json({ data: "Testing Sentry Error..." }); -} diff --git a/integrations/submissions/app/sentry-example-page/page.jsx b/integrations/submissions/app/sentry-example-page/page.jsx deleted file mode 100644 index 5dda4df362..0000000000 --- a/integrations/submissions/app/sentry-example-page/page.jsx +++ /dev/null @@ -1,86 +0,0 @@ -"use client"; - -import Head from "next/head"; -import * as Sentry from "@sentry/nextjs"; - -export default function Page() { - return ( -
- - Sentry Onboarding - - - -
-

- - - -

- -

Get started by sending us a sample error:

- - -

- Next, look for the error on the{" "} - Issues Page. -

-

- For more information, see{" "} - - https://docs.sentry.io/platforms/javascript/guides/nextjs/ - -

-
-
- ); -}