diff --git a/app/client/package.json b/app/client/package.json index 61b6ece608..d93d2d07ca 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -63,6 +63,7 @@ "interweave": "^12.1.1", "interweave-autolink": "^4.0.1", "js-base64": "^3.4.5", + "js-sha256": "^0.9.0", "json-fn": "^1.1.1", "lint-staged": "^9.2.5", "localforage": "^1.7.3", @@ -141,7 +142,6 @@ "eslintConfig": { "extends": "react-app", "parser": "@typescript-eslint/parser" - }, "browserslist": [ ">0.2%", diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index f67fdebbf4..398681a94e 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -6,6 +6,7 @@ import { getAppsmithConfigs } from "configs"; import * as Sentry from "@sentry/react"; import { ANONYMOUS_USERNAME, User } from "../constants/userConstants"; const { cloudHosting } = getAppsmithConfigs(); +import { sha256 } from "js-sha256"; export type EventLocation = | "LIGHTNING_MENU" @@ -173,13 +174,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, - }; + let user: any = {}; + if (windowDoc.cloudHosting) { + user = { + userId: userData.username, + email: userData.email, + currentOrgId: userData.currentOrganizationId, + appId: appId, + appName: app ? app.name : undefined, + }; + } finalEventData = { ...eventData, userData: user.userId === ANONYMOUS_USERNAME ? undefined : user, @@ -193,22 +197,21 @@ class AnalyticsUtil { static identifyUser(userData: User) { const windowDoc: any = window; - const userId = windowDoc.cloudHosting - ? userData.username - : userData.anonymousId; + const userId = userData.username; log.debug("Identify User " + userId); - AnalyticsUtil.user = userData; FeatureFlag.identify(userData); if (windowDoc.analytics) { - let userProperties = {}; if (windowDoc.cloudHosting) { - userProperties = { + const userProperties = { email: userData.email, name: userData.name, userId: userId, }; + AnalyticsUtil.user = userData; + windowDoc.analytics.identify(userId, userProperties); + } else { + windowDoc.analytics.identify(sha256(userId)); } - windowDoc.analytics.identify(userId, userProperties); } Sentry.configureScope(function(scope) { scope.setUser({ diff --git a/app/client/yarn.lock b/app/client/yarn.lock index fc89847cbf..e0f7dac7b5 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -11781,6 +11781,11 @@ js-base64@^3.4.5: resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.5.2.tgz#3cc800e4f10812b55fb5ec53e7cabaef35dc6d3c" integrity sha512-VG2qfvV5rEQIVxq9UmAVyWIaOdZGt9M16BLu8vFkyWyhv709Hyg4nKUb5T+Ru+HmAr9RHdF+kQDKAhbJlcdKeQ== +js-sha256@^0.9.0: + version "0.9.0" + resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966" + integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA== + js-string-escape@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/js-string-escape/-/js-string-escape-1.0.1.tgz#e2625badbc0d67c7533e9edc1068c587ae4137ef"