revert: "fix(website): Handle JS errors during Mixpanel init" (#5685)

Reverts firezone/firezone#5684
This commit is contained in:
Jamil
2024-07-02 17:19:00 -07:00
committed by GitHub
parent c0f98ea896
commit e472f21bb0
2 changed files with 3 additions and 31 deletions

View File

@@ -3,7 +3,6 @@ import { useEffect, Suspense } from "react";
import { usePathname, useSearchParams } from "next/navigation";
import { useMixpanel } from "react-mixpanel-browser";
import { HubSpotSubmittedFormData } from "./types";
import ErrorBoundary from "@/components/ErrorBoundary";
function _Mixpanel() {
const pathname = usePathname();
@@ -64,11 +63,9 @@ function _Mixpanel() {
export function Mixpanel() {
return (
<ErrorBoundary>
<Suspense>
<_Mixpanel />
</Suspense>
</ErrorBoundary>
<Suspense>
<_Mixpanel />
</Suspense>
);
}

View File

@@ -1,25 +0,0 @@
"use client";
import React, { ReactNode, useEffect } from "react";
interface ErrorBoundaryProps {
children: ReactNode;
}
const ErrorBoundary: React.FC<ErrorBoundaryProps> = ({ children }) => {
useEffect(() => {
const handleErrors = (event: ErrorEvent) => {
console.error("ErrorBoundary caught an error", event.error);
};
window.addEventListener("error", handleErrors);
return () => {
window.removeEventListener("error", handleErrors);
};
}, []);
return <>{children}</>;
};
export default ErrorBoundary;