From 2760ab23a67e092c1045b8a047de530b8c060f2d Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Fri, 2 Aug 2019 12:11:37 -0400 Subject: [PATCH] feat(build, helpers): issues/52 debug config params (#69) * build, dotenv logger id * helpers, debugging access to dotenv config params, via window * contributing md updated to explain debugging use --- .env | 2 ++ CONTRIBUTING.md | 17 +++++++++++++++++ .../__snapshots__/helpers.test.js.snap | 1 + src/common/helpers.js | 11 ++++++++--- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/.env b/.env index 002de7967..7ee155511 100644 --- a/.env +++ b/.env @@ -4,6 +4,8 @@ REACT_APP_UI_DISPLAY_NAME=Subscription Reporting REACT_APP_UI_DEPLOY_PATH_PREFIX=${UI_DEPLOY_PATH_PREFIX} PUBLIC_URL=${UI_DEPLOY_PATH_PREFIX}/apps/subscription-reporting/ +REACT_APP_UI_LOGGER_ID=curiosity + REACT_APP_AJAX_TIMEOUT=60000 REACT_APP_CONFIG_SERVICE_LOCALES_COOKIE=rh_locale diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d9f433351..beef21ecb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,6 +65,23 @@ can be found in [.codecov.yml](./.codecov.yml). ### Debugging and Testing +#### Debugging in environments +You can access basic dotenv config values via a global window object unique to the application. You'll need to access the GUI through a browser, open the development console and type + ``` + curiosity + ``` + or + ``` + window.curiosity + ``` + +This should expose a quick grouping of string values (along with a few superfluous helper functions) enabling you to identify things such as the `release version`. + +The name of the window value can be found under the dotenv file `.env` + ``` + REACT_APP_UI_LOGGER_ID=curiosity + ``` + #### Debugging the Graph Display You can apply a date override during local development by adding a `.env.local` (dotenv) file with the following line, in the repository root directory ``` diff --git a/src/common/__tests__/__snapshots__/helpers.test.js.snap b/src/common/__tests__/__snapshots__/helpers.test.js.snap index 9b79d2921..e0e4047a6 100644 --- a/src/common/__tests__/__snapshots__/helpers.test.js.snap +++ b/src/common/__tests__/__snapshots__/helpers.test.js.snap @@ -8,6 +8,7 @@ Object { "TEST_MODE": true, "UI_DEPLOY_PATH_PREFIX": "", "UI_DISPLAY_NAME": "Subscription Reporting", + "UI_LOGGER_ID": "curiosity", "UI_NAME": "subscription-reporting", "UI_PATH": "/apps/subscription-reporting/", "UI_VERSION": "0.0.0.0000000", diff --git a/src/common/helpers.js b/src/common/helpers.js index 8f4a5b613..fd6c6f317 100644 --- a/src/common/helpers.js +++ b/src/common/helpers.js @@ -33,12 +33,14 @@ const REVIEW_MODE = process.env.REACT_APP_ENV === 'review'; const TEST_MODE = process.env.REACT_APP_ENV === 'test'; -const UI_NAME = process.env.REACT_APP_UI_NAME; - const UI_DEPLOY_PATH_PREFIX = process.env.REACT_APP_UI_DEPLOY_PATH_PREFIX; const UI_DISPLAY_NAME = process.env.REACT_APP_UI_DISPLAY_NAME; +const UI_LOGGER_ID = process.env.REACT_APP_UI_LOGGER_ID || 'GUI'; + +const UI_NAME = process.env.REACT_APP_UI_NAME; + const UI_PATH = process.env.PUBLIC_URL || '/'; const UI_VERSION = process.env.REACT_APP_UI_VERSION; @@ -53,11 +55,14 @@ const helpers = { PROD_MODE, REVIEW_MODE, TEST_MODE, - UI_NAME, UI_DEPLOY_PATH_PREFIX, UI_DISPLAY_NAME, + UI_LOGGER_ID, + UI_NAME, UI_PATH, UI_VERSION }; +window[UI_LOGGER_ID] = { ...helpers }; + export { helpers as default, helpers };