Skip to content

Commit

Permalink
feat(build, helpers): issues/52 debug config params (#69)
Browse files Browse the repository at this point in the history
* build, dotenv logger id
* helpers, debugging access to dotenv config params, via window
* contributing md updated to explain debugging use
  • Loading branch information
cdcabrera committed Aug 2, 2019
1 parent fdd3b06 commit 2760ab2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
1 change: 1 addition & 0 deletions src/common/__tests__/__snapshots__/helpers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 8 additions & 3 deletions src/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 };

0 comments on commit 2760ab2

Please sign in to comment.