From 0f90b19dc0a1ea080273ba9bd7e457d348acc724 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 4 Nov 2020 15:23:26 +0530 Subject: [PATCH 01/16] added anonymization of user data for CE --- app/client/src/constants/userConstants.ts | 2 ++ app/client/src/sagas/userSagas.tsx | 2 +- app/client/src/utils/AnalyticsUtil.tsx | 22 +++++++++++++++------- app/client/src/utils/AppsmithUtils.tsx | 4 ++++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/app/client/src/constants/userConstants.ts b/app/client/src/constants/userConstants.ts index 16bbb45ac3..17e69835a1 100644 --- a/app/client/src/constants/userConstants.ts +++ b/app/client/src/constants/userConstants.ts @@ -10,6 +10,7 @@ export type User = { username: string; name: string; gender: Gender; + anonymousId: string; }; export interface UserApplication { @@ -29,4 +30,5 @@ export const DefaultCurrentUserDetails: User = { username: ANONYMOUS_USERNAME, applications: [], gender: "MALE", + anonymousId: "anonymousId", }; diff --git a/app/client/src/sagas/userSagas.tsx b/app/client/src/sagas/userSagas.tsx index 8a37087b9c..cbb1916ebe 100644 --- a/app/client/src/sagas/userSagas.tsx +++ b/app/client/src/sagas/userSagas.tsx @@ -89,7 +89,7 @@ export function* getCurrentUserSaga() { !response.data.isAnonymous && response.data.username !== ANONYMOUS_USERNAME ) { - AnalyticsUtil.identifyUser(response.data.username, response.data); + AnalyticsUtil.identifyUser(response.data); } if (window.location.pathname === BASE_URL) { if (response.data.isAnonymous) { diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 21e1aab6c3..f67fdebbf4 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -5,6 +5,7 @@ import smartlookClient from "smartlook-client"; import { getAppsmithConfigs } from "configs"; import * as Sentry from "@sentry/react"; import { ANONYMOUS_USERNAME, User } from "../constants/userConstants"; +const { cloudHosting } = getAppsmithConfigs(); export type EventLocation = | "LIGHTNING_MENU" @@ -190,17 +191,24 @@ class AnalyticsUtil { log.debug("Event fired", eventName, finalEventData); } - static identifyUser(userId: string, userData: User) { - log.debug("Identify User " + userId); + static identifyUser(userData: User) { const windowDoc: any = window; + const userId = windowDoc.cloudHosting + ? userData.username + : userData.anonymousId; + log.debug("Identify User " + userId); AnalyticsUtil.user = userData; FeatureFlag.identify(userData); if (windowDoc.analytics) { - windowDoc.analytics.identify(userId, { - email: userData.email, - name: userData.name, - userId: userId, - }); + let userProperties = {}; + if (windowDoc.cloudHosting) { + userProperties = { + email: userData.email, + name: userData.name, + userId: userId, + }; + } + windowDoc.analytics.identify(userId, userProperties); } Sentry.configureScope(function(scope) { scope.setUser({ diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index e1bd392e19..ca0006a89f 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -14,6 +14,8 @@ import { AppIconCollection, AppIconName } from "components/ads/AppIcon"; import history from "./history"; import { SERVER_ERROR_URL } from "../constants/routes"; +const SEGMENT_CE_KEY = "aLyfW0WipbrC3WP02i2Zm8SOOJoBSd0o"; + export const createReducer = ( initialState: any, handlers: { [type: string]: (state: any, action: any) => any }, @@ -54,6 +56,8 @@ export const appInitializer = () => { } if (appsmithConfigs.segment.enabled) { AnalyticsUtil.initializeSegment(appsmithConfigs.segment.apiKey); + } else { + AnalyticsUtil.initializeSegment(SEGMENT_CE_KEY); } log.setLevel(getEnvLogLevel(appsmithConfigs.logLevel)); From f05ac9a9c6e75933176d47fe3d0138a3cbbfa249 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 4 Nov 2020 16:23:15 +0530 Subject: [PATCH 02/16] added sha256 hash to obfuscate analytics data --- app/client/package.json | 2 +- app/client/src/utils/AnalyticsUtil.tsx | 31 ++++++++++++++------------ app/client/yarn.lock | 5 +++++ 3 files changed, 23 insertions(+), 15 deletions(-) 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" From 1413203251a3653d6d1a923c11236c7a0191a03d Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Wed, 4 Nov 2020 17:50:14 +0530 Subject: [PATCH 03/16] Adding the check for disabling telemetry if the environment variable is set --- app/client/public/index.html | 1 + app/client/src/configs/index.ts | 5 ++++- app/client/src/configs/types.ts | 2 ++ app/client/src/utils/AnalyticsUtil.tsx | 11 +++++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/client/public/index.html b/app/client/public/index.html index 5178386def..853d1c1629 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -137,6 +137,7 @@ }, intercomAppID: parseConfig("__APPSMITH_INTERCOM_APP_ID__"), mailEnabled: parseConfig("__APPSMITH_MAIL_ENABLED__").length > 0, + disableTelemetry: parseConfig("__APPSMITH_DISABLE_TELEMETRY__").toLowerCase() === 'true' , }; diff --git a/app/client/src/configs/index.ts b/app/client/src/configs/index.ts index ae41216bb8..49ef264af4 100644 --- a/app/client/src/configs/index.ts +++ b/app/client/src/configs/index.ts @@ -34,6 +34,7 @@ type INJECTED_CONFIGS = { }; intercomAppID: string; mailEnabled: boolean; + disableTelemetry: boolean; }; declare global { interface Window { @@ -99,6 +100,7 @@ const getConfigsFromEnvVars = (): INJECTED_CONFIGS => { mailEnabled: process.env.REACT_APP_MAIL_ENABLED ? process.env.REACT_APP_MAIL_ENABLED.length > 0 : false, + disableTelemetry: false, }; }; @@ -154,7 +156,7 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { const algoliaAPIID = getConfig( ENV_CONFIG.algolia.apiId, - APPSMITH_FEATURE_CONFIGS.algolia.apiKey, + APPSMITH_FEATURE_CONFIGS.algolia.apiId, ); const algoliaAPIKey = getConfig( ENV_CONFIG.algolia.apiKey, @@ -219,5 +221,6 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { intercomAppID: ENV_CONFIG.intercomAppID || APPSMITH_FEATURE_CONFIGS.intercomAppID, mailEnabled: ENV_CONFIG.mailEnabled || APPSMITH_FEATURE_CONFIGS.mailEnabled, + disableTelemetry: APPSMITH_FEATURE_CONFIGS.disableTelemetry, }; }; diff --git a/app/client/src/configs/types.ts b/app/client/src/configs/types.ts index 34a16b9cfd..a096383904 100644 --- a/app/client/src/configs/types.ts +++ b/app/client/src/configs/types.ts @@ -64,4 +64,6 @@ export type AppsmithUIConfigs = { }; intercomAppID: string; mailEnabled: boolean; + + disableTelemetry: boolean; }; diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 398681a94e..ff25588b13 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -5,7 +5,7 @@ import smartlookClient from "smartlook-client"; import { getAppsmithConfigs } from "configs"; import * as Sentry from "@sentry/react"; import { ANONYMOUS_USERNAME, User } from "../constants/userConstants"; -const { cloudHosting } = getAppsmithConfigs(); +const { cloudHosting, disableTelemetry } = getAppsmithConfigs(); import { sha256 } from "js-sha256"; export type EventLocation = @@ -175,7 +175,7 @@ class AnalyticsUtil { (app: any) => app.id === appId, ); let user: any = {}; - if (windowDoc.cloudHosting) { + if (cloudHosting) { user = { userId: userData.username, email: userData.email, @@ -201,7 +201,8 @@ class AnalyticsUtil { log.debug("Identify User " + userId); FeatureFlag.identify(userData); if (windowDoc.analytics) { - if (windowDoc.cloudHosting) { + // This flag is only set on Appsmith Cloud. In this case, we get more detailed analytics of the user + if (cloudHosting) { const userProperties = { email: userData.email, name: userData.name, @@ -209,7 +210,9 @@ class AnalyticsUtil { }; AnalyticsUtil.user = userData; windowDoc.analytics.identify(userId, userProperties); - } else { + } else if (!disableTelemetry) { + // This is a self-hosted instance. Only send data if the analytics are NOT disabled by the user + // This is done by setting environment variable APPSMITH_DISABLE_TELEMETRY in the docker.env file windowDoc.analytics.identify(sha256(userId)); } } From 7979dff9df16bf616223c8b9f3314d76f050c82d Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Wed, 4 Nov 2020 19:48:18 +0530 Subject: [PATCH 04/16] updated installation script --- deploy/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deploy/install.sh b/deploy/install.sh index 194ebe7386..e2154633e7 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -706,4 +706,6 @@ else } }' > /dev/null fi +echo -e "Thank you for installing appsmith! We wanted to be transparent and inform you that we do perform telemetry in our on-prem installations. This helps us understand your needs and prioritise features & bug fixes better" +echo -e "All telemetry is 100% anonymous and only statistical in nature. You can read more about it and how to disable it in our documentation https://docs.appsmith.com/telemetry/telemetry" echo -e "\nPeace out ✌️\n" From 0b5250529afd0cadf440a70ad3183fe14bb319b9 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Wed, 4 Nov 2020 20:03:17 +0530 Subject: [PATCH 05/16] Moving the getAppsmithConfig function to static function in index.ts --- app/client/src/utils/AnalyticsUtil.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index ff25588b13..c26e799c8c 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -5,7 +5,6 @@ import smartlookClient from "smartlook-client"; import { getAppsmithConfigs } from "configs"; import * as Sentry from "@sentry/react"; import { ANONYMOUS_USERNAME, User } from "../constants/userConstants"; -const { cloudHosting, disableTelemetry } = getAppsmithConfigs(); import { sha256 } from "js-sha256"; export type EventLocation = @@ -170,6 +169,8 @@ class AnalyticsUtil { let finalEventData = eventData; const userData = AnalyticsUtil.user; const appId = getApplicationId(windowDoc.location); + const { cloudHosting } = getAppsmithConfigs(); + if (userData) { const app = (userData.applications || []).find( (app: any) => app.id === appId, @@ -198,6 +199,9 @@ class AnalyticsUtil { static identifyUser(userData: User) { const windowDoc: any = window; const userId = userData.username; + + const { cloudHosting, disableTelemetry } = getAppsmithConfigs(); + log.debug("Identify User " + userId); FeatureFlag.identify(userData); if (windowDoc.analytics) { From 994d57422b0fd3bb2c75eb654762390eca1c2c0c Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Thu, 5 Nov 2020 08:01:01 +0530 Subject: [PATCH 06/16] Fixing the jest test in AnalyticsUtil --- app/client/src/utils/AnalyticsUtil.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index c26e799c8c..3be4f51f5d 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -169,9 +169,9 @@ class AnalyticsUtil { let finalEventData = eventData; const userData = AnalyticsUtil.user; const appId = getApplicationId(windowDoc.location); - const { cloudHosting } = getAppsmithConfigs(); if (userData) { + const { cloudHosting } = getAppsmithConfigs(); const app = (userData.applications || []).find( (app: any) => app.id === appId, ); @@ -200,7 +200,7 @@ class AnalyticsUtil { const windowDoc: any = window; const userId = userData.username; - const { cloudHosting, disableTelemetry } = getAppsmithConfigs(); + const { cloudHosting, disableTelemetry, smartLook } = getAppsmithConfigs(); log.debug("Identify User " + userId); FeatureFlag.identify(userData); @@ -227,7 +227,7 @@ class AnalyticsUtil { email: userData.email, }); }); - const { smartLook } = getAppsmithConfigs(); + if (smartLook.enabled) { smartlookClient.identify(userId, { email: userData.email }); } From b3eabf68ea96cbc049699a9dab48947aa641a536 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Thu, 5 Nov 2020 10:54:30 +0530 Subject: [PATCH 07/16] Moving the segment CE key to a build time variable instead of hard coding it --- app/client/public/index.html | 5 ++++- app/client/src/configs/index.ts | 20 ++++++++++++++++---- app/client/src/configs/types.ts | 1 + app/client/src/utils/AppsmithUtils.tsx | 7 ++++--- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/app/client/public/index.html b/app/client/public/index.html index 853d1c1629..bc1bbbd50c 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -119,7 +119,10 @@ enableGoogleOAuth: parseConfig("__APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__").length > 0, enableGithubOAuth: parseConfig("__APPSMITH_OAUTH2_GITHUB_CLIENT_ID__").length > 0, enableRapidAPI: parseConfig("__APPSMITH_MARKETPLACE_ENABLED__").length > 0, - segment: parseConfig("__APPSMITH_SEGMENT_KEY__"), + segment: { + apiKey: parseConfig("__APPSMITH_SEGMENT_KEY__"), + ceKey: parseConfig("__APPSMITH_SEGMENT_CE_KEY__"), + }, optimizely: parseConfig("__APPSMITH_OPTIMIZELY_KEY__"), enableMixpanel: parseConfig("__APPSMITH_SEGMENT_KEY__").length > 0, algolia: { diff --git a/app/client/src/configs/index.ts b/app/client/src/configs/index.ts index 49ef264af4..d7c734bffe 100644 --- a/app/client/src/configs/index.ts +++ b/app/client/src/configs/index.ts @@ -16,7 +16,10 @@ type INJECTED_CONFIGS = { enableGoogleOAuth: boolean; enableGithubOAuth: boolean; enableRapidAPI: boolean; - segment: string; + segment: { + apiKey: string; + ceKey: string; + }; optimizely: string; enableMixpanel: boolean; google: string; @@ -67,7 +70,10 @@ const getConfigsFromEnvVars = (): INJECTED_CONFIGS => { enableGithubOAuth: process.env.REACT_APP_OAUTH2_GITHUB_CLIENT_ID ? process.env.REACT_APP_OAUTH2_GITHUB_CLIENT_ID.length > 0 : false, - segment: process.env.REACT_APP_SEGMENT_KEY || "", + segment: { + apiKey: process.env.REACT_APP_SEGMENT_KEY || "", + ceKey: process.env.REACT_APP_SEGMENT_CE_KEY || "", + }, optimizely: process.env.REACT_APP_OPTIMIZELY_KEY || "", enableMixpanel: process.env.REACT_APP_SEGMENT_KEY ? process.env.REACT_APP_SEGMENT_KEY.length > 0 @@ -142,8 +148,8 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { APPSMITH_FEATURE_CONFIGS.sentry.environment, ); const segment = getConfig( - ENV_CONFIG.segment, - APPSMITH_FEATURE_CONFIGS.segment, + ENV_CONFIG.segment.apiKey, + APPSMITH_FEATURE_CONFIGS.segment.apiKey, ); const google = getConfig(ENV_CONFIG.google, APPSMITH_FEATURE_CONFIGS.google); @@ -167,6 +173,11 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { APPSMITH_FEATURE_CONFIGS.algolia.indexName, ); + const segmentCEKey = getConfig( + ENV_CONFIG.segment.ceKey, + APPSMITH_FEATURE_CONFIGS.segment.ceKey, + ); + return { sentry: { enabled: sentryDSN.enabled && sentryRelease.enabled && sentryENV.enabled, @@ -189,6 +200,7 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { segment: { enabled: segment.enabled, apiKey: segment.value, + ceKey: segmentCEKey.value, }, algolia: { enabled: true, diff --git a/app/client/src/configs/types.ts b/app/client/src/configs/types.ts index a096383904..7007f200fd 100644 --- a/app/client/src/configs/types.ts +++ b/app/client/src/configs/types.ts @@ -35,6 +35,7 @@ export type AppsmithUIConfigs = { segment: { enabled: boolean; apiKey: string; + ceKey: string; }; algolia: { enabled: boolean; diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index ca0006a89f..1cb4471b22 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -14,8 +14,6 @@ import { AppIconCollection, AppIconName } from "components/ads/AppIcon"; import history from "./history"; import { SERVER_ERROR_URL } from "../constants/routes"; -const SEGMENT_CE_KEY = "aLyfW0WipbrC3WP02i2Zm8SOOJoBSd0o"; - export const createReducer = ( initialState: any, handlers: { [type: string]: (state: any, action: any) => any }, @@ -54,10 +52,13 @@ export const appInitializer = () => { const { id } = appsmithConfigs.smartLook; AnalyticsUtil.initializeSmartLook(id); } + if (appsmithConfigs.segment.enabled) { + // This value is only enabled for Appsmith's cloud hosted version. It is not set in self-hosted environments AnalyticsUtil.initializeSegment(appsmithConfigs.segment.apiKey); } else { - AnalyticsUtil.initializeSegment(SEGMENT_CE_KEY); + // This value is set in self-hosted environments. But if the analytics are disabled, it's never used. + AnalyticsUtil.initializeSegment(appsmithConfigs.segment.ceKey); } log.setLevel(getEnvLogLevel(appsmithConfigs.logLevel)); From 274e2bc5cdc137efd848235824948e12a42665f9 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Thu, 5 Nov 2020 11:41:29 +0530 Subject: [PATCH 08/16] updated telemetry check --- app/client/src/utils/AnalyticsUtil.tsx | 11 +++++------ deploy/install.sh | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 3be4f51f5d..54f68c8a77 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -7,6 +7,8 @@ import * as Sentry from "@sentry/react"; import { ANONYMOUS_USERNAME, User } from "../constants/userConstants"; import { sha256 } from "js-sha256"; +const { segment, disableTelemetry, smartLook } = getAppsmithConfigs(); + export type EventLocation = | "LIGHTNING_MENU" | "API_PANE" @@ -171,12 +173,11 @@ class AnalyticsUtil { const appId = getApplicationId(windowDoc.location); if (userData) { - const { cloudHosting } = getAppsmithConfigs(); const app = (userData.applications || []).find( (app: any) => app.id === appId, ); let user: any = {}; - if (cloudHosting) { + if (!segment.ceKey && segment.apiKey) { user = { userId: userData.username, email: userData.email, @@ -200,13 +201,11 @@ class AnalyticsUtil { const windowDoc: any = window; const userId = userData.username; - const { cloudHosting, disableTelemetry, smartLook } = getAppsmithConfigs(); - log.debug("Identify User " + userId); FeatureFlag.identify(userData); if (windowDoc.analytics) { // This flag is only set on Appsmith Cloud. In this case, we get more detailed analytics of the user - if (cloudHosting) { + if (segment.apiKey) { const userProperties = { email: userData.email, name: userData.name, @@ -214,7 +213,7 @@ class AnalyticsUtil { }; AnalyticsUtil.user = userData; windowDoc.analytics.identify(userId, userProperties); - } else if (!disableTelemetry) { + } else if (!disableTelemetry && segment.ceKey) { // This is a self-hosted instance. Only send data if the analytics are NOT disabled by the user // This is done by setting environment variable APPSMITH_DISABLE_TELEMETRY in the docker.env file windowDoc.analytics.identify(sha256(userId)); diff --git a/deploy/install.sh b/deploy/install.sh index e2154633e7..0602c48efe 100755 --- a/deploy/install.sh +++ b/deploy/install.sh @@ -706,6 +706,6 @@ else } }' > /dev/null fi -echo -e "Thank you for installing appsmith! We wanted to be transparent and inform you that we do perform telemetry in our on-prem installations. This helps us understand your needs and prioritise features & bug fixes better" +echo -e "Thank you for installing appsmith! We want to be transparent and inform you that we do perform telemetry in our on-prem installations. This helps us understand your needs and prioritise features & bug fixes better." echo -e "All telemetry is 100% anonymous and only statistical in nature. You can read more about it and how to disable it in our documentation https://docs.appsmith.com/telemetry/telemetry" echo -e "\nPeace out ✌️\n" From 2c111edbbaeff54bd89a354d3cace6c1611ac53f Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Thu, 5 Nov 2020 16:56:00 +0530 Subject: [PATCH 09/16] fix for tests --- app/client/src/utils/AnalyticsUtil.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 54f68c8a77..4468784e34 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -7,8 +7,6 @@ import * as Sentry from "@sentry/react"; import { ANONYMOUS_USERNAME, User } from "../constants/userConstants"; import { sha256 } from "js-sha256"; -const { segment, disableTelemetry, smartLook } = getAppsmithConfigs(); - export type EventLocation = | "LIGHTNING_MENU" | "API_PANE" @@ -167,11 +165,11 @@ class AnalyticsUtil { } static logEvent(eventName: EventName, eventData: any = {}) { + const { segment, disableTelemetry } = getAppsmithConfigs(); const windowDoc: any = window; let finalEventData = eventData; const userData = AnalyticsUtil.user; const appId = getApplicationId(windowDoc.location); - if (userData) { const app = (userData.applications || []).find( (app: any) => app.id === appId, @@ -198,6 +196,7 @@ class AnalyticsUtil { } static identifyUser(userData: User) { + const { segment, disableTelemetry, smartLook } = getAppsmithConfigs(); const windowDoc: any = window; const userId = userData.username; From 5e938152769efdad62a8785120218bb0e42df1a2 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Thu, 5 Nov 2020 16:58:17 +0530 Subject: [PATCH 10/16] added segment CE and telemetry flags --- app/client/docker/templates/nginx-mac.conf.template | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/client/docker/templates/nginx-mac.conf.template b/app/client/docker/templates/nginx-mac.conf.template index e36919c4e8..5cf2dadc04 100644 --- a/app/client/docker/templates/nginx-mac.conf.template +++ b/app/client/docker/templates/nginx-mac.conf.template @@ -36,6 +36,8 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; + sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_KEY}'; + sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } location /f { @@ -104,6 +106,8 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; + sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_KEY}'; + sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } From 7ed8d3db9bd23170b8baffecf5d442f37c7453e6 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Thu, 5 Nov 2020 18:10:04 +0530 Subject: [PATCH 11/16] fixed conf --- app/client/docker/templates/nginx-linux.conf.template | 4 ++++ app/client/docker/templates/nginx-mac.conf.template | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/client/docker/templates/nginx-linux.conf.template b/app/client/docker/templates/nginx-linux.conf.template index b5e37d7935..6f6b3c8eca 100644 --- a/app/client/docker/templates/nginx-linux.conf.template +++ b/app/client/docker/templates/nginx-linux.conf.template @@ -36,6 +36,8 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; + sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; + sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } location /f { @@ -103,6 +105,8 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; + sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; + sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } location /f { diff --git a/app/client/docker/templates/nginx-mac.conf.template b/app/client/docker/templates/nginx-mac.conf.template index 5cf2dadc04..3b813a8a38 100644 --- a/app/client/docker/templates/nginx-mac.conf.template +++ b/app/client/docker/templates/nginx-mac.conf.template @@ -36,7 +36,7 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; - sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_KEY}'; + sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } @@ -106,7 +106,7 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; - sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_KEY}'; + sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } From 12f3a4182c9f5515e276d303548dee34861ee459 Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Thu, 5 Nov 2020 20:32:25 +0530 Subject: [PATCH 12/16] Fixing the tests and adding the segment key in the yarn build This key will be burned into the Docker image itself. Also adding the disable telemetry link to the nginx_app template during self-hosted deploys. --- .github/workflows/client.yml | 4 +++- app/client/docker/templates/nginx-linux.conf.template | 1 - app/client/docker/templates/nginx-mac.conf.template | 1 - app/client/src/utils/AnalyticsUtil.tsx | 2 +- deploy/template/nginx_app.conf.sh | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/client.yml b/.github/workflows/client.yml index cc96f7cef0..91fd2f9165 100644 --- a/.github/workflows/client.yml +++ b/.github/workflows/client.yml @@ -73,8 +73,10 @@ jobs: - name: Run the jest tests run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} yarn run test:unit + # We burn React environment & the Segment analytics key into the build itself. + # This is to ensure that we don't need to configure it in each installation - name: Create the bundle - run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} yarn build + run: REACT_APP_ENVIRONMENT=${{steps.vars.outputs.REACT_APP_ENVIRONMENT}} REACT_APP_SEGMENT_CE_KEY=${{ secrets.APPSMITH_SEGMENT_CE_KEY }} yarn build # Upload the build artifact so that it can be used by the test & deploy job in the workflow - name: Upload react build bundle diff --git a/app/client/docker/templates/nginx-linux.conf.template b/app/client/docker/templates/nginx-linux.conf.template index 6f6b3c8eca..8448003227 100644 --- a/app/client/docker/templates/nginx-linux.conf.template +++ b/app/client/docker/templates/nginx-linux.conf.template @@ -36,7 +36,6 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; - sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } diff --git a/app/client/docker/templates/nginx-mac.conf.template b/app/client/docker/templates/nginx-mac.conf.template index 3b813a8a38..0adbb24f36 100644 --- a/app/client/docker/templates/nginx-mac.conf.template +++ b/app/client/docker/templates/nginx-mac.conf.template @@ -36,7 +36,6 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; - sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 4468784e34..2ff809a52c 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -165,12 +165,12 @@ class AnalyticsUtil { } static logEvent(eventName: EventName, eventData: any = {}) { - const { segment, disableTelemetry } = getAppsmithConfigs(); const windowDoc: any = window; let finalEventData = eventData; const userData = AnalyticsUtil.user; const appId = getApplicationId(windowDoc.location); if (userData) { + const { segment } = getAppsmithConfigs(); const app = (userData.applications || []).find( (app: any) => app.id === appId, ); diff --git a/deploy/template/nginx_app.conf.sh b/deploy/template/nginx_app.conf.sh index 14c27a9eeb..4bba666b02 100644 --- a/deploy/template/nginx_app.conf.sh +++ b/deploy/template/nginx_app.conf.sh @@ -48,6 +48,7 @@ $NGINX_SSL_CMNT server_name $custom_domain ; sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '\${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '\${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '\${APPSMITH_MAIL_ENABLED}'; + sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } location /f { From a944680d50823c6022a289466507b987e5dfaedd Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Thu, 5 Nov 2020 22:00:37 +0530 Subject: [PATCH 13/16] Adding the disable telemetry config in the env example --- .env.example | 7 ++++++- app/client/docker/templates/nginx-linux.conf.template | 1 - app/client/docker/templates/nginx-mac.conf.template | 1 - deploy/template/nginx_app.conf.sh | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 2eb1d2231f..a25d8a64d5 100644 --- a/.env.example +++ b/.env.example @@ -46,4 +46,9 @@ APPSMITH_MAIL_PASSWORD= # Email server feature toggles # true | false values APPSMITH_MAIL_SMTP_AUTH= -APPSMITH_MAIL_SMTP_TLS_ENABLED= \ No newline at end of file +APPSMITH_MAIL_SMTP_TLS_ENABLED= + +# Disable all telemetry +# Note: This only takes effect in self-hosted scenarios. +# Please visit: https://docs.appsmith.com/telemetry/telemetry to read more about anonymized data collected by Appsmith +# APPSMITH_DISABLE_TELEMETRY=false \ No newline at end of file diff --git a/app/client/docker/templates/nginx-linux.conf.template b/app/client/docker/templates/nginx-linux.conf.template index 8448003227..d205da5d6f 100644 --- a/app/client/docker/templates/nginx-linux.conf.template +++ b/app/client/docker/templates/nginx-linux.conf.template @@ -104,7 +104,6 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; - sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } diff --git a/app/client/docker/templates/nginx-mac.conf.template b/app/client/docker/templates/nginx-mac.conf.template index 0adbb24f36..16c7a250e7 100644 --- a/app/client/docker/templates/nginx-mac.conf.template +++ b/app/client/docker/templates/nginx-mac.conf.template @@ -105,7 +105,6 @@ server { sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '${APPSMITH_VERSION_RELEASE_DATE}'; sub_filter __APPSMITH_INTERCOM_APP_ID__ '${APPSMITH_INTERCOM_APP_ID}'; sub_filter __APPSMITH_MAIL_ENABLED__ '${APPSMITH_MAIL_ENABLED}'; - sub_filter __APPSMITH_SEGMENT_CE_KEY__ '${APPSMITH_SEGMENT_CE_KEY}'; sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; } diff --git a/deploy/template/nginx_app.conf.sh b/deploy/template/nginx_app.conf.sh index 4bba666b02..f116fa3028 100644 --- a/deploy/template/nginx_app.conf.sh +++ b/deploy/template/nginx_app.conf.sh @@ -104,6 +104,7 @@ $NGINX_SSL_CMNT sub_filter __APPSMITH_VERSION_ID__ '\${APPSMITH_VERSION_I $NGINX_SSL_CMNT sub_filter __APPSMITH_VERSION_RELEASE_DATE__ '\${APPSMITH_VERSION_RELEASE_DATE}'; $NGINX_SSL_CMNT sub_filter __APPSMITH_INTERCOM_APP_ID__ '\${APPSMITH_INTERCOM_APP_ID}'; $NGINX_SSL_CMNT sub_filter __APPSMITH_MAIL_ENABLED__ '\${APPSMITH_MAIL_ENABLED}'; +$NGINX_SSL_CMNT sub_filter __APPSMITH_DISABLE_TELEMETRY__ '${APPSMITH_DISABLE_TELEMETRY}'; $NGINX_SSL_CMNT } $NGINX_SSL_CMNT $NGINX_SSL_CMNT location /f { From 430dfc00eae6b81977bd1331713048d7bef53e2e Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Thu, 5 Nov 2020 22:21:22 +0530 Subject: [PATCH 14/16] updated analytics checks --- app/client/src/utils/AnalyticsUtil.tsx | 17 +++++++++-------- app/client/src/utils/AppsmithUtils.tsx | 24 ++++++++++++------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 2ff809a52c..bd92366a2b 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -175,7 +175,7 @@ class AnalyticsUtil { (app: any) => app.id === appId, ); let user: any = {}; - if (!segment.ceKey && segment.apiKey) { + if (segment.enabled && segment.apiKey) { user = { userId: userData.username, email: userData.email, @@ -190,17 +190,15 @@ class AnalyticsUtil { }; } if (windowDoc.analytics) { + log.debug("Event fired", eventName, finalEventData); windowDoc.analytics.track(eventName, finalEventData); } - log.debug("Event fired", eventName, finalEventData); } static identifyUser(userData: User) { - const { segment, disableTelemetry, smartLook } = getAppsmithConfigs(); + const { segment, smartLook } = getAppsmithConfigs(); const windowDoc: any = window; - const userId = userData.username; - - log.debug("Identify User " + userId); + let userId = userData.username; FeatureFlag.identify(userData); if (windowDoc.analytics) { // This flag is only set on Appsmith Cloud. In this case, we get more detailed analytics of the user @@ -211,11 +209,14 @@ class AnalyticsUtil { userId: userId, }; AnalyticsUtil.user = userData; + log.debug("Identify User " + userId); windowDoc.analytics.identify(userId, userProperties); - } else if (!disableTelemetry && segment.ceKey) { + } else if (segment.ceKey) { // This is a self-hosted instance. Only send data if the analytics are NOT disabled by the user // This is done by setting environment variable APPSMITH_DISABLE_TELEMETRY in the docker.env file - windowDoc.analytics.identify(sha256(userId)); + userId = sha256(userId); + log.debug("Identify Anonymous User " + userId); + windowDoc.analytics.identify(userId); } } Sentry.configureScope(function(scope) { diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index 1cb4471b22..6d4a75e108 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -48,19 +48,19 @@ export const appInitializer = () => { if (appsmithConfigs.sentry.enabled) { Sentry.init(appsmithConfigs.sentry); } - if (appsmithConfigs.smartLook.enabled) { - const { id } = appsmithConfigs.smartLook; - AnalyticsUtil.initializeSmartLook(id); + if (!appsmithConfigs.disableTelemetry) { + if (appsmithConfigs.smartLook.enabled) { + const { id } = appsmithConfigs.smartLook; + AnalyticsUtil.initializeSmartLook(id); + } + if (appsmithConfigs.segment.enabled && appsmithConfigs.segment.apiKey) { + // This value is only enabled for Appsmith's cloud hosted version. It is not set in self-hosted environments + AnalyticsUtil.initializeSegment(appsmithConfigs.segment.apiKey); + } else if (appsmithConfigs.segment.ceKey) { + // This value is set in self-hosted environments. But if the analytics are disabled, it's never used. + AnalyticsUtil.initializeSegment(appsmithConfigs.segment.ceKey); + } } - - if (appsmithConfigs.segment.enabled) { - // This value is only enabled for Appsmith's cloud hosted version. It is not set in self-hosted environments - AnalyticsUtil.initializeSegment(appsmithConfigs.segment.apiKey); - } else { - // This value is set in self-hosted environments. But if the analytics are disabled, it's never used. - AnalyticsUtil.initializeSegment(appsmithConfigs.segment.ceKey); - } - log.setLevel(getEnvLogLevel(appsmithConfigs.logLevel)); }; From 2a8e756149e4a7b17a3bbab1b7248ee9e9b3499d Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Fri, 6 Nov 2020 11:57:36 +0530 Subject: [PATCH 15/16] added caching for analytics hash --- app/client/src/utils/AnalyticsUtil.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index bd92366a2b..09600ce41d 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -99,6 +99,8 @@ function getApplicationId(location: Location) { } class AnalyticsUtil { + static cachedAnonymoustId: string; + static cachedUserId: string; static user?: User = undefined; static initializeSmartLook(id: string) { smartlookClient.init(id); @@ -198,7 +200,7 @@ class AnalyticsUtil { static identifyUser(userData: User) { const { segment, smartLook } = getAppsmithConfigs(); const windowDoc: any = window; - let userId = userData.username; + const userId = userData.username; FeatureFlag.identify(userData); if (windowDoc.analytics) { // This flag is only set on Appsmith Cloud. In this case, we get more detailed analytics of the user @@ -214,9 +216,14 @@ class AnalyticsUtil { } else if (segment.ceKey) { // This is a self-hosted instance. Only send data if the analytics are NOT disabled by the user // This is done by setting environment variable APPSMITH_DISABLE_TELEMETRY in the docker.env file - userId = sha256(userId); - log.debug("Identify Anonymous User " + userId); - windowDoc.analytics.identify(userId); + if (userId !== AnalyticsUtil.cachedUserId) { + AnalyticsUtil.cachedAnonymoustId = sha256(userId); + AnalyticsUtil.cachedUserId = userId; + } + log.debug( + "Identify Anonymous User " + AnalyticsUtil.cachedAnonymoustId, + ); + windowDoc.analytics.identify(AnalyticsUtil.cachedAnonymoustId); } } Sentry.configureScope(function(scope) { From 17ffcd946e435bb757828da67a4c1c81ee352c3b Mon Sep 17 00:00:00 2001 From: Arpit Mohan Date: Fri, 6 Nov 2020 13:33:35 +0530 Subject: [PATCH 16/16] Increase the timeout while waiting for containers to start --- app/client/cypress/setup-test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/client/cypress/setup-test.sh b/app/client/cypress/setup-test.sh index 8aa8e73f82..944f88aa74 100755 --- a/app/client/cypress/setup-test.sh +++ b/app/client/cypress/setup-test.sh @@ -34,8 +34,8 @@ sudo docker run --network host --name postgres -d -p 5432:5432 \ --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 \ postgres:latest & -echo "Sleeping for 10 seconds to let the servers start" -sleep 10 +echo "Sleeping for 20 seconds to let the servers start" +sleep 20 echo "Checking if the containers have started" sudo docker ps -a