Skip to content

Commit 3c55b3a

Browse files
committed
lmendoza/onetrust2
1 parent 27ff09d commit 3c55b3a

12 files changed

+54
-5
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ cypress/plugins/token.json
7777

7878
# Packages ignore package-lock to depend only on yarn
7979
package-lock.json
80-
src/assets/runtime-environment.js
80+
scripts/environment.runtime.js

angular.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@
133133
"src/styles.scss",
134134
"src/assets/scss/grid.scss"
135135
],
136-
"scripts": ["src/assets/runtime-environment.js"]
136+
"scripts": [
137+
"/scripts/environment.runtime.js",
138+
"/scripts/onetrust.runtime.js"
139+
]
137140
},
138141
"configurations": {
139142
"local": {
@@ -370,7 +373,10 @@
370373
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
371374
"src/styles.scss"
372375
],
373-
"scripts": ["src/assets/runtime-environment.js"],
376+
"scripts": [
377+
"/scripts/environment.runtime.js",
378+
"/scripts/onetrust.runtime.js"
379+
],
374380
"assets": ["src/favicon.ico", "src/assets", "src/manifest.json"],
375381
"sourceMap": true
376382
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"start:xx": "ng serve --configuration=local-qa-xx --disable-host-check",
1212
"test": "npm run build-runtime-env && ng test",
1313
"test-headless": "npm run build-runtime-env && ng test --watch=false --browsers=ChromeHeadless",
14-
"build-runtime-env": "ts-node -P scripts/tsconfig.json scripts/runtime-environment-setter.dev-runtime.ts",
14+
"build-runtime-env": "ts-node -P scripts/tsconfig.json scripts/environment.prebuild.ts",
1515
"lint": "echo 'temporally disable Angular linter to until eslint update'",
1616
"e2e": "ng e2e",
1717
"prebuild": "rimraf dist && yarn build:i18n && yarn build:browserslist && npm run build-runtime-env",

scripts/runtime-environment-setter.dev-runtime.ts renamed to scripts/environment.prebuild.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ${runtimeEnvironmentScript()}`
1010

1111
const outputPath = path.resolve(
1212
__dirname,
13-
'../src/assets/runtime-environment.js'
13+
'../scripts/environment.runtime.js'
1414
)
1515

1616
fs.writeFileSync(outputPath, scriptContent, { encoding: 'utf8' })

scripts/onetrust.runtime.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
;(function waitForRuntimeEnvironment() {
2+
// Check if the runtime environment is available.
3+
if (window.runtimeEnvironment) {
4+
console.log('The runtime environment is available.')
5+
console.log(JSON.stringify(window.runtimeEnvironment))
6+
if (window.runtimeEnvironment.ONE_TRUST) {
7+
// Retrieve your key-value (assuming it's a string).
8+
var keyValue = window.runtimeEnvironment.ONE_TRUST
9+
10+
// Create the first script tag.
11+
var script1 = document.createElement('script')
12+
script1.type = 'text/javascript'
13+
script1.src =
14+
'https://cdn.cookielaw.org/consent/' + keyValue + '/OtAutoBlock.js'
15+
document.head.appendChild(script1)
16+
17+
// Create the second script tag.
18+
var script2 = document.createElement('script')
19+
script2.type = 'text/javascript'
20+
script2.src = 'https://cdn.cookielaw.org/scripttemplates/otSDKStub.js'
21+
script2.charset = 'UTF-8'
22+
// Set data attributes as needed.
23+
script2.setAttribute('data-document-language', 'true')
24+
script2.setAttribute('data-domain-script', keyValue)
25+
document.head.appendChild(script2)
26+
console.log('OneTrust has been added.')
27+
} else {
28+
console.log('The runtime environment does not contain the OneTrust key.')
29+
}
30+
} else {
31+
console.log('The runtime environment is not yet available.')
32+
console.log('Checking again in 50ms...')
33+
// If runtimeEnvironment is not yet available, check again in 50ms.
34+
setTimeout(waitForRuntimeEnvironment, 50)
35+
}
36+
})()

src/environments/environment.int.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const environment: EnvironmentInterface = {
1919
VERBOSE_SNACKBAR_ERRORS_REPORTS: true,
2020
WORDPRESS_S3: 'https://homepage-prod.orcid.org',
2121
WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org',
22+
ONE_TRUST: "5a6d60d3-b085-4e48-8afa-d707c7afc419-test",
2223
LANGUAGE_MENU_OPTIONS: {
2324
ar: 'العربية',
2425
cs: 'Čeština',

src/environments/environment.local.4200.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const environment: EnvironmentInterface = {
2020
VERBOSE_SNACKBAR_ERRORS_REPORTS: true,
2121
WORDPRESS_S3: 'https://homepage-qa.orcid.org',
2222
WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org',
23+
ONE_TRUST: "5a6d60d3-b085-4e48-8afa-d707c7afc419-test",
2324
NEW_RELIC_APP: '772335827',
2425
LANGUAGE_MENU_OPTIONS: {
2526
ar: 'العربية',

src/environments/environment.local.dev.orcid.org.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const environment: EnvironmentInterface = {
2020
VERBOSE_SNACKBAR_ERRORS_REPORTS: true,
2121
WORDPRESS_S3: 'https://homepage-qa.orcid.org',
2222
WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org',
23+
ONE_TRUST: "5a6d60d3-b085-4e48-8afa-d707c7afc419-test",
2324
NEW_RELIC_APP: '772335827',
2425
LANGUAGE_MENU_OPTIONS: {
2526
ar: 'العربية',

src/environments/environment.production.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const environment: EnvironmentInterface = {
2020
WORDPRESS_S3: 'https://homepage-prod.orcid.org',
2121
WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org',
2222
NEW_RELIC_APP: '772335825',
23+
ONE_TRUST: "5a6d60d3-b085-4e48-8afa-d707c7afc419",
2324
LANGUAGE_MENU_OPTIONS: {
2425
ar: 'العربية',
2526
cs: 'Čeština',

src/environments/environment.qa.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const environment: EnvironmentInterface = {
2020
VERBOSE_SNACKBAR_ERRORS_REPORTS: true,
2121
WORDPRESS_S3: 'https://homepage-qa.orcid.org',
2222
WORDPRESS_S3_FALLBACK: 'https://homepage-fallback.orcid.org',
23+
ONE_TRUST: "5a6d60d3-b085-4e48-8afa-d707c7afc419-test",
2324
NEW_RELIC_APP: '772335827',
2425
LANGUAGE_MENU_OPTIONS: {
2526
ar: 'العربية',

0 commit comments

Comments
 (0)