📈 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
Add Swetrix CAPTCHA demonstration & dev tools
Blue Mouse5228201a9100
diff --git a/web/app/hooks/useScript.ts b/web/app/hooks/useScript.tsnew file mode 100644index 000000000..cd5bfe0a2--- /dev/null+++ b/web/app/hooks/useScript.ts@@ -0,0 +1,66 @@+import { useEffect, useState } from 'react'++type ScriptStatus = 'idle' | 'loading' | 'ready' | 'error'++const getScriptStatus = (src: string): ScriptStatus => {+ if (!src) return 'idle'+ if (typeof document === 'undefined') return 'loading'++ const existingScript = document.querySelector(`script[src="${src}"]`)+ const dataStatus = existingScript?.getAttribute('data-status')++ if (dataStatus === 'ready' || dataStatus === 'error') {+ return dataStatus as ScriptStatus+ }++ return 'loading'+}++const useScript = (src: string) => {+ const [prevSrc, setPrevSrc] = useState(src)+ const [status, setStatus] = useState<ScriptStatus>(() => getScriptStatus(src))++ // Handle src changes during render (React-recommended pattern for syncing state with props)+ if (src !== prevSrc) {+ setPrevSrc(src)+ setStatus(getScriptStatus(src))+ }++ useEffect(() => {+ if (!src || status === 'ready' || status === 'error') {+ return+ }++ let script = document.querySelector(`script[src="${src}"]`) as HTMLScriptElement | null++ if (!script) {+ script = document.createElement('script')+ script.src = src+ script.defer = true+ script.setAttribute('data-status', 'loading')+ document.head.appendChild(script)+ }++ const handleLoad = () => {+ script!.setAttribute('data-status', 'ready')+ setStatus('ready')+ }++ const handleError = () => {+ script!.setAttribute('data-status', 'error')+ setStatus('error')+ }++ script.addEventListener('load', handleLoad)+ script.addEventListener('error', handleError)++ return () => {+ script!.removeEventListener('load', handleLoad)+ script!.removeEventListener('error', handleError)+ }+ }, [src, status])++ return status+}++export default useScriptdiff --git a/web/app/pages/Captcha/CaptchaDemo.tsx b/web/app/pages/Captcha/CaptchaDemo.tsxnew file mode 100644index 000000000..379468c79--- /dev/null+++ b/web/app/pages/Captcha/CaptchaDemo.tsx@@ -0,0 +1,232 @@+import { ArrowRightIcon } from '@heroicons/react/20/solid'+import { useCallback, useEffect, useState } from 'react'+import { useTranslation } from 'react-i18next'++import useScript from '~/hooks/useScript'+import { API_URL, DOCS_URL } from '~/lib/constants'+import Button from '~/ui/Button'+import Select from '~/ui/Select'+import { Text } from '~/ui/Text'++declare global {+ interface Window {+ swetrixCaptchaForceLoad?: () => void+ }+}++interface CaptchaConfig {+ theme: 'auto' | 'light' | 'dark'+ projectId: string+ dummySecret: string+}++const PROJECT_OPTIONS = [+ { value: 'PmahJ6HRJNLQ', label: 'captchaPage.demoPage.modeReal' },+ { value: 'AP00000000000', label: 'captchaPage.demoPage.modeAlwaysPass' },+ { value: 'FAIL000000000', label: 'captchaPage.demoPage.modeAlwaysFail' },+]++const TOKEN_OPTIONS = [+ { value: 'PASS000000000000000000', label: 'captchaPage.demoPage.tokenAlwaysPass' },+ { value: 'FAIL000000000000000000', label: 'captchaPage.demoPage.tokenAlwaysFail' },+ { value: 'USED000000000000000000', label: 'captchaPage.demoPage.tokenAlreadyUsed' },+]++const THEME_OPTIONS = [+ { value: 'auto', label: 'captchaPage.demoPage.themeAuto' },+ { value: 'light', label: 'captchaPage.demoPage.themeLight' },+ { value: 'dark', label: 'captchaPage.demoPage.themeDark' },+]++const CaptchaDemo = () => {+ const { t } = useTranslation('common')+ const [config, setConfig] = useState<CaptchaConfig>({+ theme: 'auto',+ projectId: 'PmahJ6HRJNLQ',+ dummySecret: 'PASS000000000000000000',+ })+ const [validationResult, setValidationResult] = useState<string | null>(null)+ const [captchaInitialised, setCaptchaInitialised] = useState(false)+ const captchaScriptStatus = useScript('https://cdn.swetrixcaptcha.com/captcha-loader.js')++ // Initialise captcha when script is loaded+ useEffect(() => {+ if (captchaScriptStatus !== 'ready' || captchaInitialised) {+ return+ }++ const interval = setInterval(() => {+ if (typeof window === 'undefined' || !window.swetrixCaptchaForceLoad) {+ return+ }++ window.swetrixCaptchaForceLoad()+ setCaptchaInitialised(true)+ clearInterval(interval)+ }, 1000)++ return () => clearInterval(interval)+ }, [captchaScriptStatus, captchaInitialised])++ // Regenerate captcha when config changes (except dummySecret)+ useEffect(() => {+ if (!captchaInitialised) {+ return+ }++ if (window.swetrixCaptchaForceLoad) {+ // Small delay to ensure DOM is updated+ const timer = setTimeout(() => {+ window.swetrixCaptchaForceLoad?.()+ }, 100)+ return () => clearTimeout(timer)+ }+ }, [config.theme, config.projectId, captchaInitialised])++ const updateConfig = useCallback((key: keyof CaptchaConfig, value: string) => {+ setConfig((prev) => ({ ...prev, [key]: value }))+ }, [])++ const handleValidateToken = async () => {+ try {+ const response = await fetch(`${API_URL}v1/captcha/validate`, {+ method: 'POST',+ headers: {+ 'Content-Type': 'application/json',+ },+ body: JSON.stringify({+ token: 'NOT_A_REAL_TOKEN',+ secret: config.dummySecret,+ }),+ })++ const data = await response.json()+ setValidationResult(JSON.stringify(data, null, 2))+ } catch {+ setValidationResult(JSON.stringify({ error: 'Failed to validate token' }, null, 2))+ }+ }++ const findSelectedOption = <T extends { value: string }>(options: T[], value: string) => {+ return options.find((opt) => opt.value === value) || options[0]+ }++ return (+ <div className='min-h-screen bg-gray-50 dark:bg-slate-900'>+ <main className='mx-auto max-w-7xl px-4 py-8 sm:px-6 md:py-12 lg:px-8'>+ {/* Header Section */}+ <div className='mb-8 md:mb-12'>+ <Text as='h1' size='3xl' weight='bold' tracking='tight' className='md:text-4xl lg:text-5xl'>+ {t('captchaPage.demoPage.title')}+ </Text>+ <Text as='p' size='lg' colour='muted' className='mt-2'>+ {t('captchaPage.demoPage.subtitle')}+ </Text>+ </div>++ {/* CAPTCHA Widget Section */}+ <section className='mb-12'>+ <Text as='h2' size='2xl' weight='bold' className='mb-4 md:text-3xl'>+ {t('captchaPage.demoPage.captchaWidget')}+ </Text>+ <div+ className='rounded-lg border border-gray-200 bg-white p-6 dark:border-slate-800/60 dark:bg-slate-800/25'+ key={`${config.theme}-${config.projectId}`}+ >+ <div className='swecaptcha' data-project-id={config.projectId} data-theme={config.theme} />+ {captchaScriptStatus === 'error' ? (+ <Text as='div' size='sm' colour='error'>+ Failed to load CAPTCHA. Please refresh the page.+ </Text>+ ) : null}+ </div>+ </section>++ {/* Configuration Section */}+ <section className='mb-12'>+ <Text as='h2' size='2xl' weight='bold' className='mb-4 md:text-3xl'>+ {t('captchaPage.demoPage.configuration')}+ </Text>+ <div className='grid gap-6 rounded-lg border border-gray-200 bg-white p-6 sm:grid-cols-2 dark:border-slate-800/60 dark:bg-slate-800/25'>+ <div>+ <Select+ label={t('captchaPage.demoPage.theme')}+ items={THEME_OPTIONS.map((opt) => ({ ...opt, label: t(opt.label) }))}+ labelExtractor={(item) => item.label}+ keyExtractor={(item) => item.value}+ onSelect={(item) => updateConfig('theme', item.value)}+ title={t(findSelectedOption(THEME_OPTIONS, config.theme).label)}+ selectedItem={THEME_OPTIONS.map((opt) => ({ ...opt, label: t(opt.label) })).find(+ (opt) => opt.value === config.theme,+ )}+ />+ </div>+ <div>+ <Select+ label={t('captchaPage.demoPage.mode')}+ items={PROJECT_OPTIONS.map((opt) => ({ ...opt, label: t(opt.label) }))}+ labelExtractor={(item) => item.label}+ keyExtractor={(item) => item.value}+ onSelect={(item) => updateConfig('projectId', item.value)}+ title={t(findSelectedOption(PROJECT_OPTIONS, config.projectId).label)}+ selectedItem={PROJECT_OPTIONS.map((opt) => ({ ...opt, label: t(opt.label) })).find(+ (opt) => opt.value === config.projectId,+ )}+ />+ </div>+ </div>+ </section>++ {/* Server-side Validation Section */}+ <section className='mb-12'>+ <Text as='h2' size='2xl' weight='bold' className='mb-4 md:text-3xl'>+ {t('captchaPage.demoPage.serverValidation')}+ </Text>+ <div className='rounded-lg border border-gray-200 bg-white p-6 dark:border-slate-800/60 dark:bg-slate-800/25'>+ <div className='flex flex-col gap-4 sm:flex-row sm:items-end'>+ <div className='flex-1'>+ <Select+ label={t('captchaPage.demoPage.tokenType')}+ items={TOKEN_OPTIONS.map((opt) => ({ ...opt, label: t(opt.label) }))}+ labelExtractor={(item) => item.label}+ keyExtractor={(item) => item.value}+ onSelect={(item) => updateConfig('dummySecret', item.value)}+ title={t(findSelectedOption(TOKEN_OPTIONS, config.dummySecret).label)}+ selectedItem={TOKEN_OPTIONS.map((opt) => ({ ...opt, label: t(opt.label) })).find(+ (opt) => opt.value === config.dummySecret,+ )}+ />+ </div>+ <Button type='button' primary regular onClick={handleValidateToken}>+ {t('captchaPage.demoPage.validateButton')}+ </Button>+ </div>++ {validationResult ? (+ <div className='mt-4'>+ <pre className='overflow-x-auto rounded-md bg-gray-100 p-4 text-sm text-gray-800 dark:bg-slate-900 dark:text-gray-200'>+ {validationResult}+ </pre>+ </div>+ ) : null}+ </div>+ </section>++ {/* Documentation Link */}+ <div className='text-center'>+ <a+ href={`${DOCS_URL}/captcha/introduction`}+ target='_blank'+ rel='noopener noreferrer'+ className='inline-flex items-center text-base font-medium text-indigo-600 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300'+ >+ {t('captchaPage.demoPage.learnMore')}+ <ArrowRightIcon className='ml-2 h-4 w-4' />+ </a>+ </div>+ </main>+ </div>+ )+}++export default CaptchaDemodiff --git a/web/app/pages/Captcha/index.tsx b/web/app/pages/Captcha/index.tsxindex 3d0fac21d..417418d64 100644--- a/web/app/pages/Captcha/index.tsx+++ b/web/app/pages/Captcha/index.tsx@@ -1,15 +1,29 @@import { ArrowRightIcon } from '@heroicons/react/20/solid'import { CodeBracketIcon, PuzzlePieceIcon, CursorArrowRaysIcon, EyeSlashIcon } from '@heroicons/react/24/outline'import _map from 'lodash/map'+import { useEffect, useState } from 'react'import { useTranslation, Trans } from 'react-i18next'import { Link } from 'react-router'import Header from '~/components/Header'import { DitchGoogle } from '~/components/marketing/DitchGoogle'import MarketingPricing from '~/components/pricing/MarketingPricing'+import useScript from '~/hooks/useScript'import { DOCS_URL } from '~/lib/constants'+import { useTheme } from '~/providers/ThemeProvider'+import Button from '~/ui/Button'+import Input from '~/ui/Input'+import { Text } from '~/ui/Text'+import Textarea from '~/ui/Textarea'+import { SWETRIX_PID } from '~/utils/analytics'import routesPath from '~/utils/routes'+declare global {+ interface Window {+ swetrixCaptchaForceLoad?: () => void+ }+}+const features = [{titleKey: 'captchaPage.features.privacy.title',@@ -35,11 +49,61 @@ const features = [const Captcha = () => {const { t } = useTranslation('common')+ const [demoName, setDemoName] = useState('')+ const [demoMessage, setDemoMessage] = useState('')+ const [demoStatus, setDemoStatus] = useState<'idle' | 'success' | 'error'>('idle')+ const [demoError, setDemoError] = useState('')+ const captchaScriptStatus = useScript('https://cdn.swetrixcaptcha.com/captcha-loader.js')+ const [captchaInitialised, setCaptchaInitialised] = useState(false)+ const { theme } = useTheme()++ useEffect(() => {+ if (captchaScriptStatus !== 'ready' || captchaInitialised) {+ return+ }++ const interval = setInterval(() => {+ if (typeof window === 'undefined' || !window.swetrixCaptchaForceLoad) {+ return+ }++ window.swetrixCaptchaForceLoad()+ setCaptchaInitialised(true)+ clearInterval(interval)+ }, 1000)++ return () => clearInterval(interval)+ }, [captchaScriptStatus, captchaInitialised])++ const handleDemoSubmit = (e: React.FormEvent) => {+ e.preventDefault()++ const captchaInput = document.querySelector('input[name="swetrix-captcha-response"]') as HTMLInputElement | null+ const token = captchaInput?.value++ if (!token) {+ setDemoStatus('error')+ setDemoError(t('captchaPage.demo.errors.notCompleted'))+ return+ }++ setDemoStatus('success')+ setDemoError('')+ setDemoName('')+ setDemoMessage('')++ if (window.swetrixCaptchaForceLoad) {+ window.swetrixCaptchaForceLoad()+ }++ setTimeout(() => {+ setDemoStatus('idle')+ }, 5000)+ }return (<div className='overflow-hidden'><main className='bg-gray-50 dark:bg-slate-900'>- {/* Hero Section */}<div className='relative isolate bg-gray-100/80 pt-2 dark:bg-slate-800/50'><div className='relative mx-2 overflow-hidden rounded-4xl'><div aria-hidden className='pointer-events-none absolute inset-0 -z-10'>@@ -48,7 +112,13 @@ const Captcha = () => {<Header transparent /><section className='mx-auto max-w-7xl px-4 pt-10 pb-20 sm:px-3 lg:px-6 lg:pt-20 xl:px-8'><div className='z-20 mx-auto flex max-w-4xl flex-col items-center text-center'>- <h1 className='text-5xl font-semibold tracking-tight text-pretty text-slate-900 sm:leading-none lg:mt-6 lg:text-6xl xl:text-7xl dark:text-white'>+ <Text+ as='h1'+ size='4xl'+ weight='semibold'+ tracking='tight'+ className='text-pretty sm:leading-none lg:mt-6 lg:text-6xl xl:text-7xl'+ ><Transt={t}i18nKey='captchaPage.slogan'@@ -58,10 +128,10 @@ const Captcha = () => {),}}/>- </h1>- <p className='mt-6 max-w-2xl text-lg text-slate-900 dark:text-gray-50'>+ </Text>+ <Text as='p' size='lg' className='mt-6 max-w-2xl'>{t('captchaPage.description')}- </p>+ </Text><div className='mt-8 flex flex-col items-stretch gap-4 sm:flex-row sm:items-center'><Linkto={routesPath.signup}@@ -73,29 +143,20 @@ const Captcha = () => {</span><ArrowRightIcon className='mt-px h-4 w-5' /></Link>- <a- href={`${DOCS_URL}/captcha/introduction`}- target='_blank'- rel='noopener noreferrer'- className='flex h-12 items-center justify-center rounded-md border-2 border-slate-900 bg-transparent px-6 text-slate-900 transition-all hover:bg-slate-900 hover:text-white dark:border-slate-50 dark:text-slate-50 dark:hover:bg-gray-50 dark:hover:text-slate-900'- >- <span className='text-center text-base font-semibold'>{t('common.docs')}</span>- </a></div></div></section></div></div>- {/* Features Section */}<div className='mx-auto mt-20 max-w-7xl bg-gray-50 px-4 pb-16 dark:bg-slate-900'><div className='text-center'>- <h2 className='text-3xl font-extrabold text-slate-900 sm:text-4xl dark:text-white'>+ <Text as='h2' size='3xl' weight='bold' className='sm:text-4xl'>{t('captchaPage.whySwetrix')}- </h2>- <p className='mx-auto mt-4 max-w-2xl text-lg text-gray-600 dark:text-gray-300'>+ </Text>+ <Text as='p' size='lg' colour='muted' className='mx-auto mt-4 max-w-2xl'>{t('captchaPage.whySwetrixDesc')}- </p>+ </Text></div><div className='mt-16 grid gap-8 sm:grid-cols-2 lg:gap-12'>@@ -105,56 +166,59 @@ const Captcha = () => {<feature.icon className='h-7 w-7 text-indigo-600 dark:text-indigo-400' aria-hidden='true' /></div><div>- <h3 className='text-xl font-semibold text-gray-900 dark:text-white'>{t(feature.titleKey)}</h3>- <p className='mt-2 text-base text-gray-600 dark:text-gray-300'>{t(feature.descKey)}</p>+ <Text as='h3' size='xl' weight='semibold'>+ {t(feature.titleKey)}+ </Text>+ <Text as='p' size='base' colour='muted' className='mt-2'>+ {t(feature.descKey)}+ </Text></div></div>))}</div></div>- {/* How it works */}<div className='mx-auto max-w-7xl px-4 py-20'>- <h2 className='text-center text-3xl font-extrabold text-slate-900 sm:text-4xl dark:text-white'>+ <Text as='h2' size='3xl' weight='bold' className='text-center sm:text-4xl'>{t('captchaPage.howItWorks.title')}- </h2>- <p className='mx-auto mt-4 max-w-2xl text-center text-lg text-gray-600 dark:text-gray-300'>+ </Text>+ <Text as='p' size='lg' colour='muted' className='mx-auto mt-4 max-w-2xl text-center'>{t('captchaPage.howItWorks.desc')}- </p>+ </Text><div className='mt-16 grid gap-8 md:grid-cols-3'><div className='relative text-center'><div className='mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-indigo-100 text-2xl font-bold text-indigo-600 dark:bg-indigo-900/30 dark:text-indigo-400'>1</div>- <h3 className='mt-6 text-lg font-semibold text-gray-900 dark:text-white'>+ <Text as='h3' size='lg' weight='semibold' className='mt-6'>{t('captchaPage.howItWorks.step1.title')}- </h3>- <p className='mt-2 text-base text-gray-600 dark:text-gray-300'>+ </Text>+ <Text as='p' size='base' colour='muted' className='mt-2'>{t('captchaPage.howItWorks.step1.desc')}- </p>+ </Text></div><div className='relative text-center'><div className='mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-indigo-100 text-2xl font-bold text-indigo-600 dark:bg-indigo-900/30 dark:text-indigo-400'>2</div>- <h3 className='mt-6 text-lg font-semibold text-gray-900 dark:text-white'>+ <Text as='h3' size='lg' weight='semibold' className='mt-6'>{t('captchaPage.howItWorks.step2.title')}- </h3>- <p className='mt-2 text-base text-gray-600 dark:text-gray-300'>+ </Text>+ <Text as='p' size='base' colour='muted' className='mt-2'>{t('captchaPage.howItWorks.step2.desc')}- </p>+ </Text></div><div className='relative text-center'><div className='mx-auto flex h-16 w-16 items-center justify-center rounded-full bg-indigo-100 text-2xl font-bold text-indigo-600 dark:bg-indigo-900/30 dark:text-indigo-400'>3</div>- <h3 className='mt-6 text-lg font-semibold text-gray-900 dark:text-white'>+ <Text as='h3' size='lg' weight='semibold' className='mt-6'>{t('captchaPage.howItWorks.step3.title')}- </h3>- <p className='mt-2 text-base text-gray-600 dark:text-gray-300'>+ </Text>+ <Text as='p' size='base' colour='muted' className='mt-2'>{t('captchaPage.howItWorks.step3.desc')}- </p>+ </Text></div></div>@@ -171,6 +235,109 @@ const Captcha = () => {</div></div>+ <div className='bg-gray-100 py-20 dark:bg-slate-800/50'>+ <div className='mx-auto max-w-7xl px-4'>+ <div className='grid gap-12 lg:grid-cols-2 lg:gap-16'>+ <div className='flex flex-col justify-center'>+ <Text+ as='p'+ size='sm'+ weight='semibold'+ tracking='wide'+ className='text-indigo-600 uppercase dark:text-indigo-400'+ >+ {t('captchaPage.demo.tagline')}+ </Text>+ <Text as='h2' size='3xl' weight='bold' className='mt-2 sm:text-4xl'>+ {t('captchaPage.demo.title')}+ </Text>+ <Text as='p' size='lg' colour='muted' className='mt-4'>+ {t('captchaPage.demo.description')}+ </Text>+ <Text as='p' size='lg' colour='muted' className='mt-4'>+ {t('captchaPage.demo.description2')}+ </Text>+ <div className='mt-8 flex flex-col items-stretch gap-4 sm:flex-row sm:items-center'>+ <Link+ to={routesPath.signup}+ className='flex h-12 items-center justify-center rounded-md border-2 border-slate-900 bg-slate-900 px-6 text-white transition-all hover:bg-transparent hover:text-slate-900 dark:border-slate-50 dark:bg-gray-50 dark:text-slate-900 dark:hover:text-gray-50'+ aria-label={t('titles.signup')}+ >+ <span className='mr-1 text-center text-base font-semibold'>+ {t('main.startAXDayFreeTrial', { amount: 14 })}+ </span>+ <ArrowRightIcon className='mt-px h-4 w-5' />+ </Link>+ <Link+ to='/captcha/demo'+ className='flex h-12 items-center justify-center rounded-md border-2 border-slate-900 bg-transparent px-6 text-slate-900 transition-all hover:bg-slate-900 hover:text-white dark:border-slate-50 dark:text-slate-50 dark:hover:bg-gray-50 dark:hover:text-slate-900'+ >+ <span className='text-center text-base font-semibold'>{t('captchaPage.demo.seeDevDemo')}</span>+ </Link>+ </div>+ </div>++ <div className='overflow-hidden rounded-lg border border-gray-200 bg-white px-4 pt-5 pb-4 dark:border-slate-800/60 dark:bg-slate-800/25'>+ <Text as='h3' size='2xl' weight='bold'>+ {t('captchaPage.demo.formTitle')}+ </Text>+ <Text as='p' colour='muted' className='mt-2'>+ {t('captchaPage.demo.formSubtitle')}+ </Text>++ {demoStatus === 'success' ? (+ <div className='mt-4 rounded-md bg-emerald-50 p-3 dark:bg-emerald-900/20'>+ <Text as='p' size='sm' weight='medium' colour='success'>+ {t('captchaPage.demo.success')}+ </Text>+ </div>+ ) : null}++ {demoStatus === 'error' && demoError ? (+ <div className='mt-4 rounded-md bg-red-50 p-3 dark:bg-red-900/20'>+ <Text as='p' size='sm' weight='medium' colour='error'>+ {demoError}+ </Text>+ </div>+ ) : null}++ <form onSubmit={handleDemoSubmit} className='mt-6 space-y-5'>+ <Input+ label={+ <>+ {t('captchaPage.demo.nameLabel')} <span className='text-red-500'>*</span>+ </>+ }+ value={demoName}+ onChange={(e) => setDemoName(e.target.value)}+ placeholder={t('captchaPage.demo.namePlaceholder')}+ required+ />++ <Textarea+ label={t('captchaPage.demo.messageLabel')}+ value={demoMessage}+ onChange={(e) => setDemoMessage(e.target.value)}+ placeholder={t('captchaPage.demo.messagePlaceholder')}+ rows={3}+ />++ <div className='swecaptcha' data-project-id={SWETRIX_PID} data-theme={theme} />+ {captchaScriptStatus === 'error' ? (+ <Text as='div' size='sm' colour='error'>+ Failed to load CAPTCHA. Please refresh the page.+ </Text>+ ) : null}++ <Button type='submit' primary giant className='w-full justify-center'>+ {t('captchaPage.demo.submit')}+ </Button>+ </form>+ </div>+ </div>+ </div>+ </div>+<MarketingPricing /><DitchGoogle />diff --git a/web/app/root.tsx b/web/app/root.tsxindex a1be2c6b2..9be8cf677 100644--- a/web/app/root.tsx+++ b/web/app/root.tsx@@ -44,6 +44,9 @@ declare global {env: anyPaddle: any++ // Swetrix CAPTCHA loader function+ swetrixCaptchaForceLoad?: () => void}}diff --git a/web/app/routes/captcha.tsx b/web/app/routes/captcha._index.tsxsimilarity index 100%rename from web/app/routes/captcha.tsxrename to web/app/routes/captcha._index.tsxdiff --git a/web/app/routes/captcha.demo.tsx b/web/app/routes/captcha.demo.tsxnew file mode 100644index 000000000..0678fb459--- /dev/null+++ b/web/app/routes/captcha.demo.tsx@@ -0,0 +1,22 @@+import { redirect } from 'react-router'+import type { SitemapFunction } from 'remix-sitemap'++import { isDisableMarketingPages, isSelfhosted } from '~/lib/constants'+import CaptchaDemo from '~/pages/Captcha/CaptchaDemo'++export const sitemap: SitemapFunction = () => ({+ priority: 0.8,+ exclude: isSelfhosted || isDisableMarketingPages,+})++export async function loader() {+ if (isSelfhosted || isDisableMarketingPages) {+ return redirect('/login', 302)+ }++ return null+}++export default function CaptchaDemoRoute() {+ return <CaptchaDemo />+}diff --git a/web/app/utils/analytics.ts b/web/app/utils/analytics.tsindex fd3fda683..2a41a004d 100644--- a/web/app/utils/analytics.ts+++ b/web/app/utils/analytics.ts@@ -3,7 +3,7 @@ import * as Swetrix from 'swetrix'import { isBrowser, isDevelopment, isIframe, isSelfhosted } from '~/lib/constants'-const SWETRIX_PID = 'STEzHcB1rALV'+export const SWETRIX_PID = 'STEzHcB1rALV'const REFS_TO_IGNORE = [/https:\/\/swetrix.com\/projects\/(?!new$)[^/]+$/i,diff --git a/web/app/utils/routes.ts b/web/app/utils/routes.tsindex 3eb7b3fed..45091228e 100644--- a/web/app/utils/routes.ts+++ b/web/app/utils/routes.ts@@ -4,6 +4,7 @@ const routes = Object.freeze({performance: '/performance',errorTracking: '/error-tracking',captchaLanding: '/captcha',+ captchaDemo: '/captcha/demo',onboarding: '/onboarding',reset_password: '/recovery',new_password_form: '/password-reset/:id',diff --git a/web/public/locales/de.json b/web/public/locales/de.jsonindex f596f836f..22b67a0ef 100644--- a/web/public/locales/de.json+++ b/web/public/locales/de.json@@ -238,6 +238,45 @@"desc": "Verwenden Sie unsere API, um die CAPTCHA-Antwort auf Ihrem Server zu verifizieren und Bots herauszufiltern"},"readDocs": "Dokumentation lesen"+ },+ "demo": {+ "tagline": "Probieren Sie es selbst aus",+ "title": "Erleben Sie Swetrix CAPTCHA",+ "description": "Swetrix CAPTCHA verwendet eine unsichtbare Proof-of-Work-Prüfung. Statt nerviger Rätsel prüft es das Gerät des Nutzers im Hintergrund.",+ "description2": "Nutzer führen eine kurze Verifizierung durch, um zu beweisen, dass sie Menschen sind. Dieser einfache Schritt schützt Ihre Formulare vor Spam und automatisierten Angriffen.",+ "seeDevDemo": "Entwickler-Demo ansehen",+ "formTitle": "Demo",+ "formSubtitle": "Nutzen Sie das Beispielformular, um Swetrix CAPTCHA in Aktion zu erleben.",+ "nameLabel": "Testname",+ "namePlaceholder": "Geben Sie Ihren Namen ein",+ "messageLabel": "Testnachricht",+ "messagePlaceholder": "Geben Sie eine Nachricht ein (optional)",+ "submit": "Absenden",+ "success": "Formular erfolgreich gesendet! Die CAPTCHA-Verifizierung war erfolgreich.",+ "errors": {+ "notCompleted": "Bitte schließen Sie zuerst die CAPTCHA-Verifizierung ab."+ }+ },+ "demoPage": {+ "title": "Swetrix CAPTCHA Entwickler-Demo",+ "subtitle": "CAPTCHA-Widget testen und konfigurieren",+ "captchaWidget": "CAPTCHA-Widget",+ "configuration": "Konfiguration",+ "theme": "Design",+ "themeAuto": "Automatisch",+ "themeLight": "Hell",+ "themeDark": "Dunkel",+ "mode": "Modus",+ "modeReal": "Echtes Beispiel",+ "modeAlwaysPass": "Immer bestehen",+ "modeAlwaysFail": "Immer fehlschlagen",+ "serverValidation": "Serverseitige Token-Validierung",+ "tokenType": "Token-Typ",+ "tokenAlwaysPass": "Immer bestehen",+ "tokenAlwaysFail": "Immer fehlschlagen",+ "tokenAlreadyUsed": "Fehlschlag (Token bereits verwendet)",+ "validateButton": "Validieren",+ "learnMore": "Erfahren Sie in unserer Dokumentation mehr über die Integration von CAPTCHA."}},"marketers": {diff --git a/web/public/locales/en.json b/web/public/locales/en.jsonindex c19de2cec..b01cab4aa 100644--- a/web/public/locales/en.json+++ b/web/public/locales/en.json@@ -238,6 +238,45 @@"desc": "Use our API to verify the CAPTCHA response on your server and filter out bots"},"readDocs": "Read the documentation"+ },+ "demo": {+ "tagline": "Try it yourself",+ "title": "Experience Swetrix CAPTCHA",+ "description": "Swetrix CAPTCHA uses an invisible proof-of-work challenge. Instead of annoying puzzles, it checks the user's device in the background.",+ "description2": "Users complete a quick verification to prove they are human. This simple step secures your forms against spam and automated attacks.",+ "seeDevDemo": "See developer demo",+ "formTitle": "Demo",+ "formSubtitle": "Use the sample form to experience Swetrix CAPTCHA in action.",+ "nameLabel": "Test Name",+ "namePlaceholder": "Enter your name",+ "messageLabel": "Test Message",+ "messagePlaceholder": "Enter a message (optional)",+ "submit": "Submit",+ "success": "Form submitted successfully! The CAPTCHA verification passed.",+ "errors": {+ "notCompleted": "Please complete the CAPTCHA verification first."+ }+ },+ "demoPage": {+ "title": "Swetrix CAPTCHA Developer Demo",+ "subtitle": "Test and configure the CAPTCHA widget",+ "captchaWidget": "CAPTCHA Widget",+ "configuration": "Configuration",+ "theme": "Theme",+ "themeAuto": "Auto",+ "themeLight": "Light",+ "themeDark": "Dark",+ "mode": "Mode",+ "modeReal": "Real example",+ "modeAlwaysPass": "Always pass",+ "modeAlwaysFail": "Always fail",+ "serverValidation": "Token server-side validation",+ "tokenType": "Token type",+ "tokenAlwaysPass": "Always pass",+ "tokenAlwaysFail": "Always fail",+ "tokenAlreadyUsed": "Fail (token already used)",+ "validateButton": "Validate",+ "learnMore": "Learn more about integrating CAPTCHA in our documentation."}},"marketers": {diff --git a/web/public/locales/fr.json b/web/public/locales/fr.jsonindex 3456792c9..d5238682d 100644--- a/web/public/locales/fr.json+++ b/web/public/locales/fr.json@@ -238,6 +238,45 @@"desc": "Utilisez notre API pour vérifier la réponse CAPTCHA sur votre serveur et filtrer les bots"},"readDocs": "Lire la documentation"+ },+ "demo": {+ "tagline": "Essayez par vous-même",+ "title": "Découvrez Swetrix CAPTCHA",+ "description": "Swetrix CAPTCHA utilise un défi de preuve de travail invisible. Au lieu de puzzles agaçants, il vérifie l’appareil de l’utilisateur en arrière-plan.",+ "description2": "Les utilisateurs effectuent une vérification rapide pour prouver qu’ils sont humains. Cette étape simple protège vos formulaires contre le spam et les attaques automatisées.",+ "seeDevDemo": "Voir la démo pour développeurs",+ "formTitle": "Démo",+ "formSubtitle": "Utilisez le formulaire d’exemple pour voir Swetrix CAPTCHA en action.",+ "nameLabel": "Nom de test",+ "namePlaceholder": "Saisissez votre nom",+ "messageLabel": "Message de test",+ "messagePlaceholder": "Saisissez un message (facultatif)",+ "submit": "Envoyer",+ "success": "Formulaire envoyé avec succès ! La vérification CAPTCHA a réussi.",+ "errors": {+ "notCompleted": "Veuillez d’abord terminer la vérification CAPTCHA."+ }+ },+ "demoPage": {+ "title": "Démo développeur Swetrix CAPTCHA",+ "subtitle": "Testez et configurez le widget CAPTCHA",+ "captchaWidget": "Widget CAPTCHA",+ "configuration": "Configuration",+ "theme": "Thème",+ "themeAuto": "Automatique",+ "themeLight": "Clair",+ "themeDark": "Sombre",+ "mode": "Mode",+ "modeReal": "Exemple réel",+ "modeAlwaysPass": "Toujours réussir",+ "modeAlwaysFail": "Toujours échouer",+ "serverValidation": "Validation du jeton côté serveur",+ "tokenType": "Type de jeton",+ "tokenAlwaysPass": "Toujours réussir",+ "tokenAlwaysFail": "Toujours échouer",+ "tokenAlreadyUsed": "Échec (jeton déjà utilisé)",+ "validateButton": "Valider",+ "learnMore": "En savoir plus sur l’intégration du CAPTCHA dans notre documentation."}},"marketers": {diff --git a/web/public/locales/pl.json b/web/public/locales/pl.jsonindex a6df71056..34cc96a53 100644--- a/web/public/locales/pl.json+++ b/web/public/locales/pl.json@@ -238,6 +238,45 @@"desc": "Użyj naszego API, aby zweryfikować odpowiedź CAPTCHA na swoim serwerze i odfiltrować boty"},"readDocs": "Przeczytaj dokumentację"+ },+ "demo": {+ "tagline": "Wypróbuj samodzielnie",+ "title": "Wypróbuj Swetrix CAPTCHA",+ "description": "Swetrix CAPTCHA wykorzystuje niewidoczne wyzwanie typu proof-of-work. Zamiast irytujących łamigłówek sprawdza urządzenie użytkownika w tle.",+ "description2": "Użytkownicy przechodzą szybką weryfikację, aby udowodnić, że są ludźmi. Ten prosty krok zabezpiecza Twoje formularze przed spamem i zautomatyzowanymi atakami.",+ "seeDevDemo": "Zobacz demo dla deweloperów",+ "formTitle": "Demo",+ "formSubtitle": "Użyj przykładowego formularza, aby zobaczyć Swetrix CAPTCHA w działaniu.",+ "nameLabel": "Nazwa testowa",+ "namePlaceholder": "Wpisz swoje imię i nazwisko",+ "messageLabel": "Wiadomość testowa",+ "messagePlaceholder": "Wpisz wiadomość (opcjonalnie)",+ "submit": "Wyślij",+ "success": "Formularz wysłano pomyślnie! Weryfikacja CAPTCHA zakończona sukcesem.",+ "errors": {+ "notCompleted": "Najpierw ukończ weryfikację CAPTCHA."+ }+ },+ "demoPage": {+ "title": "Demo deweloperskie Swetrix CAPTCHA",+ "subtitle": "Testuj i konfiguruj widżet CAPTCHA",+ "captchaWidget": "Widżet CAPTCHA",+ "configuration": "Konfiguracja",+ "theme": "Motyw",+ "themeAuto": "Automatyczny",+ "themeLight": "Jasny",+ "themeDark": "Ciemny",+ "mode": "Tryb",+ "modeReal": "Prawdziwy przykład",+ "modeAlwaysPass": "Zawsze zaliczaj",+ "modeAlwaysFail": "Zawsze nie zaliczaj",+ "serverValidation": "Walidacja tokenu po stronie serwera",+ "tokenType": "Typ tokenu",+ "tokenAlwaysPass": "Zawsze zaliczaj",+ "tokenAlwaysFail": "Zawsze nie zaliczaj",+ "tokenAlreadyUsed": "Niepowodzenie (token został już użyty)",+ "validateButton": "Zweryfikuj",+ "learnMore": "Dowiedz się więcej o integracji CAPTCHA w naszej dokumentacji."}},"marketers": {diff --git a/web/public/locales/uk.json b/web/public/locales/uk.jsonindex f6ef5a030..f8dfd6607 100644--- a/web/public/locales/uk.json+++ b/web/public/locales/uk.json@@ -238,6 +238,45 @@"desc": "Використовуйте наш API, щоб перевірити відповідь CAPTCHA на вашому сервері та відфільтрувати ботів"},"readDocs": "Прочитати документацію"+ },+ "demo": {+ "tagline": "Спробуйте самі",+ "title": "Спробуйте Swetrix CAPTCHA",+ "description": "Swetrix CAPTCHA використовує невидиму перевірку proof-of-work. Замість набридливих головоломок він перевіряє пристрій користувача у фоновому режимі.",+ "description2": "Користувачі проходять швидку перевірку, щоб довести, що вони люди. Цей простий крок захищає ваші форми від спаму та автоматизованих атак.",+ "seeDevDemo": "Переглянути демо для розробників",+ "formTitle": "Демо",+ "formSubtitle": "Скористайтеся прикладом форми, щоб побачити Swetrix CAPTCHA у дії.",+ "nameLabel": "Тестове ім’я",+ "namePlaceholder": "Введіть своє ім’я",+ "messageLabel": "Тестове повідомлення",+ "messagePlaceholder": "Введіть повідомлення (необов’язково)",+ "submit": "Надіслати",+ "success": "Форму успішно надіслано! Перевірку CAPTCHA пройдено.",+ "errors": {+ "notCompleted": "Будь ласка, спочатку пройдіть перевірку CAPTCHA."+ }+ },+ "demoPage": {+ "title": "Демо для розробників Swetrix CAPTCHA",+ "subtitle": "Тестуйте та налаштовуйте віджет CAPTCHA",+ "captchaWidget": "Віджет CAPTCHA",+ "configuration": "Налаштування",+ "theme": "Тема",+ "themeAuto": "Автоматично",+ "themeLight": "Світла",+ "themeDark": "Темна",+ "mode": "Режим",+ "modeReal": "Реальний приклад",+ "modeAlwaysPass": "Завжди проходить",+ "modeAlwaysFail": "Завжди не проходить",+ "serverValidation": "Перевірка токена на стороні сервера",+ "tokenType": "Тип токена",+ "tokenAlwaysPass": "Завжди проходить",+ "tokenAlwaysFail": "Завжди не проходить",+ "tokenAlreadyUsed": "Помилка (токен уже використано)",+ "validateButton": "Перевірити",+ "learnMore": "Дізнайтеся більше про інтеграцію CAPTCHA в нашій документації."}},"marketers": {