diff --git a/packages/web/package.json b/packages/web/package.json index a7ad5ee..98353e5 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@vercel/analytics", - "version": "1.4.1", + "version": "1.5.0-canary.2", "description": "Gain real-time traffic insights with Vercel Web Analytics", "keywords": [ "analytics", diff --git a/packages/web/src/generic.ts b/packages/web/src/generic.ts index 555ca86..6ebcef1 100644 --- a/packages/web/src/generic.ts +++ b/packages/web/src/generic.ts @@ -67,6 +67,13 @@ function inject( } if (props.endpoint) { script.dataset.endpoint = props.endpoint; + } else if ( + // eslint-disable-next-line @typescript-eslint/prefer-optional-chain -- process doesn't exist in all frameworks + typeof process !== 'undefined' && + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- process doesn't exist in all frameworks + process.env?.NEXT_PUBLIC_WEB_ANALYTICS_BASEPATH + ) { + script.dataset.endpoint = `/${process.env.NEXT_PUBLIC_WEB_ANALYTICS_BASEPATH}/_vercel/speed-insights/vitals`; } if (props.dsn) { script.dataset.dsn = props.dsn;