feat: enable sentry for the frontend

This commit is contained in:
swve 2024-08-29 19:57:24 +02:00
parent 0fc6713ec8
commit a5a87d7866
11 changed files with 2641 additions and 737 deletions

4
apps/web/.gitignore vendored
View file

@ -44,4 +44,6 @@ next.config.original.js
# Sentry Config File
.sentryclirc
certificates
certificates
# Sentry Config File
.env.sentry-build-plugin

View file

@ -0,0 +1,23 @@
"use client";
import * as Sentry from "@sentry/nextjs";
import NextError from "next/error";
import { useEffect } from "react";
export default function GlobalError({ error }: { error: Error & { digest?: string } }) {
useEffect(() => {
Sentry.captureException(error);
}, [error]);
return (
<html>
<body>
{/* `NextError` is the default Next.js error page component. Its type
definition requires a `statusCode` prop. However, since the App Router
does not expose status codes for errors, we simply pass 0 to render a
generic error message. */}
<NextError statusCode={0} />
</body>
</html>
);
}

View file

@ -0,0 +1,9 @@
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
await import('./sentry.server.config');
}
if (process.env.NEXT_RUNTIME === 'edge') {
await import('./sentry.edge.config');
}
}

View file

@ -17,3 +17,46 @@ const nextConfig = {
}
module.exports = 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
org: "learnhouse",
project: "learnhouse-web",
// Only print logs for uploading source maps in CI
silent: !process.env.CI,
// 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,
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",
// Hides source maps from generated client bundles
hideSourceMaps: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
}
);

View file

@ -19,6 +19,7 @@
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-switch": "^1.1.0",
"@radix-ui/react-tooltip": "^1.1.2",
"@sentry/nextjs": "^8",
"@stitches/react": "^1.2.8",
"@tiptap/core": "^2.5.8",
"@tiptap/extension-code-block-lowlight": "^2.5.8",

3157
apps/web/pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,31 @@
// 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: process.env.SENTRY_DSN,
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 0.5,
// 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,
enabled: process.env.NODE_ENV === 'development',
// You can remove this option if you're not planning to use the Sentry Session Replay feature:
integrations: [
Sentry.replayIntegration({
// Additional Replay configuration goes in here, for example:
maskAllText: true,
blockAllMedia: true,
}),
],
})

View file

@ -0,0 +1,18 @@
// 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: process.env.SENTRY_DSN,
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 0.5,
enabled: process.env.NODE_ENV === 'development',
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
})

View file

@ -0,0 +1,20 @@
// 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: process.env.SENTRY_DSN,
// Adjust this value in production, or use tracesSampler for greater control
tracesSampleRate: 0.5,
// Setting this option to true will print useful information to the console while you're setting up Sentry.
debug: false,
enabled: process.env.NODE_ENV === 'development',
// Uncomment the line below to enable Spotlight (https://spotlightjs.com)
// spotlight: process.env.NODE_ENV === 'development',
})

View file

@ -9,8 +9,8 @@
},
"devDependencies": {
"eslint": "^8.57.0",
"prettier": "^3.3.0",
"turbo": "^1.13.3"
"prettier": "^3.3.3",
"turbo": "^1.13.4"
},
"packageManager": "pnpm@9.0.6"
}

68
pnpm-lock.yaml generated
View file

@ -12,11 +12,11 @@ importers:
specifier: ^8.57.0
version: 8.57.0
prettier:
specifier: ^3.3.0
version: 3.3.0
specifier: ^3.3.3
version: 3.3.3
turbo:
specifier: ^1.13.3
version: 1.13.3
specifier: ^1.13.4
version: 1.13.4
packages:
@ -323,8 +323,8 @@ packages:
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'}
prettier@3.3.0:
resolution: {integrity: sha512-J9odKxERhCQ10OC2yb93583f6UnYutOeiV5i0zEDS7UGTdUt0u+y8erxl3lBKvwo/JHyyoEdXjwp4dke9oyZ/g==}
prettier@3.3.3:
resolution: {integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==}
engines: {node: '>=14'}
hasBin: true
@ -374,38 +374,38 @@ packages:
text-table@0.2.0:
resolution: {integrity: sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==}
turbo-darwin-64@1.13.3:
resolution: {integrity: sha512-glup8Qx1qEFB5jerAnXbS8WrL92OKyMmg5Hnd4PleLljAeYmx+cmmnsmLT7tpaVZIN58EAAwu8wHC6kIIqhbWA==}
turbo-darwin-64@1.13.4:
resolution: {integrity: sha512-A0eKd73R7CGnRinTiS7txkMElg+R5rKFp9HV7baDiEL4xTG1FIg/56Vm7A5RVgg8UNgG2qNnrfatJtb+dRmNdw==}
cpu: [x64]
os: [darwin]
turbo-darwin-arm64@1.13.3:
resolution: {integrity: sha512-/np2xD+f/+9qY8BVtuOQXRq5f9LehCFxamiQnwdqWm5iZmdjygC5T3uVSYuagVFsZKMvX3ycySwh8dylGTl6lg==}
turbo-darwin-arm64@1.13.4:
resolution: {integrity: sha512-eG769Q0NF6/Vyjsr3mKCnkG/eW6dKMBZk6dxWOdrHfrg6QgfkBUk0WUUujzdtVPiUIvsh4l46vQrNVd9EOtbyA==}
cpu: [arm64]
os: [darwin]
turbo-linux-64@1.13.3:
resolution: {integrity: sha512-G+HGrau54iAnbXLfl+N/PynqpDwi/uDzb6iM9hXEDG+yJnSJxaHMShhOkXYJPk9offm9prH33Khx2scXrYVW1g==}
turbo-linux-64@1.13.4:
resolution: {integrity: sha512-Bq0JphDeNw3XEi+Xb/e4xoKhs1DHN7OoLVUbTIQz+gazYjigVZvtwCvgrZI7eW9Xo1eOXM2zw2u1DGLLUfmGkQ==}
cpu: [x64]
os: [linux]
turbo-linux-arm64@1.13.3:
resolution: {integrity: sha512-qWwEl5VR02NqRyl68/3pwp3c/olZuSp+vwlwrunuoNTm6JXGLG5pTeme4zoHNnk0qn4cCX7DFrOboArlYxv0wQ==}
turbo-linux-arm64@1.13.4:
resolution: {integrity: sha512-BJcXw1DDiHO/okYbaNdcWN6szjXyHWx9d460v6fCHY65G8CyqGU3y2uUTPK89o8lq/b2C8NK0yZD+Vp0f9VoIg==}
cpu: [arm64]
os: [linux]
turbo-windows-64@1.13.3:
resolution: {integrity: sha512-Nudr4bRChfJzBPzEmpVV85VwUYRCGKecwkBFpbp2a4NtrJ3+UP1VZES653ckqCu2FRyRuS0n03v9euMbAvzH+Q==}
turbo-windows-64@1.13.4:
resolution: {integrity: sha512-OFFhXHOFLN7A78vD/dlVuuSSVEB3s9ZBj18Tm1hk3aW1HTWTuAw0ReN6ZNlVObZUHvGy8d57OAGGxf2bT3etQw==}
cpu: [x64]
os: [win32]
turbo-windows-arm64@1.13.3:
resolution: {integrity: sha512-ouJCgsVLd3icjRLmRvHQDDZnmGzT64GBupM1Y+TjtYn2LVaEBoV6hicFy8x5DUpnqdLy+YpCzRMkWlwhmkX7sQ==}
turbo-windows-arm64@1.13.4:
resolution: {integrity: sha512-u5A+VOKHswJJmJ8o8rcilBfU5U3Y1TTAfP9wX8bFh8teYF1ghP0EhtMRLjhtp6RPa+XCxHHVA2CiC3gbh5eg5g==}
cpu: [arm64]
os: [win32]
turbo@1.13.3:
resolution: {integrity: sha512-n17HJv4F4CpsYTvKzUJhLbyewbXjq1oLCi90i5tW1TiWDz16ML1eDG7wi5dHaKxzh5efIM56SITnuVbMq5dk4g==}
turbo@1.13.4:
resolution: {integrity: sha512-1q7+9UJABuBAHrcC4Sxp5lOqYS5mvxRrwa33wpIyM18hlOCpRD/fTJNxZ0vhbMcJmz15o9kkVm743mPn7p6jpQ==}
hasBin: true
type-check@0.4.0:
@ -757,7 +757,7 @@ snapshots:
prelude-ls@1.2.1: {}
prettier@3.3.0: {}
prettier@3.3.3: {}
punycode@2.3.1: {}
@ -793,32 +793,32 @@ snapshots:
text-table@0.2.0: {}
turbo-darwin-64@1.13.3:
turbo-darwin-64@1.13.4:
optional: true
turbo-darwin-arm64@1.13.3:
turbo-darwin-arm64@1.13.4:
optional: true
turbo-linux-64@1.13.3:
turbo-linux-64@1.13.4:
optional: true
turbo-linux-arm64@1.13.3:
turbo-linux-arm64@1.13.4:
optional: true
turbo-windows-64@1.13.3:
turbo-windows-64@1.13.4:
optional: true
turbo-windows-arm64@1.13.3:
turbo-windows-arm64@1.13.4:
optional: true
turbo@1.13.3:
turbo@1.13.4:
optionalDependencies:
turbo-darwin-64: 1.13.3
turbo-darwin-arm64: 1.13.3
turbo-linux-64: 1.13.3
turbo-linux-arm64: 1.13.3
turbo-windows-64: 1.13.3
turbo-windows-arm64: 1.13.3
turbo-darwin-64: 1.13.4
turbo-darwin-arm64: 1.13.4
turbo-linux-64: 1.13.4
turbo-linux-arm64: 1.13.4
turbo-windows-64: 1.13.4
turbo-windows-arm64: 1.13.4
type-check@0.4.0:
dependencies: