-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aa71e44
commit ccb3b4c
Showing
2 changed files
with
42 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters