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 ed944d5
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/frontend/apps/impress/src/hook/useSupport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ import { useEffect } from 'react';

import { User } from '@/core';

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

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

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

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

0 comments on commit ed944d5

Please sign in to comment.