Skip to content

armgit / plane

Public Imported from GitHub
0

πŸ”₯πŸ”₯πŸ”₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.

[WEB-1669] chore: enable sign out and sentry on exception error page. (#4884)

Prateek Shourya280a69bd3ccc
diff --git a/web/.gitignore b/web/.gitignore
new file mode 100644
index 0000000000..7d7c7a5f2d
--- /dev/null
+++ b/web/.gitignore
@@ -0,0 +1,3 @@
+
+# Sentry Config File
+.env.sentry-build-plugin
diff --git a/web/app/error.tsx b/web/app/error.tsx
index 5722a99137..da5d3bf200 100644
--- a/web/app/error.tsx
+++ b/web/app/error.tsx
@@ -1,49 +1,37 @@
"use client";
-// import { useEffect } from "react";
-// import * as Sentry from "@sentry/nextjs";
-// services
-import { Button } from "@plane/ui";
+// ui
+import { Button, TOAST_TYPE, setToast } from "@plane/ui";
// helpers
-// import { API_BASE_URL } from "@/helpers/common.helper";
+import { API_BASE_URL } from "@/helpers/common.helper";
+// hooks
+import { useAppRouter } from "@/hooks/use-app-router";
// layouts
import DefaultLayout from "@/layouts/default-layout";
-//
-// import { AuthService } from "@/services/auth.service";
-// layouts
-// ui
-
// services
-// const authService = new AuthService();
-
-// type props = {
-// error: Error & { digest?: string };
-// };
+import { AuthService } from "@/services/auth.service";
-// TODO: adding error sentry logging.
-// const CustomErrorComponent = ({ error }: props) => {
-const CustomErrorComponent = () => {
- // const router = useAppRouter();
+// services
+const authService = new AuthService();
- // useEffect(() => {
- // Sentry.captureException(error);
- // }, [error]);
+export default function CustomErrorComponent() {
+ const router = useAppRouter();
const handleRefresh = () => {
window.location.reload();
};
const handleSignOut = async () => {
- // await authService
- // .signOut(API_BASE_URL)
- // .catch(() =>
- // setToast({
- // type: TOAST_TYPE.ERROR,
- // title: "Error!",
- // message: "Failed to sign out. Please try again.",
- // })
- // )
- // .finally(() => router.push("/"));
+ await authService
+ .signOut(API_BASE_URL)
+ .catch(() =>
+ setToast({
+ type: TOAST_TYPE.ERROR,
+ title: "Error!",
+ message: "Failed to sign out. Please try again.",
+ })
+ )
+ .finally(() => router.push("/"));
};
return (
@@ -84,6 +72,4 @@ const CustomErrorComponent = () => {
</div>
</DefaultLayout>
);
-};
-
-export default CustomErrorComponent;
+}
diff --git a/web/app/global-error.tsx b/web/app/global-error.tsx
new file mode 100644
index 0000000000..a984441f02
--- /dev/null
+++ b/web/app/global-error.tsx
@@ -0,0 +1,23 @@
+"use client";
+
+import { useEffect } from "react";
+import * as Sentry from "@sentry/nextjs";
+import NextError from "next/error";
+
+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>
+ );
+}
diff --git a/web/package.json b/web/package.json
index 382f5a4b14..177f4dcc7b 100644
--- a/web/package.json
+++ b/web/package.json
@@ -7,7 +7,7 @@
"develop": "next dev --port 3000",
"build": "next build",
"start": "next start",
- "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
+ "lint": "next lint --dir .",
"export": "next export",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},