1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

fix: only load ga and gtm in production (#10612)

CookieYes was throwing an uncaught error triggered by GA and GTM
scripts. We don't want analytics to run in development anyway, so I
disabled them in these environments.
This commit is contained in:
Fredrik Strand Oseberg 2025-09-04 09:35:56 +02:00 committed by GitHub
parent f8990a40ba
commit 2fd40e7372
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -39,7 +39,7 @@ const LazyVideo = ({ url, title = 'YouTube video player' }) => {
className={styles.thumbnailImage} className={styles.thumbnailImage}
src={`https://img.youtube.com/vi/${videoId}/hqdefault.jpg`} src={`https://img.youtube.com/vi/${videoId}/hqdefault.jpg`}
alt={`${title} thumbnail`} alt={`${title} thumbnail`}
fetchPriority='high' fetchpriority='high'
/> />
<div className={styles.playButton}> <div className={styles.playButton}>
<svg <svg

View File

@ -8,6 +8,11 @@ export default function Root({ children }: { children: React.ReactNode }) {
} }
const loadGoogleAnalytics = () => { const loadGoogleAnalytics = () => {
// Skip Google Analytics in development
if (process.env.NODE_ENV === 'development') {
return;
}
if ( if (
window.gtag || window.gtag ||
document.querySelector('script[src*="googletagmanager"]') document.querySelector('script[src*="googletagmanager"]')
@ -33,6 +38,11 @@ export default function Root({ children }: { children: React.ReactNode }) {
}; };
const loadGoogleTagManager = () => { const loadGoogleTagManager = () => {
// Skip GTM in development
if (process.env.NODE_ENV === 'development') {
return;
}
if ( if (
window.google_tag_manager || window.google_tag_manager ||
document.querySelector( document.querySelector(