diff --git a/pages/404.tsx b/pages/404.tsx index 4ba44131..974462e4 100644 --- a/pages/404.tsx +++ b/pages/404.tsx @@ -1,10 +1,14 @@ import { useRouter } from 'next/router'; import { useEffect } from 'react'; +import { TrackEvent } from '@/utils/plausibleHelpers'; + export const NotFoundPage: React.FC = () => { const { push } = useRouter(); useEffect(() => { push('/'); + // @ts-ignore + window.plausible(TrackEvent.Error); }, [push]); return null; }; diff --git a/pages/_document.tsx b/pages/_document.tsx index 0b963ca0..d16f96f0 100644 --- a/pages/_document.tsx +++ b/pages/_document.tsx @@ -9,6 +9,26 @@ import Document, { } from 'next/document'; import { theme } from '../utils/theme'; + +export enum TrackEvent { + Signup = 'Signup', + Error = '404', + ChainCreated = 'Chain created', +} + +type PlausibleArgs = [TrackEvent, () => void] | [TrackEvent]; + +declare global { + const plausible: { + (...args: PlausibleArgs): void; + q?: PlausibleArgs[]; + }; + + interface Window { + plausible?: typeof plausible; + } +} + class TSDocument extends Document { static async getInitialProps( ctx: DocumentContext, @@ -33,6 +53,12 @@ class TSDocument extends Document { href="/logo.svg" /> +