Skip to content

Commit

Permalink
Add env variable as a fallback to config urls
Browse files Browse the repository at this point in the history
  • Loading branch information
dgcohen committed Jan 9, 2024
1 parent 4e1e249 commit b8e0f55
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion ENVIRONMENTVARS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ If an environment variable is updated, make sure to restart the server for the a
These environment variables control how certain elements on the page render and where to fetch data.

| Variable | Type | Value Example | Description |
| ---------------------------------------- | ------ | ------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|------------------------------------------|--------|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `NYPL_HEADER_URL` | string | "https://ds-header.nypl.org" | The base URL of the NYPL environment-specific header and footer scripts. |
| `NEXT_PUBLIC_CLOSED_LOCATIONS` | string | "all;Library of the Performing Arts" | A semicolon-delimited list of strings. Include quotes around the string. All locations beginning with any string in this list will be removed from the list of request options in the `ElectronicDelivery`, `HoldRequest`, and `ItemTableRow` components. Currently used physical locations: `Schwarzman;Science;Library for the Performing Arts;Schomburg`. To close all locations, add `all`. This will also remove EDD as a request option, the 'Request' buttons, and also disable the hold request/edd forms. If `all` is not present, EDD and 'Request' buttons will still be available. |
| `NEXT_PUBLIC_RECAP_CLOSED_LOCATIONS` | string | "" | A semicolon-delimited list of closed locations that are recap. |
| `NEXT_PUBLIC_NON_RECAP_CLOSED_LOCATIONS` | string | "" | A semicolon-delimited list of closed locations that are not recap. |
| `ADOBE_EMBED_URL` | string | "" | Url endpoint used for Adobe Analytics event tracking. |

## AWS ECS Environment Variables

Expand Down
4 changes: 3 additions & 1 deletion pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Html, Head, Main, NextScript } from "next/document"
import { appConfig } from "../src/config/config"

export default function Document() {
return (
Expand All @@ -17,14 +18,15 @@ export default function Document() {
</style>
<Head>
<meta name="description" content="Research Catalog | NYPL" />
<script async src={process.env.ADOBE_EMBED_URL} />
<script async src={appConfig.adobeEmbedUrl[appConfig.environment]} />
<script
dangerouslySetInnerHTML={{
__html: `
// First define the global variable for the entire data layer array
window.adobeDataLayer = window.adobeDataLayer || [];
// Then push in the variables required in the Initial Data Layer Definition
window.adobeDataLayer.push({disable_page_view: true});
${appConfig.environment}
`,
}}
/>
Expand Down
8 changes: 8 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,12 @@ export const appConfig = {
nonRecapClosedLocations: parseLocations(
process.env.NEXT_PUBLIC_NON_RECAP_CLOSED_LOCATIONS
),
adobeEmbedUrl: {
development:
process.env.ADOBE_EMBED_URL ||
"https://assets.adobedtm.com/1a9376472d37/ddf1bedfe52e/launch-4eefcc91c90e.min.js",
production:
process.env.ADOBE_EMBED_URL ||
"https://assets.adobedtm.com/1a9376472d37/8519dfce636d/launch-672b7e7f98ee.min.js",
},
}

0 comments on commit b8e0f55

Please sign in to comment.