diff --git a/app/client/src/sagas/userSagas.tsx b/app/client/src/sagas/userSagas.tsx index 7bee7764be..8a37087b9c 100644 --- a/app/client/src/sagas/userSagas.tsx +++ b/app/client/src/sagas/userSagas.tsx @@ -36,6 +36,7 @@ import { INVITE_USERS_TO_ORG_FORM } from "constants/forms"; import PerformanceTracker, { PerformanceTransactionName, } from "utils/PerformanceTracker"; +import { ANONYMOUS_USERNAME } from "constants/userConstants"; export function* createUserSaga( action: ReduxActionWithPromise, @@ -84,7 +85,10 @@ export function* getCurrentUserSaga() { const isValidResponse = yield validateResponse(response); if (isValidResponse) { - if (!response.data.isAnonymous) { + if ( + !response.data.isAnonymous && + response.data.username !== ANONYMOUS_USERNAME + ) { AnalyticsUtil.identifyUser(response.data.username, response.data); } if (window.location.pathname === BASE_URL) { diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index dfa05055e2..21e1aab6c3 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -4,7 +4,7 @@ import FeatureFlag from "./featureFlags"; import smartlookClient from "smartlook-client"; import { getAppsmithConfigs } from "configs"; import * as Sentry from "@sentry/react"; -import { User } from "../constants/userConstants"; +import { ANONYMOUS_USERNAME, User } from "../constants/userConstants"; export type EventLocation = | "LIGHTNING_MENU" @@ -172,15 +172,16 @@ class AnalyticsUtil { const app = (userData.applications || []).find( (app: any) => app.id === appId, ); + const user = { + userId: userData.username, + email: userData.email, + currentOrgId: userData.currentOrganizationId, + appId: appId, + appName: app ? app.name : undefined, + }; finalEventData = { - ...finalEventData, - userData: { - userId: userData.username, - email: userData.email, - currentOrgId: userData.currentOrganizationId, - appId: appId, - appName: app ? app.name : undefined, - }, + ...eventData, + userData: user.userId === ANONYMOUS_USERNAME ? undefined : user, }; } if (windowDoc.analytics) {