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

* [WEB-1669] chore: enable sign out and sentry on exception error page.

* fix: global error handling

---------

Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
Prateek Shourya
2024-06-20 16:50:05 +05:30
committed by GitHub
parent c36c98476c
commit 280a69bd3c
4 changed files with 48 additions and 36 deletions

3
web/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# Sentry Config File
.env.sentry-build-plugin

View File

@@ -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
import { AuthService } from "@/services/auth.service";
// services
// const authService = new AuthService();
const authService = new AuthService();
// type props = {
// error: Error & { digest?: string };
// };
// TODO: adding error sentry logging.
// const CustomErrorComponent = ({ error }: props) => {
const CustomErrorComponent = () => {
// const router = useAppRouter();
// 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;
}

23
web/app/global-error.tsx Normal file
View File

@@ -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>
);
}

View File

@@ -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"
},