docs(nxdev): create custom event for 404s (#12813)

This commit is contained in:
Benjamin Cabanes 2022-10-25 13:37:37 -04:00 committed by GitHub
parent e6054fb938
commit e70ecaefc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,8 +1,19 @@
import { sendCustomEvent } from '@nrwl/nx-dev/feature-analytics';
import { Footer, Header } from '@nrwl/nx-dev/ui-common';
import { NextSeo } from 'next-seo';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { useEffect } from 'react';
export function FourOhFour(): JSX.Element {
const router = useRouter();
useEffect(() => {
const handleRouteChange = (url: URL) =>
sendCustomEvent('custom_page_hit', '404', url.toString());
router.events.on('routeChangeStart', (url) => handleRouteChange(url));
return () => router.events.off('routeChangeStart', handleRouteChange);
}, [router]);
return (
<>
<NextSeo title="Page not found" noindex={true} />
@ -47,7 +58,7 @@ export function FourOhFour(): JSX.Element {
</article>
</div>
</main>
<Footer useDarkBackground={false} />
<Footer />
</>
);
}