@@ -3,26 +3,48 @@ import 'swiper/css';
33import type { CSSProperties } from 'react' ;
44import type { AppProps } from 'next/app' ;
55import Head from 'next/head' ;
6+ import Script from 'next/script' ;
67
78import { ThemeProvider } from '@coderscamp/ui/theme' ;
89
910import { Footer } from '@/components/Footer' ;
1011import { Navbar } from '@/components/Navbar' ;
1112import { RecruitmentModalProvider } from '@/components/RecruitmentModal' ;
13+ import { IS_PRODUCTION } from '@/constants' ;
1214
1315const globalStyles : Record < string , CSSProperties > = {
1416 'html, body' : { backgroundColor : 'white' } ,
1517 '.swiper-wrapper' : { alignItems : 'stretch' } ,
1618 '.swiper-slide' : { height : 'unset' } ,
1719} ;
1820
21+ const googleAnalyticsId = process . env . NEXT_PUBLIC_GOOGLE_ANALYTICS ;
22+
23+ const GoogleAnalytics = ( { id } : { id : string } ) => (
24+ < >
25+ < Script strategy = "lazyOnload" src = { `https://www.googletagmanager.com/gtag/js?id=${ id } ` } />
26+
27+ < Script strategy = "lazyOnload" >
28+ { `
29+ window.dataLayer = window.dataLayer || [];
30+ function gtag(){dataLayer.push(arguments);}
31+ gtag('js', new Date());
32+ gtag('config', '${ id } ', {
33+ page_path: window.location.pathname,
34+ });
35+ ` }
36+ </ Script >
37+ </ >
38+ ) ;
39+
1940const userPrefersDark =
2041 typeof window !== 'undefined' && window . matchMedia && window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ;
2142
2243// eslint-disable-next-line @typescript-eslint/naming-convention
2344const MyApp = ( { Component, pageProps } : AppProps ) => {
2445 return (
2546 < >
47+ { googleAnalyticsId && < GoogleAnalytics id = { googleAnalyticsId } /> }
2648 < Head >
2749 < title > CodersCamp - największy otwarty kurs programowania webowego w Polsce</ title >
2850 < meta
0 commit comments