📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
redesign pricing component
Blue Moused342508289c1
diff --git a/web/app/components/marketing/FAQ.tsx b/web/app/components/marketing/FAQ.tsxnew file mode 100644index 000000000..677529b20--- /dev/null+++ b/web/app/components/marketing/FAQ.tsx@@ -0,0 +1,117 @@+import _map from 'lodash/map'+import { ChevronDownIcon } from 'lucide-react'+import { Trans, useTranslation } from 'react-i18next'+import { Link } from 'react-router'++import { DOCS_URL, PLAN_LIMITS, TRIAL_DAYS, DISCORD_URL } from '~/lib/constants'+import { cn } from '~/utils/generic'+import routesPath from '~/utils/routes'++const FAQ = () => {+ const { t } = useTranslation('common')++ const onLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {+ e.stopPropagation()+ }++ const values = {+ lowestPlanEventsAmount: PLAN_LIMITS.hobby.monthlyUsageLimit.toLocaleString('en-US'),+ moderatePlanEventsAmount: PLAN_LIMITS.freelancer.monthlyUsageLimit.toLocaleString('en-US'),+ freeTrialDays: TRIAL_DAYS,+ }+ const stripTags = (html: string) => html.replace(/<[^>]+>/g, '')+ const items = t('main.faq.items', { returnObjects: true }) as { q: string; a: string }[]+ const structuredData = {+ '@context': 'https://schema.org',+ '@type': 'FAQPage',+ mainEntity: items.map((_, idx) => ({+ '@type': 'Question',+ name: t(`main.faq.items.${idx}.q`),+ acceptedAnswer: {+ '@type': 'Answer',+ text: stripTags(+ t(`main.faq.items.${idx}.a`, {+ ...values,+ }),+ ),+ },+ })),+ }++ return (+ <section className='relative mx-auto max-w-5xl px-6 py-14 lg:px-8'>+ <h2 className='text-center text-3xl font-extrabold text-slate-900 sm:text-4xl dark:text-white'>+ {t('main.faq.title')}+ </h2>+ <div className='mt-8 flex flex-col'>+ {_map(items, (item: { q: string; a: string }, idx: number) => {+ const showTopBorder = idx !== 0++ return (+ <details+ key={item.q}+ className={cn('group w-full text-left', showTopBorder && 'border-t border-gray-200 dark:border-white/10')}+ >+ <summary className='flex w-full cursor-pointer items-center justify-between px-5 py-4'>+ <span className='text-base font-medium text-slate-900 group-hover:underline dark:text-gray-100'>+ <Trans t={t} i18nKey={`main.faq.items.${idx}.q`} />+ </span>+ <ChevronDownIcon className='size-4 text-slate-900 transition-transform group-open:rotate-180 dark:text-gray-300' />+ </summary>+ <div className='px-5'>+ <p className='pb-4 text-sm whitespace-pre-line text-slate-700 dark:text-gray-300'>+ <Trans+ t={t}+ i18nKey={`main.faq.items.${idx}.a`}+ values={values}+ components={{+ dataPolicyUrl: (+ <Link+ to={routesPath.dataPolicy}+ className='underline decoration-dashed hover:decoration-solid'+ aria-label='Data policy'+ onClick={onLinkClick}+ />+ ),+ apiDocumentationUrl: (+ <a+ href={DOCS_URL}+ className='underline decoration-dashed hover:decoration-solid'+ target='_blank'+ rel='noopener noreferrer'+ aria-label='API documentation (opens in a new tab)'+ onClick={onLinkClick}+ />+ ),+ contactUsUrl: (+ <Link+ to={routesPath.contact}+ className='underline decoration-dashed hover:decoration-solid'+ aria-label='Contact us'+ onClick={onLinkClick}+ />+ ),+ discordUrl: (+ <a+ href={DISCORD_URL}+ className='underline decoration-dashed hover:decoration-solid'+ target='_blank'+ rel='noopener noreferrer'+ aria-label='Discord (opens in a new tab)'+ onClick={onLinkClick}+ />+ ),+ }}+ />+ </p>+ </div>+ </details>+ )+ })}+ </div>+ <script type='application/ld+json'>{JSON.stringify(structuredData, null, 2)}</script>+ </section>+ )+}++export default FAQdiff --git a/web/app/components/marketing/Pricing.tsx b/web/app/components/marketing/Pricing.tsxdeleted file mode 100644index 232b3cb4f..000000000--- a/web/app/components/marketing/Pricing.tsx+++ /dev/null@@ -1,600 +0,0 @@-import { Label, Radio, RadioGroup } from '@headlessui/react'-import { CheckIcon } from '@heroicons/react/24/solid'-import cx from 'clsx'-import dayjs from 'dayjs'-import _includes from 'lodash/includes'-import _isNil from 'lodash/isNil'-import _map from 'lodash/map'-import React, { memo, useState, useEffect } from 'react'-import { Trans, useTranslation } from 'react-i18next'-import { Link } from 'react-router'-import { ClientOnly } from 'remix-utils/client-only'-import { toast } from 'sonner'--import { previewSubscriptionUpdate, changeSubscriptionPlan, getPaymentMetainfo } from '~/api'-import {- CONTACT_EMAIL,- paddleLanguageMapping,- PLAN_LIMITS,- CURRENCIES,- BillingFrequency,- REFERRAL_DISCOUNT_CODE,- STANDARD_PLANS,- TRIAL_DAYS,-} from '~/lib/constants'-import { DEFAULT_METAINFO, Metainfo } from '~/lib/models/Metainfo'-import { useAuth } from '~/providers/AuthProvider'-import { useTheme } from '~/providers/ThemeProvider'-import { Badge } from '~/ui/Badge'-import Button from '~/ui/Button'-import Loader from '~/ui/Loader'-import Modal from '~/ui/Modal'-import { cn } from '~/utils/generic'-import routes from '~/utils/routes'--const getPaidFeatures = (t: any, tier: any) => {- return [- t('pricing.tiers.upToXVMo', { amount: tier.monthlyUsageLimit.toLocaleString('en-US') }),- t('pricing.tiers.upToXWebsites', { amount: 50 }),- t('pricing.tiers.xAlertsPlural', { amount: 50 }),- t('pricing.tiers.userFlowAnalysis'),- t('pricing.tiers.dataExports'),- t('pricing.tiers.dataOwnership'),- t('main.competitiveFeatures.perf'),- t('pricing.tiers.dashboards'),- t('pricing.tiers.reports'),- ]-}--interface PricingProps {- authenticated: boolean- isBillingPage?: boolean- lastEvent?: {- event: string- } | null-}--const Pricing = ({ authenticated, isBillingPage, lastEvent }: PricingProps) => {- const {- t,- i18n: { language },- } = useTranslation('common')- const { user, loadUser } = useAuth()- const { theme } = useTheme()-- const [metainfo, setMetainfo] = useState<Metainfo>(DEFAULT_METAINFO)-- const currencyCode = user?.tierCurrency || metainfo.code-- const [planCodeLoading, setPlanCodeLoading] = useState<string | null>(null)- const [isNewPlanConfirmationModalOpened, setIsNewPlanConfirmationModalOpened] = useState(false)- const [subUpdatePreview, setSubUpdatePreview] = useState<any>(null) // object - preview itself, null - loading, false - error- const [newPlanId, setNewPlanId] = useState<number | null>(null)- const [isSubUpdating, setIsSubUpdating] = useState(false)- const [downgradeTo, setDowngradeTo] = useState<{- planCode: string- name: string- pid: string- ypid: string- } | null>(null)- const [showDowngradeModal, setShowDowngradeModal] = useState(false)- const [billingFrequency, setBillingFrequency] = useState(user?.billingFrequency || BillingFrequency.monthly)-- const PLAN_CODES_ARRAY = authenticated- ? _includes(STANDARD_PLANS, user?.planCode)- ? STANDARD_PLANS- : [user?.planCode, ...STANDARD_PLANS]- : STANDARD_PLANS-- const [selectedTier, setSelectedTier] = useState(PLAN_LIMITS[user?.planCode || 'hobby'])- const planFeatures = getPaidFeatures(t, selectedTier)- const currency = CURRENCIES[currencyCode]-- const onSelectPlanChange = (e: React.ChangeEvent<HTMLInputElement>) => {- const index = Number(e.target.value)- const planCode = PLAN_CODES_ARRAY[index]-- // @ts-expect-error- setSelectedTier(PLAN_LIMITS[planCode])- }-- useEffect(() => {- const abortController = new AbortController()-- getPaymentMetainfo({ signal: abortController.signal })- .then(setMetainfo)- .catch(() => {})-- return () => abortController.abort()- }, [])-- useEffect(() => {- if (!lastEvent) {- return- }-- const lastEventHandler = async (data: { event: string }) => {- if (_isNil(data)) {- return- }-- if (data.event === 'Checkout.Complete') {- // giving some time to the API to process tier upgrate via Paddle webhook- setTimeout(async () => {- await loadUser()-- toast.success(t('apiNotifications.subscriptionUpdated'))- }, 3000)- setPlanCodeLoading(null)- setDowngradeTo(null)- } else if (data.event === 'Checkout.Close') {- setPlanCodeLoading(null)- setDowngradeTo(null)- }- }-- lastEventHandler(lastEvent)- }, [lastEvent, t, loadUser])-- const loadSubUpdatePreview = async (planId: number) => {- setIsNewPlanConfirmationModalOpened(true)- try {- const preview = await previewSubscriptionUpdate(planId)- setSubUpdatePreview(preview)- } catch (reason) {- console.error('[ERROR] An error occured while loading subscription update pricing preview:', reason)- toast.error('An error occured while loading subscription update pricing preview')- setSubUpdatePreview(false)- }- }-- const onPlanChange = async (tier: { planCode: string; name: string; pid: string; ypid: string }) => {- if (!user) {- return- }-- const isSelectingDifferentPlan =- user.planCode !== tier.planCode ||- user.billingFrequency !== billingFrequency ||- !['free', 'trial', 'none'].includes(user.planCode)-- if (planCodeLoading || !isSelectingDifferentPlan) {- return- }-- if (user.subID && !user.cancellationEffectiveDate && user.planCode !== 'none') {- const planId = Number(billingFrequency === BillingFrequency.monthly ? tier.pid : tier.ypid)- setNewPlanId(planId)- await loadSubUpdatePreview(planId)- return- }-- setPlanCodeLoading(tier.planCode)-- if (!window.Paddle) {- toast.error('Payment script has not yet loaded! Please, try again.')- setPlanCodeLoading(null)- return- }-- const discountMayBeApplied =- user.referrerID && (user.planCode === 'trial' || user.planCode === 'none') && !user.cancellationEffectiveDate- const coupon = discountMayBeApplied ? REFERRAL_DISCOUNT_CODE : undefined-- window.Paddle.Checkout.open({- product: billingFrequency === BillingFrequency.monthly ? tier.pid : tier.ypid,- email: user.email,- passthrough: JSON.stringify({- uid: user.id,- }),- locale: paddleLanguageMapping[language] || language,- title: tier.name,- displayModeTheme: theme,- country: metainfo.country,- coupon,- })- }-- const closeUpdateModal = (force?: boolean) => {- if (isSubUpdating && !force) {- return- }-- setIsNewPlanConfirmationModalOpened(false)- setSubUpdatePreview(null)- setNewPlanId(null)- setIsSubUpdating(false)- }-- const updateSubscription = async () => {- setIsSubUpdating(true)-- try {- await changeSubscriptionPlan(newPlanId as number)-- await loadUser()-- toast.success(t('apiNotifications.subscriptionUpdated'))- closeUpdateModal(true)- } catch (reason) {- console.error('[ERROR] An error occured while updating subscription:', reason)- toast.error('An error occured while updating subscription')- closeUpdateModal(true)- }- }-- const downgradeHandler = (tier: { planCode: string; name: string; pid: string; ypid: string }) => {- if (!user) {- return- }-- if (planCodeLoading === null && user.planCode !== tier.planCode) {- setDowngradeTo(tier)- setShowDowngradeModal(true)- }- }-- const userPlancodeID = user?.planCode ? PLAN_LIMITS[user.planCode]?.index : 0- const planCodeID = selectedTier.index- const downgrade = !user?.cancellationEffectiveDate && planCodeID < userPlancodeID-- let action: string-- if (user?.cancellationEffectiveDate || ['free', 'trial', 'none'].includes(user?.planCode || '')) {- action = t('pricing.subscribe')- } else if (planCodeID > userPlancodeID) {- action = t('pricing.upgrade')- } else if (downgrade) {- action = t('pricing.downgrade')- } else if (user?.billingFrequency === billingFrequency) {- action = t('pricing.yourPlan')- } else if (billingFrequency === BillingFrequency.monthly) {- action = t('pricing.switchToMonthly')- } else {- action = t('pricing.switchToYearly')- }-- return (- <>- <div id='pricing' className={cx({ 'bg-gray-100/80 dark:bg-slate-800/50': !authenticated })}>- <div- className={cx('max-w-max whitespace-pre-line', {- 'px-4 py-24 sm:px-6 lg:px-8': !authenticated,- 'mx-auto': !isBillingPage,- })}- >- <div className='sm:align-center sm:flex sm:flex-col'>- {!authenticated ? (- <>- <h2 className='font-sans text-4xl font-extrabold text-gray-900 sm:text-center dark:text-gray-50'>- {t('pricing.title')}- </h2>- <p className='my-5 text-lg leading-relaxed text-slate-900 sm:text-center dark:text-slate-300'>- {t('pricing.adv', {- amount: TRIAL_DAYS,- })}- </p>- </>- ) : null}- <div className='flex justify-between'>- <div>- <h3 className='text-lg font-medium tracking-tight text-gray-900 dark:text-gray-50'>- {selectedTier.monthlyUsageLimit.toLocaleString('en-US')}- </h3>- <p className='text-gray-700 dark:text-gray-200'>{t('pricing.eventPerMonth')}</p>- </div>- <div className='flex justify-center'>- <RadioGroup- value={billingFrequency}- onChange={setBillingFrequency}- className='grid grid-cols-2 gap-x-1 rounded-md p-1 text-center text-xs leading-5 font-semibold ring-1 ring-gray-200 ring-inset dark:ring-slate-700'- >- <Label className='sr-only'>{t('pricing.frequency')}</Label>- <Radio- key={BillingFrequency.monthly}- value={BillingFrequency.monthly}- className={({ checked }) =>- cx(- checked ? 'bg-slate-900 text-gray-50 dark:bg-indigo-700' : 'text-gray-500 dark:text-gray-200',- 'flex cursor-pointer items-center justify-center rounded-md px-2.5',- )- }- >- <span>{t('pricing.monthlyBilling')}</span>- </Radio>- <Radio- key={BillingFrequency.yearly}- value={BillingFrequency.yearly}- className={({ checked }) =>- cx(- checked ? 'bg-slate-900 text-gray-50 dark:bg-indigo-700' : 'text-gray-500 dark:text-gray-200',- 'relative flex cursor-pointer items-center justify-center rounded-md px-2.5',- )- }- >- {/* <Badge- label={t('billing.xMonthsFree', { amount: 2 })}- className='absolute -top-5 -left-1 w-max max-w-[200px]'- colour='yellow'- /> */}- <span>{t('pricing.yearlyBilling')}</span>- </Radio>- </RadioGroup>- </div>- </div>- </div>- <label className='sr-only' htmlFor='tier-selector'>- {t('pricing.selectPlan')}- </label>- <input- id='tier-selector'- type='range'- min='0'- max={PLAN_CODES_ARRAY.length - 1}- value={PLAN_CODES_ARRAY.indexOf(selectedTier.planCode)}- className='arrows-handle mt-5 h-2 w-full appearance-none rounded-full bg-gray-200 dark:bg-slate-600'- onChange={onSelectPlanChange}- />- <div className='relative mt-5 divide-y rounded-2xl border ring-1 ring-gray-200 dark:ring-slate-700'>- {user?.planCode === selectedTier.planCode ? (- <div className='absolute top-0 left-5 translate-y-px transform border-none'>- <div className='flex -translate-y-1/2 transform justify-center bg-gray-50 dark:bg-slate-900'>- <Badge label={t('pricing.currentPlan')} colour='indigo' />- </div>- </div>- ) : null}- {selectedTier.legacy ? (- <div className='absolute top-0 right-5 translate-y-px transform border-none'>- <div className='flex -translate-y-1/2 transform justify-center bg-gray-50 dark:bg-slate-900'>- <Badge label={t('pricing.legacy')} colour='yellow' />- </div>- </div>- ) : null}- <div className='border-none p-6'>- <ClientOnly fallback={<Loader />}>- {() => (- <div className='flex flex-wrap justify-between'>- <p className='mt-2 sm:mt-0'>- {selectedTier.planCode === 'trial' && user?.planCode === 'trial' ? (- <span className='text-2xl leading-10 font-bold text-slate-900 dark:text-gray-50'>- {t('pricing.tiers.trial')}- </span>- ) : (- <>- <span className='text-4xl font-bold text-slate-900 dark:text-gray-50'>- {currency.symbol}- {billingFrequency === BillingFrequency.monthly- ? selectedTier.price[currencyCode]?.monthly- : selectedTier.price[currencyCode]?.yearly}- </span>- - <span className='text-base font-medium text-gray-500 dark:text-gray-400'>- /{t(billingFrequency === BillingFrequency.monthly ? 'pricing.perMonth' : 'pricing.perYear')}- </span>- </>- )}- </p>-- {authenticated ? (- <Button- // @ts-expect-error TODO fix this later- onClick={() => (downgrade ? downgradeHandler(selectedTier) : onPlanChange(selectedTier))}- type='button'- className={cn('mt-2 sm:mt-0', {- hidden: selectedTier.planCode === 'trial',- })}- loading={planCodeLoading === selectedTier.planCode}- disabled={- planCodeLoading !== null ||- (selectedTier.planCode === user?.planCode &&- (user?.billingFrequency === billingFrequency ||- ['free', 'trial', 'none'].includes(user?.planCode || '')))- }- primary- large- >- {action}- </Button>- ) : (- <Link- className='relative inline-flex items-center rounded-md border border-transparent bg-slate-900 px-4 py-2 text-sm leading-4 font-medium text-gray-50 select-none hover:bg-slate-700 dark:bg-indigo-700 dark:hover:bg-indigo-800'- to={routes.signup}- aria-label={t('titles.signup')}- >- {t('common.getStarted')}- </Link>- )}- </div>- )}- </ClientOnly>- </div>- <div className='border-none px-6'>- <hr className='mx-auto w-full border border-gray-300 dark:border-slate-800' />- </div>- <div className='border-none px-6 pt-6 pb-8'>- <h3 className='text-xs font-medium tracking-wide text-gray-900 uppercase dark:text-gray-50'>- {t('pricing.whatIncl')}- </h3>- {/* space-y-4 */}- <ul className='mt-6 grid grid-cols-2 gap-4'>- {_map(planFeatures, (feature) => (- <li key={feature} className='flex space-x-3'>- <CheckIcon className='h-5 w-5 shrink-0 text-green-500' aria-hidden='true' />- <span className='text-sm text-gray-700 dark:text-gray-200'>{feature}</span>- </li>- ))}- </ul>- </div>- </div>- <p className='mt-5 font-sans text-base tracking-normal text-gray-900 dark:text-gray-50'>- <Trans- t={t}- i18nKey='billing.contact'- values={{- amount: 10,- }}- components={{- url: (- <Link- to={routes.contact}- className='leading-6 font-semibold text-indigo-600 hover:underline dark:text-indigo-400'- aria-label={t('footer.tos')}- />- ),- }}- />- </p>- </div>- <div className='checkout-container' id='checkout-container' />- </div>- <Modal- onClose={() => {- setDowngradeTo(null)- setShowDowngradeModal(false)- }}- onSubmit={() => {- setShowDowngradeModal(false)- if (downgradeTo) {- onPlanChange(downgradeTo)- }- }}- submitText={t('common.yes')}- closeText={t('common.no')}- title={t('pricing.downgradeTitle')}- type='warning'- message={- <Trans- t={t}- i18nKey='pricing.downgradeDesc'- values={{- email: CONTACT_EMAIL,- }}- />- }- isOpened={showDowngradeModal}- />- <Modal- onClose={closeUpdateModal}- onSubmit={updateSubscription}- submitText={t('common.confirm')}- closeText={t('common.goBack')}- title={t('billing.confirmNewPlan')}- submitType='regular'- type='info'- isLoading={isSubUpdating}- message={- <>- {subUpdatePreview === null ? <Loader /> : null}- {subUpdatePreview === false ? (- <p className='whitespace-pre-line'>- <Trans- t={t}- i18nKey='billing.previewLoadingError'- values={{- email: CONTACT_EMAIL,- }}- components={{- mail: (- <a- title={`Email us at ${CONTACT_EMAIL}`}- href={`mailto:${CONTACT_EMAIL}`}- className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'- />- ),- }}- />- </p>- ) : null}- {subUpdatePreview ? (- <div>- <h2 className='text-base font-bold'>{t('billing.dueNow')}</h2>- <p className='text-sm'>{t('billing.dueNowDescription')}</p>- <div className='mt-2 overflow-hidden ring-1 ring-black/5 md:rounded-lg'>- <table className='200 min-w-full divide-y divide-gray-300 dark:divide-gray-500'>- <thead className='bg-gray-50 dark:bg-slate-800'>- <tr>- <th- scope='col'- className='py-3.5 pr-3 pl-4 text-left text-sm font-semibold text-gray-900 sm:pl-6 dark:text-gray-50'- >- {t('common.amount')}- </th>- <th- scope='col'- className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-gray-50'- >- {t('common.date')}- </th>- </tr>- </thead>- <tbody className='divide-y divide-gray-200 bg-white dark:divide-gray-600 dark:bg-slate-800'>- <tr>- <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 sm:pl-6 dark:text-gray-50'>- {`${subUpdatePreview.immediatePayment.symbol}${subUpdatePreview.immediatePayment.amount}`}- </td>- <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 dark:text-gray-50'>- {language === 'en'- ? dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('MMMM D, YYYY')- : dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('D MMMM, YYYY')}- </td>- </tr>- </tbody>- </table>- </div>- {subUpdatePreview.immediatePayment.amount < 0 ? (- <p className='mt-2 italic'>- {t('billing.negativePayment', {- currency: subUpdatePreview.immediatePayment.symbol,- dueNowAmount: -subUpdatePreview.immediatePayment.amount,- dueNowDate:- language === 'en'- ? dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('MMMM D, YYYY')- : dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('D MMMM, YYYY'),- nextPaymentAmount: subUpdatePreview.nextPayment.amount,- })}- </p>- ) : null}- <h2 className='mt-5 text-base font-bold'>{t('billing.nextPayment')}</h2>- <div className='mt-2 overflow-hidden ring-1 ring-black/5 md:rounded-lg'>- <table className='200 min-w-full divide-y divide-gray-300 dark:divide-gray-500'>- <thead className='bg-gray-50 dark:bg-slate-800'>- <tr>- <th- scope='col'- className='py-3.5 pr-3 pl-4 text-left text-sm font-semibold text-gray-900 sm:pl-6 dark:text-gray-50'- >- {t('common.amount')}- </th>- <th- scope='col'- className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-gray-50'- >- {t('common.date')}- </th>- </tr>- </thead>- <tbody className='divide-y divide-gray-200 bg-white dark:divide-gray-600 dark:bg-slate-800'>- <tr>- <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 sm:pl-6 dark:text-gray-50'>- {`${subUpdatePreview.nextPayment.symbol}${subUpdatePreview.nextPayment.amount}`}- </td>- <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 dark:text-gray-50'>- {language === 'en'- ? dayjs(subUpdatePreview.nextPayment.date).locale(language).format('MMMM D, YYYY')- : dayjs(subUpdatePreview.nextPayment.date).locale(language).format('D MMMM, YYYY')}- </td>- </tr>- </tbody>- </table>- </div>- </div>- ) : null}- </>- }- isOpened={isNewPlanConfirmationModalOpened}- />- </>- )-}--export default memo(Pricing)diff --git a/web/app/components/pricing/BillingPricing.tsx b/web/app/components/pricing/BillingPricing.tsxnew file mode 100644index 000000000..294bc2c22--- /dev/null+++ b/web/app/components/pricing/BillingPricing.tsx@@ -0,0 +1,480 @@+import { Label, Radio, RadioGroup } from '@headlessui/react'+import cx from 'clsx'+import dayjs from 'dayjs'+import _includes from 'lodash/includes'+import _isNil from 'lodash/isNil'+import _map from 'lodash/map'+import React, { memo, useEffect, useMemo, useState } from 'react'+import { Trans, useTranslation } from 'react-i18next'+import { Link } from 'react-router'+import { toast } from 'sonner'++import { changeSubscriptionPlan, getPaymentMetainfo, previewSubscriptionUpdate } from '~/api'+import {+ BillingFrequency,+ CURRENCIES,+ CONTACT_EMAIL,+ PLAN_LIMITS,+ REFERRAL_DISCOUNT_CODE,+ STANDARD_PLANS,+ paddleLanguageMapping,+} from '~/lib/constants'+import { DEFAULT_METAINFO, Metainfo } from '~/lib/models/Metainfo'+import { useAuth } from '~/providers/AuthProvider'+import { useTheme } from '~/providers/ThemeProvider'+import Button from '~/ui/Button'+import Loader from '~/ui/Loader'+import Modal from '~/ui/Modal'+import { cn } from '~/utils/generic'+import routes from '~/utils/routes'++interface BillingPricingProps {+ lastEvent?: { event: string } | null+}++const formatEventsLong = (value: number): string => value.toLocaleString('en-US')++const BillingPricing = ({ lastEvent }: BillingPricingProps) => {+ const {+ t,+ i18n: { language },+ } = useTranslation('common')+ const { isAuthenticated, user, loadUser } = useAuth()+ const { theme } = useTheme()++ const [metainfo, setMetainfo] = useState<Metainfo>(DEFAULT_METAINFO)+ const [planCodeLoading, setPlanCodeLoading] = useState<string | null>(null)+ const [isNewPlanConfirmationModalOpened, setIsNewPlanConfirmationModalOpened] = useState(false)+ const [subUpdatePreview, setSubUpdatePreview] = useState<any>(null)+ const [newPlanId, setNewPlanId] = useState<number | null>(null)+ const [isSubUpdating, setIsSubUpdating] = useState(false)+ const [downgradeTo, setDowngradeTo] = useState<{+ planCode: string+ name: string+ pid: string+ ypid: string+ } | null>(null)+ const [showDowngradeModal, setShowDowngradeModal] = useState(false)+ const [billingFrequency, setBillingFrequency] = useState(user?.billingFrequency || BillingFrequency.monthly)++ const PLAN_CODES_ARRAY = useMemo(+ () =>+ isAuthenticated+ ? _includes(STANDARD_PLANS, user?.planCode)+ ? STANDARD_PLANS+ : [user?.planCode, ...STANDARD_PLANS]+ : STANDARD_PLANS,+ [isAuthenticated, user?.planCode],+ )++ const currencyCode = user?.tierCurrency || metainfo.code+ const currency = CURRENCIES[currencyCode]++ useEffect(() => {+ const abortController = new AbortController()+ getPaymentMetainfo({ signal: abortController.signal })+ .then(setMetainfo)+ .catch(() => {})+ return () => abortController.abort()+ }, [])++ useEffect(() => {+ if (!lastEvent) return++ const lastEventHandler = async (data: { event: string }) => {+ if (_isNil(data)) return+ if (data.event === 'Checkout.Complete') {+ setTimeout(async () => {+ await loadUser()+ toast.success(t('apiNotifications.subscriptionUpdated'))+ }, 3000)+ setPlanCodeLoading(null)+ setDowngradeTo(null)+ } else if (data.event === 'Checkout.Close') {+ setPlanCodeLoading(null)+ setDowngradeTo(null)+ }+ }+ lastEventHandler(lastEvent)+ }, [lastEvent, t, loadUser])++ const loadSubUpdatePreview = async (planId: number) => {+ setIsNewPlanConfirmationModalOpened(true)+ try {+ const preview = await previewSubscriptionUpdate(planId)+ setSubUpdatePreview(preview)+ } catch (reason) {+ console.error('[ERROR] An error occured while loading subscription update pricing preview:', reason)+ toast.error('An error occured while loading subscription update pricing preview')+ setSubUpdatePreview(false)+ }+ }++ const onPlanChange = async (tier: any) => {+ if (!user) return++ const isSelectingDifferentPlan =+ user.planCode !== tier.planCode ||+ user.billingFrequency !== billingFrequency ||+ !isUnselectablePlanCode(user.planCode)++ if (planCodeLoading || !isSelectingDifferentPlan) return++ if (user.subID && !user.cancellationEffectiveDate && user.planCode !== 'none') {+ const planId = Number(billingFrequency === BillingFrequency.monthly ? tier.pid : tier.ypid)+ setNewPlanId(planId)+ await loadSubUpdatePreview(planId)+ return+ }++ setPlanCodeLoading(tier.planCode)++ if (!window.Paddle) {+ toast.error('Payment script has not yet loaded! Please, try again.')+ setPlanCodeLoading(null)+ return+ }++ const discountMayBeApplied =+ user.referrerID && (user.planCode === 'trial' || user.planCode === 'none') && !user.cancellationEffectiveDate+ const coupon = discountMayBeApplied ? REFERRAL_DISCOUNT_CODE : undefined++ window.Paddle.Checkout.open({+ product: billingFrequency === BillingFrequency.monthly ? tier.pid : tier.ypid,+ email: user.email,+ passthrough: JSON.stringify({ uid: user.id }),+ locale: paddleLanguageMapping[language] || language,+ title: tier.name,+ displayModeTheme: theme,+ country: metainfo.country,+ coupon,+ })+ }++ const closeUpdateModal = (force?: boolean) => {+ if (isSubUpdating && !force) return+ setIsNewPlanConfirmationModalOpened(false)+ setSubUpdatePreview(null)+ setNewPlanId(null)+ setIsSubUpdating(false)+ }++ const updateSubscription = async () => {+ setIsSubUpdating(true)+ try {+ await changeSubscriptionPlan(newPlanId as number)+ await loadUser()+ toast.success(t('apiNotifications.subscriptionUpdated'))+ closeUpdateModal(true)+ } catch (reason) {+ console.error('[ERROR] An error occured while updating subscription:', reason)+ toast.error('An error occured while updating subscription')+ closeUpdateModal(true)+ }+ }++ const downgradeHandler = (tier: any) => {+ if (!user) return+ if (planCodeLoading === null && user.planCode !== tier.planCode) {+ setDowngradeTo(tier)+ setShowDowngradeModal(true)+ }+ }++ const isUnselectablePlanCode = (planCode: any): boolean => {+ return ['free', 'trial', 'none'].includes(planCode)+ }++ const userPlancodeID = user?.planCode ? PLAN_LIMITS[user.planCode]?.index : 0++ const getActionLabel = (tier: any): string => {+ const planCodeID = tier.index+ const downgrade = !user?.cancellationEffectiveDate && planCodeID < userPlancodeID+ if (user?.cancellationEffectiveDate || isUnselectablePlanCode(user?.planCode)) {+ return t('pricing.subscribe')+ }+ if (planCodeID > userPlancodeID) {+ return t('pricing.upgrade')+ }+ if (downgrade) {+ return t('pricing.downgrade')+ }+ if (user?.billingFrequency === billingFrequency && user?.planCode === tier.planCode) {+ return t('pricing.yourPlan')+ }+ return billingFrequency === BillingFrequency.monthly ? t('pricing.switchToMonthly') : t('pricing.switchToYearly')+ }++ const isDisabledForTier = (tier: any): boolean => {+ return (+ planCodeLoading !== null ||+ (tier.planCode === user?.planCode &&+ (user?.billingFrequency === billingFrequency || isUnselectablePlanCode(user?.planCode)))+ )+ }++ const tiers = useMemo(() => {+ const validCodes = PLAN_CODES_ARRAY.filter(+ (code): code is keyof typeof PLAN_LIMITS => typeof code === 'string' && code in PLAN_LIMITS,+ )+ return validCodes.map((code) => PLAN_LIMITS[code])+ }, [PLAN_CODES_ARRAY])++ return (+ <>+ <div className='rounded-xl border border-gray-200 p-4 sm:p-6 dark:border-white/10'>+ <div className='mb-3 flex justify-between'>+ <h2 className='text-2xl font-bold text-black dark:text-gray-50'>{t('common.billing')}</h2>+ <RadioGroup+ value={billingFrequency}+ onChange={setBillingFrequency}+ className='grid grid-cols-2 gap-x-1 rounded-md p-1 text-center text-xs leading-5 font-semibold ring-1 ring-gray-200 dark:ring-white/20'+ >+ <Label className='sr-only'>{t('pricing.frequency')}</Label>+ <Radio+ key={BillingFrequency.monthly}+ value={BillingFrequency.monthly}+ className={({ checked }) =>+ cx(+ checked+ ? 'bg-slate-900 text-gray-50 dark:bg-white/90 dark:text-slate-900'+ : 'text-slate-700 dark:text-gray-200',+ 'flex cursor-pointer items-center justify-center rounded-md px-2.5 py-1 transition-all',+ )+ }+ >+ <span>{t('pricing.monthlyBilling')}</span>+ </Radio>+ <Radio+ key={BillingFrequency.yearly}+ value={BillingFrequency.yearly}+ className={({ checked }) =>+ cx(+ checked+ ? 'bg-slate-900 text-gray-50 dark:bg-white/90 dark:text-slate-900'+ : 'text-slate-700 dark:text-gray-200',+ 'flex cursor-pointer items-center justify-center rounded-md px-2.5 py-1 transition-all',+ )+ }+ >+ <span>{t('pricing.yearlyBilling')}</span>+ </Radio>+ </RadioGroup>+ </div>++ <div className='space-y-3'>+ {_map(tiers, (tier) => (+ <div+ key={tier.planCode}+ className={cn(+ 'flex items-center justify-between rounded-xl border px-4 py-3 text-black backdrop-blur-sm dark:bg-white/2 dark:text-white',+ {+ 'border-gray-200 dark:border-white/10':+ user?.planCode !== tier.planCode || isUnselectablePlanCode(tier.planCode),+ 'border-indigo-500': user?.planCode === tier.planCode && !isUnselectablePlanCode(tier.planCode),+ },+ )}+ >+ <div>+ <span className='text-base font-medium'>{formatEventsLong(tier.monthlyUsageLimit)}</span>+ + <span className='text-sm text-gray-500 dark:text-gray-400'>{t('pricing.eventsPerMonth')}</span>+ </div>+ <div className='flex items-center gap-3 text-sm'>+ <div className='text-sm'>+ <span className='font-semibold text-black dark:text-white'>+ {currency.symbol}+ {Number(+ (billingFrequency === BillingFrequency.monthly+ ? tier.price[currencyCode]?.monthly+ : tier.price[currencyCode]?.yearly) ?? 0,+ ).toFixed(2)}+ </span>+ + <span className='text-sm'>+ /{t(billingFrequency === BillingFrequency.monthly ? 'pricing.perMonth' : 'pricing.perYear')}+ </span>+ </div>+ <Button+ onClick={() => {+ const action = getActionLabel(tier)++ if (action === t('pricing.downgrade')) {+ downgradeHandler(tier)+ } else {+ onPlanChange(tier)+ }+ }}+ type='button'+ loading={planCodeLoading === tier.planCode}+ disabled={isDisabledForTier(tier)}+ small+ primary+ >+ {getActionLabel(tier)}+ </Button>+ </div>+ </div>+ ))}++ <p className='mt-6 text-slate-800 dark:text-slate-200'>+ <Trans+ t={t}+ i18nKey='billing.contact'+ values={{ amount: 10 }}+ components={{+ url: (+ <Link+ to={routes.contact}+ className='underline decoration-dashed hover:decoration-solid'+ aria-label={t('footer.tos')}+ />+ ),+ }}+ />+ </p>+ </div>+ </div>++ <div className='checkout-container' id='checkout-container' />++ <Modal+ onClose={() => {+ setDowngradeTo(null)+ setShowDowngradeModal(false)+ }}+ onSubmit={() => {+ setShowDowngradeModal(false)+ if (downgradeTo) onPlanChange(downgradeTo)+ }}+ submitText={t('common.yes')}+ closeText={t('common.no')}+ title={t('pricing.downgradeTitle')}+ type='warning'+ message={<Trans t={t} i18nKey='pricing.downgradeDesc' values={{ email: CONTACT_EMAIL }} />}+ isOpened={showDowngradeModal}+ />++ <Modal+ onClose={closeUpdateModal}+ onSubmit={updateSubscription}+ submitText={t('common.confirm')}+ closeText={t('common.goBack')}+ title={t('billing.confirmNewPlan')}+ submitType='regular'+ type='info'+ isLoading={isSubUpdating}+ message={+ <>+ {subUpdatePreview === null ? <Loader /> : null}+ {subUpdatePreview === false ? (+ <p className='whitespace-pre-line'>+ <Trans+ t={t}+ i18nKey='billing.previewLoadingError'+ values={{ email: CONTACT_EMAIL }}+ components={{+ mail: (+ <a+ title={`Email us at ${CONTACT_EMAIL}`}+ href={`mailto:${CONTACT_EMAIL}`}+ className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'+ />+ ),+ }}+ />+ </p>+ ) : null}+ {subUpdatePreview ? (+ <div>+ <h2 className='text-base font-bold'>{t('billing.dueNow')}</h2>+ <p className='text-sm'>{t('billing.dueNowDescription')}</p>+ <div className='mt-2 overflow-hidden ring-1 ring-black/5 md:rounded-lg'>+ <table className='200 min-w-full divide-y divide-gray-300 dark:divide-gray-500'>+ <thead className='bg-gray-50 dark:bg-slate-800'>+ <tr>+ <th+ scope='col'+ className='py-3.5 pr-3 pl-4 text-left text-sm font-semibold text-gray-900 sm:pl-6 dark:text-gray-50'+ >+ {t('common.amount')}+ </th>+ <th+ scope='col'+ className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-gray-50'+ >+ {t('common.date')}+ </th>+ </tr>+ </thead>+ <tbody className='divide-y divide-gray-200 bg-white dark:divide-gray-600 dark:bg-slate-800'>+ <tr>+ <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 sm:pl-6 dark:text-gray-50'>+ {`${subUpdatePreview.immediatePayment.symbol}${subUpdatePreview.immediatePayment.amount}`}+ </td>+ <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 dark:text-gray-50'>+ {language === 'en'+ ? dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('MMMM D, YYYY')+ : dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('D MMMM, YYYY')}+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ {subUpdatePreview.immediatePayment.amount < 0 ? (+ <p className='mt-2 italic'>+ {t('billing.negativePayment', {+ currency: subUpdatePreview.immediatePayment.symbol,+ dueNowAmount: -subUpdatePreview.immediatePayment.amount,+ dueNowDate:+ language === 'en'+ ? dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('MMMM D, YYYY')+ : dayjs(subUpdatePreview.immediatePayment.date).locale(language).format('D MMMM, YYYY'),+ nextPaymentAmount: subUpdatePreview.nextPayment.amount,+ })}+ </p>+ ) : null}+ <h2 className='mt-5 text-base font-bold'>{t('billing.nextPayment')}</h2>+ <div className='mt-2 overflow-hidden ring-1 ring-black/5 md:rounded-lg'>+ <table className='200 min-w-full divide-y divide-gray-300 dark:divide-gray-500'>+ <thead className='bg-gray-50 dark:bg-slate-800'>+ <tr>+ <th+ scope='col'+ className='py-3.5 pr-3 pl-4 text-left text-sm font-semibold text-gray-900 sm:pl-6 dark:text-gray-50'+ >+ {t('common.amount')}+ </th>+ <th+ scope='col'+ className='px-3 py-3.5 text-left text-sm font-semibold text-gray-900 dark:text-gray-50'+ >+ {t('common.date')}+ </th>+ </tr>+ </thead>+ <tbody className='divide-y divide-gray-200 bg-white dark:divide-gray-600 dark:bg-slate-800'>+ <tr>+ <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 sm:pl-6 dark:text-gray-50'>+ {`${subUpdatePreview.nextPayment.symbol}${subUpdatePreview.nextPayment.amount}`}+ </td>+ <td className='px-3 py-4 text-sm whitespace-nowrap text-gray-900 dark:text-gray-50'>+ {language === 'en'+ ? dayjs(subUpdatePreview.nextPayment.date).locale(language).format('MMMM D, YYYY')+ : dayjs(subUpdatePreview.nextPayment.date).locale(language).format('D MMMM, YYYY')}+ </td>+ </tr>+ </tbody>+ </table>+ </div>+ </div>+ ) : null}+ </>+ }+ isOpened={isNewPlanConfirmationModalOpened}+ />+ </>+ )+}++export default memo(BillingPricing)diff --git a/web/app/components/pricing/MarketingPricing.tsx b/web/app/components/pricing/MarketingPricing.tsxnew file mode 100644index 000000000..ce534136c--- /dev/null+++ b/web/app/components/pricing/MarketingPricing.tsx@@ -0,0 +1,167 @@+import { Label, Radio, RadioGroup } from '@headlessui/react'+import { CheckIcon } from '@heroicons/react/24/solid'+import cx from 'clsx'+import _map from 'lodash/map'+import { ArrowRightIcon } from 'lucide-react'+import { useEffect, useState } from 'react'+import { Trans, useTranslation } from 'react-i18next'+import { Link } from 'react-router'++import { getPaymentMetainfo } from '~/api'+import { CURRENCIES, PLAN_LIMITS, STANDARD_PLANS, BillingFrequency, TRIAL_DAYS } from '~/lib/constants'+import { DEFAULT_METAINFO, Metainfo } from '~/lib/models/Metainfo'+import { useAuth } from '~/providers/AuthProvider'+import routes from '~/utils/routes'++const formatEventsLong = (value: number) => value.toLocaleString('en-US')++const MarketingPricing = () => {+ const { isAuthenticated } = useAuth()+ const { t } = useTranslation('common')+ const [metainfo, setMetainfo] = useState<Metainfo>(DEFAULT_METAINFO)+ const [billingFrequency, setBillingFrequency] = useState(BillingFrequency.monthly)++ useEffect(() => {+ const abortController = new AbortController()+ getPaymentMetainfo({ signal: abortController.signal })+ .then(setMetainfo)+ .catch(() => {})+ return () => abortController.abort()+ }, [])++ const currencyCode = metainfo.code+ const currency = CURRENCIES[currencyCode]++ const plans = STANDARD_PLANS.map((code) => PLAN_LIMITS[code as keyof typeof PLAN_LIMITS])++ return (+ <section className='relative p-2'>+ <div className='rounded-xl bg-slate-900 py-16 sm:py-20'>+ <div className='mx-auto grid max-w-7xl grid-cols-1 gap-6 px-4 sm:px-6 lg:grid-cols-12 lg:gap-10 lg:px-8'>+ <div className='col-span-12 lg:col-span-5'>+ <h2 className='text-3xl font-extrabold tracking-tight text-white sm:text-4xl'>{t('pricing.title')}</h2>+ <p className='mt-2 max-w-md text-sm text-gray-100'>+ {t('pricing.adv', {+ amount: TRIAL_DAYS,+ })}+ </p>++ <div className='mt-8 space-y-3'>+ {[+ t('pricing.tiers.upToXWebsites', { amount: 50 }),+ t('pricing.tiers.userFlowAnalysis'),+ t('pricing.tiers.sessionAnalysis'),+ t('pricing.tiers.errorTracking'),+ t('pricing.tiers.apiAccess'),+ t('pricing.tiers.dataOwnership'),+ t('pricing.tiers.reports'),+ ].map((label) => (+ <div key={label} className='flex items-center text-gray-100'>+ <CheckIcon className='mr-3 size-5' />+ <span className='text-sm'>{label}</span>+ </div>+ ))}+ </div>++ <Link+ to={isAuthenticated ? routes.billing : routes.signup}+ className='mt-8 flex max-w-max items-center justify-center rounded-md border-2 border-slate-50 bg-gray-50 px-8 py-4 text-slate-900 transition-all duration-300 hover:bg-transparent hover:text-gray-50'+ aria-label={+ isAuthenticated ? t('main.goToBilling') : t('main.startAXDayFreeTrial', { amount: TRIAL_DAYS })+ }+ >+ <span className='mr-1 text-center text-base font-semibold'>+ {isAuthenticated ? t('main.goToBilling') : t('main.startAXDayFreeTrial', { amount: TRIAL_DAYS })}+ </span>+ <ArrowRightIcon className='mt-[1px] h-4 w-5' />+ </Link>+ </div>++ <div className='col-span-12 lg:col-span-7'>+ <div className='mb-3 flex justify-end'>+ <RadioGroup+ value={billingFrequency}+ onChange={setBillingFrequency}+ className='grid grid-cols-2 gap-x-1 rounded-md p-1 text-center text-xs leading-5 font-semibold ring-1 ring-white/20'+ >+ <Label className='sr-only'>{t('pricing.frequency')}</Label>+ <Radio+ key={BillingFrequency.monthly}+ value={BillingFrequency.monthly}+ className={({ checked }) =>+ cx(+ checked ? 'bg-white/90 text-slate-900' : 'text-gray-200',+ 'flex cursor-pointer items-center justify-center rounded-md px-2.5 py-1 transition-all',+ )+ }+ >+ <span>{t('pricing.monthlyBilling')}</span>+ </Radio>+ <Radio+ key={BillingFrequency.yearly}+ value={BillingFrequency.yearly}+ className={({ checked }) =>+ cx(+ checked ? 'bg-white/90 text-slate-900' : 'text-gray-200',+ 'flex cursor-pointer items-center justify-center rounded-md px-2.5 py-1 transition-all',+ )+ }+ >+ <span>{t('pricing.yearlyBilling')}</span>+ </Radio>+ </RadioGroup>+ </div>+ <div className='space-y-3'>+ {_map(plans, (tier) => (+ <div+ key={tier.planCode}+ className='flex items-center justify-between rounded-xl border border-white/10 bg-white/2 px-4 py-3 text-white backdrop-blur-sm transition-all duration-300 hover:bg-white/10'+ >+ <div>+ <span className='text-base font-medium'>{formatEventsLong(tier.monthlyUsageLimit)}</span>+ + <span className='text-sm text-gray-400'>{t('pricing.eventsPerMonth')}</span>+ </div>+ <div className='text-sm'>+ <span className='font-semibold text-white'>+ {currency.symbol}+ {(billingFrequency === BillingFrequency.monthly+ ? tier.price[currencyCode].monthly+ : tier.price[currencyCode].yearly+ ).toFixed(2)}+ </span>+ + <span className='text-sm text-gray-400'>+ /{t(billingFrequency === BillingFrequency.monthly ? 'pricing.perMonth' : 'pricing.perYear')}+ </span>+ </div>+ </div>+ ))}++ <p className='mt-6 text-slate-200'>+ <Trans+ t={t}+ i18nKey='billing.contact'+ values={{ amount: 10 }}+ components={{+ url: (+ <a+ href={routes.contact}+ target='_blank'+ rel='noopener noreferrer'+ className='underline decoration-dashed hover:decoration-solid'+ aria-label={`${t('footer.contact')} (opens in a new tab)`}+ />+ ),+ }}+ />+ </p>+ </div>+ </div>+ </div>+ </div>+ </section>+ )+}++export default MarketingPricingdiff --git a/web/app/pages/Billing/index.tsx b/web/app/pages/Billing/index.tsxindex a881ad8f7..7a1f496fc 100644--- a/web/app/pages/Billing/index.tsx+++ b/web/app/pages/Billing/index.tsx@@ -9,6 +9,8 @@ import { toast } from 'sonner'import { getPaymentMetainfo, getUsageInfo } from '~/api'import DashboardLockedBanner from '~/components/DashboardLockedBanner'+import FAQ from '~/components/marketing/FAQ'+import BillingPricing from '~/components/pricing/BillingPricing'import { withAuthentication, auth } from '~/hoc/protected'import { isSelfhosted, PADDLE_JS_URL, PADDLE_VENDOR_ID, CONTACT_EMAIL, paddleLanguageMapping } from '~/lib/constants'import { DEFAULT_METAINFO, Metainfo } from '~/lib/models/Metainfo'@@ -21,8 +23,6 @@ import Modal from '~/ui/Modal'import MultiProgress from '~/ui/MultiProgress'import { loadScript } from '~/utils/generic'-import Pricing from '../../components/marketing/Pricing'-dayjs.extend(utc)dayjs.extend(duration)@@ -36,7 +36,6 @@ const Billing = () => {const { user, isLoading: authLoading } = useAuth()const { theme } = useTheme()- const { isAuthenticated } = useAuth()const [usageInfo, setUsageInfo] = useState<UsageInfo>({total: 0,traffic: 0,@@ -214,12 +213,12 @@ const Billing = () => {<div className='min-h-page bg-gray-50 dark:bg-slate-900'><DashboardLockedBanner />- <div className='mx-auto px-4 pt-12 whitespace-pre-line sm:px-6 md:w-5/6'>+ <div className='mx-auto px-4 pt-12 whitespace-pre-line sm:px-6 md:w-11/12'><h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50'>{t('billing.title')}</h1></div>- <div className='mx-auto mt-5 grid gap-x-10 gap-y-8 px-4 pb-16 whitespace-pre-line sm:px-6 md:w-5/6 lg:grid-cols-2'>- <div>+ <div className='mx-auto mt-5 grid gap-x-10 gap-y-8 px-4 pb-4 whitespace-pre-line sm:px-6 md:w-11/12 lg:grid-cols-3'>+ <div className='lg:col-span-2'><h2 id='billing' className='mb-2 text-2xl font-medium text-gray-900 dark:text-gray-50'>{t('billing.subscription')}</h2>@@ -301,7 +300,7 @@ const Billing = () => {<Loader />) : (<div className='mt-8 flex flex-col'>- <Pricing authenticated={isAuthenticated} isBillingPage lastEvent={lastEvent} />+ <BillingPricing lastEvent={lastEvent} /><div className='mt-2 space-y-2'>{subUpdateURL && !cancellationEffectiveDate ? (<Button className='mr-2' onClick={onUpdatePaymentDetails} type='button' primary large>@@ -318,7 +317,7 @@ const Billing = () => {)}</div>- <div>+ <div className='lg:col-span-1'><h2 id='usage' className='mb-2 text-2xl font-medium text-gray-900 dark:text-gray-50'>{t('billing.planUsage')}</h2>@@ -448,22 +447,22 @@ const Billing = () => {</p></div>- <div className='mt-4 flex items-center justify-between'>- <p className='text-sm text-gray-600 dark:text-gray-400'>{t('billing.resetDate')}</p>- <p className='text-sm text-gray-600 dark:text-gray-400'>- {t('billing.daysUntilReset', {- days: Math.ceil(- (new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1).getTime() -- new Date().getTime()) /- (1000 * 60 * 60 * 24),- ),- })}- </p>- </div>+ <p className='mt-4 text-sm text-gray-600 dark:text-gray-400'>+ {t('billing.resetDate', {+ days: Math.ceil(+ (new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1).getTime() -+ new Date().getTime()) /+ (1000 * 60 * 60 * 24),+ ),+ })}+ </p></div>)}</div></div>++ <FAQ />+<ModalonClose={() => {setIsCancelSubModalOpened(false)diff --git a/web/app/pages/ErrorTracking/index.tsx b/web/app/pages/ErrorTracking/index.tsxindex 4eb5edd79..f2aaf5ba7 100644--- a/web/app/pages/ErrorTracking/index.tsx+++ b/web/app/pages/ErrorTracking/index.tsx@@ -16,7 +16,7 @@ import { useTheme } from '~/providers/ThemeProvider'import BackgroundSvg from '~/ui/icons/BackgroundSvg'import routesPath from '~/utils/routes'-import Pricing from '../../components/marketing/Pricing'+import MarketingPricing from '~/components/pricing/MarketingPricing'import { PeopleLoveSwetrix } from '../Performance'const Lines = () => (@@ -210,7 +210,7 @@ const ErrorTracking = () => {</div>{/* For now let's hide Pricing for authenticated users on the main page as the Paddle script only loads on the Billing page */}- {!isAuthenticated ? <Pricing authenticated={false} /> : null}+ {!isAuthenticated ? <MarketingPricing authenticated={false} /> : null}<DitchGoogle />diff --git a/web/app/pages/Performance/index.tsx b/web/app/pages/Performance/index.tsxindex 51d4f90fa..63f063e1a 100644--- a/web/app/pages/Performance/index.tsx+++ b/web/app/pages/Performance/index.tsx@@ -18,7 +18,7 @@ import BackgroundSvg from '~/ui/icons/BackgroundSvg'import { nFormatterSeparated } from '~/utils/generic'import routesPath from '~/utils/routes'-import Pricing from '../../components/marketing/Pricing'+import MarketingPricing from '~/components/pricing/MarketingPricing'const Lines = () => (<div className='pointer-events-none relative'>@@ -275,7 +275,7 @@ const Performance = () => {</div>{/* For now let's hide Pricing for authenticated users on the main page as the Paddle script only loads on the Billing page */}- {isAuthenticated ? null : <Pricing authenticated={false} />}+ {isAuthenticated ? null : <MarketingPricing authenticated={false} />}<DitchGoogle />diff --git a/web/app/routes/_index.tsx b/web/app/routes/_index.tsxindex 4206978d6..a7b470538 100644--- a/web/app/routes/_index.tsx+++ b/web/app/routes/_index.tsx@@ -28,7 +28,8 @@ import { ClientOnly } from 'remix-utils/client-only'import { getGeneralStats, getPaymentMetainfo } from '~/api'import Header from '~/components/Header'import { DitchGoogle } from '~/components/marketing/DitchGoogle'-import Pricing from '~/components/marketing/Pricing'+import FAQ from '~/components/marketing/FAQ'+import MarketingPricing from '~/components/pricing/MarketingPricing'import {GITHUB_URL,LIVE_DEMO_URL,@@ -37,16 +38,11 @@ import {OS_LOGO_MAP,OS_LOGO_MAP_DARK,BROWSER_LOGO_MAP,- DOCS_URL,- DISCORD_URL,- PLAN_LIMITS,- TRIAL_DAYS,} from '~/lib/constants'import { DEFAULT_METAINFO, Metainfo } from '~/lib/models/Metainfo'import { Stats } from '~/lib/models/Stats'import CCRow from '~/pages/Project/View/components/CCRow'import { MetricCard, MetricCardSelect } from '~/pages/Project/View/components/MetricCards'-import { useAuth } from '~/providers/AuthProvider'import { useTheme } from '~/providers/ThemeProvider'import Flag from '~/ui/Flag'import { cn, getStringFromTime, getTimeFromSeconds } from '~/utils/generic'@@ -404,113 +400,6 @@ const Hero = () => {)}-const FAQ = () => {- const { t } = useTranslation('common')-- const onLinkClick = (e: React.MouseEvent<HTMLAnchorElement>) => {- e.stopPropagation()- }-- const values = {- lowestPlanEventsAmount: PLAN_LIMITS.hobby.monthlyUsageLimit.toLocaleString('en-US'),- moderatePlanEventsAmount: PLAN_LIMITS.freelancer.monthlyUsageLimit.toLocaleString('en-US'),- freeTrialDays: TRIAL_DAYS,- }- const stripTags = (html: string) => html.replace(/<[^>]+>/g, '')- const items = t('main.faq.items', { returnObjects: true }) as { q: string; a: string }[]- const structuredData = {- '@context': 'https://schema.org',- '@type': 'FAQPage',- mainEntity: items.map((_, idx) => ({- '@type': 'Question',- name: t(`main.faq.items.${idx}.q`),- acceptedAnswer: {- '@type': 'Answer',- text: stripTags(- t(`main.faq.items.${idx}.a`, {- ...values,- }),- ),- },- })),- }-- return (- <section className='relative mx-auto max-w-5xl px-6 py-14 lg:px-8'>- <h2 className='text-center text-3xl font-extrabold text-slate-900 sm:text-4xl dark:text-white'>- {t('main.faq.title')}- </h2>- <div className='mt-8 flex flex-col'>- {_map(items, (item: { q: string; a: string }, idx: number) => {- const showTopBorder = idx !== 0-- return (- <details- key={item.q}- className={cn('group w-full text-left', showTopBorder && 'border-t border-gray-200 dark:border-white/10')}- >- <summary className='flex w-full cursor-pointer items-center justify-between px-5 py-4'>- <span className='text-base font-medium text-slate-900 group-hover:underline dark:text-gray-100'>- <Trans t={t} i18nKey={`main.faq.items.${idx}.q`} />- </span>- <ChevronDownIcon className='size-4 text-slate-900 transition-transform group-open:rotate-180 dark:text-gray-300' />- </summary>- <div className='px-5'>- <p className='pb-4 text-sm whitespace-pre-line text-slate-700 dark:text-gray-300'>- <Trans- t={t}- i18nKey={`main.faq.items.${idx}.a`}- values={values}- components={{- dataPolicyUrl: (- <Link- to={routesPath.dataPolicy}- className='underline decoration-dashed hover:decoration-solid'- aria-label='Data policy'- onClick={onLinkClick}- />- ),- apiDocumentationUrl: (- <a- href={DOCS_URL}- className='underline decoration-dashed hover:decoration-solid'- target='_blank'- rel='noopener noreferrer'- aria-label='API documentation (opens in a new tab)'- onClick={onLinkClick}- />- ),- contactUsUrl: (- <Link- to={routesPath.contact}- className='underline decoration-dashed hover:decoration-solid'- aria-label='Contact us'- onClick={onLinkClick}- />- ),- discordUrl: (- <a- href={DISCORD_URL}- className='underline decoration-dashed hover:decoration-solid'- target='_blank'- rel='noopener noreferrer'- aria-label='Discord (opens in a new tab)'- onClick={onLinkClick}- />- ),- }}- />- </p>- </div>- </details>- )- })}- </div>- <script type='application/ld+json'>{JSON.stringify(structuredData, null, 2)}</script>- </section>- )-}-const FeatureCard = ({ title, description, media }: { title: string; description: string; media: React.ReactNode }) => (<div className='flex h-full flex-col overflow-hidden rounded-xl bg-white ring-1 ring-black/5 dark:bg-slate-800 dark:ring-white/10'><div className='relative h-60 overflow-hidden'>{media}</div>@@ -1459,8 +1348,6 @@ const FeaturesShowcase = () => {}export default function Index() {- const { isAuthenticated } = useAuth()-return (<div className='overflow-hidden'><main className='bg-gray-50 dark:bg-slate-900'>@@ -1470,8 +1357,7 @@ export default function Index() {<FeaturesShowcase />- {/* Hiding the Pricing for authenticated users on the main page as the Paddle script only loads on the Billing page */}- {!isAuthenticated ? <Pricing authenticated={false} /> : null}+ <MarketingPricing /><FAQ />diff --git a/web/app/ui/Button.tsx b/web/app/ui/Button.tsxindex 6b4ef93c2..471aaf62a 100644--- a/web/app/ui/Button.tsx+++ b/web/app/ui/Button.tsx@@ -50,7 +50,7 @@ const Button = ({disabled={disabled || loading}type={type}className={cn(- 'relative inline-flex items-center rounded-md border leading-4 font-medium select-none',+ 'relative inline-flex items-center rounded-md border leading-4 font-medium transition-all select-none disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',{'border-transparent bg-slate-900 text-gray-50 shadow-xs hover:bg-slate-700 dark:border-slate-700/50 dark:bg-slate-800 dark:hover:bg-slate-700':primary,@@ -65,7 +65,6 @@ const Button = ({'px-4 py-2 text-sm': large,'px-6 py-3 text-base': giant,'px-3 py-2 text-sm': regular,- 'cursor-not-allowed': loading,'focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 focus:outline-hidden': focus,},className,diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex 247e0be6b..03fcca72d 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -353,6 +353,7 @@},"main": {"seeLiveDemo": "See the live demo",+ "goToBilling": "Go to billing","faq": {"title": "Frequently asked questions","items": [@@ -1250,17 +1251,16 @@"negativePayment": "Negative 'Amount' means that you will have a credit balance of {{currency}}{{dueNowAmount}}. You will be billed {{currency}}0.00 on {{dueNowDate}}. Once the credit balance is used up, your recurring billing amount will be {{currency}}{{nextPaymentAmount}} every billing cycle of your subscription plan.","nextPayment": "Next payment","subscription": "Subscription",- "planUsageDesc": "The plan usage shows the number of events (page views, custom events, CAPTCHA completions) that you have used for the current month.",+ "planUsageDesc": "The plan usage shows the number of events (page views, custom events, error events) that you have used for the current month.","xofy": "{{x}} of {{y}}",- "resetDate": "The plan usage resets on the first day of each month.",+ "resetDate": "The plan usage resets on the first day of each month ({{days}} days until reset)","selectPlan": "Select a subscription plan to unveil full Swetrix potential.","changePlan": "You can change or cancel your subscription plan at any time here.",- "membersNotification": "Pageviews, custom events and CAPTCHA completions are counted towards the limit of the subscription of the account owner. People you invite into your projects don't need a subscription.",+ "membersNotification": "Pageviews, custom events and error events are counted towards the limit of the subscription of the account owner. People you invite into your projects don't need a subscription.","xMonthsFree": "{{amount}} months free","trialDescription": "Your free trial includes access to all features and unlimited data collection limits. When your trial ends, you'll need to select a paid plan that matches your usage to continue using Swetrix.","usageWarningHigh": "You've used {{percentage}}% of your monthly event limit. Consider upgrading your plan to avoid service interruption.","usageWarningCritical": "Warning: You've used {{percentage}}% of your monthly event limit! Upgrade now to ensure uninterrupted service.",- "daysUntilReset": "{{days}} days until reset","xPercentUsed": "{{percentage}}% used","xPercentRemaining": "{{percentage}}% remaining"},@@ -1305,34 +1305,25 @@"yearlyBilling": "Yearly","switchToMonthly": "Switch to monthly billing","frequency": "Payment frequency",- "eventPerMonth": "Events per month",+ "eventsPerMonth": "events / month","switchToYearly": "Switch to yearly billing","xTrialDaysLeft": "{{amount}} trial days left","trialEnded": "Trial ended","trialEndsToday": "Trial ends today","trialEndsTomorrow": "Trial ends tomorrow","tiers": {- "hobby": "Hobby",- "freelancer": "Freelancer",- "startup": "Startup",- "enterprise": "Enterprise","trial": "Free trial","upToXEVMo": "Up to {{amount}} events per month",- "xEvMo": "{{amount}} events per month","upToXVMo": "Up to {{amount}} visits per month",- "xVMo": "{{amount}} visits per month",- "xAlertsSingular": "{{amount}} alerting rule",- "xAlertsPlural": "{{amount}} alerting rules",- "upToXProjects": "Create up to {{amount}} projects","upToXWebsites": "Add up to {{amount}} websites",- "xMoDataRetention": "{{amount}} months of data retention","evXPlanIncl": "Everything {{plan}} plan includes",- "smallBusiSupport": "By buying this you are supporting a small business","dataExports": "Unlimited data exports","dataOwnership": "100% data ownership",- "dashboards": "Shared & Public Dashboards",+ "apiAccess": "API access","reports": "Email reports",- "userFlowAnalysis": "User flow analysis"+ "userFlowAnalysis": "User flow analysis",+ "sessionAnalysis": "Session analysis",+ "errorTracking": "Error tracking"},"downgradeTitle": "Are you sure you want to downgrade?","downgradeDesc": "After downgrading, your plan will include fewer projects and available events per month. In case your website contains more traffic than the plan you want to downgrade to includes, this will result in not all events being stored in our database.\nYou will be able to return to your current plan at any time.\nIf you have any questions, you can always email us at {{email}}.",