nuxt-modules / web-vitals

Web Vitals: Essential module for a healthy project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integrate with Vercel Analytics

atinux opened this issue · comments

I believe it would be nice to support Vercel analytics since they also use web-vitals for their API.

Vercel did a prototype based on this module actually: https://github.com/vercel/nuxt-plugin-vercel

We could imagine a provider option, default to ga and overwritten with NUXT_VITALS_PROVIDER or directly having NUXT_VITALS_URL?

Analytics is currently only available for projects using Next.js and Gatsby.
We need provider option because url and payload data are different between ga and vercel.
First we need to solve how to get access/enable analytics for nuxt project.
Can via this module...

If we use target static and buildModules we dont have during the build process.env.VERCEL_ANALYTICS_ID.
Status 400 Bad request.
Demo: https://nxt-vercel.vercel.app/
Other works as expected. Dinamicaly applied provider based on option trackingID.
Problem is only in VERCEL_ANALYTICS_ID environment variable.

edit: typo

Hi :D

Other works as expected. Dinamicaly applied provider based on option trackingID.

I think you can leverage runtimeConfig for this.

@pi0 I try but during the build on vercel we dont have VERCEL_ANALYTICS_ID environment for some reason...

I notice for gatsby they have GATSBY_VERCEL_ANALYTICS_ID, then i/we can expect for nuxt to be NUXT_VERCEL_ANALYTICS_ID. For now vercel official have support ONLY for gatsby and for next...

Hmm interesting 🤔

For Gatsby they alias it here: https://github.com/vercel/vercel/blob/5bea99c1d9817cbfa3983f2386bd3083f5129d73/packages/now-static-build/src/utils/gatsby.ts#L23

For VERCEL_ANALYTICS_ID, let me ask :)

Module released with vercel support. Waiting for vercel team to make final touches on their side :)