Skip to content

Commit

Permalink
fix: improve plausible setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupert Redington committed Nov 23, 2021
1 parent 9d09db2 commit 1d762e7
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 84 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"mongoose": "6.0.10",
"mongoose-paginate": "5.0.3",
"next": "12.0.1",
"next-plausible": "3.1.4",
"prop-types": "15.7.2",
"query-string": "7.0.1",
"react": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/LocationSearch/LocationSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const LocationSearch = ({ onSelectedItemChange }) => {
if (!selectedItem) {
return;
}
window['plausible']('Search');

const { lat, lng } = await getPlaceLatLng(selectedItem);

onSelectedItemChange({ lat, lng });
Expand Down
1 change: 0 additions & 1 deletion src/components/LooMap/LocateMapControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const LocateMapControl = ({ position }) => {
const handleClick = () => {
if (!isActive) {
startLocate();
window.plausible('Geolocate');
} else {
stopLocate();
}
Expand Down
6 changes: 0 additions & 6 deletions src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ const Sidebar = ({
geolocation: location,
center: location,
});

typeof window !== 'undefined' &&
window.plausible('Find a toilet near me');
});
}}
aria-label="Find a toilet near me"
Expand Down Expand Up @@ -240,9 +237,6 @@ const Sidebar = ({
geolocation: location,
center: location,
});

typeof window !== 'undefined' &&
window.plausible('Find a toilet near me');
});
}}
>
Expand Down
7 changes: 5 additions & 2 deletions src/globalStyles.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { Global, css } from '@emotion/react';

import theme from './theme';

// loosely based on https://hankchizljaw.com/wrote/a-modern-css-reset
// loosely based on https://hankchizljaw.com/wrote/a-modern-css-reset + a height declaration on the next container...
const globalStyles = (
<Global
styles={css`
Expand Down Expand Up @@ -171,6 +170,10 @@ const globalStyles = (
scroll-behavior: auto !important;
}
}
#__next {
height: 100%;
}
`}
/>
);
Expand Down
2 changes: 0 additions & 2 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import PageLayout from '../components/PageLayout';
import Box from '../components/Box';
import Spacer from '../components/Spacer';
Expand Down
16 changes: 11 additions & 5 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import 'resize-observer-polyfill';

import { UserProvider } from '@auth0/nextjs-auth0';
import { MapStateProvider } from '../components/MapState';
import PlausibleProvider from 'next-plausible';

const App = ({ Component, pageProps }) => (
<UserProvider>
<MapStateProvider>
<Component {...pageProps} />
</MapStateProvider>
</UserProvider>
<PlausibleProvider
domain="toiletmap.org.uk"
customDomain="https://stats.toiletmap.org.uk/"
>
<UserProvider>
<MapStateProvider>
<Component {...pageProps} />
</MapStateProvider>
</UserProvider>
</PlausibleProvider>
);

export default App;
52 changes: 0 additions & 52 deletions src/pages/_document.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions src/pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import Link from 'next/link';
import Head from 'next/head';
import styled from '@emotion/styled';
Expand Down Expand Up @@ -30,7 +29,7 @@ const SubHeading = (props: TextProps) => (
</>
);

const AboutPage = (props) => {
const AboutPage = () => {
return (
<PageLayout layoutMode="blog">
<Head>
Expand Down
3 changes: 1 addition & 2 deletions src/pages/contact.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import Head from 'next/head';

import PageLayout from '../components/PageLayout';
Expand All @@ -10,7 +9,7 @@ import Spacer from '../components/Spacer';
import config from '../config';
import { NextPage } from 'next';

const ContactPage = (props) => {
const ContactPage = () => {
return (
<PageLayout layoutMode="blog">
<Head>
Expand Down
2 changes: 0 additions & 2 deletions src/pages/cookies.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';
import Link from 'next/link';
import Head from 'next/head';

import PageLayout from '../components/PageLayout';
Expand Down
10 changes: 1 addition & 9 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import VisuallyHidden from '../components/VisuallyHidden';
import { useMapState } from '../components/MapState';
import config from '../config';
import { withApollo } from '../components/withApollo';
import { GetServerSideProps } from 'next';
import useFilters from '../hooks/useFilters';
import { dbConnect } from '../api/db';
import { ssrUkLooMarkers, PageUkLooMarkersComp } from '../api-client/page';

const SIDEBAR_BOTTOM_MARGIN = 32;
const MapLoader = () => <p>Loading map...</p>;
Expand All @@ -19,7 +16,7 @@ const LooMap = dynamic(() => import('../components/LooMap'), {
ssr: false,
});

const HomePage: PageUkLooMarkersComp = (props) => {
const HomePage = () => {
const [mapState, setMapState] = useMapState();

const { filters, setFilters } = useFilters([]);
Expand Down Expand Up @@ -71,9 +68,4 @@ const HomePage: PageUkLooMarkersComp = (props) => {
);
};

// export const getStaticProps: GetServerSideProps = async ({ params, req }) => {
// await dbConnect();
// return await ssrUkLooMarkers.getServerPage({}, { req });
// };

export default withApollo(HomePage);
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7338,6 +7338,11 @@ neo-async@^2.6.1:
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f"
integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==

next-plausible@3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/next-plausible/-/next-plausible-3.1.4.tgz#a386ff4e2327995cb4a1307e53e1b4af70817b52"
integrity sha512-NMLKJ0AKlKuvYU//RytyqSES5NtLRoH/ym3fCC02w2Ed1SrTgNRUrgpxyJrcguY/DYGPncQ3a0/nQ358vUTAwQ==

next@12.0.1:
version "12.0.1"
resolved "https://registry.yarnpkg.com/next/-/next-12.0.1.tgz#7b82a73bc185bfda7372e7e8309f9b38e6be9cb0"
Expand Down

0 comments on commit 1d762e7

Please sign in to comment.