diff --git a/apps/dashboard/web/pages/login.jsp b/apps/dashboard/web/pages/login.jsp index c53f800bc3..ba607806eb 100644 --- a/apps/dashboard/web/pages/login.jsp +++ b/apps/dashboard/web/pages/login.jsp @@ -96,7 +96,9 @@ if (window.USER_NAME.length > 0) { // Initialize mixpanel - clarity("set", "userEmail", window.USER_NAME) + if(window.IS_SAAS == 'true'){ + clarity("set", "userEmail", window.USER_NAME) + } mixpanel.init('c403d0b00353cc31d7e33d68dc778806', { debug: false, ignore_dnt: true }); let distinct_id = window.USER_NAME + '_' + (window.IS_SAAS === 'true' ? "SAAS" : window.DASHBOARD_MODE); mixpanel.identify(distinct_id); diff --git a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/Dashboard.jsx b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/Dashboard.jsx index 800adf21e6..2cf9a6f823 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/Dashboard.jsx +++ b/apps/dashboard/web/polaris_web/web/src/apps/dashboard/pages/Dashboard.jsx @@ -27,8 +27,8 @@ function Dashboard() { const subCategoryMap = LocalStore(state => state.subCategoryMap) const [eventForUser, setEventForUser] = useState({}) - const sendEventOnLogin = PersistStore(state => state.sendEventOnLogin) - const setSendEventOnLogin = PersistStore(state => state.setSendEventOnLogin) + const sendEventOnLogin = LocalStore(state => state.sendEventOnLogin) + const setSendEventOnLogin = LocalStore(state => state.setSendEventOnLogin) const fetchAllCollections = async () => { let apiCollections = await homeFunctions.getAllCollections() const allCollectionsMap = func.mapCollectionIdToName(apiCollections) @@ -44,8 +44,9 @@ function Dashboard() { const getEventForIntercom = async() => { let resp = await homeRequests.getEventForIntercom(); - setEventForUser(resp) - setSendEventOnLogin(true) + if(resp !== null){ + setEventForUser(resp) + } } useEffect(() => { @@ -60,8 +61,11 @@ function Dashboard() { } if(window?.Intercom){ if(!sendEventOnLogin){ + setSendEventOnLogin(true) getEventForIntercom() - window.Intercom("trackEvent","metrics", eventForUser) + if(Object.keys(eventForUser).length > 0){ + window?.Intercom("trackEvent","metrics", eventForUser) + } } } }, []) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/main/LocalStorageStore.js b/apps/dashboard/web/polaris_web/web/src/apps/main/LocalStorageStore.js index 070046ce8e..0db6cb4a84 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/main/LocalStorageStore.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/main/LocalStorageStore.js @@ -4,12 +4,14 @@ import {devtools, persist, createJSONStorage} from "zustand/middleware" const initialState = { subCategoryMap: {}, categoryMap: {}, + sendEventOnLogin: false, }; let localStore = (set) => ({ ...initialState, setSubCategoryMap: (subCategoryMap) => set({ subCategoryMap }), setCategoryMap: (categoryMap) => set({ categoryMap }), + setSendEventOnLogin: (sendEventOnLogin) => set({ sendEventOnLogin }), resetStore: () => set(initialState), // Reset function }) diff --git a/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js b/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js index 8fd96dbb68..604ac4d981 100644 --- a/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js +++ b/apps/dashboard/web/polaris_web/web/src/apps/main/PersistStore.js @@ -45,7 +45,6 @@ let persistStore = (set) => ({ setCoverageMap:(coverageMap)=>{set({coverageMap: coverageMap})}, setFiltersMap: (filtersMap) => set({ filtersMap }), setTableInitialState: (tableInitialState) => set({ tableInitialState }), - setSendEventOnLogin: (sendEventOnLogin) => set({ sendEventOnLogin }), resetAll: () => set(initialState), // Reset function }) diff --git a/apps/dashboard/web/polaris_web/web/src/util/request.js b/apps/dashboard/web/polaris_web/web/src/util/request.js index 36164222e3..d622b20863 100644 --- a/apps/dashboard/web/polaris_web/web/src/util/request.js +++ b/apps/dashboard/web/polaris_web/web/src/util/request.js @@ -105,7 +105,7 @@ service.interceptors.response.use((response) => { if (['put', 'post', 'delete', 'patch'].includes(response.method) && response.data.meta) { func.setToast(true, false, response.data.meta.message ) } - if (response.data.error) { + if (response?.data?.error !== undefined) { func.setToast(true, true, response.data.error ) } else { if ( window?.mixpanel?.track && response?.config?.url) {