From 31f8befdb998034e30be8d3a12e9ef518958ab54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mi=C5=82osz=20Szekiel?= <12242002+mszekiel@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:12:01 +0100 Subject: [PATCH] feat: remove analytics and provide ory consent --- docusaurus.config.ts | 8 +-- src/plugins/analytics/analytics.js | 37 ---------- src/plugins/analytics/index.js | 35 --------- src/plugins/analytics/package.json | 3 - .../docusaurus-plugin-matamo/analytics.js | 37 ---------- src/plugins/docusaurus-plugin-matamo/index.js | 47 ------------ .../docusaurus-plugin-matamo/package.json | 4 -- .../plugin-usercentrics-gtm/analytics.js | 25 ------- src/plugins/plugin-usercentrics-gtm/index.js | 72 ------------------- .../plugin-usercentrics-gtm/package.json | 3 - src/static/scripts/init.js | 12 ---- 11 files changed, 1 insertion(+), 282 deletions(-) delete mode 100644 src/plugins/analytics/analytics.js delete mode 100644 src/plugins/analytics/index.js delete mode 100644 src/plugins/analytics/package.json delete mode 100644 src/plugins/docusaurus-plugin-matamo/analytics.js delete mode 100644 src/plugins/docusaurus-plugin-matamo/index.js delete mode 100644 src/plugins/docusaurus-plugin-matamo/package.json delete mode 100644 src/plugins/plugin-usercentrics-gtm/analytics.js delete mode 100644 src/plugins/plugin-usercentrics-gtm/index.js delete mode 100644 src/plugins/plugin-usercentrics-gtm/package.json delete mode 100644 src/static/scripts/init.js diff --git a/docusaurus.config.ts b/docusaurus.config.ts index ae603b7cd..5c6fac460 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -213,7 +213,6 @@ const config: Config = { }, } satisfies Preset.ThemeConfig, plugins: [ - require.resolve("./src/plugins/analytics"), [ "docusaurus-pushfeedback", { @@ -237,12 +236,6 @@ const config: Config = { }, ], "@docusaurus/plugin-content-pages", - require.resolve("./src/plugins/docusaurus-plugin-matamo"), - enableUserCentrics && - process.env.NODE_ENV !== "development" && [ - "./src/plugins/plugin-usercentrics-gtm", - { usercentricsID: "dwogEWVkK", gtmID: "GTM-NTT7RMX" }, - ], require.resolve("./src/plugins/docusaurus-polyfill"), "@docusaurus/plugin-sitemap", [ @@ -284,6 +277,7 @@ const config: Config = { scripts: [ // Needed as a workaround for https://answers.netlify.com/t/trailing-slash-missing-on-proxied-netlify-site/36367 "/docs/scripts/redirect.js", + "https://consent.ory.sh", { src: "https://widget.kapa.ai/kapa-widget.bundle.js", "data-website-id": "e89e7663-df2c-4c7f-974a-1bf8accdd615", diff --git a/src/plugins/analytics/analytics.js b/src/plugins/analytics/analytics.js deleted file mode 100644 index 13b9c5cf5..000000000 --- a/src/plugins/analytics/analytics.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment" - -export default (function () { - if (!ExecutionEnvironment.canUseDOM) { - return null - } - - // Workaround until https://github.com/facebook/docusaurus/issues/3399 is fixed - let lastLocation = window.location.pathname - return { - onRouteUpdate({ location }) { - if (typeof window.gtag !== "function") { - return - } - - const pagePath = location - ? location.pathname + location.search + location.hash - : undefined - - if (lastLocation === location.pathname) { - return - } - lastLocation = location.pathname - - window.gtag("config", "UA-71865250-1", { - page_path: pagePath, - }) - }, - } -})() diff --git a/src/plugins/analytics/index.js b/src/plugins/analytics/index.js deleted file mode 100644 index 2a8c13da5..000000000 --- a/src/plugins/analytics/index.js +++ /dev/null @@ -1,35 +0,0 @@ -module.exports = function (context) { - return { - name: "ory-plugin-analytics", - - injectHtmlTags() { - return { - headTags: [ - { - tagName: "script", - innerHTML: ` - window.TERMLY_CUSTOM_BLOCKING_MAP = { - "sqa-web.ory.sh": "essential", - "static.reo.dev": "analytics", - "cdn.redoc.ly": "essential", - } - ` - }, - { - tagName: "script", - attributes: { - type: "text/javascript", - src: "https://app.termly.io/resource-blocker/3563b8d6-caf2-41c3-a821-9d0eb05a7409?autoBlock=on", - }, - }, - { - tagName: "script", - innerHTML: ` - !function(){var e,t,n;e="400b988f083a73b",t=function(){Reo.init({clientID:"400b988f083a73b"})},(n=document.createElement("script")).src="https://static.reo.dev/"+e+"/reo.js",n.async=!0,n.onload=t,document.head.appendChild(n)}(); - ` - }, - ], - } - }, - } -} diff --git a/src/plugins/analytics/package.json b/src/plugins/analytics/package.json deleted file mode 100644 index 14ab704d8..000000000 --- a/src/plugins/analytics/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "index.js" -} diff --git a/src/plugins/docusaurus-plugin-matamo/analytics.js b/src/plugins/docusaurus-plugin-matamo/analytics.js deleted file mode 100644 index 16f59802d..000000000 --- a/src/plugins/docusaurus-plugin-matamo/analytics.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment" - -export default (function () { - if (!ExecutionEnvironment.canUseDOM) { - return null - } - - // Workaround until https://github.com/facebook/docusaurus/issues/3399 is fixed - let lastLocation = window.location.pathname - return { - onRouteUpdate({ location }) { - if (!window._paq) { - return - } - - const pagePath = location - ? location.pathname + location.search + location.hash - : undefined - - if (lastLocation === location.pathname) { - return - } - lastLocation = location.pathname - - _paq.push(["setCustomUrl", pagePath]) - _paq.push(["setDocumentTitle", document.domain + "/" + document.title]) - _paq.push(["trackPageView"]) - }, - } -})() diff --git a/src/plugins/docusaurus-plugin-matamo/index.js b/src/plugins/docusaurus-plugin-matamo/index.js deleted file mode 100644 index 223e6a0c6..000000000 --- a/src/plugins/docusaurus-plugin-matamo/index.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -const path = require("path") - -module.exports = function (context) { - return { - name: "docusaurus-plugin-matamo", - - getClientModules() { - return [path.resolve(__dirname, "./analytics")] - }, - - injectHtmlTags() { - return { - postBodyTags: [ - ``, - ], - headTags: [ - { - tagName: "script", - innerHTML: ` -var _paq = window._paq = window._paq || []; -/* tracker methods like "setCustomDimension" should be called before "trackPageView" */ -_paq.push(["setDocumentTitle", document.domain + "/" + document.title]); -_paq.push(["setCookieDomain", "*.ory.sh"]); -_paq.push(["disableCookies"]); -_paq.push(['trackPageView']); -_paq.push(['enableLinkTracking']); -(function() { - var u="//sqa-web.ory.sh/"; - _paq.push(['setTrackerUrl', u+'np.php']); - _paq.push(['setSiteId', '2']); - var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.src=u+'js/np.min.js'; s.parentNode.insertBefore(g,s); -})(); -`, - }, - ], - } - }, - } -} diff --git a/src/plugins/docusaurus-plugin-matamo/package.json b/src/plugins/docusaurus-plugin-matamo/package.json deleted file mode 100644 index e002d0e5c..000000000 --- a/src/plugins/docusaurus-plugin-matamo/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "docusaurus-plugin-matamo", - "main": "index.js" -} diff --git a/src/plugins/plugin-usercentrics-gtm/analytics.js b/src/plugins/plugin-usercentrics-gtm/analytics.js deleted file mode 100644 index d96bce855..000000000 --- a/src/plugins/plugin-usercentrics-gtm/analytics.js +++ /dev/null @@ -1,25 +0,0 @@ -import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment" - -export default (function () { - if (!ExecutionEnvironment.canUseDOM) { - return null - } - - return { - onRouteDidUpdate({ location, previousLocation }) { - if ( - previousLocation && - (location.pathname !== previousLocation.pathname || - location.search !== previousLocation.search || - location.hash !== previousLocation.hash) - ) { - window.dataLayer = window.dataLayer || [] - window.dataLayer.push({ - event: "track", - action: "page_view", - track: null, - }) - } - }, - } -})() diff --git a/src/plugins/plugin-usercentrics-gtm/index.js b/src/plugins/plugin-usercentrics-gtm/index.js deleted file mode 100644 index 666958888..000000000 --- a/src/plugins/plugin-usercentrics-gtm/index.js +++ /dev/null @@ -1,72 +0,0 @@ -module.exports = function pluginUsercentrics(_, options) { - const { usercentricsID, gtmID } = options - - return { - name: "docusaurus-plugin-usercentrics", - getClientModules() { - return [require.resolve("./analytics")] - }, - injectHtmlTags() { - return { - headTags: [ - { - tagName: "script", - innerHTML: ` -window.dataLayer = window.dataLayer || []; -function gtag(){window.dataLayer.push(arguments);} - -gtag('consent', 'default', { - 'analytics_storage': 'allowed', - 'ad_storage': 'denied', - 'ads_data_redaction': true -}); - -gtag('consent', 'default', { - 'ad_storage': 'denied', - 'analytics_storage': 'denied', - 'ads_data_redaction': true, - 'region': ['BE','BG','CZ','DK','DE','EE','IE','EL','ES','FR','HR','IT','CY','LV','LT','LU','HU','MT','NL','AT','PL','PT','RO','SI','SK','FI','SE','US-CA'] -}); - -window.originalPushFunction = window.dataLayer.push; -window.dataLayer.push = function () { - for (var args = arguments, i = 0; i < args.length; i++) { - if (!window.google_tag_manager) { - if ( - (args[i].length == 3 && args[i][0] == 'consent' && args[i][1] == 'update') || - (args[i] && args[i].event && -1 < args[i].event.indexOf("consent_status")) - ) { - window.dataLayer.splice(2, 0, args[i]) - continue; - } - } - window.originalPushFunction.call(window.dataLayer, args[i]); - } -}; -window.dataLayer.push({'gtm.start':new Date().getTime(),event:'gtm.js'}); -window.dataLayer.push({event: "track", action: "page_view",track: null}); - `, - }, - { - tagName: "script", - attributes: { - async: true, - id: "usercentrics-cmp", - "data-settings-id": usercentricsID, - src: "https://app.usercentrics.eu/browser-ui/latest/loader.js", - }, - }, - { - tagName: "script", - attributes: { - async: true, - type: "text/plain", - "data-usercentrics": "Google Tag Manager", - src: "https://sst.ory.sh/gtm.js?id=" + gtmID, - }, - }, - ], - } - }, - } -} diff --git a/src/plugins/plugin-usercentrics-gtm/package.json b/src/plugins/plugin-usercentrics-gtm/package.json deleted file mode 100644 index 14ab704d8..000000000 --- a/src/plugins/plugin-usercentrics-gtm/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "index.js" -} diff --git a/src/static/scripts/init.js b/src/static/scripts/init.js deleted file mode 100644 index 8b402aad0..000000000 --- a/src/static/scripts/init.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright © 2022 Ory Corp -// SPDX-License-Identifier: Apache-2.0 - -;(function () { - const script = document.createElement("script") - script.src = "https://www.ory.sh/scripts.js" - script.async = true - script.onload = function () { - window.initAnalytics("GTM-NTT7RMX") - } - document.body.appendChild(script) -})()