Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UHF-11039: Updated hds cookie consent to use 4.0.0 version #857

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/hdbt_cookie_banner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ Settings can be overridden by selecting the `Use instance specific cookie settin

#### The cookie banner doesn’t appear, and the "Content cannot be displayed" message is shown on each YouTube, Map, or Chart paragraph.
Check the browser console for a message such as `The hds-cookie-consent.min.js script is not loaded. Check the HDBT cookie banner configurations.`. If this message appears, it means the HDS cookie consent JavaScript file is not loaded. Verify that the Hel.fi Etusivu instance is up and running. If your site uses custom cookie settings, check the configurations at `/admin/structure/hdbt-cookie-banner`.

## hds-cookie-consent.min.js changes
In the 4.0.0 version change the theme--dark stopped working. The style string in the current min.js file has been replaced by the older version string in order to keep the theme styles working. Style string can be found from this variable in the file `const o=document.createElement("style");o.textContent="..."`.
12 changes: 6 additions & 6 deletions modules/hdbt_cookie_banner/assets/js/hdbt-cookie-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
loadFunction: (loadFunction) => {
if (typeof loadFunction === 'function') {
document.addEventListener('hds_cookieConsent_ready', loadFunction);
window.addEventListener('hds-cookie-consent-ready', loadFunction);
}
},
getConsentStatus: (categories) => {
Expand Down Expand Up @@ -67,12 +67,12 @@
window.addEventListener(
'hds-cookie-consent-unapproved-item-found',
(e) => {
const { type, keys, consentedGroups } = e.detail
const { storageType, keys, acceptedGroups } = e.detail

if (window.Sentry) {
// Sentry requires a unique name for each error in order to record
// each found unapproved item per type.
const name = `Unapproved ${type}`
const name = `Unapproved ${storageType}`
const message = `Found: ${keys.join(', ')}`

class UnapprovedItemError extends Error {
Expand All @@ -87,12 +87,12 @@
window.Sentry.captureException(new UnapprovedItemError(message), {
level: 'warning',
tags: {
approvedCategories: consentedGroups.join(', '),
approvedCategories: acceptedGroups.join(', '),
},
extra: {
type,
storageType,
cookieNames: keys,
approvedCategories: consentedGroups,
approvedCategories: acceptedGroups,
},
})
} else {
Expand Down

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions modules/hdbt_cookie_banner/assets/json/siteSettings.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@
}
]
},
"type": {
"storageType": {
"type": "integer",
"title": "Type",
"title": "Storage type",
"description": "Type of the stored item, shown to the user and used in code.",
"default": 1,
"enum": [
Expand Down Expand Up @@ -121,7 +121,7 @@
"host",
"description",
"expiration",
"type"
"storageType"
]
},
"Group": {
Expand Down Expand Up @@ -340,9 +340,9 @@
"description": "Machine name for the cookie, used only in code",
"minLength": 1
},
"type": {
"storageType": {
"type": "integer",
"title": "Type",
"title": "Storage type",
"description": "Type of the stored item",
"enum": [
1,
Expand All @@ -365,14 +365,14 @@
"title": "Robot cookie or item",
"required": [
"name",
"type"
"storageType"
],
"description": "(Not visible to end user)"
},
"default": [
{
"name": "exampleCookieName",
"type": 1
"storageType": 1
}
]
},
Expand Down Expand Up @@ -423,17 +423,17 @@
},
"heading": {
"title": "Banner heading",
"description": "Banner heading supports ${siteName} token, it's replaced with the value from siteName setting",
"description": "Banner heading supports {{siteName}} token, it's replaced with the value from siteName setting",
"options": {
"disable_collapse": true
},
"allOf": [
{ "$ref": "#/$defs/LocalisedUniversalText" },
{
"default": {
"fi": "${siteName} käyttää evästeitä",
"sv": "${siteName} använder kakor",
"en": "${siteName} uses cookies"
"fi": "{{siteName}} käyttää evästeitä",
"sv": "{{siteName}} använder kakor",
"en": "{{siteName}} uses cookies"
}
}
]
Expand Down Expand Up @@ -486,7 +486,7 @@
}
]
},
"form_heading": {
"formHeading": {
"title": "Form heading",
"description": "Visible when details are opened",
"options": {
Expand All @@ -503,7 +503,7 @@
}
]
},
"form_text": {
"formText": {
"title": "Form text",
"description": "Visible when details are opened",
"options": {
Expand Down Expand Up @@ -547,9 +547,9 @@
{ "$ref": "#/$defs/LocalisedUniversalText" },
{
"default": {
"fi": "Hyvä tietää kategorialle: ${title}",
"sv": "Bra att veta för kategorin: ${title}",
"en": "Good to know for category: ${title}"
"fi": "Hyvä tietää kategorialle: {{title}}",
"sv": "Bra att veta för kategorin: {{title}}",
"en": "Good to know for category: {{title}}"
}
}
]
Expand Down Expand Up @@ -588,17 +588,17 @@
},
"acceptedAt": {
"title": "Accepted at",
"description": "Formats the ${date} and ${time} (in Finnish datetime format) to tell the user when this group of cookies has been accepted.",
"description": "Formats the {{date}} and {{time}} (in Finnish datetime format) to tell the user when this group of cookies has been accepted.",
"options": {
"disable_collapse": true
},
"allOf": [
{ "$ref": "#/$defs/LocalisedUniversalText" },
{
"default": {
"fi": "Olet hyväksynyt tämän kategorian: ${date} klo ${time}.",
"sv": "Du har accepterat denna kategori: ${date} kl. ${time}.",
"en": "You have accepted this category: ${date} at ${time}."
"fi": "Olet hyväksynyt tämän kategorian: {{date}} klo {{time}}.",
"sv": "Du har accepterat denna kategori: {{date}} kl. {{time}}.",
"en": "You have accepted this category: {{date}} at {{time}}."
}
}
]
Expand Down Expand Up @@ -765,7 +765,7 @@
}
]
},
"type_1": {
"storageType1": {
"title": "Type 1 - Cookie",
"description": "Text for type column to show to users with cookies",
"options": {
Expand All @@ -782,7 +782,7 @@
}
]
},
"type_2": {
"storageType2": {
"title": "Type 2 - localStorage",
"description": "Text for type column to show to users with localStorage items",
"options": {
Expand All @@ -795,7 +795,7 @@
}
]
},
"type_3": {
"storageType3": {
"title": "Type 3 - sessionStorage",
"description": "Text for type column to show to users with sessionStorage items",
"options": {
Expand All @@ -808,7 +808,7 @@
}
]
},
"type_4": {
"storageType4": {
"title": "Type 4 - IndexedDB",
"description": "Text for type column to show to users with indexedDB tables",
"options": {
Expand All @@ -821,7 +821,7 @@
}
]
},
"type_5": {
"storageType5": {
"title": "Type 5 - Cache Storage",
"description": "Text for type column to show to users with Cache Storage items",
"options": {
Expand All @@ -841,8 +841,8 @@
"description",
"showDetails",
"hideDetails",
"form_heading",
"form_text",
"formHeading",
"formText",
"highlightedGroup",
"highlightedGroupAria",
"showCookieSettings",
Expand All @@ -858,11 +858,11 @@
"approveOnlyRequiredConsents",
"settingsSaved",
"notificationAriaLabel",
"type_1",
"type_2",
"type_3",
"type_4",
"type_5"
"storageType1",
"storageType2",
"storageType3",
"storageType4",
"storageType5"
]
}
},
Expand Down
Loading