Skip to content

Commit 3a1dbd2

Browse files
Merge pull request #19 from austincondiff/dev
Added analytics
2 parents 66326a1 + bdc6fed commit 3a1dbd2

File tree

6 files changed

+75
-0
lines changed

6 files changed

+75
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"react": "17.0.2",
1717
"react-dom": "17.0.2",
1818
"react-feather": "^2.0.10",
19+
"react-ga": "^3.3.1",
1920
"react-parallax": "^3.5.1",
2021
"styled-components": "^5.3.5",
2122
"uuid": "^9.0.0"

pages/_app.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
1+
import { useEffect } from 'react';
12
import Head from 'next/head';
23
import Footer from '@/components/common/Footer';
34
import Header from '@/components//common/Header';
45
import Site from '@/components/common/Site';
56
import '@/styles/globals.css';
7+
import { initGA, logPageView } from '@/utils/analytics';
68

79
function MyApp({ Component, pageProps }) {
10+
useEffect(() => {
11+
if (!window.GA_INITIALIZED) {
12+
initGA();
13+
window.GA_INITIALIZED = true;
14+
}
15+
logPageView();
16+
17+
const appHeight = () => {
18+
const doc = document.documentElement;
19+
doc.style.setProperty('--app-height', `${window.innerHeight}px`);
20+
};
21+
22+
window.addEventListener('resize', appHeight);
23+
24+
appHeight();
25+
}, []);
26+
827
return (
928
<Site>
1029
<Head>

pages/_document.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,35 @@ export default class MyDocument extends Document {
3434
<Head>
3535
<meta charset="utf-8" />
3636
<meta name="apple-mobile-web-app-capable" content="yes"></meta>
37+
<meta
38+
property="og:title"
39+
content="The Portfolio of Austin Condiff - UX/UI Designer & Developer"
40+
></meta>
41+
<meta
42+
property="og:image"
43+
content="http://codeedit.app/assets/social-preview.jpg"
44+
></meta>
45+
<meta
46+
property="og:description"
47+
content="I design and develop beautiful yet functional interactive user experiences that provide both customer value and product success."
48+
></meta>
49+
<meta property="og:url" content="http://codeedit.app"></meta>
50+
<meta
51+
name="twitter:image"
52+
content="https://codeedit.app/assets/social-preview.jpg"
53+
></meta>
54+
<meta
55+
name="twitter:image:src"
56+
content="https://codeedit.app/assets/social-preview.jpg"
57+
></meta>
58+
<meta name="twitter:card" content="summary_large_image"></meta>
59+
<meta name="twitter:site" content="@CodeEditApp"></meta>
60+
<meta name="twitter:creator" content="@CodeEditApp"></meta>
61+
<meta name="twitter:title" content="CodeEdit for macOS"></meta>
62+
<meta
63+
name="twitter:description"
64+
content="CodeEdit, a lightweight, natively built editor for macOS. Open source. Free forever."
65+
></meta>
3766
<link rel="icon" href="/favicon.svg" type="image/svg+xml" />
3867
</Head>
3968
<body>

public/social-preview.jpg

433 KB
Loading

utils/analytics.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import ReactGA from 'react-ga';
2+
3+
export const initGA = () => {
4+
console.log('GA init');
5+
ReactGA.initialize('G-14NVNPBGNR');
6+
};
7+
export const logPageView = () => {
8+
console.log(`Logging pageview for ${window.location.pathname}`);
9+
ReactGA.set({ page: window.location.pathname });
10+
ReactGA.pageview(window.location.pathname);
11+
};
12+
export const logEvent = (category = '', action = '') => {
13+
if (category && action) {
14+
ReactGA.event({ category, action });
15+
}
16+
};
17+
export const logException = (description = '', fatal = false) => {
18+
if (description) {
19+
ReactGA.exception({ description, fatal });
20+
}
21+
};

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,6 +2956,11 @@ react-feather@^2.0.10:
29562956
dependencies:
29572957
prop-types "^15.7.2"
29582958

2959+
react-ga@^3.3.1:
2960+
version "3.3.1"
2961+
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
2962+
integrity sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==
2963+
29592964
react-is@^16.13.1, react-is@^16.7.0:
29602965
version "16.13.1"
29612966
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"

0 commit comments

Comments
 (0)