diff --git a/.env.example b/.env.example index 3194c70121..2eb1d2231f 100644 --- a/.env.example +++ b/.env.example @@ -4,9 +4,8 @@ # Sentry APPSMITH_SENTRY_DSN= -# Hotjar -APPSMITH_HOTJAR_HJID= -APPSMITH_HOTJAR_HJSV= +# Smart look +APPSMITH_SMART_LOOK_ID= # Google OAuth APPSMITH_OAUTH2_GOOGLE_CLIENT_ID= diff --git a/app/client/docker/templates/nginx-linux.conf.template b/app/client/docker/templates/nginx-linux.conf.template index 210138a28f..b5e37d7935 100644 --- a/app/client/docker/templates/nginx-linux.conf.template +++ b/app/client/docker/templates/nginx-linux.conf.template @@ -18,8 +18,7 @@ server { location / { proxy_pass http://localhost:3000; sub_filter __APPSMITH_SENTRY_DSN__ '${APPSMITH_SENTRY_DSN}'; - sub_filter __APPSMITH_APPSMITH_HOTJAR_HJID__ '${APPSMITH_HOTJAR_HJID}'; - sub_filter __APPSMITH_HOTJAR_HJSV__ '${APPSMITH_HOTJAR_HJSV}'; + sub_filter __APPSMITH_SMART_LOOK_ID__ '${APPSMITH_SMART_LOOK_ID}'; sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}'; sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '${APPSMITH_OAUTH2_GITHUB_CLIENT_ID}'; sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '${APPSMITH_MARKETPLACE_ENABLED}'; @@ -86,8 +85,7 @@ server { location / { proxy_pass http://localhost:3000; sub_filter __APPSMITH_SENTRY_DSN__ '${APPSMITH_SENTRY_DSN}'; - sub_filter __APPSMITH_HOTJAR_HJID__ '${APPSMITH_HOTJAR_HJID}'; - sub_filter __APPSMITH_HOTJAR_HJSV__ '${APPSMITH_HOTJAR_HJSV}'; + sub_filter __APPSMITH_SMART_LOOK_ID__ '${APPSMITH_SMART_LOOK_ID}'; sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}'; sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '${APPSMITH_OAUTH2_GITHUB_CLIENT_ID}'; sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '${APPSMITH_MARKETPLACE_ENABLED}'; diff --git a/app/client/docker/templates/nginx-mac.conf.template b/app/client/docker/templates/nginx-mac.conf.template index 888d15c25a..aa348e5cbd 100644 --- a/app/client/docker/templates/nginx-mac.conf.template +++ b/app/client/docker/templates/nginx-mac.conf.template @@ -18,8 +18,7 @@ server { location / { proxy_pass http://host.docker.internal:3000; sub_filter __APPSMITH_SENTRY_DSN__ '${APPSMITH_SENTRY_DSN}'; - sub_filter __APPSMITH_HOTJAR_HJID__ '${APPSMITH_HOTJAR_HJID}'; - sub_filter __APPSMITH_HOTJAR_HJSV__ '${APPSMITH_HOTJAR_HJSV}'; + sub_filter __APPSMITH_SMART_LOOK_ID__ '${APPSMITH_SMART_LOOK_ID}'; sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}'; sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '${APPSMITH_OAUTH2_GITHUB_CLIENT_ID}'; sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '${APPSMITH_MARKETPLACE_ENABLED}'; @@ -87,8 +86,7 @@ server { location / { proxy_pass http://host.docker.internal:3000; sub_filter __APPSMITH_SENTRY_DSN__ '${APPSMITH_SENTRY_DSN}'; - sub_filter __APPSMITH_HOTJAR_HJID__ '${APPSMITH_HOTJAR_HJID}'; - sub_filter __APPSMITH_HOTJAR_HJSV__ '${APPSMITH_HOTJAR_HJSV}'; + sub_filter __APPSMITH_SMART_LOOK_ID__ '${APPSMITH_SMART_LOOK_ID}; sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}'; sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '${APPSMITH_OAUTH2_GITHUB_CLIENT_ID}'; sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '${APPSMITH_MARKETPLACE_ENABLED}'; diff --git a/app/client/netlify.toml b/app/client/netlify.toml index b075c55fea..12f43a8d4f 100644 --- a/app/client/netlify.toml +++ b/app/client/netlify.toml @@ -3,8 +3,6 @@ # REACT_APP_SENTRY_DSN= # REACT_APP_SENTRY_ENVIRONMENT= # REACT_APP_SENTRY_RELEASE= -# REACT_APP_HOTJAR_HJID= -# REACT_APP_HOTJAR_HJSV= # REACT_APP_OAUTH2_GOOGLE_CLIENT_ID= # REACT_APP_OAUTH2_GITHUB_CLIENT_ID= # REACT_APP_SEGMENT_KEY= @@ -76,4 +74,4 @@ [[redirects]] from = "/*" to = "/index.html" - status = 200 \ No newline at end of file + status = 200 diff --git a/app/client/package.json b/app/client/package.json index e17e64f269..df24c35d3e 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -104,6 +104,7 @@ "redux-saga": "^1.1.3", "reselect": "^4.0.0", "shallowequal": "^1.1.0", + "smartlook-client": "^4.5.1", "styled-components": "^4.1.3", "styled-system": "^5.1.5", "tern": "^0.21.0", @@ -198,4 +199,4 @@ "pre-commit": "lint-staged" } } -} \ No newline at end of file +} diff --git a/app/client/public/index.html b/app/client/public/index.html index 7a51cdaa5e..2a2ff74f62 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -20,7 +20,7 @@ // INTERCOM SETUP const APP_ID = "%REACT_APP_INTERCOM_APP_ID%" const CLOUD_HOSTING = "%REACT_APP_CLOUD_HOSTING%" - if (APP_ID.length && CLOUD_HOSTING.length) { + if (APP_ID.length && APP_ID[0] !== "%" && CLOUD_HOSTING.length) { (function () { var w = window; var ic = w.Intercom; if (typeof ic === "function") { ic('reattach_activator'); ic('update', w.intercomSettings); } else { var d = document; var i = function () { i.c(arguments); }; i.q = []; i.c = function (args) { i.q.push(args); }; w.Intercom = i; var l = function () { var s = d.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = 'https://widget.intercom.io/widget/' + APP_ID; var x = d.getElementsByTagName('script')[0]; x.parentNode.insertBefore(s, x); }; if (document.readyState === 'complete') { l(); } else if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); } } })(); } @@ -33,18 +33,6 @@ gtag('config', "%REACT_APP_GOOGLE_ANALYTICS_ID%"); - @@ -87,9 +75,8 @@ release: parseConfig("__APPSMITH_SENTRY_RELEASE__"), environment: parseConfig("__APPSMITH_SENTRY_ENVIRONMENT__"), }, - hotjar: { - id: parseConfig("__APPSMITH_HOTJAR_HJID__"), - sv: parseConfig("__APPSMITH_HOTJAR_HJSV__"), + smartLook: { + id: parseConfig("__APPSMITH_SMART_LOOK_ID__"), }, enableGoogleOAuth: parseConfig("__APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__").length > 0, enableGithubOAuth: parseConfig("__APPSMITH_OAUTH2_GITHUB_CLIENT_ID__").length > 0, diff --git a/app/client/src/configs/index.ts b/app/client/src/configs/index.ts index 56e6d1b02b..061b3b8478 100644 --- a/app/client/src/configs/index.ts +++ b/app/client/src/configs/index.ts @@ -5,9 +5,8 @@ type INJECTED_CONFIGS = { release: string; environment: string; }; - hotjar: { + smartLook: { id: string; - sv: string; }; enableGoogleOAuth: boolean; enableGithubOAuth: boolean; @@ -30,7 +29,6 @@ type INJECTED_CONFIGS = { }; intercomAppID: string; mailEnabled: boolean; - smartLookKey: string; }; declare global { interface Window { @@ -52,9 +50,8 @@ const getConfigsFromEnvVars = (): INJECTED_CONFIGS => { release: process.env.REACT_APP_SENTRY_RELEASE || "", environment: capitalizeText(process.env.NODE_ENV), }, - hotjar: { - id: process.env.REACT_APP_HOTJAR_HJID || "", - sv: process.env.REACT_APP_HOTJAR_HJSV || "", + smartLook: { + id: process.env.REACT_APP_SMART_LOOK_ID || "", }, enableGoogleOAuth: process.env.REACT_APP_OAUTH2_GOOGLE_CLIENT_ID ? process.env.REACT_APP_OAUTH2_GOOGLE_CLIENT_ID.length > 0 @@ -95,7 +92,6 @@ const getConfigsFromEnvVars = (): INJECTED_CONFIGS => { mailEnabled: process.env.REACT_APP_MAIL_ENABLED ? process.env.REACT_APP_MAIL_ENABLED.length > 0 : false, - smartLookKey: process.env.REACT_APP_SMART_LOOK_KEY || "", }; }; @@ -144,13 +140,9 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { // As the following shows, the config variables can be set using a combination // of env variables and injected configs - const hotjarId = getConfig( - ENV_CONFIG.hotjar.id, - APPSMITH_FEATURE_CONFIGS.hotjar.id, - ); - const hotjarSV = getConfig( - ENV_CONFIG.hotjar.sv, - APPSMITH_FEATURE_CONFIGS.hotjar.sv, + const smartLook = getConfig( + ENV_CONFIG.smartLook.id, + APPSMITH_FEATURE_CONFIGS.smartLook.id, ); const algoliaAPIID = getConfig( @@ -173,10 +165,9 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { release: sentryRelease.value, environment: sentryENV.value, }, - hotjar: { - enabled: hotjarId.enabled && hotjarSV.enabled, - id: hotjarId.value, - sv: hotjarSV.value, //parse as int? + smartLook: { + enabled: smartLook.enabled, + id: smartLook.value, }, segment: { enabled: segment.enabled, diff --git a/app/client/src/configs/types.ts b/app/client/src/configs/types.ts index fa6566bbed..e218d3ad99 100644 --- a/app/client/src/configs/types.ts +++ b/app/client/src/configs/types.ts @@ -5,11 +5,6 @@ export type SentryConfig = { environment: string; }; -export type HotjarConfig = { - id: string; - sv: string; -}; - type Milliseconds = number; export enum FeatureFlagsEnum {} @@ -30,10 +25,9 @@ export type AppsmithUIConfigs = { release: string; environment: string; }; - hotjar: { + smartLook: { enabled: boolean; id: string; - sv: string; }; segment: { enabled: boolean; diff --git a/app/client/src/utils/AnalyticsUtil.tsx b/app/client/src/utils/AnalyticsUtil.tsx index 83b9bb58f6..d0b8edbb2f 100644 --- a/app/client/src/utils/AnalyticsUtil.tsx +++ b/app/client/src/utils/AnalyticsUtil.tsx @@ -1,6 +1,8 @@ // Events import * as log from "loglevel"; import FeatureFlag from "./featureFlags"; +import smartlookClient from "smartlook-client"; +import { getAppsmithConfigs } from "configs"; export type EventName = | "LOGIN_CLICK" @@ -27,15 +29,12 @@ export type EventName = | "PREVIEW_APP" | "EDITOR_OPEN" | "CREATE_API" - | "IMPORT_API" - | "IMPORT_API_CLICK" | "SAVE_API" | "SAVE_API_CLICK" | "RUN_API" | "RUN_API_CLICK" | "DELETE_API" | "DELETE_API_CLICK" - | "DUPLICATE_API_CLICK" | "IMPORT_API" | "EXPAND_API" | "IMPORT_API_CLICK" @@ -85,20 +84,8 @@ function getApplicationId(location: Location) { class AnalyticsUtil { static user: any = undefined; - static initializeHotjar(id: string, sv: string) { - (function init(h: any, o: any, t: any, j: any, a?: any, r?: any) { - h.hj = - h.hj || - function() { - (h.hj.q = h.hj.q || []).push(arguments); //eslint-disable-line prefer-rest-params - }; - h._hjSettings = { hjid: id, hjsv: sv }; - a = o.getElementsByTagName("head")[0]; - r = o.createElement("script"); - r.async = 1; - r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv; - a.appendChild(r); - })(window, document, "//static.hotjar.com/c/hotjar-", ".js?sv="); + static initializeSmartLook(id: string) { + smartlookClient.init(id); } static initializeSegment(key: string) { @@ -199,15 +186,9 @@ class AnalyticsUtil { userId: userId, }); } - if (windowDoc.hj) { - windowDoc.hj("identify", userData.email, { email: userData.email }); - } - if (windowDoc.smartLook) { - windowDoc.smartlook("identify", userId, { - email: userData.email, - name: userData.name, - userId: userId, - }); + const { smartLook } = getAppsmithConfigs(); + if (smartLook.enabled) { + smartlookClient.identify(userData.email, { email: userData.email }); } } diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index cc710a8537..b74a983f4d 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -32,9 +32,9 @@ export const appInitializer = () => { if (appsmithConfigs.sentry.enabled) { Sentry.init(appsmithConfigs.sentry); } - if (appsmithConfigs.hotjar.enabled) { - const { id, sv } = appsmithConfigs.hotjar; - AnalyticsUtil.initializeHotjar(id, sv); + if (appsmithConfigs.smartLook.enabled) { + const { id } = appsmithConfigs.smartLook; + AnalyticsUtil.initializeSmartLook(id); } if (appsmithConfigs.segment.enabled) { AnalyticsUtil.initializeSegment(appsmithConfigs.segment.apiKey); diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 4a4247dcda..2407202f4b 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -15385,6 +15385,11 @@ slice-ansi@^2.1.0: astral-regex "^1.0.0" is-fullwidth-code-point "^2.0.0" +smartlook-client@^4.5.1: + version "4.5.1" + resolved "https://registry.yarnpkg.com/smartlook-client/-/smartlook-client-4.5.1.tgz#86884e19107fbd1ec284d96fb4273e209deb7cea" + integrity sha512-Y8zBr6rD9aE9/KockRlxNtAF4B+66CJzfPt8y27nrrkXqgC58lEqsWpTmy8opP5U2OprZHYI0Yh5LNKT7r4kRA== + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" diff --git a/deploy/template/nginx_app.conf.sh b/deploy/template/nginx_app.conf.sh index d98be8ce2c..78cca642a9 100644 --- a/deploy/template/nginx_app.conf.sh +++ b/deploy/template/nginx_app.conf.sh @@ -31,8 +31,7 @@ $NGINX_SSL_CMNT server_name $custom_domain ; try_files $uri /index.html =404; sub_filter __APPSMITH_SENTRY_DSN__ '\''${APPSMITH_SENTRY_DSN}'\''; - sub_filter __APPSMITH_APPSMITH_HOTJAR_HJID__ '\''${APPSMITH_HOTJAR_HJID}'\''; - sub_filter __APPSMITH_HOTJAR_HJSV__ '\''${APPSMITH_HOTJAR_HJSV}'\''; + sub_filter __APPSMITH_SMART_LOOK_ID__ '\''${APPSMITH_SMART_LOOK_ID}'\''; sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '\''${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}'\''; sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '\''${APPSMITH_OAUTH2_GITHUB_CLIENT_ID}'\''; sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '\''${APPSMITH_MARKETPLACE_ENABLED}'\''; @@ -87,8 +86,7 @@ $NGINX_SSL_CMNT location / { $NGINX_SSL_CMNT try_files $uri /index.html =404; $NGINX_SSL_CMNT $NGINX_SSL_CMNT sub_filter __APPSMITH_SENTRY_DSN__ '\''${APPSMITH_SENTRY_DSN}'\''; -$NGINX_SSL_CMNT sub_filter __APPSMITH_APPSMITH_HOTJAR_HJID__ '\''${APPSMITH_HOTJAR_HJID}'\''; -$NGINX_SSL_CMNT sub_filter __APPSMITH_HOTJAR_HJSV__ '\''${APPSMITH_HOTJAR_HJSV}'\''; +$NGINX_SSL_CMNT sub_filter __APPSMITH_SMART_LOOK_ID__ '\''${APPSMITH_SMART_LOOK_ID}'\''; $NGINX_SSL_CMNT sub_filter __APPSMITH_OAUTH2_GOOGLE_CLIENT_ID__ '\''${APPSMITH_OAUTH2_GOOGLE_CLIENT_ID}'\''; $NGINX_SSL_CMNT sub_filter __APPSMITH_OAUTH2_GITHUB_CLIENT_ID__ '\''${APPSMITH_OAUTH2_GITHUB_CLIENT_ID}'\''; $NGINX_SSL_CMNT sub_filter __APPSMITH_MARKETPLACE_ENABLED__ '\''${APPSMITH_MARKETPLACE_ENABLED}'\'';