We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hey team, I've set up @vercel/analytics in my Next.js project, and it's working fine.
@vercel/analytics
I want to track errors thrown to the error boundary in error.tsx. I've written this code:
error.tsx
'use client' import { track } from '@vercel/analytics'; // ... export default function Error({ error, reset }: { error: Error; reset: () => void; }) { useEffect(() => { track('thrown-error', { message: error.message, time: formatDate(new Date()) }); }, [error.message]); return // jsx }
For some reason, this doesn't work as expected; there are no custom events showing up in the analytics dashboard.
When I'm in the development environment, It logs the event in the console. but in production, it does not send to the Vercel analytics dashboard.
I tried another experiment:
<button onClick={() => { track('test-event', { name: 'someone' }); }}>trigger</button>
This worked as expected. However, I'm unsure why the first example isn't working. Any help would be appreciated.
The text was updated successfully, but these errors were encountered:
Hey @A7med3bdulBaset !
Did you resolve this issue already? This should work fine. If not, please send us a reproducible example!
Thanks
Sorry, something went wrong.
@tobiaslins It's still not resolved
I think what we need is not a reproducible repo since the problem is not in the code but in Vercel.
To produce it:
create-next-app
'use client' import { track } from '@vercel/analytics'; // ... export default function Error({ error, reset }: { error: Error; reset: () => void; }) { useEffect(() => { track('thrown-error', { message: error.message, time: new Date().toLocaleString() }); }, [error.message]); return // jsx }
throw new Error("should be tracked")
Hey @A7med3bdulBaset
I just added a example for error tracking (same as you mentioned) and it works fine https://github.com/vercel/analytics/pull/113/files
Also the deployed version does work for us.
Make sure adblockers are not blocking the script on production!
No branches or pull requests
Hey team, I've set up
@vercel/analytics
in my Next.js project, and it's working fine.I want to track errors thrown to the error boundary in
error.tsx
. I've written this code:For some reason, this doesn't work as expected; there are no custom events showing up in the analytics dashboard.
When I'm in the development environment, It logs the event in the console. but in production, it does not send to the Vercel analytics dashboard.
I tried another experiment:
This worked as expected. However, I'm unsure why the first example isn't working. Any help would be appreciated.
The text was updated successfully, but these errors were encountered: