From a4e8b0d5db56030cc3c01c2c201c5466dcf2afb2 Mon Sep 17 00:00:00 2001 From: Abhinav Jha Date: Thu, 13 Aug 2020 10:16:06 +0530 Subject: [PATCH 1/5] Add sentry release and environment configurations (#277) * Add sentry release and environment configurations * Fixing nginx config issue Co-authored-by: Satbir Singh --- .../templates/nginx-linux.conf.template | 4 ++ .../docker/templates/nginx-mac.conf.template | 4 ++ app/client/public/index.html | 6 ++- app/client/src/configs/index.ts | 39 +++++++++++++++++-- app/client/src/configs/types.ts | 4 +- app/client/src/utils/AppsmithUtils.tsx | 2 +- 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/app/client/docker/templates/nginx-linux.conf.template b/app/client/docker/templates/nginx-linux.conf.template index ad70d138c3..7142c4355e 100644 --- a/app/client/docker/templates/nginx-linux.conf.template +++ b/app/client/docker/templates/nginx-linux.conf.template @@ -31,6 +31,8 @@ server { sub_filter __APPSMITH_CLIENT_LOG_LEVEL__ '${APPSMITH_CLIENT_LOG_LEVEL}'; sub_filter __APPSMITH_GOOGLE_MAPS_API_KEY__ '${APPSMITH_GOOGLE_MAPS_API_KEY}'; sub_filter __APPSMITH_TNC_PP__ '${APPSMITH_TNC_PP}'; + sub_filter __APPSMITH_SENTRY_RELEASE__ '${APPSMITH_SENTRY_RELEASE}'; + sub_filter __APPSMITH_SENTRY_ENVIRONMENT__ '${APPSMITH_SENTRY_ENVIRONMENT}'; } location /f { @@ -93,6 +95,8 @@ server { sub_filter __APPSMITH_CLIENT_LOG_LEVEL__ '${APPSMITH_CLIENT_LOG_LEVEL}'; sub_filter __APPSMITH_GOOGLE_MAPS_API_KEY__ '${APPSMITH_GOOGLE_MAPS_API_KEY}'; sub_filter __APPSMITH_TNC_PP__ '${APPSMITH_TNC_PP}'; + sub_filter __APPSMITH_SENTRY_RELEASE__ '${APPSMITH_SENTRY_RELEASE}'; + sub_filter __APPSMITH_SENTRY_ENVIRONMENT__ '${APPSMITH_SENTRY_ENVIRONMENT}'; } location /f { diff --git a/app/client/docker/templates/nginx-mac.conf.template b/app/client/docker/templates/nginx-mac.conf.template index bbef205cd5..39ec75fd7b 100644 --- a/app/client/docker/templates/nginx-mac.conf.template +++ b/app/client/docker/templates/nginx-mac.conf.template @@ -31,6 +31,8 @@ server { sub_filter __APPSMITH_CLIENT_LOG_LEVEL__ '${APPSMITH_CLIENT_LOG_LEVEL}'; sub_filter __APPSMITH_GOOGLE_MAPS_API_KEY__ '${APPSMITH_GOOGLE_MAPS_API_KEY}'; sub_filter __APPSMITH_TNC_PP__ '${APPSMITH_TNC_PP}'; + sub_filter __APPSMITH_SENTRY_RELEASE__ '${APPSMITH_SENTRY_RELEASE}'; + sub_filter __APPSMITH_SENTRY_ENVIRONMENT__ '${APPSMITH_SENTRY_ENVIRONMENT}'; } location /f { @@ -94,6 +96,8 @@ server { sub_filter __APPSMITH_CLIENT_LOG_LEVEL__ '${APPSMITH_CLIENT_LOG_LEVEL}'; sub_filter __APPSMITH_GOOGLE_MAPS_API_KEY__ '${APPSMITH_GOOGLE_MAPS_API_KEY}'; sub_filter __APPSMITH_TNC_PP__ '${APPSMITH_TNC_PP}'; + sub_filter __APPSMITH_SENTRY_RELEASE__ '${APPSMITH_SENTRY_RELEASE}'; + sub_filter __APPSMITH_SENTRY_ENVIRONMENT__ '${APPSMITH_SENTRY_ENVIRONMENT}'; } diff --git a/app/client/public/index.html b/app/client/public/index.html index c24a1fd079..1df3d5fcc9 100755 --- a/app/client/public/index.html +++ b/app/client/public/index.html @@ -53,7 +53,11 @@ const CONFIG_LOG_LEVEL_INDEX = LOG_LEVELS.indexOf(parseConfig("__APPSMITH_CLIENT_LOG_LEVEL__")); window.SENTRY_CONFIG = parseConfig("__APPSMITH_SENTRY_DSN__"); window.APPSMITH_FEATURE_CONFIGS = { - sentry: parseConfig("__APPSMITH_SENTRY_DSN__"), + sentry: { + dsn: parseConfig("__APPSMITH_SENTRY_DSN__"), + release: parseConfig("__APPSMITH_SENTRY_RELEASE__"), + environment: parseConfig("__APPSMITH_SENTRY_ENVIRONMENT__"), + }, hotjar: { id: parseConfig("__APPSMITH_HOTJAR_HJID__"), sv: parseConfig("__APPSMITH_HOTJAR_HJSV__"), diff --git a/app/client/src/configs/index.ts b/app/client/src/configs/index.ts index 1ad9d0ba7a..24ba7f7a3a 100644 --- a/app/client/src/configs/index.ts +++ b/app/client/src/configs/index.ts @@ -1,6 +1,10 @@ import { AppsmithUIConfigs, FeatureFlagConfig } from "./types"; type INJECTED_CONFIGS = { - sentry: string; + sentry: { + dsn: string; + release: string; + environment: string; + }; hotjar: { id: string; sv: string; @@ -27,9 +31,19 @@ declare global { } } +const capitalizeText = (text: string) => { + const rest = text.slice(1); + const first = text[0].toUpperCase(); + return `${first}${rest}`; +}; + const getConfigsFromEnvVars = (): INJECTED_CONFIGS => { return { - sentry: process.env.REACT_APP_SENTRY_DSN || "", + sentry: { + dsn: process.env.REACT_APP_SENTRY_DSN || "", + 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 || "", @@ -92,7 +106,19 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { return; }; - const sentry = getConfig(ENV_CONFIG.sentry, APPSMITH_FEATURE_CONFIGS.sentry); + // const sentry = getConfig(ENV_CONFIG.sentry, APPSMITH_FEATURE_CONFIGS.sentry); + const sentryDSN = getConfig( + ENV_CONFIG.sentry.dsn, + APPSMITH_FEATURE_CONFIGS.sentry.dsn, + ); + const sentryRelease = getConfig( + ENV_CONFIG.sentry.release, + APPSMITH_FEATURE_CONFIGS.sentry.release, + ); + const sentryENV = getConfig( + APPSMITH_FEATURE_CONFIGS.sentry.environment, + ENV_CONFIG.sentry.environment, + ); const segment = getConfig( ENV_CONFIG.segment, APPSMITH_FEATURE_CONFIGS.segment, @@ -124,7 +150,12 @@ export const getAppsmithConfigs = (): AppsmithUIConfigs => { ); return { - sentry: { enabled: sentry.enabled, apiKey: sentry.value }, + sentry: { + enabled: sentryDSN.enabled && sentryRelease.enabled && sentryENV.enabled, + dsn: sentryDSN.value, + release: sentryRelease.value, + environment: sentryENV.value, + }, hotjar: { enabled: hotjarId.enabled && hotjarSV.enabled, id: hotjarId.value, diff --git a/app/client/src/configs/types.ts b/app/client/src/configs/types.ts index 03e62bef6a..7fbd8178c3 100644 --- a/app/client/src/configs/types.ts +++ b/app/client/src/configs/types.ts @@ -26,7 +26,9 @@ export type FeatureFlagConfig = { export type AppsmithUIConfigs = { sentry: { enabled: boolean; - apiKey: string; + dsn: string; + release: string; + environment: string; }; hotjar: { enabled: boolean; diff --git a/app/client/src/utils/AppsmithUtils.tsx b/app/client/src/utils/AppsmithUtils.tsx index 0e1199435c..643a4611b4 100644 --- a/app/client/src/utils/AppsmithUtils.tsx +++ b/app/client/src/utils/AppsmithUtils.tsx @@ -31,7 +31,7 @@ export const appInitializer = () => { FeatureFlag.initialize(appsmithConfigs.featureFlag); if (appsmithConfigs.sentry.enabled) { - Sentry.init({ dsn: appsmithConfigs.sentry.apiKey }); + Sentry.init(appsmithConfigs.sentry); } if (appsmithConfigs.hotjar.enabled) { const { id, sv } = appsmithConfigs.hotjar; From 550a370f5753ee14fb9c1b9aa87cba3e5408643e Mon Sep 17 00:00:00 2001 From: satbir121 <39981226+satbir121@users.noreply.github.com> Date: Thu, 13 Aug 2020 22:07:15 +0530 Subject: [PATCH 2/5] Adding base64 library to realm executor (#304) * Adding base64 library to realm executor * Changing base64 interface to btoa and atob * Making base64 a dependancy --- app/client/package.json | 1 + .../jsExecution/JSExecutionManagerSingleton.ts | 9 +++++++++ app/client/yarn.lock | 15 +++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/app/client/package.json b/app/client/package.json index bd589e3bdc..149eae99f9 100644 --- a/app/client/package.json +++ b/app/client/package.json @@ -60,6 +60,7 @@ "instantsearch.js": "^4.4.1", "interweave": "^12.1.1", "interweave-autolink": "^4.0.1", + "js-base64": "^3.4.5", "json-fn": "^1.1.1", "lint-staged": "^9.2.5", "localforage": "^1.7.3", diff --git a/app/client/src/jsExecution/JSExecutionManagerSingleton.ts b/app/client/src/jsExecution/JSExecutionManagerSingleton.ts index df0240c910..f10d0d2f8c 100644 --- a/app/client/src/jsExecution/JSExecutionManagerSingleton.ts +++ b/app/client/src/jsExecution/JSExecutionManagerSingleton.ts @@ -1,6 +1,7 @@ import RealmExecutor from "./RealmExecutor"; import moment from "moment-timezone"; import { ActionDescription } from "entities/DataTree/dataTreeFactory"; +import { btoa, atob } from "js-base64"; export type JSExecutorGlobal = Record; export type JSExecutorResult = { @@ -30,6 +31,14 @@ export const extraLibraries = [ accessor: "moment", lib: moment, }, + { + accessor: "btoa", + lib: btoa, + }, + { + accessor: "atob", + lib: atob, + }, ]; class JSExecutionManager { diff --git a/app/client/yarn.lock b/app/client/yarn.lock index 781ea92f0e..79e6c13028 100644 --- a/app/client/yarn.lock +++ b/app/client/yarn.lock @@ -7322,6 +7322,21 @@ js-base64@^2.1.8: version "2.5.1" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.1.tgz#1efa39ef2c5f7980bb1784ade4a8af2de3291121" +js-base64@^3.4.5: + version "3.4.5" + resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.4.5.tgz#6d1921e65a172cfd924604e1416dfaff45752c3e" + integrity sha512-Ub/AANierdcT8nm4ndBn3KzpZQ3MdHX4a+bwoVdjgeHCZ0ZEcP+UB4nmR4Z5lR6SH3Y+qAPmgVR0RxKJNHNHEg== + +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" + integrity sha1-4mJbrbwNZ8dTPp7cEGjFh65BN+8= + +js-stringify@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/js-stringify/-/js-stringify-1.0.2.tgz#1736fddfd9724f28a3682adc6230ae7e4e9679db" + integrity sha1-Fzb939lyTyijaCrcYjCufk6Weds= + "js-tokens@^3.0.0 || ^4.0.0", js-tokens@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" From e1f1e6292d8402244dc17d5c8321c6e70a0ac505 Mon Sep 17 00:00:00 2001 From: Hetu Nandu Date: Mon, 17 Aug 2020 10:33:15 +0530 Subject: [PATCH 3/5] Fixes date widget crashing when no date format is mentioned (#322) Fixed by using a proper default format string for ISO dates --- app/client/src/constants/WidgetValidation.ts | 2 ++ app/client/src/utils/Validators.ts | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/client/src/constants/WidgetValidation.ts b/app/client/src/constants/WidgetValidation.ts index 9741656714..556c0e6fe3 100644 --- a/app/client/src/constants/WidgetValidation.ts +++ b/app/client/src/constants/WidgetValidation.ts @@ -33,3 +33,5 @@ export type Validator = ( props: WidgetProps, dataTree?: DataTree, ) => ValidationResponse; + +export const ISO_DATE_FORMAT = "YYYY-MM-DDTHH:mm:ss.SSSZ"; diff --git a/app/client/src/utils/Validators.ts b/app/client/src/utils/Validators.ts index 449f23e8f1..7be2897b03 100644 --- a/app/client/src/utils/Validators.ts +++ b/app/client/src/utils/Validators.ts @@ -1,5 +1,6 @@ import _ from "lodash"; import { + ISO_DATE_FORMAT, VALIDATION_TYPES, ValidationResponse, ValidationType, @@ -392,8 +393,8 @@ export const VALIDATORS: Record = { .minute(0) .second(0) .millisecond(0); - const dateFormat = props.dateFormat ? props.dateFormat : moment.ISO_8601; - // const dateStr = moment().toISOString(); + const dateFormat = props.dateFormat ? props.dateFormat : ISO_DATE_FORMAT; + const todayDateString = today.format(dateFormat); if (dateString === undefined) { return { From 4de99e1bed92d865858d1580bf0409ffd0dfad47 Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Fri, 28 Aug 2020 20:04:00 +0530 Subject: [PATCH 4/5] minor fix --- app/client/craco.build.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/client/craco.build.config.js b/app/client/craco.build.config.js index cc57165f69..2ca83fa0f2 100644 --- a/app/client/craco.build.config.js +++ b/app/client/craco.build.config.js @@ -18,7 +18,7 @@ if (env === "PRODUCTION" || env === "STAGING") { auto: true }, deploy: { - env: REACT_APP_SENTRY_ENVIRONMENT + env: process.env.REACT_APP_SENTRY_ENVIRONMENT } }), ); From 0699e63846ec5c4cd6b9bb334f9c645ba34e02cc Mon Sep 17 00:00:00 2001 From: Nikhil Nandagopal Date: Thu, 10 Sep 2020 17:15:24 +0530 Subject: [PATCH 5/5] Update netlify.toml --- app/client/netlify.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/client/netlify.toml b/app/client/netlify.toml index a8dd51af32..d90d1e5924 100644 --- a/app/client/netlify.toml +++ b/app/client/netlify.toml @@ -15,7 +15,6 @@ REACT_APP_SENTRY_DSN = "https://abf15a075d1347969df44c746cca7eaa@o296332.ingest.sentry.io/1546547" REACT_APP_SENTRY_ENVIRONMENT = "Production" SENTRY_AUTH_TOKEN = "dfdf7fa46c5b483a944b4571554d6466da3c64a6ed8b46e3b8a4285183a6bcc3" - SENTRY_URL = "https://sentry.io" SENTRY_DSN = "https://abf15a075d1347969df44c746cca7eaa@o296332.ingest.sentry.io/1546547" SENTRY_ORG = "appsmith" SENTRY_PROJECT = "appsmith"