add paywall events
This commit is contained in:
parent
9655ff7102
commit
d778f61f33
1 changed files with 11 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ import { api } from "~/utils/api";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { CheckIcon } from "@heroicons/react/20/solid";
|
import { CheckIcon } from "@heroicons/react/20/solid";
|
||||||
import Tooltip from "~/components/Tooltip";
|
import Tooltip from "~/components/Tooltip";
|
||||||
|
import { usePostHog } from "posthog-js/react";
|
||||||
|
|
||||||
export default function Paywall() {
|
export default function Paywall() {
|
||||||
const { mutateAsync: createCheckoutSession } =
|
const { mutateAsync: createCheckoutSession } =
|
||||||
|
|
@ -14,9 +15,12 @@ export default function Paywall() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [open, setOpen] = useAtom(paywallAtom);
|
const [open, setOpen] = useAtom(paywallAtom);
|
||||||
const [billedAnnually, setBilledAnnually] = useState<boolean>(false);
|
const [billedAnnually, setBilledAnnually] = useState<boolean>(false);
|
||||||
|
const posthog = usePostHog();
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
|
||||||
|
posthog?.capture("close paywall");
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleCheckout = async () => {
|
const handleCheckout = async () => {
|
||||||
|
|
@ -26,6 +30,12 @@ export default function Paywall() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toggleBillingCycle = () => {
|
||||||
|
setBilledAnnually(!billedAnnually);
|
||||||
|
|
||||||
|
posthog?.capture("change billing cycle");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Transition appear show={open} as={Fragment}>
|
<Transition appear show={open} as={Fragment}>
|
||||||
<Dialog as="div" className="relative z-10" onClose={closeModal}>
|
<Dialog as="div" className="relative z-10" onClose={closeModal}>
|
||||||
|
|
@ -85,7 +95,7 @@ export default function Paywall() {
|
||||||
<span className=" svelte-10wstod">Monthly</span>
|
<span className=" svelte-10wstod">Monthly</span>
|
||||||
<label className="group relative flex cursor-pointer items-center gap-2 text-sm font-medium text-gray-600">
|
<label className="group relative flex cursor-pointer items-center gap-2 text-sm font-medium text-gray-600">
|
||||||
<input
|
<input
|
||||||
onChange={() => setBilledAnnually(!billedAnnually)}
|
onChange={toggleBillingCycle}
|
||||||
checked={billedAnnually}
|
checked={billedAnnually}
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
className="peer absolute left-1/2 hidden h-full w-full -translate-x-1/2 rounded-md"
|
className="peer absolute left-1/2 hidden h-full w-full -translate-x-1/2 rounded-md"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue