diff --git a/packages/core/src/App/Components/Elements/LiveChat/use-freshchat.ts b/packages/core/src/App/Components/Elements/LiveChat/use-freshchat.ts index 7d2cbc04c1e0..5afd4c8d80a0 100644 --- a/packages/core/src/App/Components/Elements/LiveChat/use-freshchat.ts +++ b/packages/core/src/App/Components/Elements/LiveChat/use-freshchat.ts @@ -1,16 +1,18 @@ import { useEffect, useState } from 'react'; import { useScript } from 'usehooks-ts'; +import { useGrowthbookGetFeatureValue } from '@deriv/hooks'; const useFreshChat = (token: string | null) => { const scriptStatus = useScript('https://static.deriv.com/scripts/freshchat.js'); const [isReady, setIsReady] = useState(false); - const language = localStorage.getItem('i18n_language') || 'EN'; + const [enable_freshworks_live_chat, isGBLoaded] = useGrowthbookGetFeatureValue({ + featureFlag: 'enable_freshworks_live_chat', + }); useEffect(() => { const checkFcWidget = (intervalId: NodeJS.Timeout) => { if (typeof window !== 'undefined') { if (window.fcWidget?.isInitialized() == true && !isReady) { - // window.fcWidget?.user.setLocale(language.toLowerCase()); setIsReady(true); clearInterval(intervalId); } @@ -30,8 +32,8 @@ const useFreshChat = (token: string | null) => { } }; - initFreshChat(); - }, [isReady, language, scriptStatus, token]); + enable_freshworks_live_chat && isGBLoaded && initFreshChat(); + }, [enable_freshworks_live_chat, isGBLoaded, isReady, scriptStatus, token]); return { isReady,