Skip to content

Commit

Permalink
Made tracking client side only
Browse files Browse the repository at this point in the history
  • Loading branch information
amykapernick committed Jul 7, 2024
1 parent aa71e44 commit ccb3b4c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 48 deletions.
82 changes: 41 additions & 41 deletions src/components/fathom/index.tsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
"use client"
"use client";

import { load, trackEvent, trackPageview } from "fathom-client"
import { usePathname, useSearchParams } from "next/navigation"
import { Suspense, useEffect } from "react"
import { load, trackEvent, trackPageview } from "fathom-client";
import { usePathname, useSearchParams } from "next/navigation";
import { Suspense, useEffect } from "react";
import { getReplay } from "@sentry/nextjs";

type EventTypes = 'Signed In' | 'Gift Claimed' | 'RSVP Form Submitted' | 'Initial RSVP'
type EventTypes = "Signed In" | "Gift Claimed" | "RSVP Form Submitted" | "Initial RSVP";

const TrackPageView = () =>
{
const pathname = usePathname()
const searchParams = useSearchParams()
const TrackPageView = () => {
const pathname = usePathname();
const searchParams = useSearchParams();

useEffect(() =>
{
useEffect(() => {
load(process.env.NEXT_PUBLIC_FATHOM_SITE ?? "", {
includedDomains: [process.env.URL ?? ""]
})
}, [])

useEffect(() =>
{
trackPageview()
}, [pathname, searchParams])

return null
}

export const TrackEvent = ({ name }: { name: EventTypes }) =>
{
useEffect(() =>
{
includedDomains: [process.env.URL ?? ""],
});
}, []);

useEffect(() => {
trackPageview();
}, [pathname, searchParams]);

return null;
};

export const TrackEvent = ({ name }: { name: EventTypes }) => {
useEffect(() => {
load(process.env.NEXT_PUBLIC_FATHOM_SITE ?? "", {
includedDomains: [process.env.URL ?? ""]
})
}, [])
includedDomains: [process.env.URL ?? ""],
});
}, []);

useEffect(() => {
trackEvent(name);
}, [name]);

return null;
};

useEffect(() =>
{
trackEvent(name)
}, [name])
const Fathom = () => {
const replay = getReplay();

return null
}
if (replay && !replay?._replay?.isEnabled()) {
replay.start();
}

const Fathom = () =>
{
return (
<Suspense fallback={null}>
<TrackPageView />
</Suspense>
)
}
);
};

export default Fathom
export default Fathom;
8 changes: 1 addition & 7 deletions utils/fetchData/currentGuest.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import { currentUser } from "@clerk/nextjs/server";
import type { NotionGuest } from "@ts/people";
import type { User } from "@clerk/nextjs/server";
import { captureException, getReplay } from "@sentry/nextjs";
import { captureException } from "@sentry/nextjs";
import notion from './notion'

const fetchCurrentGuest = async (guestId?: string) =>
{
const replay = getReplay();

if (replay)
{
replay.start()
}

const { emailAddresses } = (await currentUser()) as User;

Expand Down

0 comments on commit ccb3b4c

Please sign in to comment.