added sentry error monitoring

This commit is contained in:
Rajpreet0 2026-08-04 14:17:53 +02:00
parent b9645dd32f
commit bc02cd4de1
10 changed files with 1492 additions and 65 deletions

4
.gitignore vendored
View file

@ -43,4 +43,6 @@ next-env.d.ts
/src/generated/prisma /src/generated/prisma
/graphify-out/* /graphify-out/*
# Sentry Config File
.env.sentry-build-plugin

View file

@ -1,3 +1,4 @@
import { withSentryConfig } from "@sentry/nextjs";
import type { NextConfig } from "next"; import type { NextConfig } from "next";
import createNextIntlPlugin from "next-intl/plugin"; import createNextIntlPlugin from "next-intl/plugin";
@ -27,4 +28,40 @@ const nextConfig: NextConfig = {
}, },
}; };
export default withNextIntl(nextConfig); export default withSentryConfig(withNextIntl(nextConfig), {
// For all available options, see:
// https://www.npmjs.com/package/@sentry/webpack-plugin#options
org: "kumasy",
project: "javascript-nextjs",
// 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",
webpack: {
// 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,
// Tree-shaking options for reducing bundle size
treeshake: {
// Automatically tree-shake Sentry logger statements to reduce bundle size
removeDebugLogging: true,
},
},
});

1392
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -28,6 +28,7 @@
"@radix-ui/react-slider": "^1.3.6", "@radix-ui/react-slider": "^1.3.6",
"@radix-ui/react-slot": "^1.2.4", "@radix-ui/react-slot": "^1.2.4",
"@radix-ui/react-tooltip": "^1.2.8", "@radix-ui/react-tooltip": "^1.2.8",
"@sentry/nextjs": "^10.69.0",
"@stripe/stripe-js": "^9.5.0", "@stripe/stripe-js": "^9.5.0",
"@supabase/ssr": "^0.7.0", "@supabase/ssr": "^0.7.0",
"@tiptap/extension-placeholder": "^3.13.0", "@tiptap/extension-placeholder": "^3.13.0",

23
sentry.edge.config.ts Normal file
View file

@ -0,0 +1,23 @@
// 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://e8bb1cf7421d4fd387d1235b742ea68f@o4511852428525568.ingest.de.sentry.io/4511852431802448",
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 1,
// Enable logs to be sent to Sentry
enableLogs: true,
dataCollection: {
// To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#dataCollection
// userInfo: false,
// httpBodies: [],
},
});

22
sentry.server.config.ts Normal file
View file

@ -0,0 +1,22 @@
// 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://e8bb1cf7421d4fd387d1235b742ea68f@o4511852428525568.ingest.de.sentry.io/4511852431802448",
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 1,
// Enable logs to be sent to Sentry
enableLogs: true,
dataCollection: {
// To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#dataCollection
// userInfo: false,
// httpBodies: [],
},
});

23
src/app/global-error.tsx Normal file
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 lang="en">
<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,23 @@
// This file configures the initialization of Sentry on the client.
// The added config 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://e8bb1cf7421d4fd387d1235b742ea68f@o4511852428525568.ingest.de.sentry.io/4511852431802448",
// Define how likely traces are sampled. Adjust this value in production, or use tracesSampler for greater control.
tracesSampleRate: 1,
// Enable logs to be sent to Sentry
enableLogs: true,
dataCollection: {
// To disable sending user data and HTTP bodies, uncomment the lines below. For more info visit:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/options/#dataCollection
// userInfo: false,
// httpBodies: [],
},
});
export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;

13
src/instrumentation.ts Normal file
View file

@ -0,0 +1,13 @@
import * as Sentry from "@sentry/nextjs";
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");
}
}
export const onRequestError = Sentry.captureRequestError;

View file

@ -2,6 +2,7 @@ import Image from "next/image";
import MultiStepProzess from "./MultiStepProzess"; import MultiStepProzess from "./MultiStepProzess";
import Logo from "@/src/public/logo.png"; import Logo from "@/src/public/logo.png";
import { Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/src/components/ui/card"; import { Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/src/components/ui/card";
import Link from "next/link";
interface AuthSidebarComponentProps { interface AuthSidebarComponentProps {
title: string; title: string;
@ -40,13 +41,15 @@ const AuthSidebarComponent: React.FC<AuthSidebarComponentProps> = ({
> >
<CardHeader className="p-0 pb-4 hidden lg:grid"> <CardHeader className="p-0 pb-4 hidden lg:grid">
<CardTitle> <CardTitle>
<Image <Link href="/">
src={Logo} <Image
width={150} src={Logo}
height={150} width={150}
alt="Logo" height={150}
className="w-auto h-auto max-w-[120px] lg:max-w-[150px]" alt="Logo"
/> className="w-auto h-auto max-w-[120px] lg:max-w-[150px]"
/>
</Link>
</CardTitle> </CardTitle>
</CardHeader> </CardHeader>