Skip to content

Commit c63bff4

Browse files
authored
analytics: move to goatcounter (#4)
1 parent 37ba998 commit c63bff4

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

Diff for: lib/goat-counter.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const pageView = url => {
2+
window.goatcounter?.count({
3+
path: url,
4+
});
5+
};
6+
7+
export { pageView };

Diff for: package-lock.json

+14-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"lint:fix": "npm run lint -- --fix"
1212
},
1313
"dependencies": {
14-
"@happykit/analytics": "^1",
1514
"clsx": "^1",
1615
"lite-vimeo-embed": "^0.1.0",
1716
"lite-youtube-embed": "^0.1.2",
@@ -37,6 +36,7 @@
3736
"next-seo": "^4.17.0",
3837
"postcss": "^8.1.8",
3938
"prettier": "^2.1.2",
39+
"prismjs": ">=1.22.0",
4040
"rehype": "^11.0.0",
4141
"remark-code-titles": "^0.1.1",
4242
"stylelint-config-recommended": "^3.0.0",

Diff for: pages/_app.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import { useEffect } from 'react';
22
import { MDXProvider } from '@mdx-js/react';
33
import Head from 'next/head';
44
import { DefaultSeo } from 'next-seo';
5-
import { useAnalytics } from '@happykit/analytics';
65

76
import Footer from '@/components/footer';
87
import Header from '@/components/header';
98
import MDXComponents from '@/components/mdx-components';
109
import SEO from '../next-seo.config';
10+
import { pageView } from '@/lib/goat-counter';
1111
import theme from '@/lib/theme';
1212

1313
import '@/styles/globals.css';
1414
import '@/styles/custom.css';
1515
import '@/styles/prism.css';
1616

1717
const MyApp = ({ Component, pageProps, router }) => {
18-
useAnalytics({ publicKey: 'analytics_pub_bba22bdbcd' });
1918
useEffect(() => {
20-
const handleRouteChange = () => {
19+
const handleRouteChange = url => {
20+
pageView(url);
2121
window.scrollTo({
2222
top: 0,
2323
left: 0,

Diff for: pages/_document.js

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class MyDocument extends Document {
1111
href='https://fonts.gstatic.com/'
1212
crossOrigin=''
1313
/>
14+
<link rel='preconnect' href='https://arturocampos.goatcounter.com' />
1415
<link
1516
rel='apple-touch-icon'
1617
sizes='180x180'
@@ -38,6 +39,11 @@ class MyDocument extends Document {
3839
rel='stylesheet'
3940
href='https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap'
4041
/>
42+
<script
43+
async
44+
data-goatcounter='https://arturocampos.goatcounter.com/count'
45+
src='//gc.zgo.at/count.js'
46+
></script>
4147
</Head>
4248
<body className='text-gray-700 body-font'>
4349
<Main />

0 commit comments

Comments
 (0)