From dca74342508d6f2939230c19f1fd81619c46afa7 Mon Sep 17 00:00:00 2001 From: feugy Date: Tue, 19 Nov 2024 17:55:13 +0100 Subject: [PATCH] fix(#157): error when rendering Nuxt component --- packages/web/package.json | 2 +- packages/web/src/generic.ts | 4 ---- packages/web/src/vue/create-component.ts | 2 +- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/web/package.json b/packages/web/package.json index 4d17fbf..a7ad5ee 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,6 +1,6 @@ { "name": "@vercel/analytics", - "version": "1.5.0-canary.1", + "version": "1.4.1", "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 509a387..555ca86 100644 --- a/packages/web/src/generic.ts +++ b/packages/web/src/generic.ts @@ -20,8 +20,6 @@ export const DEV_SCRIPT_URL = 'https://va.vercel-scripts.com/v1/script.debug.js'; export const PROD_SCRIPT_URL = '/_vercel/insights/script.js'; -export const basepathVariableName = 'NEXT_PUBLIC_WEB_ANALYTICS_BASEPATH'; - /** * Injects the Vercel Web Analytics script into the page head and starts tracking page views. Read more in our [documentation](https://vercel.com/docs/concepts/analytics/package). * @param [props] - Analytics options. @@ -69,8 +67,6 @@ function inject( } if (props.endpoint) { script.dataset.endpoint = props.endpoint; - } else if (process.env[basepathVariableName]) { - script.dataset.endpoint = `/${process.env[basepathVariableName]}/_vercel/insights`; } if (props.dsn) { script.dataset.dsn = props.dsn; diff --git a/packages/web/src/vue/create-component.ts b/packages/web/src/vue/create-component.ts index 1d699bd..21486d6 100644 --- a/packages/web/src/vue/create-component.ts +++ b/packages/web/src/vue/create-component.ts @@ -19,7 +19,7 @@ export function createComponent( framework, }); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route is undefined for barebone vue project. - if (route && window) { + if (route && typeof window !== 'undefined') { const changeRoute = (): void => { pageview({ route: computeRoute(route.path, route.params),