Skip to content

Commit 962c7a9

Browse files
committed
feat: conditionally enable Vercel analytics
1 parent dd6e9d2 commit 962c7a9

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ loading across the platform.
4343
<tr>
4444
<td align="center"><b>deployment</b></td>
4545
<td>
46-
<img src="https://img.shields.io/badge/Vercel-black?style=flat&logo=Vercel&logoColor=white" alt="Vercel" />
46+
<img src="https://img.shields.io/badge/Vercel-black?style=flat&logo=Vercel&logoColor=white" alt="Vercel" /> <i>(used until 2024)</i>
47+
<br/>
48+
<img src="https://img.shields.io/badge/Docker-2496ED?style=flat&logo=Docker&logoColor=white" alt="Docker" /> current self-hosted
4749
</td>
4850
</tr>
4951
</table>

next.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const withVanillaExtract = createVanillaExtractPlugin();
66
/** @type {import('next').NextConfig} */
77
const nextConfig = {
88
reactStrictMode: true,
9+
env: {
10+
NEXT_PUBLIC_VERCEL: process.env.VERCEL,
11+
}
912
};
1013

1114
export default withVanillaExtract(withPlaiceholder(nextConfig));

src/app/providers.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ type ProvidersProps = {
99
children: ReactNode;
1010
};
1111

12+
const isVercel = process.env.NEXT_PUBLIC_VERCEL === '1';
13+
1214
const Providers = ({ children }: ProvidersProps) => {
1315
useScreenSize();
1416

1517
return (
1618
<>
17-
<Analytics />
18-
<SpeedInsights />
19+
{isVercel && (
20+
<>
21+
<Analytics />
22+
<SpeedInsights />
23+
</>
24+
)}
1925
{children}
2026
</>
2127
);

0 commit comments

Comments
 (0)