Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
analytics: move to goatcounter (#4)
  • Loading branch information
arturocr committed Nov 24, 2020
1 parent 37ba998 commit c63bff4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 12 deletions.
7 changes: 7 additions & 0 deletions lib/goat-counter.js
@@ -0,0 +1,7 @@
const pageView = url => {
window.goatcounter?.count({
path: url,
});
};

export { pageView };
22 changes: 14 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -11,7 +11,6 @@
"lint:fix": "npm run lint -- --fix"
},
"dependencies": {
"@happykit/analytics": "^1",
"clsx": "^1",
"lite-vimeo-embed": "^0.1.0",
"lite-youtube-embed": "^0.1.2",
Expand All @@ -37,6 +36,7 @@
"next-seo": "^4.17.0",
"postcss": "^8.1.8",
"prettier": "^2.1.2",
"prismjs": ">=1.22.0",
"rehype": "^11.0.0",
"remark-code-titles": "^0.1.1",
"stylelint-config-recommended": "^3.0.0",
Expand Down
6 changes: 3 additions & 3 deletions pages/_app.js
Expand Up @@ -2,22 +2,22 @@ import { useEffect } from 'react';
import { MDXProvider } from '@mdx-js/react';
import Head from 'next/head';
import { DefaultSeo } from 'next-seo';
import { useAnalytics } from '@happykit/analytics';

import Footer from '@/components/footer';
import Header from '@/components/header';
import MDXComponents from '@/components/mdx-components';
import SEO from '../next-seo.config';
import { pageView } from '@/lib/goat-counter';
import theme from '@/lib/theme';

import '@/styles/globals.css';
import '@/styles/custom.css';
import '@/styles/prism.css';

const MyApp = ({ Component, pageProps, router }) => {
useAnalytics({ publicKey: 'analytics_pub_bba22bdbcd' });
useEffect(() => {
const handleRouteChange = () => {
const handleRouteChange = url => {
pageView(url);
window.scrollTo({
top: 0,
left: 0,
Expand Down
6 changes: 6 additions & 0 deletions pages/_document.js
Expand Up @@ -11,6 +11,7 @@ class MyDocument extends Document {
href='https://fonts.gstatic.com/'
crossOrigin=''
/>
<link rel='preconnect' href='https://arturocampos.goatcounter.com' />
<link
rel='apple-touch-icon'
sizes='180x180'
Expand Down Expand Up @@ -38,6 +39,11 @@ class MyDocument extends Document {
rel='stylesheet'
href='https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap'
/>
<script
async
data-goatcounter='https://arturocampos.goatcounter.com/count'
src='//gc.zgo.at/count.js'
></script>
</Head>
<body className='text-gray-700 body-font'>
<Main />
Expand Down

1 comment on commit c63bff4

@vercel
Copy link

@vercel vercel bot commented on c63bff4 Nov 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.