-
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
c05fe4b
commit 4718879
Showing
12 changed files
with
269 additions
and
55 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client" | ||
|
||
import { load, trackEvent, trackPageview } from "fathom-client" | ||
import { usePathname, useSearchParams } from "next/navigation" | ||
import { Suspense, useEffect } from "react" | ||
|
||
type EventTypes = 'Signed In' | 'Gift Claimed' | 'RSVP Form Submitted' | 'Initial RSVP' | ||
|
||
const TrackPageView = () => | ||
{ | ||
const pathname = usePathname() | ||
const searchParams = useSearchParams() | ||
|
||
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(() => | ||
{ | ||
load(process.env.NEXT_PUBLIC_FATHOM_SITE, { | ||
includedDomains: [process.env.URL] | ||
}) | ||
}, []) | ||
|
||
useEffect(() => | ||
{ | ||
trackEvent(name) | ||
}, [name]) | ||
|
||
return null | ||
} | ||
|
||
const Fathom = () => | ||
{ | ||
return ( | ||
<Suspense fallback={null}> | ||
<TrackPageView /> | ||
</Suspense> | ||
) | ||
} | ||
|
||
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
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
Oops, something went wrong.