From e98e81d6d90fd9588b0fc3af2be36b2da8dfb764 Mon Sep 17 00:00:00 2001 From: dubemoyibe-star Date: Mon, 14 Sep 2026 15:59:37 +0100 Subject: [PATCH] Enabled vercel analytics --- package.json | 1 + pnpm-lock.yaml | 38 +++++++++++++++++++++++++++++++++++++- src/theme/Root.tsx | 23 +++++++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 src/theme/Root.tsx diff --git a/package.json b/package.json index 8fa3b44..2e5d3b1 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@docusaurus/faster": "3.10.2", "@docusaurus/preset-classic": "3.10.2", "@mdx-js/react": "^3.0.0", + "@vercel/analytics": "^2.0.1", "clsx": "^2.0.0", "prism-react-renderer": "^2.3.0", "prismjs": "^1.30.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0ce1ec8..2d56498 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,6 +20,9 @@ importers: '@mdx-js/react': specifier: ^3.0.0 version: 3.1.1(@types/react@19.3.0)(react@19.3.0) + '@vercel/analytics': + specifier: ^2.0.1 + version: 2.0.1(react@19.3.0) clsx: specifier: ^2.0.0 version: 2.1.1 @@ -2169,6 +2172,35 @@ packages: '@ungap/structured-clone@1.4.0': resolution: {integrity: sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==} + '@vercel/analytics@2.0.1': + 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 + '@webassemblyjs/ast@1.14.1': resolution: {integrity: sha512-nuBEDgQfm1ccRp/8bCQrx1frohyufl4JlbMMZ4P1wpeOfDhF6FQkxZJ1b/e+PLwr6X1Nhw6OLme5usuBWYBvuQ==} @@ -8840,6 +8872,10 @@ snapshots: '@ungap/structured-clone@1.4.0': {} + '@vercel/analytics@2.0.1(react@19.3.0)': + optionalDependencies: + react: 19.3.0 + '@webassemblyjs/ast@1.14.1': dependencies: '@webassemblyjs/helper-numbers': 1.13.2 @@ -10439,7 +10475,7 @@ snapshots: jest-worker@27.5.1: dependencies: - '@types/node': 26.5.1 + '@types/node': 20.19.43 merge-stream: 2.0.0 supports-color: 8.1.1 diff --git a/src/theme/Root.tsx b/src/theme/Root.tsx new file mode 100644 index 0000000..5bdb565 --- /dev/null +++ b/src/theme/Root.tsx @@ -0,0 +1,23 @@ +import type {ReactNode} from 'react'; +import {Analytics} from '@vercel/analytics/react'; + +// Docusaurus has no built-in Root component of its own to extend — this +// file, once present under src/theme/, is picked up automatically and +// wraps the entire app. That makes it the right place to mount +// @vercel/analytics: it needs to render once, outside any page, and Root +// is the only place Docusaurus guarantees is common to every route +// (browser vs. server-rendered pages included). +// +// Vercel Web Analytics itself only reports anything once this site is +// deployed on Vercel with Analytics turned on for the project (Vercel +// dashboard → project → Analytics tab) — this component is inert +// (no requests, no error) in local dev and in any other hosting +// environment. +export default function Root({children}: {children: ReactNode}): ReactNode { + return ( + <> + {children} + + + ); +}