diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index 1f5298da2..590e31678 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -3,11 +3,12 @@ import { ConfigProvider } from "antd"; import enLocale from "antd/es/locale/en_US"; import LogRocket from "logrocket"; import moment from "moment"; -import React from "react"; +import React, { useEffect } from "react"; import GlobalLoadingBar from "../components/global-loading-bar/global-loading-bar.component"; import client from "../utils/GraphQLClient"; import App from "./App"; import { useTranslation } from "react-i18next"; +import JiraSupportComponent from "../components/jira-support-widget/jira-support-widget.component"; moment.locale("en-US"); if (process.env.NODE_ENV === "production") LogRocket.init("gvfvfw/bodyshopapp"); @@ -15,6 +16,23 @@ if (process.env.NODE_ENV === "production") LogRocket.init("gvfvfw/bodyshopapp"); export default function AppContainer() { const { t } = useTranslation(); + useEffect(() => { + // Include the Crisp code here, without the tags + window.$crisp = []; + window.CRISP_WEBSITE_ID = "36724f62-2eb0-4b29-9cdd-9905fb99913e"; + + var d = document; + var s = d.createElement("script"); + + s.src = "https://client.crisp.chat/l.js"; + s.async = 1; + d.getElementsByTagName("head")[0].appendChild(s); + + return () => { + d.getElementsByTagName("head")[0].removeChild(s); + }; + }, []); + return ( + ); diff --git a/client/src/redux/user/user.sagas.js b/client/src/redux/user/user.sagas.js index cbeba03af..c467aceed 100644 --- a/client/src/redux/user/user.sagas.js +++ b/client/src/redux/user/user.sagas.js @@ -164,6 +164,12 @@ export function* onSignInSuccess() { export function* signInSuccessSaga({ payload }) { LogRocket.identify(payload.email); + try { + window.$crisp.push(["set", "user:email", [payload.email]]); + window.$crisp.push(["set", "user:nickname", [payload.displayName]]); + } catch (error) { + console.log("Error updating Crisp settings.", error); + } // if (!payload.email.includes("@imex.")) yield put(setInstanceId(payload.uid)); analytics.setUserId(payload.email); @@ -220,6 +226,8 @@ export function* SetAuthLevelFromShopDetails({ payload }) { try { const userEmail = yield select((state) => state.user.currentUser.email); + window.$crisp.push(["set", "user:company", [payload.shopname]]); + const authRecord = payload.associations.filter( (a) => a.useremail === userEmail );