Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

refactor(frontend): remove Vercel Web Analytics, keep Speed Insights (#15749)

Krzysztof Czerwinski6460c2038186
diff --git a/autogpt_platform/frontend/.env.default b/autogpt_platform/frontend/.env.default
index a82c551c79..516003d6b9 100644
--- a/autogpt_platform/frontend/.env.default
+++ b/autogpt_platform/frontend/.env.default
@@ -105,7 +105,7 @@ NEXT_PUBLIC_GOOGLE_ADS_CONVERSION_LABELS=
# Cookiebot consent banner (Settings > Your scripts > "Domain group ID").
# Leave empty to run without a banner: every optional cookie category
# (analytics, monitoring, advertising) is then treated as denied, so no
-# GA/Ads/DataFast/Vercel Analytics/session replay loads.
+# GA/Ads/DataFast/Vercel Speed Insights/session replay loads.
NEXT_PUBLIC_COOKIEBOT_CBID=
# Optional: other Cookiebot domain groups for specific regions, passed
# verbatim as the script's data-georegions attribute. Visitors elsewhere get
diff --git a/autogpt_platform/frontend/package.json b/autogpt_platform/frontend/package.json
index 081ad624d3..d6c155796c 100644
--- a/autogpt_platform/frontend/package.json
+++ b/autogpt_platform/frontend/package.json
@@ -74,7 +74,6 @@
"@tanstack/react-query": "5.90.6",
"@tanstack/react-virtual": "3.13.18",
"@types/jaro-winkler": "0.2.4",
- "@vercel/analytics": "2.0.1",
"@vercel/speed-insights": "1.2.0",
"@xyflow/react": "12.9.2",
"ai": "6.0.134",
diff --git a/autogpt_platform/frontend/pnpm-lock.yaml b/autogpt_platform/frontend/pnpm-lock.yaml
index 7931440e41..7dfe48f435 100644
--- a/autogpt_platform/frontend/pnpm-lock.yaml
+++ b/autogpt_platform/frontend/pnpm-lock.yaml
@@ -124,9 +124,6 @@ importers:
'@types/jaro-winkler':
specifier: 0.2.4
version: 0.2.4
- '@vercel/analytics':
- specifier: 2.0.1
'@vercel/speed-insights':
specifier: 1.2.0
@@ -4542,35 +4539,6 @@ packages:
cpu: [x64]
os: [win32]
- '@vercel/[email protected]':
- resolution: {integrity: sha512-MTQG6V9qQrt1tsDeF+2Uoo5aPjqbVPys1xvnIftXSJYG2SrwXRHnqEvVoYID7BTruDz4lCd2Z7rM1BdkUehk2g==}
- peerDependencies:
- '@remix-run/react': ^2
- '@sveltejs/kit': ^1 || ^2
- next: '>= 13'
- nuxt: '>= 3'
- react: ^18 || ^19 || ^19.0.0-rc
- svelte: '>= 4'
- vue: ^3
- vue-router: ^4
- peerDependenciesMeta:
- '@remix-run/react':
- optional: true
- '@sveltejs/kit':
- optional: true
- next:
- optional: true
- nuxt:
- optional: true
- react:
- optional: true
- svelte:
- optional: true
- vue:
- optional: true
- vue-router:
- optional: true
-
'@vercel/[email protected]':
resolution: {integrity: sha512-Fw28YZpRnA3cAHHDlkt7xQHiJ0fcL+NRcIqsocZQUSmbzeIKRpwttJjik5ZGanXP+vlA4SbTg+AbA3bP363l+w==}
engines: {node: '>= 20'}
@@ -14028,11 +13996,6 @@ snapshots:
optional: true
- optionalDependencies:
- react: 19.3.0
-
'@vercel/[email protected]': {}
@@ -15664,7 +15627,7 @@ snapshots:
'@typescript-eslint/parser': 8.52.0([email protected])([email protected])
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.10.1([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected])
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected])
eslint-plugin-jsx-a11y: 6.10.2([email protected])
eslint-plugin-react: 7.37.5([email protected])
@@ -15684,7 +15647,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.3
@@ -15699,14 +15662,14 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
'@typescript-eslint/parser': 8.52.0([email protected])([email protected])
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
- eslint-import-resolver-typescript: 3.10.1([email protected](@typescript-eslint/[email protected]([email protected])([email protected]))([email protected]))([email protected])
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected])
transitivePeerDependencies:
- supports-color
@@ -15721,7 +15684,7 @@ snapshots:
doctrine: 2.1.0
eslint: 8.57.1
eslint-import-resolver-node: 0.3.9
hasown: 2.0.2
is-core-module: 2.16.1
is-glob: 4.0.3
diff --git a/autogpt_platform/frontend/src/app/__tests__/layout.test.tsx b/autogpt_platform/frontend/src/app/__tests__/layout.test.tsx
index 95c6127526..3dc482320d 100644
--- a/autogpt_platform/frontend/src/app/__tests__/layout.test.tsx
+++ b/autogpt_platform/frontend/src/app/__tests__/layout.test.tsx
@@ -23,8 +23,8 @@ vi.mock("@/components/molecules/Toast/toaster", () => ({
Toaster: () => null,
}));
vi.mock("@/services/analytics", () => ({ SetupAnalytics: () => null }));
-vi.mock("@/services/analytics/VercelAnalyticsWrapper", () => ({
- VercelAnalyticsWrapper: () => null,
+vi.mock("@/services/analytics/VercelSpeedInsights", () => ({
+ VercelSpeedInsights: () => null,
}));
vi.mock("@tanstack/react-query-devtools", () => ({
ReactQueryDevtools: () => null,
diff --git a/autogpt_platform/frontend/src/app/layout.tsx b/autogpt_platform/frontend/src/app/layout.tsx
index fb0565b0b4..d11e813278 100644
--- a/autogpt_platform/frontend/src/app/layout.tsx
+++ b/autogpt_platform/frontend/src/app/layout.tsx
@@ -9,7 +9,7 @@ import { ErrorBoundary } from "@/components/molecules/ErrorBoundary/ErrorBoundar
import { Toaster } from "@/components/molecules/Toast/toaster";
import { SetupAnalytics } from "@/services/analytics";
import { buildConsentDefaultsScript } from "@/services/analytics/consent-mode";
-import { VercelAnalyticsWrapper } from "@/services/analytics/VercelAnalyticsWrapper";
+import { VercelSpeedInsights } from "@/services/analytics/VercelSpeedInsights";
import { ConsentWithdrawalReload } from "@/services/consent/ConsentWithdrawalReload";
import {
COOKIEBOT_SCRIPT_ID,
@@ -129,7 +129,7 @@ export default async function RootLayout({
/>
<div className="flex min-h-screen flex-col items-stretch justify-items-stretch supports-[min-height:100dvh]:min-h-dvh">
{children}
- <VercelAnalyticsWrapper />
+ <VercelSpeedInsights />
{/* React Query DevTools is only available in development */}
{process.env.NEXT_PUBLIC_REACT_QUERY_DEVTOOL && (
diff --git a/autogpt_platform/frontend/src/services/analytics/VercelAnalyticsWrapper.tsx b/autogpt_platform/frontend/src/services/analytics/VercelSpeedInsights.tsx
similarity index 56%
rename from autogpt_platform/frontend/src/services/analytics/VercelAnalyticsWrapper.tsx
rename to autogpt_platform/frontend/src/services/analytics/VercelSpeedInsights.tsx
index 5a209b014f..9581179302 100644
--- a/autogpt_platform/frontend/src/services/analytics/VercelAnalyticsWrapper.tsx
+++ b/autogpt_platform/frontend/src/services/analytics/VercelSpeedInsights.tsx
@@ -1,20 +1,14 @@
"use client";
import { useConsent } from "@/services/consent/useConsent";
-import { Analytics } from "@vercel/analytics/next";
import { SpeedInsights } from "@vercel/speed-insights/next";
-export function VercelAnalyticsWrapper() {
+export function VercelSpeedInsights() {
const { analytics } = useConsent();
if (!analytics) {
return null;
}
- return (
- <>
- <SpeedInsights />
- <Analytics />
- </>
- );
+ return <SpeedInsights />;
}
diff --git a/autogpt_platform/frontend/src/services/analytics/__tests__/consent-consumers.test.tsx b/autogpt_platform/frontend/src/services/analytics/__tests__/consent-consumers.test.tsx
index 7e7ff80b71..9cfb6b8dc9 100644
--- a/autogpt_platform/frontend/src/services/analytics/__tests__/consent-consumers.test.tsx
+++ b/autogpt_platform/frontend/src/services/analytics/__tests__/consent-consumers.test.tsx
@@ -8,7 +8,7 @@ import {
} from "@/tests/integrations/cookiebot";
import { ConsentWithdrawalReload } from "@/services/consent/ConsentWithdrawalReload";
import { SetupAnalytics } from "../index";
-import { VercelAnalyticsWrapper } from "../VercelAnalyticsWrapper";
+import { VercelSpeedInsights } from "../VercelSpeedInsights";
vi.mock("next/script", () => ({
default: ({
@@ -35,9 +35,6 @@ vi.mock("next/script", () => ({
),
}));
-vi.mock("@vercel/analytics/next", () => ({
- Analytics: () => <div data-testid="vercel-analytics" />,
-}));
vi.mock("@vercel/speed-insights/next", () => ({
SpeedInsights: () => <div data-testid="vercel-speed-insights" />,
}));
@@ -66,13 +63,13 @@ describe("without NEXT_PUBLIC_COOKIEBOT_CBID", () => {
render(
<>
<SetupAnalytics host="platform.agpt.co" ga={GA} />
- <VercelAnalyticsWrapper />
+ <VercelSpeedInsights />
</>,
);
expect(queryScript("_custom-ga")).toBeNull();
expect(queryScript(DATAFAST_SRC)).toBeNull();
- expect(screen.queryByTestId("vercel-analytics")).toBeNull();
+ expect(screen.queryByTestId("vercel-speed-insights")).toBeNull();
});
it("keeps the Google tag off locally even for an opted-in browser", () => {
@@ -120,21 +117,21 @@ describe("with NEXT_PUBLIC_COOKIEBOT_CBID", () => {
delete (window as unknown as { dataLayer?: unknown }).dataLayer;
});
- it("starts DataFast and Vercel Analytics when the visitor accepts, without a reload", () => {
+ it("starts DataFast and Vercel Speed Insights when the visitor accepts, without a reload", () => {
installCookiebot();
render(
<>
<SetupAnalytics host="platform.agpt.co" ga={GA} />
- <VercelAnalyticsWrapper />
+ <VercelSpeedInsights />
</>,
);
expect(queryScript(DATAFAST_SRC)).toBeNull();
- expect(screen.queryByTestId("vercel-analytics")).toBeNull();
+ expect(screen.queryByTestId("vercel-speed-insights")).toBeNull();
act(() => answerCookiebot({ statistics: true }));
expect(queryScript(DATAFAST_SRC)).not.toBeNull();
- expect(screen.getByTestId("vercel-analytics")).toBeDefined();
+ expect(screen.getByTestId("vercel-speed-insights")).toBeDefined();
});
it("loads the Google tag locally once the visitor accepts statistics", () => {
@@ -150,14 +147,14 @@ describe("with NEXT_PUBLIC_COOKIEBOT_CBID", () => {
expect(queryScript("_custom-ga")).not.toBeNull();
});
- it("stops rendering Vercel Analytics when the visitor declines", () => {
+ it("stops rendering Vercel Speed Insights when the visitor declines", () => {
installCookiebot({ statistics: true });
- render(<VercelAnalyticsWrapper />);
- expect(screen.getByTestId("vercel-analytics")).toBeDefined();
+ render(<VercelSpeedInsights />);
+ expect(screen.getByTestId("vercel-speed-insights")).toBeDefined();
act(() => answerCookiebot({}));
- expect(screen.queryByTestId("vercel-analytics")).toBeNull();
+ expect(screen.queryByTestId("vercel-speed-insights")).toBeNull();
});
});
diff --git a/autogpt_platform/frontend/src/services/consent/ConsentWithdrawalReload.tsx b/autogpt_platform/frontend/src/services/consent/ConsentWithdrawalReload.tsx
index 91ca6df7da..d591ba664b 100644
--- a/autogpt_platform/frontend/src/services/consent/ConsentWithdrawalReload.tsx
+++ b/autogpt_platform/frontend/src/services/consent/ConsentWithdrawalReload.tsx
@@ -9,7 +9,7 @@ import {
type ConsentState,
} from "./consent";
-// A script that already ran (DataFast, Vercel Analytics, session replay)
+// A script that already ran (DataFast, Vercel Speed Insights, session replay)
// cannot be unloaded, so taking a category back reloads the page to shed it.
// Granting needs no reload: consumers pick it up through useConsent.
export function ConsentWithdrawalReload() {