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:
parent
f8990a40ba
commit
2fd40e7372
@ -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
|
||||||
|
@ -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(
|
||||||
|
Loading…
Reference in New Issue
Block a user