The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Add Fathom
Steven Tey398dafe124be
diff --git a/apps/web/app/app.dub.co/(auth)/welcome/page-client.tsx b/apps/web/app/app.dub.co/(auth)/welcome/page-client.tsxindex 1e350c0285..e27601235c 100644--- a/apps/web/app/app.dub.co/(auth)/welcome/page-client.tsx+++ b/apps/web/app/app.dub.co/(auth)/welcome/page-client.tsx@@ -3,6 +3,7 @@import { useAddWorkspaceModal } from "@/ui/modals/add-workspace-modal";import { useUpgradePlanModal } from "@/ui/modals/upgrade-plan-modal";import Intro from "@/ui/welcome/intro";+import { trackEvent } from "fathom-client";import { AnimatePresence } from "framer-motion";import { ArrowLeft } from "lucide-react";import { useSession } from "next-auth/react";@@ -24,6 +25,7 @@ export default function WelcomePageClient() {const { data: session } = useSession();useEffect(() => {+ trackEvent("Signed Up");plausible("Signed Up");if (session?.user) {posthog.identify(session.user["id"], {diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/page-client.tsxindex 0c7d00ef86..66b66d3d4a 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/billing/page-client.tsx@@ -13,6 +13,7 @@ import {useRouterStuff,} from "@dub/ui";import { getFirstAndLastDay, getPlanDetails, nFormatter } from "@dub/utils";+import { trackEvent } from "fathom-client";import { usePlausible } from "next-plausible";import { useRouter, useSearchParams } from "next/navigation";import posthog from "posthog-js";@@ -76,6 +77,9 @@ export default function WorkspaceBillingClient() {const currentPlan = plan ? getPlanDetails(plan) : undefined;if (currentPlan && currentPlan.price.monthly) {// track upgrade event+ trackEvent(`Upgraded to ${currentPlan.name}`, {+ _value: currentPlan.price.monthly * 100, // in cents+ });plausible("Upgraded Plan", {props: {},revenue: {diff --git a/apps/web/app/providers.tsx b/apps/web/app/providers.tsxindex 2f2393fcf8..072dfd65da 100644--- a/apps/web/app/providers.tsx+++ b/apps/web/app/providers.tsx@@ -1,5 +1,6 @@"use client";+import { Fathom } from "@/ui/layout/fathom";import { PosthogPageview } from "@/ui/layout/posthog-pageview";import { ModalProvider } from "@/ui/modals/modal-provider";import { KeyboardShortcutProvider } from "@dub/ui";@@ -34,6 +35,7 @@ export default function Providers({ children }: { children: ReactNode }) {<SessionProvider><ModalProvider><KeyboardShortcutProvider>+ <Fathom /><PosthogPageview />{children}</KeyboardShortcutProvider>diff --git a/apps/web/package.json b/apps/web/package.jsonindex 61bb2a213a..2332dbe47b 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -64,6 +64,7 @@"d3-array": "^3.2.4","date-fns": "^3.6.0","dub": "^0.32.0",+ "fathom-client": "^3.7.2","framer-motion": "^10.16.16","fuse.js": "^6.6.2","github-slugger": "^2.0.0",diff --git a/apps/web/ui/layout/fathom.tsx b/apps/web/ui/layout/fathom.tsxnew file mode 100644index 0000000000..d3ff271ca9--- /dev/null+++ b/apps/web/ui/layout/fathom.tsx@@ -0,0 +1,27 @@+import { load, trackPageview } from "fathom-client";+import { usePathname, useSearchParams } from "next/navigation";+import { Suspense, useEffect } from "react";++export function Fathom() {+ return (+ <Suspense>+ <TrackPageView />+ </Suspense>+ );+}++function TrackPageView() {+ const pathname = usePathname();+ const searchParams = useSearchParams();++ useEffect(() => {+ load("ORFDPXEC");+ }, []);++ // Record a pageview when route changes+ useEffect(() => {+ trackPageview();+ }, [pathname, searchParams]);++ return null;+}diff --git a/apps/web/ui/modals/add-workspace-modal.tsx b/apps/web/ui/modals/add-workspace-modal.tsxindex bcb1fb524c..f071429929 100644--- a/apps/web/ui/modals/add-workspace-modal.tsx+++ b/apps/web/ui/modals/add-workspace-modal.tsx@@ -8,6 +8,7 @@ import {useRouterStuff,} from "@dub/ui";import slugify from "@sindresorhus/slugify";+import { trackEvent } from "fathom-client";import { usePlausible } from "next-plausible";import { usePathname, useRouter, useSearchParams } from "next/navigation";import posthog from "posthog-js";@@ -101,6 +102,7 @@ function AddWorkspaceModalHelper({}).then(async (res) => {if (res.status === 200) {const { id: workspaceId } = await res.json();+ trackEvent("Created Workspace");plausible("Created Workspace");// track workspace creation eventposthog.capture("workspace_created", {diff --git a/apps/web/ui/modals/upgrade-plan-modal.tsx b/apps/web/ui/modals/upgrade-plan-modal.tsxindex ada00f8477..1aae639a81 100644--- a/apps/web/ui/modals/upgrade-plan-modal.tsx+++ b/apps/web/ui/modals/upgrade-plan-modal.tsx@@ -20,6 +20,7 @@ import {capitalize,cn,} from "@dub/utils";+import { trackEvent } from "fathom-client";import { motion } from "framer-motion";import { ChevronDown } from "lucide-react";import { usePlausible } from "next-plausible";@@ -317,6 +318,7 @@ function UpgradePlanModal({}),}).then(async (res) => {+ trackEvent("Opened Checkout");plausible("Opened Checkout");posthog.capture("checkout_opened", {currentPlan: capitalize(currentPlan),diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 24030ccfd5..39d5744a4b 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -188,6 +188,9 @@ importers:dub:specifier: ^0.32.0version: 0.32.0([email protected])+ fathom-client:+ specifier: ^3.7.2+ version: 3.7.2framer-motion:specifier: ^10.16.16version: 10.18.0([email protected])([email protected])@@ -12124,6 +12127,10 @@ packages:dependencies:reusify: 1.0.4+ resolution: {integrity: sha512-sWtaNivhg7uwp/q1bUuIiNj4LeQZMEZ5NXXFFpZ8le4uDedAfQG84gPOdYehtVXbl+1yX2s8lmXZ2+IQ9a/xxA==}+ dev: false+resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==}dependencies: