Skip to content
Merged
25 changes: 25 additions & 0 deletions apps/timo-web/app/global-error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client";

import * as Sentry from "@sentry/nextjs";
import { useEffect } from "react";

interface GlobalErrorProps {
error: Error & { digest?: string };
reset: () => void;
}

export default function GlobalError({ error, reset }: GlobalErrorProps) {
useEffect(() => {
Sentry.captureException(error);
}, [error]);

return (
<html lang="ko">
<body>
<h1>문제가 발생했어요</h1>
<p>잠시 후 다시 시도해주세요.</p>
<button onClick={reset}>다시 시도</button>
Comment thread
ehye1 marked this conversation as resolved.
</body>
</html>
);
}
12 changes: 12 additions & 0 deletions apps/timo-web/instrumentation-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as Sentry from "@sentry/nextjs";

const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN;

if (dsn) {
Sentry.init({
dsn,
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT ?? "local",
});
}

export const onRouterTransitionStart = Sentry.captureRouterTransitionStart;
13 changes: 13 additions & 0 deletions apps/timo-web/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;
12 changes: 11 additions & 1 deletion apps/timo-web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
/* global process */
import { withSentryConfig } from "@sentry/nextjs";

/** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ["@repo/timo-design-system"],
};

export default nextConfig;
export default withSentryConfig(nextConfig, {
org: "timo-client",
project: "timo-web",
authToken: process.env["SENTRY_AUTH_TOKEN"],
silent: !process.env.CI,
Comment thread
ehye1 marked this conversation as resolved.
widenClientFileUpload: true,
disableLogger: true,
});
1 change: 1 addition & 0 deletions apps/timo-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"@repo/timo-design-system": "workspace:*",
"@sentry/nextjs": "^10.61.0",
"@tanstack/react-query": "^5.101.1",
"@tanstack/react-query-devtools": "^5.101.1",
"axios": "^1.18.1",
Expand Down
10 changes: 10 additions & 0 deletions apps/timo-web/sentry.edge.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Sentry from "@sentry/nextjs";

const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN;

if (dsn) {
Sentry.init({
dsn,
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT ?? "local",
});
}
10 changes: 10 additions & 0 deletions apps/timo-web/sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as Sentry from "@sentry/nextjs";

const dsn = process.env.NEXT_PUBLIC_SENTRY_DSN;

if (dsn) {
Sentry.init({
dsn,
environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT ?? "local",
});
}
Loading
Loading