mirror of
https://github.com/makeplane/plane.git
synced 2025-12-16 11:57:56 +01:00
[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:
3
web/.gitignore
vendored
Normal file
3
web/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
# Sentry Config File
|
||||
.env.sentry-build-plugin
|
||||
@@ -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
23
web/app/global-error.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
@@ -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"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user