From 668f0ee2dcc2bea3647e43db019ec3d9ee61e00e Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Sun, 15 Nov 2020 13:38:09 -0500 Subject: add goatcounter as page element to hopefully catch routing --- src/App.js | 4 ++-- src/GoatCounter.js | 26 ++++++++++++++++++++++++++ src/History.js | 2 ++ src/MainPage.js | 2 ++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 src/GoatCounter.js (limited to 'src') diff --git a/src/App.js b/src/App.js index 68d7f08..e01dbdf 100644 --- a/src/App.js +++ b/src/App.js @@ -63,7 +63,7 @@ function App() { @@ -159,7 +159,7 @@ function App() { By Galen Guyer. Source available on{" "} GitHub - + (Report Issue)

diff --git a/src/GoatCounter.js b/src/GoatCounter.js new file mode 100644 index 0000000..15ec5ef --- /dev/null +++ b/src/GoatCounter.js @@ -0,0 +1,26 @@ +import React from 'react' + +class GoatCounter extends React.Component { + componentDidMount () { + window.counter = 'https://rcd.goatcounter.com/count'; + const script = window.document.createElement('script'); + script.async = 1; + script.src = 'https://gc.zgo.at/count.js'; + script.id = 'goatcounter'; + script.setAttribute('data-goatcounter', "https://rcd.goatcounter.com/count"); + (window.document.head || window.document.body).appendChild(script); + } + + componentWillUnmount () { + const script = window.document.getElementById('goatcounter') + if (script) { + script.parentNode.removeChild(script) + } + } + + render () { + return null + } +} + +export default GoatCounter \ No newline at end of file diff --git a/src/History.js b/src/History.js index df5398b..2e710de 100644 --- a/src/History.js +++ b/src/History.js @@ -12,6 +12,7 @@ import { ResponsiveContainer, Label, } from "recharts"; +import GoatCounter from './GoatCounter'; const History = (props) => { const offset = DateTime.fromSQL(props.data[0].date, { zone: "UTC" }).setZone(DateTime.local().zoneName).toSeconds(); @@ -45,6 +46,7 @@ const History = (props) => { + ); }; diff --git a/src/MainPage.js b/src/MainPage.js index ade335e..7c316c4 100644 --- a/src/MainPage.js +++ b/src/MainPage.js @@ -1,5 +1,6 @@ import React from "react"; import Card from "./Card"; +import GoatCounter from "./GoatCounter"; const MainPage = (props) => { const latest = props.latest; @@ -102,6 +103,7 @@ const MainPage = (props) => { /> + ); }; -- cgit v1.2.3