diff --git a/package.json b/package.json index 06e26fc3..0b745b75 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@types/react": "18.2.25", "@types/react-dom": "18.2.10", "@use-gesture/react": "10.3.1", + "@vercel/analytics": "^1.6.1", "cross-env": "7.0.3", "electron-context-menu": "3.3.0", "electron-is-dev": "2.0.0", diff --git a/src/index.tsx b/src/index.tsx index e759955a..fd144263 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,12 +7,19 @@ import './lib/init-translations'; import './index.css'; import './themes.css'; import { App as CapacitorApp } from '@capacitor/app'; +import { Analytics } from '@vercel/analytics/react'; + +// Only enable analytics on 5chan.app (Vercel deployment) +// Exclude Electron (file:// or localhost), Capacitor/APK (capacitor:// or localhost), and IPFS (ipfs:// or different domain) +const isVercelDeployment = + typeof window !== 'undefined' && (window.location.hostname === '5chan.app' || window.location.hostname === 'www.5chan.app') && !window.isElectron; const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement); root.render( + {isVercelDeployment && } , ); diff --git a/yarn.lock b/yarn.lock index 0f73a086..54a37f42 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5145,6 +5145,11 @@ dependencies: "@use-gesture/core" "10.3.1" +"@vercel/analytics@^1.6.1": + version "1.6.1" + resolved "https://registry.yarnpkg.com/@vercel/analytics/-/analytics-1.6.1.tgz#b4e16daf445cf6cd365a91e43d86e9e5b3428ddc" + integrity sha512-oH9He/bEM+6oKlv3chWuOOcp8Y6fo6/PSro8hEkgCW3pu9/OiCXiUpRUogDh3Fs3LH2sosDrx8CxeOLBEE+afg== + "@vitejs/plugin-react@4.3.4": version "4.3.4" resolved "https://registry.yarnpkg.com/@vitejs/plugin-react/-/plugin-react-4.3.4.tgz#c64be10b54c4640135a5b28a2432330e88ad7c20"