Skip to content

Commit

Permalink
Update documentation to explain methods used to determine application…
Browse files Browse the repository at this point in the history
…s, generations and tiers.
  • Loading branch information
Colin Gourlay committed Jun 8, 2020
1 parent 102eede commit bce219a
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ console.log(GENERATIONS);
// }
console.log(TIERS);
// > {
// L: 'live',
// P: 'preview',
// LIVE: 'live',
// PREVIEW: 'preview',
// }
```

Note: _News Web Chromeless_ is technically the _News Web_ application, but renders articles without their Header/Nav/Footer in order to sit naturally in the ABC News app. We make a distinction in this library so that both environments can be handled separately.

### `getApplication(): string`
### `getApplication(): string | null`

Return the environment's **application** (Phase 1 Mobile; Phase 1 Standard; Phase 2; News Web; News Web Chromeless).
Return the environment's **application** (Phase 1 Mobile; Phase 1 Standard; Phase 2; News Web; News Web Chromeless) as a string value from the `APPLICATIONS` enum, or `null` if the application couldn't be determined.

```js
import { APPLICATIONS, getApplication } from '@abcnews/env-utils';
Expand All @@ -82,9 +82,11 @@ getApplication() === APPLICATIONS.NW;
// > true
```

### `getGeneration(): string`
Applications are currently determined by success/failure of selecting DOM nodes in the document, which hint at the technology used to render them on the server.

Return the environment's **generation** (Phase 1; Phase 2; Presentation Layer).
### `getGeneration(): string | null`

Return the environment's **generation** (Phase 1; Phase 2; Presentation Layer) as a string value from the `GENERATIONS` enum, or `null` if the generation couldn't be determined.

```js
import { GENERATIONS, getGeneration } from '@abcnews/env-utils';
Expand All @@ -96,20 +98,24 @@ getGeneration() === GENERATIONS.PL;
// > true
```

### `getTier(): string`
Generations are currently determined by categorising detected applications.

### `getTier(): string | null`

Return the environment's **tier** (Live; Preview).
Return the environment's **tier** (Live; Preview) as a string value from the `TIERS` enum, or `null` if the tier couldn't be determined.

```js
import { TIERS, getTier } from '@abcnews/env-utils';

getTier();
// > 'preview'

getTier() === TIERS.P;
getTier() === TIERS.PREVIEW;
// > true
```

Tiers are currently determined by comparing `window.location.hostname` to domains that tiers are potentially served from.

### `requestDOMPermit(key: string, onRevokeHandler?: Function): Promise`

Request a permit to modify the DOM.
Expand Down

0 comments on commit bce219a

Please sign in to comment.