From 833c2c3be374ba3adb2724105dea95ca274b65da Mon Sep 17 00:00:00 2001 From: Korbs Date: Thu, 11 Jul 2024 15:25:00 -0400 Subject: [PATCH] Create custom error page, don't use default from Astro --- src/layouts/Error.astro | 81 +++++++++++++++++++++++++++++++++++++++++ src/pages/500.astro | 4 ++ 2 files changed, 85 insertions(+) create mode 100644 src/layouts/Error.astro create mode 100644 src/pages/500.astro diff --git a/src/layouts/Error.astro b/src/layouts/Error.astro new file mode 100644 index 0000000..70ad73e --- /dev/null +++ b/src/layouts/Error.astro @@ -0,0 +1,81 @@ +--- +// Properties +const { Title, Description } = Astro.props + +// Components +import Head from '@components/global/Head.astro' + +// Styles +import '@styles/index.scss' +import '@styles/mobile.scss' + +// Error +interface Props { + error: unknown +} + +const { error } = Astro.props + +// SDK +import { OpenpanelSdk } from '@openpanel/sdk'; +const op = new OpenpanelSdk({ + clientId: 'b4c27f56-18f5-4d66-bb62-cbf7f7161812', + clientSecret: 'sec_107558407af59a591b50', +}); + +// Track Event +if (Astro.cookies.get("Telemtry").value === "Enabled") { + op.event('Error', { Error: error instanceof Error ? error.message : 'Unknown error' }); +} +else if (Astro.cookies.get("Telemtry").value === "Disabled") { + null +} + +// Cookies +if (Astro.cookies.get("Telemtry").value === "Enabled") { + var UserIsOptedIn = true +} +else if (Astro.cookies.get("Telemtry").value === "Disabled") { + var UserIsOptedIn = false +} +--- + + +
+
+
+

An error has occured:

+

{error instanceof Error ? error.message : 'Unknown error'}

+
+ {UserIsOptedIn ? + The error has been reported + : + null + } + +
+ + \ No newline at end of file diff --git a/src/pages/500.astro b/src/pages/500.astro new file mode 100644 index 0000000..feb975a --- /dev/null +++ b/src/pages/500.astro @@ -0,0 +1,4 @@ +--- +import Error from '@layouts/Error.astro' +--- + \ No newline at end of file