fix(frontend): use dynamic import and gate Agentation to local/dev only

- Switch from static to dynamic import for proper tree-shaking in production
- Gate rendering behind isLocal || isDev using environment service
This commit is contained in:
abhi1992002
2026-04-02 13:13:49 +05:30
parent bbea5d948a
commit 060b96818d

View File

@@ -12,8 +12,13 @@ import { Toaster } from "@/components/molecules/Toast/toaster";
import { SetupAnalytics } from "@/services/analytics";
import { VercelAnalyticsWrapper } from "@/services/analytics/VercelAnalyticsWrapper";
import { environment } from "@/services/environment";
import { Agentation } from "agentation";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import dynamic from "next/dynamic";
const Agentation = dynamic(
() => import("agentation").then((mod) => mod.Agentation),
{ ssr: false },
);
import { headers } from "next/headers";
const isDev = environment.isDev();
@@ -79,7 +84,8 @@ export default async function RootLayout({
</div>
<Toaster />
<CookieConsentBanner />
{process.env.NEXT_PUBLIC_AGENTATION_DEVTOOL && <Agentation />}
{(isLocal || isDev) &&
process.env.NEXT_PUBLIC_AGENTATION_DEVTOOL && <Agentation />}
</Providers>
</ErrorBoundary>
</body>