From f18fe8caa611e9273c5504fa81522e1ac93b95d2 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 21 Feb 2022 17:13:50 +0100 Subject: feat: replace Matomo with Ackee I do not use all Matomo features so I was searching a lightweight analytics tools. I will give a try to Ackee. --- .env.example | 5 +++-- .vscode/settings.json | 1 + next.config.js | 18 +++++++++--------- package.json | 1 - src/components/Layouts/Layout.tsx | 8 ++++++++ src/pages/_app.tsx | 9 --------- src/utils/config.ts | 9 +++++---- yarn.lock | 5 ----- 8 files changed, 26 insertions(+), 30 deletions(-) diff --git a/.env.example b/.env.example index 3200101..6217f82 100644 --- a/.env.example +++ b/.env.example @@ -10,8 +10,9 @@ APP_FEED_DESCRIPTION="What you want..." NEXT_PUBLIC_APP_DOMAIN="$APP_FRONTEND_DOMAIN" NEXT_PUBLIC_APP_PROTOCOL="$APP_PROTOCOL" NEXT_PUBLIC_GRAPHQL_API="https://$APP_BACKEND_DOMAIN$APP_GRAPHQL_ENDPOINT" -NEXT_PUBLIC_MATOMO_SITE_ID=1 -NEXT_PUBLIC_MATOMO_DOMAIN="www.analyticsDomain.com" +NEXT_PUBLIC_ACKEE_DOMAIN="www.ackeeDomain.com" +NEXT_PUBLIC_ACKEE_FILENAME="tracker.js" +NEXT_PUBLIC_ACKEE_SITE_ID="your-id-string" # Use this only in development mode. It prevents "unable to verify the first # certificate" error when using a local domain with mkcert certificate for diff --git a/.vscode/settings.json b/.vscode/settings.json index 06d65d6..5ac3d84 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,6 +2,7 @@ "css.lint.validProperties": ["composes"], "scss.lint.validProperties": ["composes"], "cSpell.words": [ + "Ackee", "aligncenter", "developpement", "hexcode", diff --git a/next.config.js b/next.config.js index dfbb523..4b8214d 100644 --- a/next.config.js +++ b/next.config.js @@ -2,29 +2,29 @@ const path = require('path'); const backendDomain = process.env.APP_BACKEND_DOMAIN; const frontendDomain = process.env.APP_FRONTEND_DOMAIN; -const matomoDomain = process.env.NEXT_PUBLIC_MATOMO_DOMAIN; +const ackeeDomain = process.env.NEXT_PUBLIC_ACKEE_DOMAIN; const contentSecurityPolicy = ` default-src 'self' ${backendDomain}; child-src 'self' *.${frontendDomain.replace('www.', '')}; - connect-src 'self' ${backendDomain} ${matomoDomain} api.github.com; + connect-src 'self' ${backendDomain} api.github.com; font-src 'self'; - frame-src 'self' ${matomoDomain}; - img-src 'self' ${backendDomain} ${matomoDomain} secure.gravatar.com data:; + frame-src 'self'; + img-src 'self' ${backendDomain} secure.gravatar.com data:; media-src 'self' data:; - script-src 'self' ${matomoDomain} 'unsafe-inline'; + script-src 'self' ${ackeeDomain} 'unsafe-inline'; style-src 'self' 'unsafe-inline'; `; const contentSecurityPolicyDev = ` default-src 'self' ${backendDomain}; child-src 'self' *.${frontendDomain.replace('www.', '')}; - connect-src 'self' ${backendDomain} ${matomoDomain} api.github.com; + connect-src 'self' ${backendDomain} api.github.com; font-src 'self'; - frame-src 'self' ${matomoDomain}; - img-src 'self' ${backendDomain} ${matomoDomain} secure.gravatar.com data:; + frame-src 'self'; + img-src 'self' ${backendDomain} secure.gravatar.com data:; media-src 'self' data:; - script-src 'self' ${matomoDomain} 'unsafe-inline' 'unsafe-eval'; + script-src 'self' ${ackeeDomain} 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; `; diff --git a/package.json b/package.json index e5bda70..c3a3a66 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,6 @@ "@mdx-js/react": "^2.0.0-rc.2", "@next/bundle-analyzer": "^12.0.10", "@next/mdx": "^12.0.7", - "@socialgouv/matomo-next": "^1.2.2", "@types/mdx": "^2.0.1", "@types/prismjs": "^1.16.6", "babel-plugin-formatjs": "^10.3.17", diff --git a/src/components/Layouts/Layout.tsx b/src/components/Layouts/Layout.tsx index 9a47b2b..9c29df9 100644 --- a/src/components/Layouts/Layout.tsx +++ b/src/components/Layouts/Layout.tsx @@ -9,6 +9,7 @@ import { ReactElement, ReactNode, useEffect, useRef } from 'react'; import { useIntl } from 'react-intl'; import { SearchAction, WebSite, WithContext } from 'schema-dts'; import styles from './Layout.module.scss'; +import Script from 'next/script'; const Layout = ({ children, @@ -111,6 +112,13 @@ const Layout = ({ }} > +