diff --git a/website/assets/js/app.js b/website/assets/js/app.js index d4bb1c3f834cf..953c5752d7907 100644 --- a/website/assets/js/app.js +++ b/website/assets/js/app.js @@ -3,6 +3,7 @@ {{ $siteGeneration := site.Params.site_generation }} import '@ryangjchandler/spruce'; import 'alpinejs'; +import './cookie-banner' const sayHello = () => { console.log('Welcome to the Vector website and documentation!'); diff --git a/website/assets/js/cookie-banner.js b/website/assets/js/cookie-banner.js new file mode 100644 index 0000000000000..ee3044b545802 --- /dev/null +++ b/website/assets/js/cookie-banner.js @@ -0,0 +1,41 @@ +window.addEventListener('load', function () { + const { env } = document.documentElement.dataset; + + if (env !== 'development') { + // add trustarc script to head + const trustarc = document.createElement('script'); + trustarc.setAttribute('src','https://consent.trustarc.com/v2/notice/ufocto'); + document.head.appendChild(trustarc); + + // add divs + const divA = document.createElement("div"); + const divB = document.createElement("div"); + divA.id = "teconsent"; + divA.style = "cursor: pointer; color:#fff" + divB.id = "consent-banner"; + divB.style = "position:fixed; bottom:0px; right:0px; width:100%;"; + document.body.appendChild(divA); + document.body.appendChild(divB); + + // update Cookie link + this.setTimeout(function () { + const banner = document.getElementById('consent-banner'); + const prefsElement = document.getElementById('teconsent'); + const cookieLink = document.querySelector('footer a[href*="/cookies"]'); + prefsElement.className = cookieLink.className; + + if (banner) { + // listen for click and remove banner to avoid interfering with + document.addEventListener('click', function (event) { + const targetElement = event.target; + if (targetElement.matches('#truste-consent-required') || targetElement.matches('#truste-consent-button')) { + banner.remove(); + } + }); + } + + // replace Cookie link with Prefs div + return (cookieLink && document.getElementById('teconsent').innerHTML.length > 0) ? cookieLink.replaceWith(prefsElement) : false; + }, 200); + } +}); \ No newline at end of file diff --git a/website/config.toml b/website/config.toml index 1308eff1af5af..a51fd243a30dc 100644 --- a/website/config.toml +++ b/website/config.toml @@ -175,6 +175,12 @@ url = "https://www.datadoghq.com/legal/privacy/" parent = "about" weight = 3 +[[languages.en.menus.footer]] +name = "Cookies" +url = "https://www.datadoghq.com/legal/cookies/" +parent = "about" +weight = 4 + [[languages.en.menus.footer]] name = "Components" url = "/components" diff --git a/website/layouts/partials/meta.html b/website/layouts/partials/meta.html index 242f6401c9bed..2a6cd8553f131 100644 --- a/website/layouts/partials/meta.html +++ b/website/layouts/partials/meta.html @@ -16,6 +16,10 @@ {{ end }} +{{/* TrustArc */}} + + + {{ hugo.Generator }}