trackEvent in ErrorBoundary, disable trackEvent in dev
continuous-integration/drone/push Build is running Details

This commit is contained in:
Martti Malmi 2024-01-09 15:16:47 +02:00
parent 376096c5af
commit 7073e8d9dd
3 changed files with 21 additions and 16 deletions

View File

@ -1,5 +1,7 @@
import React from "react";
import {trackEvent} from "@/Utils";
interface ErrorBoundaryState {
hasError: boolean;
errorMessage?: string;
@ -21,6 +23,7 @@ export default class ErrorBoundary extends React.Component<ErrorBoundaryProps, E
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
console.error("Caught an error:", error, errorInfo);
trackEvent("error", { error: error.message, errorInfo: JSON.stringify(errorInfo) });
}
render() {

View File

@ -56,24 +56,26 @@ export default function Index() {
const isStalker = !!stalker;
return (
<div className="flex justify-center">
<div className="w-full max-w-screen-xl">
<div className="flex flex-row">
<NavSidebar />
<div className="flex flex-1 flex-col pb-footer-height md:pb-0 w-full md:w-1/3">
{!shouldHideHeader && <Header />}
<ErrorBoundary>
<Outlet />
</ErrorBoundary>
<ErrorBoundary>
<div className="flex justify-center">
<div className="w-full max-w-screen-xl">
<div className="flex flex-row">
<NavSidebar />
<div className="flex flex-1 flex-col pb-footer-height md:pb-0 w-full md:w-1/3">
{!shouldHideHeader && <Header />}
<ErrorBoundary>
<Outlet />
</ErrorBoundary>
</div>
<RightColumn />
</div>
<RightColumn />
<Toaster />
</div>
<Toaster />
<LoginUnlock />
{isStalker && <StalkerModal id={id} />}
{!shouldHideFooter && <Footer />}
</div>
<LoginUnlock />
{isStalker && <StalkerModal id={id} />}
{!shouldHideFooter && <Footer />}
</div>
</ErrorBoundary>
);
}

View File

@ -538,7 +538,7 @@ export function trackEvent(
props?: Record<string, string | boolean>,
e?: { destination?: { url: string } },
) {
if (CONFIG.features.analytics && (LoginStore.snapshot().appData.item.preferences.telemetry ?? true)) {
if (!import.meta.env.DEV && CONFIG.features.analytics && (LoginStore.snapshot().appData.item.preferences.telemetry ?? true)) {
fetch("https://analytics.v0l.io/api/event", {
method: "POST",
headers: {