analytics only in production

This commit is contained in:
Matthias Kretschmann 2024-04-06 18:34:43 +01:00
parent 979e2361fb
commit 183e92af7d
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 10 additions and 6 deletions

View File

@ -2,7 +2,7 @@ import type { Metadata } from 'next'
import '@/styles/globals.css' import '@/styles/globals.css'
import '@/styles/loading-ui.css' import '@/styles/loading-ui.css'
import Script from 'next/script' import Script from 'next/script'
import { title, description, font, liveUrl } from '@/constants' import { title, description, font, liveUrl, isProduction } from '@/constants'
export const metadata: Metadata = { export const metadata: Metadata = {
title, title,
@ -19,11 +19,13 @@ export default function RootLayout({
return ( return (
<html lang="en"> <html lang="en">
<head> <head>
<Script {isProduction ? (
async <Script
src="https://a.kretschmann.io/script.js" async
data-website-id="6565eff1-a1c8-4b3e-a6c4-08ecb00b06ab" src="https://a.kretschmann.io/script.js"
/> data-website-id="6565eff1-a1c8-4b3e-a6c4-08ecb00b06ab"
/>
) : null}
</head> </head>
<body className={font.variable}>{children}</body> <body className={font.variable}>{children}</body>
</html> </html>

View File

@ -21,3 +21,5 @@ export const font = Hanken_Grotesk({
subsets: ['latin'], subsets: ['latin'],
variable: '--font-hanken-grotesk' variable: '--font-hanken-grotesk'
}) })
export const isProduction = process.env.NODE_ENV === 'production'