Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/nextjs/app/errors/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use client';
import { useEffect } from 'react';
import { track } from '@vercel/analytics';

export default function Error({ error }: { error: Error; reset: () => void }) {
useEffect(() => {
track('thrown-error', {
message: error.message,
time: new Date().toLocaleString(),
});
}, [error.message]);

return <div>Error</div>;
}
10 changes: 10 additions & 0 deletions apps/nextjs/app/errors/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use client';
import { useEffect } from 'react';

export default function ErrorPage() {
useEffect(() => {
throw new Error('Error!');
}, []);

return <div>I should error</div>;
}
3 changes: 3 additions & 0 deletions apps/nextjs/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Analytics } from '@vercel/analytics/react';

export const metadata = {
title: 'Next.js',
description: 'Generated by Next.js',
Expand All @@ -10,6 +12,7 @@ export default function RootLayout({
}) {
return (
<html lang="en">
<Analytics />
<body>{children}</body>
</html>
);
Expand Down