chore: remove google analytics and tracking cookies

This commit is contained in:
mildtomato committed 2021-01-27 20:38:59 +08:00
1 parent 6243272386
commit e3ea2768af
5 files changed
+72 -13

No files matched your search

+1
View File
@@ -244,6 +244,7 @@ module.exports = {
},
],
],
scripts: [{ src: '/scripts/telemetry.js' }],
// plugins: [
// // [
// // '@docusaurus/plugin-content-docs',
+18
View File
@@ -0,0 +1,18 @@
function telemetry() {
return fetch('https://app.supabase.io/api/telemetry/page', {
mode: 'no-cors', // 'cors' by default,
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({
referrer: document.referrer,
title: document.title,
}),
}).catch((error) => {
console.error('Error at telemetry - post:', error)
})
}
telemetry()
+19
View File
@@ -0,0 +1,19 @@
interface DataProps {
referrer?: string
title: string
}
export const post = (url: string, data: DataProps, options = {}) => {
return fetch(url, {
mode: 'no-cors', // 'cors' by default,
method: 'POST',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify(data),
...options,
}).catch((error) => {
console.error('Error at fetchWrapper - post:', error)
})
}
+33
View File
@@ -1,6 +1,39 @@
import { AppProps } from 'next/app'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import '../styles/index.css'
import { post } from './../lib/fetchWrapper'
export default function MyApp({ Component, pageProps }: AppProps) {
const router = useRouter()
function telemetry() {
return post(`https://app.supabase.io/api/telemetry/page`, {
referrer: document.referrer,
title: document.title,
})
}
useEffect(() => {
// `routeChangeComplete` won't run for the first page load unless the query string is
// hydrated later on, so here we log a page view if this is the first render and
// there's no query string
if (!router.asPath.includes('?')) {
telemetry()
}
}, [])
useEffect(() => {
function handleRouteChange() {
telemetry()
}
// Listen for page changes after a navigation or when the query changes
router.events.on('routeChangeComplete', handleRouteChange)
return () => {
router.events.off('routeChangeComplete', handleRouteChange)
}
}, [router.events])
return <Component {...pageProps} />
}
+1 -13
View File
@@ -11,19 +11,7 @@ export default class MyDocument extends Document {
render() {
return (
<Html lang="en" className="dark">
<Head>
<script
dangerouslySetInnerHTML={{
__html: `(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-155232740-1', 'auto');
ga('send', 'pageview');`,
}}
/>
</Head>
<Head></Head>
<body>
<Main />
<NextScript />