11import "./style" ;
22import "react-toastify/dist/ReactToastify.css" ;
3- import { BrowserRouter , Redirect , Route , Switch } from "react-router-dom" ;
3+ import {
4+ BrowserRouter ,
5+ Redirect ,
6+ Route ,
7+ Switch ,
8+ useLocation ,
9+ } from "react-router-dom" ;
410import React , { Suspense , lazy } from "react" ;
511import Container from "@material-ui/core/Container" ;
612import CssBaseline from "@material-ui/core/CssBaseline" ;
@@ -10,6 +16,7 @@ import { Navbar } from "t9/apps/main/components/navbar";
1016import { Provider } from "react-redux" ;
1117import { Theme } from "t9/apps/main/components/theme" ;
1218import { ToastContainer } from "react-toastify" ;
19+ import { getEnv } from "src/common/utils" ;
1320import { mainStore } from "t9/apps/main/redux" ;
1421import { render } from "react-dom" ;
1522
@@ -18,38 +25,48 @@ const Articles = lazy(() => import("t9/apps/main/scenes/articles"));
1825const Projects = lazy ( ( ) => import ( "t9/apps/main/scenes/projects" ) ) ;
1926const Learn = lazy ( ( ) => import ( "t9/apps/main/scenes/learn" ) ) ;
2027const Faq = lazy ( ( ) => import ( "t9/apps/main/scenes/faq" ) ) ;
21-
2228const Contact = lazy ( ( ) => import ( "t9/apps/main/scenes/contact" ) ) ;
2329
30+ const env = getEnv ( ) ;
31+
2432export const App = ( ) => {
33+ const location = useLocation ( ) ;
34+ React . useEffect ( ( ) => {
35+ if ( env !== "development" ) {
36+ window . ga ( "set" , "page" , location . pathname ) ;
37+ window . ga ( "send" , "pageview" ) ;
38+ window . fbq ( "track" , "PageView" ) ;
39+ }
40+ } , [ location ] ) ;
41+
2542 return (
2643 < Theme >
27- < BrowserRouter >
28- < Navbar />
29- < Container maxWidth = "lg" >
30- < ToastContainer />
31- < Suspense fallback = { Loading } >
32- < Switch >
33- < Route path = "/" exact component = { Landing } />
34- < Route path = "/Learn" component = { Learn } />
35- < Route path = "/Articles" component = { Articles } />
36- < Route path = "/Projects" component = { Projects } />
37- < Route path = "/Contact-Us" component = { Contact } />
38- < Route path = "/FAQ" component = { Faq } />
39- < Route render = { ( ) => < Redirect to = "/" /> } />
40- </ Switch >
41- </ Suspense >
42- </ Container >
43- < Footer />
44- </ BrowserRouter >
44+ < Navbar />
45+ < Container maxWidth = "lg" >
46+ < ToastContainer />
47+ < Suspense fallback = { Loading } >
48+ < Switch >
49+ < Route path = "/" exact component = { Landing } />
50+ < Route path = "/Learn" component = { Learn } />
51+ < Route path = "/Articles" component = { Articles } />
52+ < Route path = "/Projects" component = { Projects } />
53+ < Route path = "/Contact-Us" component = { Contact } />
54+ < Route path = "/FAQ" component = { Faq } />
55+ < Route render = { ( ) => < Redirect to = "/" /> } />
56+ </ Switch >
57+ </ Suspense >
58+ </ Container >
59+ < Footer />
4560 < CssBaseline />
4661 </ Theme >
4762 ) ;
4863} ;
4964
5065render (
5166 < Provider store = { mainStore } >
52- < App />
67+ < BrowserRouter >
68+ < App />
69+ </ BrowserRouter >
5370 </ Provider > ,
5471 document . getElementById ( "app-container" ) ,
5572) ;
0 commit comments