add analytics

This commit is contained in:
2024-07-17 01:13:25 +02:00
parent fb9c340832
commit 796d866a33
5 changed files with 77 additions and 8 deletions

View File

@@ -1,7 +1,16 @@
import { LinksFunction } from '@remix-run/node'
import { Link, Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'
import {
Link,
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useLocation,
} from '@remix-run/react'
import stylesheet from '~/tailwind.css?url'
import { PropsWithChildren } from 'react'
import { PropsWithChildren, useEffect } from 'react'
import posthog from 'posthog-js'
export const links: LinksFunction = () => [{ rel: 'stylesheet', href: stylesheet }]
@@ -35,5 +44,18 @@ export function Layout({ children }: PropsWithChildren) {
}
export default function App() {
return <Outlet />
return (
<>
<CapturePageView />
<Outlet />
</>
)
}
function CapturePageView() {
const location = useLocation()
useEffect(() => {
posthog.capture('$pageview')
}, [location])
return null
}