Skip to content

Commit

Permalink
Fix Sentry configuration (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
markspolakovs authored Sep 6, 2024
1 parent eae6224 commit 96af3b1
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 152 deletions.
27 changes: 27 additions & 0 deletions app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"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>
);
}
13 changes: 13 additions & 0 deletions instrumentation.ts
Original file line number Diff line number Diff line change
@@ -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;
3 changes: 3 additions & 0 deletions next.config.build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// This config file contains only the necessary next config needed in production
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
instrumentationHook: true,
},
images: {
remotePatterns: [
// User avatars
Expand Down
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const sentryRelease = `${version}-${gitCommit.slice(0, 7)}`;
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "standalone",
experimental: {
instrumentationHook: true,
},
images: {
remotePatterns: [
// User avatars
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@mantine/modals": "^7.0.2",
"@mantine/notifications": "^7.1.3",
"@prisma/client": "^5.8.1",
"@sentry/nextjs": "^8.26.0",
"@sentry/nextjs": "^8.28.0",
"@slack/bolt": "^3.14.0",
"@tanstack/react-query": "^5.51.23",
"@trpc/server": "^10.33.1",
Expand Down
Loading

0 comments on commit 96af3b1

Please sign in to comment.