fix: chat with us key handling

This commit is contained in:
sriram veeraghanta 2024-04-08 19:39:43 +05:30
parent 2ea6d70fac
commit c843a1757f
2 changed files with 23 additions and 23 deletions

View File

@ -142,6 +142,7 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observe
</span> </span>
</Link> </Link>
))} ))}
{process.env.NEXT_PUBLIC_CRISP_ID && (
<button <button
type="button" type="button"
onClick={handleCrispWindowShow} onClick={handleCrispWindowShow}
@ -152,6 +153,7 @@ export const WorkspaceHelpSection: React.FC<WorkspaceHelpSectionProps> = observe
</div> </div>
<span className="text-xs">Chat with us</span> <span className="text-xs">Chat with us</span>
</button> </button>
)}
</div> </div>
<div className="px-2 pb-1 pt-2 text-[10px]">Version: v{packageJson.version}</div> <div className="px-2 pb-1 pt-2 text-[10px]">Version: v{packageJson.version}</div>
</div> </div>

View File

@ -18,10 +18,9 @@ const CrispWrapper: FC<ICrispWrapper> = (props) => {
const { children, user } = props; const { children, user } = props;
useEffect(() => { useEffect(() => {
if (typeof window && user?.email) { if (typeof window && user?.email && process.env.NEXT_PUBLIC_CRISP_ID) {
window.$crisp = []; window.$crisp = [];
window.CRISP_WEBSITE_ID = process.env.NEXT_PUBLIC_CRISP_ID; window.CRISP_WEBSITE_ID = process.env.NEXT_PUBLIC_CRISP_ID;
if (window.CRISP_WEBSITE_ID != null) {
(function () { (function () {
const d = document; const d = document;
const s = d.createElement("script"); const s = d.createElement("script");
@ -33,7 +32,6 @@ const CrispWrapper: FC<ICrispWrapper> = (props) => {
window.$crisp.push(["do", "chat:close"]); window.$crisp.push(["do", "chat:close"]);
})(); })();
} }
}
}, [user?.email]); }, [user?.email]);
return <>{children}</>; return <>{children}</>;