Add matomo configuration
diff --git a/website-v2/docusaurus.config.js b/website-v2/docusaurus.config.js
index 4c87287..23ea22b 100644
--- a/website-v2/docusaurus.config.js
+++ b/website-v2/docusaurus.config.js
@@ -6,7 +6,6 @@
"organizationName": "apache",
"projectName": "streampipes-docs",
"scripts": [
- "/js/matomo.js",
"/js/jquery-3.3.1.min.js",
"/js/buttons.js",
"/js/slick.min.js",
@@ -63,6 +62,7 @@
]
],
"plugins": [
+ "./src/plugins/matomo",
"docusaurus-plugin-sass",
[
"@docusaurus/plugin-client-redirects",
@@ -81,6 +81,12 @@
prism: {
additionalLanguages: ['java']
},
+ matomo: {
+ matomoUrl: '//analytics.apache.org/',
+ siteId: '35',
+ phpLoader: 'matomo.php',
+ jsLoader: 'matomo.js',
+ },
"navbar": {
"logo": {
"src": "img/sp-logo-color.png"
diff --git a/website-v2/src/plugins/matomo/index.js b/website-v2/src/plugins/matomo/index.js
new file mode 100644
index 0000000..bdd5126
--- /dev/null
+++ b/website-v2/src/plugins/matomo/index.js
@@ -0,0 +1,67 @@
+const path = require('path');
+
+module.exports = function (context) {
+ const {siteConfig} = context;
+ const {themeConfig} = siteConfig;
+ const {matomo} = themeConfig || {};
+
+ if (!matomo) {
+ throw new Error(`Please specify 'matomo' object in 'themeConfig' with 'matomoUrl' and 'siteId' fields in it to use docusaurus-plugin-matomo`);
+ }
+
+ const {matomoUrl, siteId} = matomo;
+
+ if (!matomoUrl) {
+ throw new Error('Please specify the `matomoUrl` field in the `themeConfig.matomo`');
+ }
+ if (!siteId) {
+ throw new Error('Please specify the `siteId` field in the `themeConfig.matomo`');
+ }
+ const phpLoader = matomo.phpLoader || 'matomo.php';
+ const jsLoader = matomo.jsLoader || 'matomo.js';
+
+ const isProd = process.env.NODE_ENV === 'production';
+
+ return {
+ name: 'docusaurus-plugin-matomo',
+ getClientModules() {
+
+ return isProd ? [path.resolve(__dirname, './track')] : [];
+ },
+
+ injectHtmlTags() {
+ if (!isProd) {
+ return {};
+ }
+ return {
+ headTags: [
+ {
+ tagName: 'link',
+ attributes: {
+ rel: 'preconnect',
+ href: `${matomoUrl}`,
+ },
+ },
+ {
+ tagName: 'script',
+ innerHTML: `
+ var _paq = window._paq = window._paq || [];
+ _paq.push(['setRequestMethod', 'POST']);
+ _paq.push(['trackPageView']);
+ _paq.push(['enableLinkTracking']);
+ _paq.push(['enableHeartBeatTimer']);
+ (function() {
+ var u="${matomoUrl}";
+ _paq.push(['setRequestMethod', 'POST']);
+ _paq.push(['setTrackerUrl', u+'${phpLoader}']);
+ _paq.push(['setSiteId', '${siteId}']);
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+ g.type='text/javascript'; g.async=true; g.src=u+'${jsLoader}'; s.parentNode.insertBefore(g,s);
+ })();
+ `,
+ },
+ ],
+ };
+ },
+ };
+};
diff --git a/website-v2/src/plugins/matomo/track.js b/website-v2/src/plugins/matomo/track.js
new file mode 100644
index 0000000..719de54
--- /dev/null
+++ b/website-v2/src/plugins/matomo/track.js
@@ -0,0 +1,14 @@
+import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment';
+
+export default (function () {
+ if (!ExecutionEnvironment.canUseDOM) {
+ return null;
+ }
+ return {
+ onRouteUpdate({location}) {
+ _paq.push(['setCustomUrl', location.pathname]);
+ _paq.push(['setDocumentTitle', document.title]);
+ _paq.push(['trackPageView']);
+ },
+ };
+})();
diff --git a/website-v2/src/theme/Footer/index.tsx b/website-v2/src/theme/Footer/index.tsx
index 518e81b..7d0cc76 100644
--- a/website-v2/src/theme/Footer/index.tsx
+++ b/website-v2/src/theme/Footer/index.tsx
@@ -58,7 +58,7 @@
{
icon: githubIcon,
label: 'Github Discussions',
- to: 'https://github.com/apache/streampipes/issues',
+ to: 'https://github.com/apache/streampipes/discussions',
},
{
icon: twitterIcon,