Skip to content

Commit

Permalink
Merge pull request #1376 from akto-api-security/hotfix/fix_clarity_error
Browse files Browse the repository at this point in the history
Fixed null check for clarity
  • Loading branch information
notshivansh authored Aug 20, 2024
2 parents 54912c3 + f7fe059 commit 77780e8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion apps/dashboard/web/pages/login.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -44,8 +44,9 @@ function Dashboard() {

const getEventForIntercom = async() => {
let resp = await homeRequests.getEventForIntercom();
setEventForUser(resp)
setSendEventOnLogin(true)
if(resp !== null){
setEventForUser(resp)
}
}

useEffect(() => {
Expand All @@ -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)
}
}
}
}, [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
})

Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/web/polaris_web/web/src/util/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 77780e8

Please sign in to comment.