Skip to content

Commit

Permalink
chore(fronend): replace problematic useLayoutEffect usage with useIso…
Browse files Browse the repository at this point in the history
…morphicLayoutEffect
  • Loading branch information
ardaerzin committed Dec 10, 2024
1 parent e99b46f commit f65f493
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions agenta-web/src/hooks/usePostHogAg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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])

Expand Down

0 comments on commit f65f493

Please sign in to comment.