diff --git a/.eslintrc b/.eslintrc index cdaf6a6..ba627b3 100644 --- a/.eslintrc +++ b/.eslintrc @@ -13,6 +13,7 @@ "react/require-default-props": "off", "linebreak-style": "off", "no-param-reassign": "off", + "react/prop-types": "off", "max-len": "off" } } \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 19cc654..c5d0ad9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,11 +1,19 @@ import React from 'react'; import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'; - +// import ReactGa from 'react-ga'; import Home from 'pages/Home'; import Auth from 'pages/Auth'; import StaticFileRedirect from 'components/StaticFileRedirect'; function App(): JSX.Element { + // const notifyGA = (path: string) => { + // switch (path) { + // case "/": + // ReactGa.pageview() + // break; + // }; + // }; + return ( diff --git a/src/GARouteUpdater.tsx b/src/GARouteUpdater.tsx new file mode 100644 index 0000000..da427da --- /dev/null +++ b/src/GARouteUpdater.tsx @@ -0,0 +1,8 @@ +import React from 'react'; + +const GARouteUpdater: React.FC = () => ( + <> + +); + +export default GARouteUpdater; diff --git a/src/index.tsx b/src/index.tsx index 2ebd1e1..6851659 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -6,7 +6,7 @@ import App from './App'; import reportWebVitals from './reportWebVitals'; ReactGA.initialize('G-2D2S4GLZPR', { - testMode: process.env.NODE_ENV !== 'production', + // testMode: process.env.NODE_ENV !== 'production', }); ReactDOM.render( diff --git a/src/pages/Auth/index.tsx b/src/pages/Auth/index.tsx index 22c3066..e3eb56f 100644 --- a/src/pages/Auth/index.tsx +++ b/src/pages/Auth/index.tsx @@ -1,40 +1,47 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import queryString from 'query-string'; import { useLocation } from 'react-router-dom'; - +import ReactGa from 'react-ga'; import { getToken } from 'util/api'; // import Loading from 'components/Loading'; function mobileRedirect(os: 'android' | 'ios', code: string) { + ReactGa.event({ + category: 'mobile', + action: os, + }); const to = `hackillinois://org.hackillinois.${os}/auth?code=${code}`; window.location.replace(to); } +type QueryTypes = { + code?: string; + isAndroid?: string; + isiOS?: string; + to?: string; +}; + const Auth: React.FC = () => { const location = useLocation(); - type QueryTypes = { - code?: string; - isAndroid?: string; - isiOS?: string; - to?: string; - }; - const { code, isAndroid, isiOS, to }: QueryTypes = queryString.parse(location.search); + useEffect(() => { + ReactGa.pageview('/auth'); + const { code, isAndroid, isiOS, to }: QueryTypes = queryString.parse(location.search); - if (code) { - if (isAndroid || isiOS) { - const os = isAndroid ? 'android' : 'ios'; - mobileRedirect(os, code); + if (code) { + if (isAndroid || isiOS) { + const os = isAndroid ? 'android' : 'ios'; + mobileRedirect(os, code); + } else { + getToken(code).then((token) => { + sessionStorage.setItem('token', token); + window.location.replace(to as string); + }); + } } else { - getToken(code).then((token) => { - sessionStorage.setItem('token', token); - window.location.replace(to as string); - }); + window.location.replace('/'); } - } else { - window.location.replace('/'); - } - + }, []); return
Loading...
; // ; }; diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index caf11c1..282dc65 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -1,13 +1,21 @@ -import React from 'react'; - +import React, { useEffect } from 'react'; +import ReactGa from 'react-ga'; import Hero from './Hero'; // import EventInfo from './EventInfo'; -const Home: React.FC = () => ( - <> - - {/* */} - -); +const Home: React.FC = () => { + useEffect(() => { + ReactGa.pageview('/'); + }, []); + + return ( + <> + + { + /* */ + } + + ); +}; export default Home;