replace splitbee and panelbear with fathom

This commit is contained in:
m5r
2022-07-02 01:49:12 +02:00
parent 06f0078dfd
commit a8491e28a5
13 changed files with 76 additions and 87 deletions

View File

@ -0,0 +1,21 @@
import { useEffect } from "react";
import { useLocation } from "@remix-run/react";
import * as Fathom from "fathom-client";
export default function useFathom() {
const location = useLocation();
useEffect(() => {
const { fathom, app } = window.shellphoneConfig;
Fathom.load(fathom.siteId, {
spa: "history",
url: fathom.domain ? `https://${fathom.domain}/script.js` : undefined,
includedDomains: [app.baseUrl.replace("https://", "")],
});
}, []);
useEffect(() => {
console.log(`tracking ${location.pathname}`);
Fathom.trackPageview();
}, [location]);
}

View File

@ -1,21 +0,0 @@
import { useEffect } from "react";
import { useLocation } from "@remix-run/react";
import * as Panelbear from "@panelbear/panelbear-js";
import type { PanelbearConfig } from "@panelbear/panelbear-js";
export default function usePanelbear(siteId: string, config: PanelbearConfig = {}) {
const location = useLocation();
useEffect(() => {
Panelbear.load(siteId, {
scriptSrc: "/bear.js",
spaMode: "off",
autoTrack: false,
...config,
});
}, []);
useEffect(() => {
Panelbear.trackPageview();
}, [location]);
}