Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Sponsorship Document #15

Merged
merged 1 commit into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"rules": {
"object-curly-newline": "off",
"react/require-default-props": "off",
"linebreak-style": "off"
"linebreak-style": "off",
"max-len": "off"
}
}
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@types/node": "^14.14.5",
"@types/react": "^16.9.53",
"@types/react-dom": "^16.9.8",
"@types/react-gtm-module": "^2.0.0",
"@types/react-router-dom": "^5.1.6",
"@typescript-eslint/eslint-plugin": "^4.6.0",
"@typescript-eslint/parser": "^4.6.0",
Expand All @@ -18,6 +19,7 @@
"query-string": "^6.13.6",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-ga": "^3.3.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.0",
"typescript": "^4.0.5",
Expand Down
Binary file added public/documents/sponsorship.pdf
Binary file not shown.
13 changes: 13 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,18 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>


<!-- The following shouldn't be necessary, but ReactGA doesn't support Google Analytics 4 currently -->
<!-- so this is a workaround: -->

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2D2S4GLZPR"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-2D2S4GLZPR');
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

import Home from 'pages/Home';
import Auth from 'pages/Auth';
import StaticFileRedirect from 'components/StaticFileRedirect';

function App(): JSX.Element {
return (
Expand All @@ -15,6 +16,10 @@ function App(): JSX.Element {
<Route path="/auth" exact>
<Auth />
</Route>

<Route path="/sponsor" exact>
<StaticFileRedirect to="/documents/sponsorship.pdf" />
</Route>
</Switch>
</Router>
);
Expand Down
23 changes: 23 additions & 0 deletions src/components/StaticFileRedirect/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ReactGA from 'react-ga';

type PropTypes = {
to: string,
};

const StaticFileRedirect = ({ to }: PropTypes): null => {
const redirect = () => window.location.replace(to);

// Record the pageview to google analytics before redirect
ReactGA.set({ page: to });
document.title = to.slice(to.lastIndexOf('/') + 1); // filename for google analytics
ReactGA.ga('send', 'pageview', to, {
hitCallback: redirect,
});

// In case google analytics is down or request fails for some reason, continue to redirect after timeout
setTimeout(redirect, 1000);

return null;
};

export default StaticFileRedirect;
5 changes: 5 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import React from 'react';
import ReactDOM from 'react-dom';
import ReactGA from 'react-ga';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';

ReactGA.initialize('G-2D2S4GLZPR', {
testMode: process.env.NODE_ENV !== 'production',
});

ReactDOM.render(
<React.StrictMode>
<App />
Expand Down