From f65f4938a348dcc1ff2bea35b363af50466a668f Mon Sep 17 00:00:00 2001 From: Arda Erzin Date: Tue, 10 Dec 2024 23:20:19 +0100 Subject: [PATCH] chore(fronend): replace problematic useLayoutEffect usage with useIsomorphicLayoutEffect --- agenta-web/src/hooks/usePostHogAg.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/agenta-web/src/hooks/usePostHogAg.ts b/agenta-web/src/hooks/usePostHogAg.ts index 8b3a4655e6..3fbac630cd 100644 --- a/agenta-web/src/hooks/usePostHogAg.ts +++ b/agenta-web/src/hooks/usePostHogAg.ts @@ -2,6 +2,7 @@ import {useLayoutEffect} from "react" import {isDemo, generateOrRetrieveDistinctId} from "@/lib/helpers/utils" import {usePostHog} from "posthog-js/react" import {useProfileData} from "@/contexts/profile.context" +import useIsomorphicLayoutEffect from "./useIsomorphicLayoutEffect" export const usePostHogAg = () => { const trackingEnabled = process.env.NEXT_PUBLIC_TELEMETRY_TRACKING_ENABLED === "true" @@ -23,11 +24,11 @@ export const usePostHogAg = () => { } } - useLayoutEffect(() => { + useIsomorphicLayoutEffect(() => { if (!trackingEnabled) posthog.opt_out_capturing() }, [trackingEnabled]) - useLayoutEffect(() => { + useIsomorphicLayoutEffect(() => { if (posthog.get_distinct_id() !== _id) identify() }, [user?.id])