Skip to content

Commit

Permalink
fixup! ✨(frontend) add crisp chatbot
Browse files Browse the repository at this point in the history
  • Loading branch information
lebaudantoine committed Sep 23, 2024
1 parent 574c167 commit 8bb136d
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/frontend/apps/impress/src/hook/useSupport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,15 @@ import { useEffect } from 'react';

import { User } from '@/core';

const isCrispConfigured = (): boolean => {
return typeof window !== 'undefined' && !!window.$crisp;
};

export const initializeSupportSession = (user: User) => {
if (!isCrispConfigured()) {
return;
}
if (!Crisp.isCrispInjected()) return;
Crisp.setTokenId(user.id);
Crisp.user.setEmail(user.email);
};

export const terminateSupportSession = () => {
if (!isCrispConfigured()) {
return;
}
if (!Crisp.isCrispInjected()) return;
Crisp.setTokenId();
Crisp.session.reset();
};

Expand All @@ -33,9 +26,7 @@ export const useSupport = () => {
console.warn('Crisp Website ID is not set');
return;
}
if (isCrispConfigured()) {
return;
}
if (Crisp.isCrispInjected()) return;
Crisp.configure(CRISP_WEBSITE_ID);
}, []);

Expand Down

0 comments on commit 8bb136d

Please sign in to comment.