Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions partners/dynamic/app/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use client'

import { inject } from '@vercel/analytics'

export function Analytics() {
inject()
return null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing useEffect causes inject to run every render

The inject() function from @vercel/analytics is called directly in the component body without being wrapped in a useEffect hook. This causes the analytics initialization to run on every render instead of only once when the component mounts. In React StrictMode (development mode), this will execute twice per mount, and any re-render of parent components will trigger additional calls. The same issue exists in quickstarts/wagmi/app/analytics.tsx.

Additional Locations (2)

Fix in Cursor Fix in Web

}
2 changes: 2 additions & 0 deletions partners/dynamic/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { Providers } from "./providers";
import { Navbar } from "@/components/Navbar";
import { Analytics } from "./analytics";

const geistSans = Geist({
variable: "--font-geist-sans",
Expand Down Expand Up @@ -35,6 +36,7 @@ export default async function RootLayout({
<Navbar />
{children}
</Providers>
<Analytics />
</main>
</body>
</html>
Expand Down
1 change: 1 addition & 0 deletions partners/dynamic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"@radix-ui/react-separator": "^1.1.3",
"@radix-ui/react-slot": "^1.2.0",
"@tanstack/react-query": "^5.72.2",
"@vercel/analytics": "^1.6.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.487.0",
Expand Down
34 changes: 34 additions & 0 deletions partners/dynamic/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions partners/web3auth/app/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use client'

import { inject } from '@vercel/analytics'

export function Analytics() {
inject()
return null
}
3 changes: 3 additions & 0 deletions partners/web3auth/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { Providers } from "./providers";
import { Navbar } from "@/components/Navbar";
import { Analytics } from "./analytics";

const geistSans = Geist({
variable: "--font-geist-sans",
subsets: ["latin"],
Expand Down Expand Up @@ -34,6 +36,7 @@ export default async function RootLayout({
<Navbar />
{children}
</Providers>
<Analytics />
</main>
</body>
</html>
Expand Down
1 change: 1 addition & 0 deletions partners/web3auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@radix-ui/react-separator": "^1.1.3",
"@radix-ui/react-slot": "^1.2.0",
"@tanstack/react-query": "^5.74.3",
"@vercel/analytics": "^1.6.1",
"@web3auth/modal": "10.0.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
Expand Down
34 changes: 34 additions & 0 deletions partners/web3auth/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions quickstarts/connectkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@metamask/sdk": "^0.33.0",
"@tanstack/react-query": "^5.84.2",
"@vercel/analytics": "^1.6.1",
"connectkit": "^1.9.1",
"react": "^19.1.1",
"react-dom": "^19.1.1",
Expand Down
33 changes: 33 additions & 0 deletions quickstarts/connectkit/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions quickstarts/connectkit/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import "./index.css";
import App from "./App.tsx";
import { inject } from "@vercel/analytics";

import { ConnectKitProvider, getDefaultConfig } from "connectkit";
import { createConfig, http, WagmiProvider } from "wagmi";
import { mainnet, linea, sepolia, lineaSepolia } from "wagmi/chains";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";

inject();

const queryClient = new QueryClient();

const config = createConfig(
Expand Down
1 change: 1 addition & 0 deletions quickstarts/javascript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MetaMask SDK JavaScript Quickstart</title>
<script defer src="https://cdn.vercel-analytics.com/v1/script.js"></script>
</head>
<body>
<div id="app"></div>
Expand Down
3 changes: 2 additions & 1 deletion quickstarts/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"vite": "^7.1.2"
},
"dependencies": {
"@metamask/sdk": "^0.33.0"
"@metamask/sdk": "^0.33.0",
"@vercel/analytics": "^1.6.1"
}
}
31 changes: 31 additions & 0 deletions quickstarts/javascript/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions quickstarts/next/app/analytics.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use client'

import { inject } from '@vercel/analytics'

export function Analytics() {
inject()
return null
}
2 changes: 2 additions & 0 deletions quickstarts/next/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { Analytics } from "./analytics";

const geistSans = Geist({
variable: "--font-geist-sans",
Expand All @@ -26,6 +27,7 @@ export default function RootLayout({
<html lang="en">
<body className={`${geistSans.variable} ${geistMono.variable}`}>
{children}
<Analytics />
</body>
</html>
);
Expand Down
1 change: 1 addition & 0 deletions quickstarts/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@metamask/sdk": "^0.33.0",
"@vercel/analytics": "^1.6.1",
"next": "15.5.7",
"react": "19.1.0",
"react-dom": "19.1.0"
Expand Down
Loading