mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-06-30 22:46:39 -04:00
re-add fathom
couldn't sleep at night even with a few days of google analytics...
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
// Site info
|
||||
export const siteName = "Jake Jarvis";
|
||||
export const siteDomain = "https://jarv.is";
|
||||
export const siteDomain = "jarv.is";
|
||||
export const shortDescription = "Front-End Web Developer in Boston, MA 👨💻";
|
||||
export const longDescription =
|
||||
"Hi there! I'm a frontend web developer based in Boston, Massachusetts specializing in the JAMstack, modern JavaScript frameworks, and progressive web apps.";
|
||||
export const githubRepo = "jakejarvis/jarv.is";
|
||||
export const fathomSiteId = "WBGNQUKW";
|
||||
|
||||
let baseURL = ""; // default to relative URLs
|
||||
if (process.env.NEXT_PUBLIC_VERCEL_ENV === "production") {
|
||||
// vercel production (set manually above)
|
||||
baseURL = siteDomain;
|
||||
baseURL = `https://${siteDomain}`;
|
||||
} else if (process.env.NEXT_PUBLIC_VERCEL_URL) {
|
||||
// vercel deploy previews
|
||||
baseURL = `https://${process.env.NEXT_PUBLIC_VERCEL_URL}`;
|
||||
|
@ -38,6 +38,7 @@
|
||||
"classnames": "^2.3.1",
|
||||
"copy-to-clipboard": "^3.3.1",
|
||||
"date-fns": "^2.28.0",
|
||||
"fathom-client": "^3.2.0",
|
||||
"faunadb": "^4.4.1",
|
||||
"feed": "^4.2.2",
|
||||
"gray-matter": "^4.0.3",
|
||||
|
@ -6,6 +6,7 @@ import { useRouter } from "next/router";
|
||||
import Script from "next/script";
|
||||
import type { AppProps } from "next/app";
|
||||
import { DefaultSeo, SocialProfileJsonLd } from "next-seo";
|
||||
import * as Fathom from "fathom-client";
|
||||
import * as config from "../lib/config";
|
||||
|
||||
import meJpg from "../public/static/images/me.jpg";
|
||||
@ -18,20 +19,24 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
const router = useRouter();
|
||||
|
||||
useEffect(() => {
|
||||
// https://nextjs.org/docs/messages/next-script-for-ga
|
||||
// https://developers.google.com/analytics/devguides/collection/gtagjs/single-page-applications#measure_virtual_pageviews
|
||||
const handlePageview = (url: string) => {
|
||||
if (typeof window.gtag === "function") {
|
||||
window.gtag("set", "page_path", url);
|
||||
window.gtag("event", "page_view");
|
||||
}
|
||||
// https://usefathom.com/docs/integrations/next
|
||||
// https://vercel.com/guides/deploying-nextjs-using-fathom-analytics-with-vercel
|
||||
Fathom.load(config.fathomSiteId, {
|
||||
includedDomains: [config.siteDomain],
|
||||
});
|
||||
|
||||
const onRouteChangeComplete = () => {
|
||||
Fathom.trackPageview();
|
||||
};
|
||||
|
||||
router.events.on("routeChangeComplete", handlePageview);
|
||||
// send ping when route changes
|
||||
router.events.on("routeChangeComplete", onRouteChangeComplete);
|
||||
|
||||
return () => {
|
||||
router.events.off("routeChangeComplete", handlePageview);
|
||||
// unassign event listener
|
||||
router.events.off("routeChangeComplete", onRouteChangeComplete);
|
||||
};
|
||||
}, [router.events]);
|
||||
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -153,15 +158,6 @@ try {
|
||||
document.documentElement.setAttribute("data-theme", dark ? "dark" : "light");
|
||||
} catch (e) {}`}</Script>
|
||||
|
||||
<Script src={`https://www.googletagmanager.com/gtag/js?id=UA-1563964-4`} strategy="afterInteractive" />
|
||||
<Script id="ga4" strategy="afterInteractive">{`
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'UA-1563964-4', {
|
||||
anonymize_ip: true
|
||||
});`}</Script>
|
||||
|
||||
<Component {...pageProps} />
|
||||
</>
|
||||
);
|
||||
|
@ -12,7 +12,7 @@ Sentry.init({
|
||||
environment: process.env.NODE_ENV || process.env.VERCEL_ENV || process.env.NEXT_PUBLIC_VERCEL_ENV || "",
|
||||
});
|
||||
|
||||
const BASE_URL = config.baseURL === "" ? `${config.siteDomain}/` : `${config.baseURL}/`;
|
||||
const BASE_URL = config.baseURL === "" ? `https://${config.siteDomain}/` : `${config.baseURL}/`;
|
||||
|
||||
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
try {
|
||||
|
@ -2852,6 +2852,11 @@ fastq@^1.6.0:
|
||||
dependencies:
|
||||
reusify "^1.0.4"
|
||||
|
||||
fathom-client@^3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/fathom-client/-/fathom-client-3.2.0.tgz#781c0b11db90e0ffc5061709dc890a1d2b94ef62"
|
||||
integrity sha512-WF/qA5wXYSuA5K8uiIhGNbErOcTAmfLEWrBxWP2px2dEc9waH9zxjdh9k0F907VCBhdJrv+f7V3HT/Pmro40zA==
|
||||
|
||||
fault@^2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fault/-/fault-2.0.1.tgz#d47ca9f37ca26e4bd38374a7c500b5a384755b6c"
|
||||
|
Reference in New Issue
Block a user