-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into PennyWalker-patch-3
- Loading branch information
Showing
39 changed files
with
320 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use client"; | ||
import { useAppInsightsContext } from "@microsoft/applicationinsights-react-js"; | ||
import React, { useEffect } from "react"; | ||
function GlobalErrorHandler({ error, children }) { | ||
const appInsights = useAppInsightsContext(); | ||
useEffect(() => { | ||
if (!appInsights) { | ||
// eslint-disable-next-line no-console | ||
console.error("AppInsights not initialized"); | ||
} | ||
|
||
try { | ||
appInsights.trackException({ | ||
exception: error, | ||
properties: { | ||
Request: `GET /${window?.location?.pathname || "unknown"}`, | ||
Type: "ErrorBoundary", | ||
ErrorInfo: error.stack || error.message, | ||
}, | ||
}); | ||
// eslint-disable-next-line no-console | ||
console.log("error", error); | ||
// eslint-disable-next-line no-console | ||
console.log("appInsights client", appInsights); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.error("Error in tracking exception", e.message); | ||
} | ||
}, [appInsights, error]); | ||
return <>{children}</>; | ||
} | ||
|
||
export default GlobalErrorHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Footer } from "@/components/layout/footer/footer"; | ||
|
||
type PageLayoutProps = { | ||
children: React.ReactNode; | ||
megaMenu: React.ReactNode; | ||
}; | ||
const PageLayout = ({ children, megaMenu }: PageLayoutProps) => { | ||
return ( | ||
<div className="flex min-h-screen flex-col"> | ||
<header className="no-print">{megaMenu}</header> | ||
<main className="grow bg-white">{children}</main> | ||
<Footer /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PageLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"use client"; | ||
import { ErrorPage } from "@/components/util/error-page"; | ||
import GlobalErrorHandler from "./components/global-error-handler"; | ||
export const Error = ({ | ||
error, | ||
}: { | ||
error: Error & { digest?: string }; | ||
reset: () => void; | ||
}) => { | ||
return ( | ||
<GlobalErrorHandler error={error}> | ||
<ErrorPage details={error.message} /> | ||
</GlobalErrorHandler> | ||
); | ||
}; | ||
|
||
export default Error; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
"use client"; | ||
import { MegaMenuWrapper } from "@/components/server/MegaMenuWrapper"; | ||
import { ErrorPage } from "@/components/util/error-page"; | ||
import { ReactPlugin } from "@microsoft/applicationinsights-react-js"; | ||
import { ApplicationInsights } from "@microsoft/applicationinsights-web"; | ||
import { Inter } from "next/font/google"; | ||
import { useEffect } from "react"; | ||
import "styles.css"; | ||
import menu from "../content/megamenu/menu.json"; | ||
import { MenuWrapper } from "./components/MenuWrapper"; | ||
import PageLayout from "./components/page-layout"; | ||
|
||
// Error boundaries must be Client Components | ||
|
||
const inter = Inter({ | ||
variable: "--inter-font", | ||
subsets: ["latin"], | ||
display: "swap", | ||
weight: ["400", "600", "700"], | ||
}); | ||
|
||
export default function GlobalError({ error }: { error: Error }) { | ||
useEffect(() => { | ||
const reactPlugin = new ReactPlugin(); | ||
const appInsights = new ApplicationInsights({ | ||
config: { | ||
connectionString: process.env.NEXT_PUBLIC_APP_INSIGHT_CONNECTION_STRING, | ||
extensions: [reactPlugin], | ||
autoExceptionInstrumented: true, | ||
autoTrackPageVisitTime: true, | ||
enableRequestHeaderTracking: true, | ||
enableResponseHeaderTracking: true, | ||
enableAjaxErrorStatusText: true, | ||
distributedTracingMode: 0, | ||
loggingLevelTelemetry: 1, | ||
loggingLevelConsole: 1, | ||
extensionConfig: { | ||
[reactPlugin.identifier]: {}, | ||
}, | ||
disablePageUnloadEvents: ["unload"], | ||
}, | ||
}); | ||
|
||
if (appInsights.config.connectionString) { | ||
appInsights.loadAppInsights(); | ||
appInsights.trackException({ | ||
exception: error, | ||
properties: { | ||
Request: `GET /${window?.location?.pathname || "unknown"}`, | ||
Type: "ErrorBoundary", | ||
ErrorInfo: error.stack || error.message, | ||
}, | ||
}); | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.error( | ||
"Failed to log root layout exception to Application Insights!" | ||
); | ||
} | ||
}, [error]); | ||
|
||
const errorDetails = error.stack || error.message; | ||
return ( | ||
<html lang="en" className={inter.className}> | ||
<body> | ||
<PageLayout megaMenu={MegaMenu()}> | ||
<ErrorPage details={errorDetails}></ErrorPage> | ||
</PageLayout> | ||
</body> | ||
</html> | ||
); | ||
} | ||
|
||
const MegaMenu = () => { | ||
return ( | ||
<MenuWrapper> | ||
<MegaMenuWrapper menuBarItems={menu.menuGroups} /> | ||
</MenuWrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.