replace splitbee and panelbear with fathom
This commit is contained in:
21
app/features/core/hooks/use-fathom.ts
Normal file
21
app/features/core/hooks/use-fathom.ts
Normal 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]);
|
||||
}
|
@ -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]);
|
||||
}
|
@ -145,6 +145,7 @@ async function setTwilioCredentials(request: Request, formData: unknown) {
|
||||
await Promise.all(
|
||||
phoneNumbers.map(async (phoneNumber) => {
|
||||
const phoneNumberId = phoneNumber.sid;
|
||||
logger.info(`Importing phone number with id=${phoneNumberId}`);
|
||||
try {
|
||||
await db.phoneNumber.create({
|
||||
data: {
|
||||
@ -166,6 +167,8 @@ async function setTwilioCredentials(request: Request, formData: unknown) {
|
||||
}),
|
||||
]);
|
||||
} catch (error: any) {
|
||||
logger.error(error);
|
||||
|
||||
if (error.code !== "P2002") {
|
||||
// if it's not a duplicate, it's a real error we need to handle
|
||||
throw error;
|
||||
|
Reference in New Issue
Block a user