diff --git a/components/elements/CustomButton/index.tsx b/components/elements/CustomButton/index.tsx index 8da885b6..84f86fc8 100644 --- a/components/elements/CustomButton/index.tsx +++ b/components/elements/CustomButton/index.tsx @@ -5,64 +5,93 @@ import Link from "next/link"; import { FC, ReactNode } from "react"; import styles from "./CustomButton.module.css"; -interface CommonButtonProps - extends React.ButtonHTMLAttributes { - variant: "primary" | "secondary" | "tertiary" | "blackwhite"; +type ButtonVariant = "primary" | "secondary" | "tertiary" | "blackwhite"; + +interface CommonProps { + variant: ButtonVariant; children: ReactNode; invertOnDark?: boolean; + className?: string; } -interface ButtonProps extends CommonButtonProps { - href?: string; -} +type AnchorProps = CommonProps & + React.AnchorHTMLAttributes & { + href: string; + }; + +type NativeButtonProps = CommonProps & + React.ButtonHTMLAttributes & { + href?: undefined; + }; -const CustomButton: FC = ({ - variant = "none", - invertOnDark, - className, - children, - href, -}) => { - // Primary and secondary switch for dark mode +type ButtonProps = AnchorProps | NativeButtonProps; - const classNames = clsx( +const getButtonClassNames = ( + variant: ButtonVariant, + invertOnDark?: boolean, + className?: string, +) => + clsx( `${styles.button} flex relative items-center gap-2 whitespace-nowrap px-6 py-3`, - variant === "primary" - ? invertOnDark + variant === "primary" && + (invertOnDark ? `bg-black text-head dark:bg-[#D8D8D8] dark:text-black dark:hover:bg-gradient-to-r dark:hover:from-[#fc540c] dark:hover:to-[#f5c57a] dark:hover:text-white` - : `bg-[#E9E9E9] text-black hover:bg-gradient-to-r hover:from-[#fc540c] hover:to-[#f5c57a] hover:text-white` - : "", - variant === "secondary" - ? `${styles.secondaryButton} ${styles.secondaryButtonShadow} ${styles.secondaryButtonBorderGradient} text-head` - : "", + : `bg-[#E9E9E9] text-black hover:bg-gradient-to-r hover:from-[#fc540c] hover:to-[#f5c57a] hover:text-white`), + variant === "secondary" && + `${styles.secondaryButton} ${styles.secondaryButtonShadow} ${styles.secondaryButtonBorderGradient} text-head`, variant === "tertiary" && - "${styles.buttonShadow} ${styles.shadowGradient} text-black", + `${styles.buttonShadow} ${styles.shadowGradient} text-black`, variant === "blackwhite" && - "border-[1px] border-solid border-[#ffffff40] px-6 py-3 font-gradual text-base text-white hover:bg-gradient-1", + "border border-[#ffffff40] px-6 py-3 font-gradual text-base text-white hover:bg-gradient-1", className, ); - const tertBg = { - backgroundImage: - "linear-gradient(73deg, #FC540C -7.95%, rgba(255, 215, 111, 0.72) 45.94%, #38D4E9 116.73%", - }; +const CustomButton: FC = (props) => { + const { variant, invertOnDark, className, children, href, ...rest } = props; - children = ( - - ); + const classNames = getButtonClassNames(variant, invertOnDark, className); + const style = + variant === "tertiary" + ? { + backgroundImage: + "linear-gradient(73deg, #FC540C -7.95%, rgba(255, 215, 111, 0.72) 45.94%, #38D4E9 116.73%)", + } + : undefined; + + if (href) { + const anchorProps = rest as React.AnchorHTMLAttributes; - if (href) - if (href.startsWith("/")) children = {children}; - else - children = ( - - {children} - + if (href.startsWith("/")) { + return ( + + + ); + } + + return ( + + {children} + + ); + } + + const buttonProps = rest as React.ButtonHTMLAttributes; - return children; + return ( + + ); }; export default CustomButton; diff --git a/components/sections/Pricing/PricingCards/PricingButton.tsx b/components/sections/Pricing/PricingCards/PricingButton.tsx index ba075f1b..70b73243 100644 --- a/components/sections/Pricing/PricingCards/PricingButton.tsx +++ b/components/sections/Pricing/PricingCards/PricingButton.tsx @@ -7,6 +7,7 @@ interface PricingButtonProps { variant?: "default" | "highlight"; collapsed?: boolean; href?: string; + onClick?: () => void; } export const PricingButton: React.FC = ({ @@ -14,6 +15,7 @@ export const PricingButton: React.FC = ({ variant = "default", collapsed, href, + onClick, }) => { return ( = ({ "xl:mt-4": collapsed, "xl:mt-8": !collapsed, })} + onClick={onClick} > {text} diff --git a/components/sections/Pricing/PricingCards/PricingCard.tsx b/components/sections/Pricing/PricingCards/PricingCard.tsx index c4744fc3..b390188e 100644 --- a/components/sections/Pricing/PricingCards/PricingCard.tsx +++ b/components/sections/Pricing/PricingCards/PricingCard.tsx @@ -13,6 +13,7 @@ export interface PricingCardProps { href: string; icon: React.ComponentType; collapsed?: boolean; + onClick?: () => void; } export const PricingCard: React.FC = ({ @@ -26,6 +27,7 @@ export const PricingCard: React.FC = ({ href = "", icon, collapsed, + onClick, }) => { const featuresListClassName = collapsed ? "xl:max-h-0" : "xl:max-h-[300px]"; @@ -71,6 +73,7 @@ export const PricingCard: React.FC = ({ text={buttonText} variant={buttonVariant} href={href} + onClick={onClick} /> diff --git a/components/sections/Pricing/PricingCards/PricingCards.tsx b/components/sections/Pricing/PricingCards/PricingCards.tsx index d39cfc8f..c4bab11a 100644 --- a/components/sections/Pricing/PricingCards/PricingCards.tsx +++ b/components/sections/Pricing/PricingCards/PricingCards.tsx @@ -1,5 +1,6 @@ "use client"; import React, { useEffect, useRef, useState } from "react"; +import { trackEvent } from "lib/posthog"; import { PricingCard, PricingCardProps } from "./PricingCard"; import { CheckIcon } from "components/svgs/pricing-icons/CheckIcon"; import { CONTACT_US_URI, GET_STARTED_URI } from "../../../../lib/constants"; @@ -21,6 +22,9 @@ const pricingTiers: PricingCardProps[] = [ buttonVariant: "highlight", href: GET_STARTED_URI, icon: CheckIcon, + onClick: () => { + trackEvent("pricing_click_tier_community"); + }, }, { title: "Pro", @@ -37,6 +41,9 @@ const pricingTiers: PricingCardProps[] = [ buttonVariant: "highlight", href: GET_STARTED_URI, icon: CheckIcon, + onClick: () => { + trackEvent("pricing_click_tier_pro"); + }, }, { title: "Growth", @@ -52,6 +59,9 @@ const pricingTiers: PricingCardProps[] = [ buttonText: "Start 14 day trial", href: GET_STARTED_URI, icon: CheckIcon, + onClick: () => { + trackEvent("pricing_click_tier_growth"); + }, }, { title: "Enterprise", @@ -68,6 +78,9 @@ const pricingTiers: PricingCardProps[] = [ buttonVariant: "highlight", href: CONTACT_US_URI, icon: CheckIcon, + onClick: () => { + trackEvent("pricing_click_tier_enterprise"); + }, }, ]; @@ -102,11 +115,6 @@ const PricingCards = () => { ref={ref} className="absolute left-0 w-full h-[100px] opacity-0 -z-10 -translate-y-[10px]" /> - {/**/}
) { posthog.capture(event, properties); } + +export function TrackUniqueUsers() { + posthog.capture("page_view", { + path: window.location.pathname, + user: posthog.get_distinct_id(), + }); +} diff --git a/pages/pricing.tsx b/pages/pricing.tsx index e90f13a7..527b1e68 100644 --- a/pages/pricing.tsx +++ b/pages/pricing.tsx @@ -1,11 +1,11 @@ -import React, { ReactNode } from "react"; +import React, { ReactNode, useEffect } from "react"; import { NextSeo } from "next-seo"; import { GetStaticPropsResult } from "next"; import { QuestionAttrs } from "../components/sections/FrequentlyAskedQuestions"; import { pricingQuestions } from "../content"; +import { TrackUniqueUsers } from "lib/posthog"; import { Page } from "components/templates"; import FeatureList from "components/sections/Pricing/FeatureList"; -import { BackgroundShape } from "../components/BackgroundShape"; import { ImageSection } from "../components/sections/Pricing/ImageSection"; import PricingCards from "../components/sections/Pricing/PricingCards/PricingCards"; import { PricingComparison } from "../components/sections/Pricing/Comparison/PricingComparison"; @@ -28,6 +28,10 @@ interface Props { } export default function PricingPage({ questions }: Props) { + useEffect(() => { + TrackUniqueUsers(); + }, []); + return (
- {/**/}