Skip to content

Commit

Permalink
feat: Add Matomo analytics (#199)
Browse files Browse the repository at this point in the history
* chore: update .env.local.example

* chore: update netlify.toml

* chore: matomo setup
  • Loading branch information
nhsz authored Dec 21, 2022
1 parent b285c11 commit e3a4984
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ NEXT_PUBLIC_ALGOLIA_BASE_SEARCH_INDEX_NAME=
# GitHub API
# check fine-grained tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens
GITHUB_TOKEN_READ_ONLY=

# Matomo
NEXT_PUBLIC_MATOMO_URL=
NEXT_PUBLIC_MATOMO_SITE_ID=
5 changes: 5 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@

[functions]
included_files = ["src/**"]

[[headers]]
for = "/*"
[headers.values]
Access-Control-Allow-Origin = "https://matomo.ethereum.org"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@docsearch/react": "3",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
"@socialgouv/matomo-next": "^1.4.0",
"algoliasearch": "^4.14.2",
"chakra-ui-markdown-renderer": "^4.1.0",
"fast-xml-parser": "^4.0.12",
Expand Down
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export const GETH_TWITTER_URL = 'https://twitter.com/go_ethereum';
export const GETH_DISCORD_URL = 'https://discord.com/invite/nthXNEv';
export const GO_URL = 'https://go.dev/';

// analytics
export const DO_NOT_TRACK_URL =
'http://matomo.ethereum.org/piwik/index.php?module=CoreAdminHome&action=optOut';

// Downloads
export const DEFAULT_BUILD_AMOUNT_TO_SHOW = 12;
export const DOWNLOAD_HEADER_BUTTONS: {
Expand Down
9 changes: 9 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ChakraProvider } from '@chakra-ui/react';
import { AppProps } from 'next/app';
import { useEffect } from 'react';
import { init } from '@socialgouv/matomo-next';

import { Layout } from '../components/layouts';

Expand All @@ -10,6 +12,13 @@ import theme from '../theme';
import '../theme/search.css';

export default function App({ Component, pageProps }: AppProps) {
useEffect(() => {
init({
url: process.env.NEXT_PUBLIC_MATOMO_URL!,
siteId: process.env.NEXT_PUBLIC_MATOMO_SITE_ID!
});
}, []);

return (
<ChakraProvider theme={theme}>
<Layout>
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,11 @@
resolved "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.1.4.tgz"
integrity sha512-LwzQKA4vzIct1zNZzBmRKI9QuNpLgTQMEjsQLf3BXuGYb3QPTP4Yjf6mkdX+X1mYttZ808QpOwAzZjv28kq7DA==

"@socialgouv/matomo-next@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@socialgouv/matomo-next/-/matomo-next-1.4.0.tgz#9c428b542671542686b56f4ebdca1aa0896af628"
integrity sha512-S+kNX7dwo/cL0VE7GWY8Gnf3t7aeXD4CzallRz9IEttjHJDJI2S8xOrcyaGimYpInr3nDNo+WqeYrafKUdsn1g==

"@swc/[email protected]":
version "0.4.11"
resolved "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.11.tgz"
Expand Down

0 comments on commit e3a4984

Please sign in to comment.