Skip to content

📈 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!

Rework onboarding

Blue Mouse47bb0d94707d
diff --git a/web/app/App.tsx b/web/app/App.tsx
index 93a10a2d5..535a2f635 100644
--- a/web/app/App.tsx
+++ b/web/app/App.tsx
@@ -16,6 +16,7 @@ const App = () => {
const { theme } = useTheme()
const isReferralPage = _startsWith(pathname, '/ref/')
+ const isOnboardingPage = pathname === routesPath.onboarding
const isProjectViewPage =
_startsWith(pathname, '/projects/') &&
!_endsWith(pathname, '/new') &&
@@ -39,7 +40,8 @@ const App = () => {
<>
{!_includes(routesWithOutHeader, pathname) &&
!isReferralPage &&
- !isProjectViewPage ? (
+ !isProjectViewPage &&
+ !isOnboardingPage ? (
<Header />
) : null}
<Outlet />
@@ -49,7 +51,9 @@ const App = () => {
duration: 5000,
}}
/>
- {!isReferralPage && !isProjectViewPage ? <Footer /> : null}
+ {!isReferralPage && !isProjectViewPage && !isOnboardingPage ? (
+ <Footer />
+ ) : null}
</>
)
}
diff --git a/web/app/pages/Onboarding/Onboarding.tsx b/web/app/pages/Onboarding/Onboarding.tsx
index a6f33e58d..47ebdfecf 100644
--- a/web/app/pages/Onboarding/Onboarding.tsx
+++ b/web/app/pages/Onboarding/Onboarding.tsx
@@ -1,30 +1,42 @@
-import type { TFunction } from 'i18next'
+import { AnimatePresence, motion, useReducedMotion } from 'framer-motion'
+import _map from 'lodash/map'
import {
- CaretRightIcon,
- LaptopIcon,
+ ChartLineUpIcon,
+ BugIcon,
+ UsersThreeIcon,
RocketIcon,
CodeIcon,
- EnvelopeOpenIcon,
- SparkleIcon,
EnvelopeIcon,
CheckCircleIcon,
+ SparkleIcon,
+ GlobeIcon,
+ ClockIcon,
} from '@phosphor-icons/react'
-import { useState, useEffect, useMemo, useRef } from 'react'
+import { useState, useEffect, useRef, useCallback } from 'react'
import { Trans, useTranslation } from 'react-i18next'
-import { Link, useNavigate, useFetcher, useLoaderData } from 'react-router'
+import { useNavigate, useFetcher, useLoaderData } from 'react-router'
import { toast } from 'sonner'
-import { CONTACT_US_URL } from '~/components/Footer'
import { useAuthProxy } from '~/hooks/useAuthProxy'
-import { DOCS_URL, INTEGRATIONS_URL, isSelfhosted } from '~/lib/constants'
+import {
+ DOCS_URL,
+ INTEGRATIONS_URL,
+ isSelfhosted,
+ whitelist,
+ languages,
+ languageFlag,
+} from '~/lib/constants'
+import { changeLanguage } from '~/i18n'
import { getSnippet } from '~/modals/TrackingSnippet'
import { useAuth } from '~/providers/AuthProvider'
+import { useTheme } from '~/providers/ThemeProvider'
import type {
OnboardingActionData,
OnboardingLoaderData,
} from '~/routes/onboarding'
import { Badge } from '~/ui/Badge'
import Button from '~/ui/Button'
+import Flag from '~/ui/Flag'
import PulsatingCircle from '~/ui/icons/PulsatingCircle'
import Input from '~/ui/Input'
import Loader from '~/ui/Loader'
@@ -35,49 +47,349 @@ import { cn } from '~/utils/generic'
import routes from '~/utils/routes'
const MAX_PROJECT_NAME_LENGTH = 50
+const ANIMATION_DURATION = 0.4
+const EASE_OUT_QUART = [0.25, 1, 0.5, 1] as const
-const STEP_ICONS = {
- confirm_email: EnvelopeOpenIcon,
- create_project: RocketIcon,
- setup_tracking: CodeIcon,
- waiting_for_events: SparkleIcon,
+interface Project {
+ id: string
+ name: string
}
-const getOnboardingSteps = (t: TFunction) => [
- {
- id: 'confirm_email',
- title: t('onboarding.confirm.navTitle'),
- description: t('onboarding.confirm.navDesc'),
- completed: false,
- uiHidden: isSelfhosted,
- },
- {
- id: 'create_project',
- title: t('onboarding.createProject.navTitle'),
- description: t('onboarding.createProject.navDesc'),
- completed: false,
- },
- {
- id: 'setup_tracking',
- title: t('onboarding.installTracking.navTitle'),
- description: t('onboarding.installTracking.navDesc'),
- completed: false,
- },
- {
- id: 'waiting_for_events',
- title: t('onboarding.verifyInstallation.navTitle'),
- description: t('onboarding.verifyInstallation.navDesc'),
- completed: false,
+type OnboardingStep =
+ | 'language'
+ | 'welcome'
+ | 'feature_traffic'
+ | 'feature_errors'
+ | 'feature_sessions'
+ | 'create_project'
+ | 'setup_tracking'
+ | 'verify_email'
+
+const getSteps = (): OnboardingStep[] => {
+ const baseSteps: OnboardingStep[] = [
+ 'language',
+ 'welcome',
+ 'feature_traffic',
+ 'feature_errors',
+ 'feature_sessions',
+ 'create_project',
+ 'setup_tracking',
+ ]
+
+ if (!isSelfhosted) {
+ baseSteps.push('verify_email')
+ }
+
+ return baseSteps
+}
+
+const STEPS = getSteps()
+
+const slideVariants = {
+ enter: (direction: number) => ({
+ x: direction > 0 ? 40 : -40,
+ opacity: 0,
+ }),
+ center: {
+ x: 0,
+ opacity: 1,
},
-]
+ exit: (direction: number) => ({
+ x: direction < 0 ? 40 : -40,
+ opacity: 0,
+ }),
+}
-interface Project {
- id: string
- name: string
+const reducedMotionVariants = {
+ enter: { opacity: 0 },
+ center: { opacity: 1 },
+ exit: { opacity: 0 },
+}
+
+const ProgressBar = ({
+ currentStep,
+ totalSteps,
+}: {
+ currentStep: number
+ totalSteps: number
+}) => {
+ const progress = ((currentStep + 1) / totalSteps) * 100
+
+ return (
+ <div className='h-1 w-full overflow-hidden rounded-full bg-gray-100 dark:bg-slate-700/50'>
+ <motion.div
+ className='h-full rounded-full bg-indigo-500'
+ initial={{ width: 0 }}
+ animate={{ width: `${progress}%` }}
+ transition={{
+ duration: 0.3,
+ ease: EASE_OUT_QUART,
+ }}
+ />
+ </div>
+ )
+}
+
+const FeatureVisualization = ({
+ type,
+}: {
+ type: 'traffic' | 'errors' | 'sessions'
+}) => {
+ if (type === 'traffic') {
+ return (
+ <div className='relative mx-auto mt-8 w-full max-w-lg'>
+ <div className='overflow-hidden rounded-xl bg-white p-6 shadow-xl ring-1 ring-black/5 dark:bg-slate-800 dark:ring-white/10'>
+ <div className='mb-4 flex items-center justify-between'>
+ <div className='flex items-center gap-2'>
+ <div className='flex size-8 items-center justify-center rounded-lg bg-indigo-100 dark:bg-indigo-900/30'>
+ <ChartLineUpIcon className='size-4 text-indigo-600 dark:text-indigo-400' />
+ </div>
+ <Text as='span' size='sm' weight='medium'>
+ Page Views
+ </Text>
+ </div>
+ <Badge label='+24%' colour='green' />
+ </div>
+ <div className='flex items-end gap-1'>
+ {[40, 55, 35, 65, 45, 80, 60, 90, 70, 95, 85, 100].map(
+ (height, i) => (
+ <motion.div
+ key={i}
+ className='flex-1 rounded-t bg-indigo-500'
+ initial={{ height: 0 }}
+ animate={{ height: `${height}px` }}
+ transition={{
+ delay: i * 0.04,
+ duration: 0.4,
+ ease: EASE_OUT_QUART,
+ }}
+ />
+ ),
+ )}
+ </div>
+ <div className='mt-4 grid grid-cols-3 gap-4'>
+ <div className='rounded-lg bg-gray-50 p-3 dark:bg-slate-700/50'>
+ <Text as='span' size='xs' colour='muted' className='block'>
+ Visitors
+ </Text>
+ <Text as='span' size='lg' weight='semibold'>
+ 12.4K
+ </Text>
+ </div>
+ <div className='rounded-lg bg-gray-50 p-3 dark:bg-slate-700/50'>
+ <Text as='span' size='xs' colour='muted' className='block'>
+ Bounce Rate
+ </Text>
+ <Text as='span' size='lg' weight='semibold'>
+ 42%
+ </Text>
+ </div>
+ <div className='rounded-lg bg-gray-50 p-3 dark:bg-slate-700/50'>
+ <Text as='span' size='xs' colour='muted' className='block'>
+ Avg. Time
+ </Text>
+ <Text as='span' size='lg' weight='semibold'>
+ 2:34
+ </Text>
+ </div>
+ </div>
+ </div>
+ <div className='absolute -right-2 -bottom-2 -z-10 size-full rounded-xl bg-indigo-100 dark:bg-indigo-900/30' />
+ </div>
+ )
+ }
+
+ if (type === 'errors') {
+ return (
+ <div className='relative mx-auto mt-8 w-full max-w-lg'>
+ <div className='overflow-hidden rounded-xl bg-white p-6 shadow-xl ring-1 ring-black/5 dark:bg-slate-800 dark:ring-white/10'>
+ <div className='mb-4 flex items-center justify-between'>
+ <div className='flex items-center gap-2'>
+ <div className='flex size-8 items-center justify-center rounded-lg bg-rose-100 dark:bg-rose-900/30'>
+ <BugIcon className='size-4 text-rose-600 dark:text-rose-400' />
+ </div>
+ <Text as='span' size='sm' weight='medium'>
+ Error Tracking
+ </Text>
+ </div>
+ <Badge label='3 new' colour='red' />
+ </div>
+ <div className='space-y-3'>
+ {[
+ {
+ type: 'TypeError',
+ message: "Cannot read property 'map' of undefined",
+ count: 23,
+ },
+ {
+ type: 'ReferenceError',
+ message: 'window is not defined',
+ count: 12,
+ },
+ {
+ type: 'NetworkError',
+ message: 'Failed to fetch /api/data',
+ count: 8,
+ },
+ ].map((error, i) => (
+ <motion.div
+ key={i}
+ initial={{ opacity: 0, x: -16 }}
+ animate={{ opacity: 1, x: 0 }}
+ transition={{
+ delay: i * 0.08,
+ duration: 0.3,
+ ease: EASE_OUT_QUART,
+ }}
+ className='flex items-start gap-3 rounded-lg bg-rose-50 p-3 dark:bg-rose-900/20'
+ >
+ <div className='mt-0.5 size-2 shrink-0 rounded-full bg-rose-500' />
+ <div className='min-w-0 flex-1'>
+ <Text
+ as='span'
+ size='xs'
+ weight='semibold'
+ className='text-rose-700 dark:text-rose-300'
+ >
+ {error.type}
+ </Text>
+ <Text as='p' size='xs' colour='muted' className='truncate'>
+ {error.message}
+ </Text>
+ </div>
+ <Badge label={String(error.count)} colour='slate' />
+ </motion.div>
+ ))}
+ </div>
+ </div>
+ <div className='absolute -right-2 -bottom-2 -z-10 size-full rounded-xl bg-rose-100 dark:bg-rose-900/30' />
+ </div>
+ )
+ }
+
+ return (
+ <div className='relative mx-auto mt-8 w-full max-w-lg'>
+ <div className='overflow-hidden rounded-xl bg-white p-6 shadow-xl ring-1 ring-black/5 dark:bg-slate-800 dark:ring-white/10'>
+ <div className='mb-4 flex items-center justify-between'>
+ <div className='flex items-center gap-2'>
+ <div className='flex size-8 items-center justify-center rounded-lg bg-emerald-100 dark:bg-emerald-900/30'>
+ <UsersThreeIcon className='size-4 text-emerald-600 dark:text-emerald-400' />
+ </div>
+ <Text as='span' size='sm' weight='medium'>
+ User Sessions
+ </Text>
+ </div>
+ <div className='flex items-center gap-1 text-emerald-600 dark:text-emerald-400'>
+ <PulsatingCircle type='small' />
+ <Text as='span' size='xs' weight='medium'>
+ 12 online
+ </Text>
+ </div>
+ </div>
+ <div className='space-y-3'>
+ {[
+ {
+ country: 'US',
+ pages: 5,
+ duration: '4:23',
+ device: 'Desktop',
+ },
+ {
+ country: 'DE',
+ pages: 3,
+ duration: '2:15',
+ device: 'Mobile',
+ },
+ {
+ country: 'GB',
+ pages: 8,
+ duration: '6:42',
+ device: 'Desktop',
+ },
+ ].map((session, i) => (
+ <motion.div
+ key={i}
+ initial={{ opacity: 0, y: 8 }}
+ animate={{ opacity: 1, y: 0 }}
+ transition={{
+ delay: i * 0.08,
+ duration: 0.3,
+ ease: EASE_OUT_QUART,
+ }}
+ className='flex items-center gap-3 rounded-lg bg-gray-50 p-3 dark:bg-slate-700/50'
+ >
+ <Flag country={session.country} size={20} />
+ <div className='flex-1'>
+ <div className='flex items-center gap-2'>
+ <Text as='span' size='xs' weight='medium'>
+ {session.pages} pages
+ </Text>
+ <Text as='span' size='xs' colour='muted'>
+ •
+ </Text>
+ <Text as='span' size='xs' colour='muted'>
+ {session.device}
+ </Text>
+ </div>
+ </div>
+ <div className='flex items-center gap-1 text-gray-500 dark:text-gray-400'>
+ <ClockIcon className='size-3' />
+ <Text as='span' size='xs'>
+ {session.duration}
+ </Text>
+ </div>
+ </motion.div>
+ ))}
+ </div>
+ </div>
+ <div className='absolute -right-2 -bottom-2 -z-10 size-full rounded-xl bg-emerald-100 dark:bg-emerald-900/30' />
+ </div>
+ )
+}
+
+const ProjectVisualization = () => {
+ return (
+ <div className='relative mx-auto mb-8 w-full max-w-md'>
+ <div className='overflow-hidden rounded-xl bg-white p-6 shadow-lg ring-1 ring-black/5 dark:bg-slate-800 dark:ring-white/10'>
+ <div className='flex items-center gap-4'>
+ <motion.div
+ initial={{ scale: 0, opacity: 0 }}
+ animate={{ scale: 1, opacity: 1 }}
+ transition={{ delay: 0.15, duration: 0.4, ease: EASE_OUT_QUART }}
+ className='flex size-14 items-center justify-center rounded-xl bg-indigo-500'
+ >
+ <RocketIcon className='size-7 text-white' weight='fill' />
+ </motion.div>
+ <div className='flex-1 space-y-2'>
+ <motion.div
+ initial={{ scaleX: 0, originX: 0 }}
+ animate={{ scaleX: 1 }}
+ transition={{ delay: 0.25, duration: 0.4, ease: EASE_OUT_QUART }}
+ className='h-4 w-3/4 rounded bg-gray-200 dark:bg-slate-600'
+ />
+ <motion.div
+ initial={{ scaleX: 0, originX: 0 }}
+ animate={{ scaleX: 1 }}
+ transition={{ delay: 0.35, duration: 0.4, ease: EASE_OUT_QUART }}
+ className='h-3 w-full rounded bg-gray-100 dark:bg-slate-700'
+ />
+ <motion.div
+ initial={{ scaleX: 0, originX: 0 }}
+ animate={{ scaleX: 1 }}
+ transition={{ delay: 0.45, duration: 0.4, ease: EASE_OUT_QUART }}
+ className='h-3 w-3/5 rounded bg-gray-100 dark:bg-slate-700'
+ />
+ </div>
+ </div>
+ </div>
+ </div>
+ )
}
const Onboarding = () => {
- const { t } = useTranslation('common')
+ const { t, i18n } = useTranslation('common')
+ const { theme } = useTheme()
+ const prefersReducedMotion = useReducedMotion()
const loaderData = useLoaderData<OnboardingLoaderData>()
const { user, loadUser, logout } = useAuth()
const { authMe } = useAuthProxy()
@@ -85,19 +397,28 @@ const Onboarding = () => {
const fetcher = useFetcher<OnboardingActionData>()
const lastHandledFetcherDataRef = useRef<OnboardingActionData | null>(null)
- const [currentStep, setCurrentStep] = useState(0)
+ const [currentStepIndex, setCurrentStepIndex] = useState(0)
+ const [direction, setDirection] = useState(0)
const [projectName, setProjectName] = useState('')
const [project, setProject] = useState<Project | null>(loaderData.project)
const [isWaitingForEvents, setIsWaitingForEvents] = useState(false)
const [hasEvents, setHasEvents] = useState(false)
+ const [selectedLanguage, setSelectedLanguage] = useState(i18n.language)
const [newProjectErrors, setNewProjectErrors] = useState<{
name?: string
}>({})
+ const [isCheckingVerification, setIsCheckingVerification] = useState(false)
+ const currentStep = STEPS[currentStepIndex]
const isLoading =
fetcher.state === 'submitting' || fetcher.state === 'loading'
+ const stepsForProgress = STEPS
+
+ const totalSteps = stepsForProgress.length
+ const progressStepIndex = stepsForProgress.indexOf(currentStep)
+
useEffect(() => {
if (!fetcher.data) return
if (lastHandledFetcherDataRef.current === fetcher.data) return
@@ -108,12 +429,7 @@ const Onboarding = () => {
if (intent === 'create-project' && newProject) {
setTimeout(() => setProject(newProject), 0)
- // Update the step after project creation
- const stepFormData = new FormData()
- stepFormData.set('intent', 'update-step')
- stepFormData.set('step', 'setup_tracking')
- fetcher.submit(stepFormData, { method: 'post' })
- setTimeout(() => setCurrentStep(2), 0)
+ goToStep('setup_tracking')
} else if (intent === 'update-step') {
loadUser()
} else if (intent === 'complete-onboarding') {
@@ -140,33 +456,17 @@ const Onboarding = () => {
return
}
- if (!user?.isActive && !isSelfhosted) {
- setTimeout(() => setCurrentStep(0), 0)
- return
- }
-
- if (!user?.onboardingStep) {
- setTimeout(() => setCurrentStep(1), 0)
+ if (user?.onboardingStep === 'setup_tracking' && project) {
+ goToStep('setup_tracking')
return
}
- switch (user.onboardingStep) {
- case 'create_project':
- setTimeout(() => setCurrentStep(1), 0)
- break
- case 'setup_tracking':
- setTimeout(() => setCurrentStep(2), 0)
- break
- case 'waiting_for_events':
- setTimeout(() => {
- setCurrentStep(3)
- setIsWaitingForEvents(true)
- }, 0)
- break
- default:
- setTimeout(() => setCurrentStep(1), 0)
+ if (user?.onboardingStep === 'waiting_for_events' && project) {
+ goToStep('setup_tracking')
+ setIsWaitingForEvents(true)
}
- }, [user, navigate])
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [user, navigate, project])
useEffect(() => {
if (!isWaitingForEvents || !project) return
@@ -178,8 +478,8 @@ const Onboarding = () => {
setHasEvents(true)
setIsWaitingForEvents(false)
}
- } catch (reason) {
- console.error('Failed to check for events:', reason)
+ } catch {
+ // Silently handle error - will retry on next interval
}
}
@@ -187,13 +487,39 @@ const Onboarding = () => {
return () => clearInterval(interval)
}, [isWaitingForEvents, project, authMe])
- const updateUserStep = (step: string) => {
- if (fetcher.state !== 'idle') return
+ const goToStep = useCallback(
+ (step: OnboardingStep) => {
+ const newIndex = STEPS.indexOf(step)
+ setDirection(newIndex > currentStepIndex ? 1 : -1)
+ setCurrentStepIndex(newIndex)
+ },
+ [currentStepIndex],
+ )
- const formData = new FormData()
- formData.set('intent', 'update-step')
- formData.set('step', step)
- fetcher.submit(formData, { method: 'post' })
+ const goNext = useCallback(() => {
+ if (currentStepIndex < STEPS.length - 1) {
+ setDirection(1)
+ setCurrentStepIndex((prev) => prev + 1)
+ }
+ }, [currentStepIndex])
+
+ const goBack = useCallback(() => {
+ if (currentStepIndex > 0) {
+ setDirection(-1)
+ setCurrentStepIndex((prev) => prev - 1)
+ }
+ }, [currentStepIndex])
+
+ const handleLanguageSelect = (lng: string) => {
+ setSelectedLanguage(lng)
+ }
+
+ const handleLanguageConfirm = () => {
+ if (selectedLanguage !== i18n.language) {
+ changeLanguage(selectedLanguage)
+ } else {
+ goNext()
+ }
}
const handleCreateProject = (e?: React.FormEvent<HTMLFormElement>) => {
@@ -243,526 +569,570 @@ const Onboarding = () => {
fetcher.submit(formData, { method: 'post' })
}
- const steps = useMemo(() => {
- return getOnboardingSteps(t).map((step, index) => ({
- ...step,
- completed:
- index < currentStep ||
- (index === currentStep &&
- ((index === 0 && user?.isActive) || // Email step is completed when user is active
- (index === 3 && hasEvents))), // Events step is completed when we have events
- current: index === currentStep,
- }))
- }, [t, currentStep, hasEvents, user?.isActive])
+ const handleSkipTracking = () => {
+ if (isSelfhosted) {
+ handleCompleteOnboarding(true)
+ } else {
+ goNext()
+ }
+ }
if (!user) {
return (
- <div className='flex min-h-min-footer items-center justify-center bg-gray-50 dark:bg-slate-900'>
+ <div className='flex min-h-screen items-center justify-center bg-gray-50 dark:bg-slate-900'>
<Loader />
</div>
)
}
- const progressPercentage = (currentStep / (steps.length - 1)) * 100
- const visibleSteps = steps.filter((step) => !step.uiHidden)
-
return (
- <div className='min-h-min-footer bg-gray-50 dark:bg-slate-900'>
- <div className='mx-auto flex max-w-6xl gap-6 px-4 py-6 md:px-6 lg:px-8'>
- {/* Sidebar - Desktop */}
- <aside className='sticky top-6 hidden h-fit w-72 shrink-0 self-start overflow-hidden rounded-lg border border-gray-200 bg-white md:block dark:border-slate-800/60 dark:bg-slate-800/25'>
- <div className='border-b border-gray-200 p-5 dark:border-slate-800/60'>
- <Text
- as='span'
- size='xs'
- weight='medium'
- colour='muted'
- className='tracking-wide uppercase'
- >
- {t('onboarding.welcome')}
- </Text>
- <Text
- as='h1'
- size='xl'
- weight='semibold'
- tracking='tight'
- className='mt-1'
- >
- {t('onboarding.title')}
- </Text>
- </div>
+ <div className='flex h-screen flex-col overflow-hidden bg-gray-200 p-2 sm:p-2.5 dark:bg-slate-950'>
+ <div className='flex h-full w-full items-center justify-center overflow-hidden rounded-xl bg-gray-50 ring-1 ring-black/5 dark:bg-slate-900 dark:ring-white/10'>
+ <div className='flex h-full max-h-[min(92%,50rem)] min-h-0 w-full max-w-3xl flex-col'>
+ <div className='relative mx-auto min-h-0 w-full max-w-5xl flex-1 overflow-hidden rounded-2xl bg-white ring-1 ring-black/5 dark:bg-slate-800 dark:ring-white/10'>
+ <div className='flex h-full min-h-0 flex-col'>
+ <div className='shrink-0 px-6 pt-5 md:px-10'>
+ <ProgressBar
+ currentStep={progressStepIndex}
+ totalSteps={totalSteps}
+ />
+ </div>
+ <div className='relative min-h-0 flex-1 overflow-x-hidden overflow-y-auto scroll-smooth'>
+ <AnimatePresence mode='wait' custom={direction} initial={false}>
+ <motion.div
+ key={currentStep}
+ custom={direction}
+ variants={
+ prefersReducedMotion
+ ? reducedMotionVariants
+ : slideVariants
+ }
+ initial='enter'
+ animate='center'
+ exit='exit'
+ transition={{
+ x: {
+ type: 'tween',
+ duration: prefersReducedMotion ? 0.1 : 0.3,
+ ease: EASE_OUT_QUART,
+ },
+ opacity: { duration: prefersReducedMotion ? 0.1 : 0.2 },
+ }}
+ className='px-6 py-6 md:px-10'
+ >
+ {currentStep === 'language' && (
+ <div>
+ <Text
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2'
+ >
+ {t('onboarding.selectLanguage.title')}
+ </Text>
+ <Text as='p' colour='secondary' className='mb-8'>
+ {t('onboarding.selectLanguage.subtitle')}
+ </Text>
- <nav aria-label='Progress' className='p-4'>
- <ol className='space-y-1'>
- {steps.map((step) => {
- if (step.uiHidden) return null
-
- const status = step.completed
- ? 'complete'
- : step.current
- ? 'current'
- : 'upcoming'
- const StepIcon = STEP_ICONS[step.id as keyof typeof STEP_ICONS]
-
- return (
- <li key={step.id}>
- <div
- className={cn(
- 'group flex items-center gap-3 rounded-lg px-3 py-2.5 transition-colors',
- status === 'current' &&
- 'bg-gradient-to-r from-indigo-500/10 to-purple-500/10 dark:from-indigo-500/20 dark:to-purple-500/20',
- status === 'complete' &&
- 'bg-green-50/50 dark:bg-green-500/10',
- status === 'upcoming' && 'opacity-60',
- )}
- >
- <div
- className={cn(
- 'flex size-9 shrink-0 items-center justify-center rounded-lg transition-colors',
- status === 'complete' &&
- 'bg-green-100 dark:bg-green-500/20',
- status === 'current' &&
- 'bg-indigo-100 dark:bg-indigo-500/20',
- status === 'upcoming' &&
- 'bg-gray-100 dark:bg-slate-700',
- )}
- >
- {status === 'complete' ? (
- <CheckCircleIcon className='size-5 text-green-600 dark:text-green-400' />
- ) : StepIcon ? (
- <StepIcon
- className={cn(
- 'size-4',
- status === 'current' &&
- 'text-indigo-600 dark:text-indigo-400',
- status === 'upcoming' &&
- 'text-gray-400 dark:text-gray-500',
- )}
+ <div className='grid grid-cols-2 gap-3 sm:grid-cols-3'>
+ {_map(whitelist, (lng) => {
+ const isSelected = selectedLanguage === lng
+
+ return (
+ <button
+ key={lng}
+ type='button'
+ onClick={() => handleLanguageSelect(lng)}
+ className={cn(
+ 'flex flex-col items-center justify-center rounded-xl px-4 py-5 ring-1 transition-all duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 dark:focus-visible:ring-offset-slate-800',
+ isSelected
+ ? 'bg-indigo-50 ring-2 ring-indigo-500 dark:bg-indigo-900/20 dark:ring-indigo-400'
+ : 'ring-gray-200 hover:bg-gray-50 hover:ring-gray-300 dark:ring-slate-700 dark:hover:bg-slate-700/50 dark:hover:ring-slate-600',
+ )}
+ >
+ <Flag
+ country={languageFlag[lng]}
+ size={32}
+ alt={languages[lng]}
+ className='mb-3'
+ />
+ <Text
+ as='span'
+ size='sm'
+ weight={isSelected ? 'semibold' : 'medium'}
+ colour='inherit'
+ className={cn(
+ isSelected
+ ? 'text-indigo-700 dark:text-indigo-300'
+ : 'text-gray-900 dark:text-gray-100',
+ )}
+ >
+ {languages[lng]}
+ </Text>
+ </button>
+ )
+ })}
+ </div>
+ </div>
+ )}
+
+ {currentStep === 'welcome' && (
+ <div>
+ <Text
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2'
+ >
+ {t('onboarding.welcomeScreen.title')}
+ </Text>
+ <Text as='p' colour='secondary' className='mb-8'>
+ {t('onboarding.welcomeScreen.subtitle')}
+ </Text>
+
+ <div className='relative overflow-hidden rounded-xl'>
+ <img
+ src={
+ theme === 'dark'
+ ? '/assets/screenshot_dark.png'
+ : '/assets/screenshot_light.png'
+ }
+ alt='Swetrix Dashboard'
+ className='w-full'
/>
- ) : null}
+ <div className='pointer-events-none absolute inset-x-0 bottom-0 h-32 bg-linear-to-t from-white to-transparent dark:from-slate-800' />
+ </div>
+
+ <div className='mt-6 rounded-xl bg-indigo-50 p-4 dark:bg-indigo-900/20'>
+ <div className='flex items-start gap-3'>
+ <SparkleIcon className='mt-0.5 size-5 shrink-0 text-indigo-600 dark:text-indigo-400' />
+ <div>
+ <Text as='h3' size='sm' weight='semibold'>
+ {t('onboarding.welcomeScreen.featureTitle')}
+ </Text>
+ <Text as='p' size='sm' colour='secondary'>
+ {t('onboarding.welcomeScreen.featureDesc')}
+ </Text>
+ </div>
+ </div>
+ </div>
</div>
- <div className='min-w-0 flex-1'>
+ )}
+
+ {currentStep === 'feature_traffic' && (
+ <div>
+ <div className='mb-2 text-xs font-medium tracking-wider text-indigo-600 uppercase dark:text-indigo-400'>
+ {t('onboarding.features.feature')} 1
+ </div>
<Text
- as='span'
- size='sm'
- weight='medium'
- className={cn(
- 'block',
- status === 'current' &&
- 'text-indigo-700 dark:text-indigo-300',
- status === 'complete' &&
- 'text-green-700 dark:text-green-300',
- )}
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2'
>
- {step.title}
+ {t('onboarding.features.traffic.title')}
+ </Text>
+ <Text as='p' colour='secondary' className='max-w-md'>
+ {t('onboarding.features.traffic.desc')}
</Text>
+
+ <FeatureVisualization type='traffic' />
+
+ <div className='mt-6 rounded-xl bg-indigo-50 p-4 dark:bg-indigo-900/20'>
+ <div className='flex items-center gap-2'>
+ <GlobeIcon className='size-4 text-indigo-600 dark:text-indigo-400' />
+ <Text
+ as='span'
+ size='sm'
+ className='text-indigo-700 dark:text-indigo-300'
+ >
+ {t('onboarding.features.traffic.tip')}
+ </Text>
+ </div>
+ </div>
+ </div>
+ )}
+
+ {currentStep === 'feature_errors' && (
+ <div className='py-6'>
+ <div className='mb-2 text-xs font-medium tracking-wider text-rose-600 uppercase dark:text-rose-400'>
+ {t('onboarding.features.feature')} 2
+ </div>
<Text
- as='span'
- size='xs'
- colour='muted'
- className='block'
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2'
>
- {step.description}
+ {t('onboarding.features.errors.title')}
+ </Text>
+ <Text as='p' colour='secondary' className='max-w-md'>
+ {t('onboarding.features.errors.desc')}
</Text>
+
+ <FeatureVisualization type='errors' />
+
+ <div className='mt-6 rounded-xl bg-rose-50 p-4 dark:bg-rose-900/20'>
+ <div className='flex items-center gap-2'>
+ <BugIcon className='size-4 text-rose-600 dark:text-rose-400' />
+ <Text
+ as='span'
+ size='sm'
+ className='text-rose-700 dark:text-rose-300'
+ >
+ {t('onboarding.features.errors.tip')}
+ </Text>
+ </div>
+ </div>
</div>
- </div>
- </li>
- )
- })}
- </ol>
- </nav>
-
- {/* Skip onboarding - only shown after email confirmation */}
- {currentStep > 0 ? (
- <div className='border-t border-gray-200 p-4 dark:border-slate-800/60'>
- <button
- type='button'
- onClick={() => handleCompleteOnboarding(true)}
- className='flex w-full items-center justify-center gap-1 rounded-lg px-3 py-2 text-sm text-gray-600 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-slate-800 dark:hover:text-gray-200'
- >
- {t('onboarding.skipOnboarding')}
- <CaretRightIcon className='size-3.5' />
- </button>
- </div>
- ) : null}
- </aside>
-
- {/* Main content */}
- <div className='min-w-0 flex-1'>
- {/* Mobile progress bar */}
- <div className='mb-6 block md:hidden'>
- <div className='flex items-center justify-between'>
- <Text as='span' size='sm' weight='medium'>
- {steps[currentStep]?.title}
- </Text>
- <Text as='span' size='xs' colour='muted'>
- {visibleSteps.findIndex(
- (s) => s.id === steps[currentStep]?.id,
- ) + 1}{' '}
- / {visibleSteps.length}
- </Text>
- </div>
- <div className='mt-3 overflow-hidden rounded-full bg-gray-200 dark:bg-slate-700'>
- <div
- style={{ width: `${progressPercentage}%` }}
- className='h-1.5 rounded-full bg-gradient-to-r from-indigo-500 to-purple-500 transition-all duration-300'
- />
- </div>
- {currentStep > 0 ? (
- <button
- type='button'
- onClick={() => handleCompleteOnboarding(true)}
- className='mt-3 flex w-full items-center justify-center gap-1 text-sm text-gray-500 dark:text-gray-400'
- >
- {t('onboarding.skipOnboarding')}
- <CaretRightIcon className='size-3.5' />
- </button>
- ) : null}
- </div>
+ )}
- {/* Content card */}
- <div className='overflow-hidden rounded-lg border border-gray-200 bg-white dark:border-slate-800/60 dark:bg-slate-800/25'>
- {/* "Confirm your email" step */}
- {currentStep === 0 ? (
- <div className='p-6 md:p-8'>
- <div className='mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-gradient-to-br from-indigo-100 to-purple-100 dark:from-indigo-500/20 dark:to-purple-500/20'>
- <EnvelopeIcon className='size-8 text-indigo-600 dark:text-indigo-400' />
- </div>
- <Text
- as='h1'
- size='3xl'
- weight='semibold'
- tracking='tight'
- className='text-center'
- >
- {t('onboarding.confirm.title')}
- </Text>
- <Text
- as='p'
- colour='secondary'
- className='mx-auto mt-4 max-w-md text-center whitespace-pre-line'
- >
- {t('onboarding.confirm.linkSent', { email: user?.email })}
- </Text>
+ {currentStep === 'feature_sessions' && (
+ <div>
+ <div className='mb-2 text-xs font-medium tracking-wider text-emerald-600 uppercase dark:text-emerald-400'>
+ {t('onboarding.features.feature')} 3
+ </div>
+ <Text
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2'
+ >
+ {t('onboarding.features.sessions.title')}
+ </Text>
+ <Text as='p' colour='secondary' className='max-w-md'>
+ {t('onboarding.features.sessions.desc')}
+ </Text>
- <Text
- as='p'
- size='sm'
- colour='muted'
- className='mx-auto mt-8 max-w-md text-center'
- >
- {t('onboarding.confirm.spam')}
- </Text>
- <Text
- as='p'
- size='sm'
- colour='muted'
- className='mt-2 text-center'
- >
- <Trans
- t={t}
- i18nKey='onboarding.confirm.wrongEmail'
- components={{
- url: (
- <button
- type='button'
- className='cursor-pointer font-medium text-indigo-600 hover:underline dark:text-indigo-400'
- onClick={handleDeleteAccount}
- />
- ),
- }}
- />
- </Text>
- </div>
- ) : null}
+ <FeatureVisualization type='sessions' />
- {/* "Create a project" step */}
- {currentStep === 1 ? (
- <form onSubmit={handleCreateProject} className='p-6 md:p-8'>
- <div className='mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-gradient-to-br from-indigo-100 to-purple-100 dark:from-indigo-500/20 dark:to-purple-500/20'>
- <RocketIcon className='size-8 text-indigo-600 dark:text-indigo-400' />
- </div>
- <Text
- as='h1'
- size='3xl'
- weight='semibold'
- tracking='tight'
- className='text-center'
- >
- {t('onboarding.createProject.title')}
- </Text>
- <Text
- as='p'
- colour='secondary'
- className='mx-auto mt-4 max-w-md text-center whitespace-pre-line'
- >
- {t('onboarding.createProject.desc')}
- </Text>
+ <div className='mt-6 rounded-xl bg-emerald-50 p-4 dark:bg-emerald-900/20'>
+ <div className='flex items-center gap-2'>
+ <UsersThreeIcon className='size-4 text-emerald-600 dark:text-emerald-400' />
+ <Text
+ as='span'
+ size='sm'
+ className='text-emerald-700 dark:text-emerald-300'
+ >
+ {t('onboarding.features.sessions.tip')}
+ </Text>
+ </div>
+ </div>
+ </div>
+ )}
- <div className='mx-auto mt-8 max-w-sm'>
- <Input
- label={t('project.settings.name')}
- placeholder='My awesome website'
- maxLength={MAX_PROJECT_NAME_LENGTH}
- value={projectName}
- onChange={(e) => {
- setProjectName(e.target.value)
- setNewProjectErrors({})
- }}
- error={newProjectErrors.name}
- />
- </div>
+ {currentStep === 'create_project' && (
+ <form onSubmit={handleCreateProject} className='py-6'>
+ <Text
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2'
+ >
+ {t('onboarding.createProject.title')}
+ </Text>
+ <Text as='p' colour='secondary' className='mb-8'>
+ {t('onboarding.createProject.desc')}
+ </Text>
- <div className='mt-8 flex justify-center'>
- <Button type='submit' loading={isLoading} primary large>
- {t('common.continue')}
- </Button>
- </div>
- </form>
- ) : null}
-
- {/* "Install tracking script" step */}
- {currentStep === 2 && project ? (
- <div className='p-6 md:p-8'>
- <div className='mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-gradient-to-br from-indigo-100 to-purple-100 dark:from-indigo-500/20 dark:to-purple-500/20'>
- <CodeIcon className='size-8 text-indigo-600 dark:text-indigo-400' />
- </div>
- <Text
- as='h1'
- size='3xl'
- weight='semibold'
- tracking='tight'
- className='text-center'
- >
- {t('onboarding.installTracking.title')}
- </Text>
- <Text
- as='p'
- colour='secondary'
- className='mx-auto mt-4 max-w-lg text-center whitespace-pre-line'
- >
- <Trans
- t={t}
- i18nKey='onboarding.installTracking.desc'
- components={{
- url: (
- <a
- href={INTEGRATIONS_URL}
- target='_blank'
- rel='noopener noreferrer'
- className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'
- />
- ),
- }}
- />
- </Text>
+ <ProjectVisualization />
- <div className='mt-8 rounded-lg border border-gray-200 bg-gray-50 p-5 dark:border-slate-700/60 dark:bg-slate-800/50'>
- <div className='flex items-center gap-3'>
- <div className='flex size-11 items-center justify-center rounded-lg bg-white dark:bg-slate-700'>
- <LaptopIcon className='size-5 text-gray-700 dark:text-gray-200' />
- </div>
- <div>
- <Text as='h3' size='sm' weight='semibold'>
- {t('onboarding.installTracking.websiteInstallation')}
- </Text>
- <Text as='p' size='xs' colour='muted'>
- {t('onboarding.installTracking.pasteScript')}
- </Text>
- </div>
- </div>
-
- <Text as='p' size='sm' colour='secondary' className='mt-4'>
- <Trans
- t={t}
- i18nKey='modals.trackingSnippet.add'
- components={{
- bsect: <Badge label='<body>' colour='slate' />,
- }}
- />
- </Text>
+ <div className='mx-auto max-w-sm'>
+ <Input
+ label={t('project.settings.name')}
+ placeholder={t(
+ 'onboarding.createProject.placeholder',
+ )}
+ maxLength={MAX_PROJECT_NAME_LENGTH}
+ value={projectName}
+ onChange={(e) => {
+ setProjectName(e.target.value)
+ setNewProjectErrors({})
+ }}
+ error={newProjectErrors.name}
+ />
+ </div>
+ </form>
+ )}
- <Textarea
- classes={{
- container: 'mt-3 font-mono text-sm',
- textarea:
- 'bg-white dark:bg-slate-900 ring-1 ring-gray-200 dark:ring-slate-700',
- }}
- value={getSnippet(project.id)}
- rows={15}
- readOnly
- />
-
- <Text as='p' size='xs' colour='muted' className='mt-4'>
- <Trans
- t={t}
- i18nKey='onboarding.installTracking.weAlsoSupport'
- components={{
- url: (
- <a
- href={DOCS_URL}
- target='_blank'
- rel='noopener noreferrer'
- className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'
+ {currentStep === 'setup_tracking' && project && (
+ <div>
+ <Text
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2'
+ >
+ {t('onboarding.installTracking.title')}
+ </Text>
+ <Text as='p' colour='secondary' className='mb-6'>
+ <Trans
+ t={t}
+ i18nKey='onboarding.installTracking.desc'
+ components={{
+ url: (
+ <a
+ href={INTEGRATIONS_URL}
+ target='_blank'
+ rel='noopener noreferrer'
+ className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'
+ />
+ ),
+ }}
/>
- ),
- }}
- />
- </Text>
- </div>
+ </Text>
- <div className='mt-8 flex justify-center'>
- <Button
- onClick={async () => {
- await updateUserStep('waiting_for_events')
- setCurrentStep(3)
- setIsWaitingForEvents(true)
- }}
- primary
- large
- >
- {t('common.continue')}
- </Button>
- </div>
- </div>
- ) : null}
-
- {/* "Verify installation" step */}
- {currentStep === 3 ? (
- <div className='p-6 md:p-8'>
- <div
- className={cn(
- 'mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl',
- hasEvents
- ? 'bg-gradient-to-br from-green-100 to-emerald-100 dark:from-green-500/20 dark:to-emerald-500/20'
- : 'bg-gradient-to-br from-indigo-100 to-purple-100 dark:from-indigo-500/20 dark:to-purple-500/20',
- )}
- >
- {hasEvents ? (
- <CheckCircleIcon className='size-8 text-green-600 dark:text-green-400' />
- ) : (
- <PulsatingCircle type='giant' />
- )}
- </div>
- <Text
- as='h1'
- size='3xl'
- weight='semibold'
- tracking='tight'
- className='text-center'
- >
- {hasEvents
- ? t('onboarding.verifyInstallation.perfect')
- : t('onboarding.verifyInstallation.navTitle')}
- </Text>
- <Text
- as='p'
- colour='secondary'
- className='mx-auto mt-4 max-w-md text-center whitespace-pre-line'
- >
- {hasEvents
- ? t('onboarding.verifyInstallation.eventReceived')
- : t('onboarding.verifyInstallation.desc')}
- </Text>
+ <div className='rounded-xl border border-gray-200 bg-gray-50 p-5 dark:border-slate-700 dark:bg-slate-800/50'>
+ <div className='mb-4 flex items-center gap-3'>
+ <div className='flex size-10 items-center justify-center rounded-lg bg-white dark:bg-slate-700'>
+ <CodeIcon className='size-5 text-gray-700 dark:text-gray-200' />
+ </div>
+ <div>
+ <Text as='h3' size='sm' weight='semibold'>
+ {t(
+ 'onboarding.installTracking.websiteInstallation',
+ )}
+ </Text>
+ <Text as='p' size='xs' colour='muted'>
+ <Trans
+ t={t}
+ i18nKey='modals.trackingSnippet.add'
+ components={{
+ bsect: (
+ <Badge label='<body>' colour='slate' />
+ ),
+ }}
+ />
+ </Text>
+ </div>
+ </div>
- {hasEvents ? (
- <div className='mx-auto mt-8 max-w-sm rounded-lg bg-green-50 p-4 dark:bg-green-500/10'>
- <Text
- as='p'
- size='sm'
- className='text-center text-green-700 dark:text-green-300'
- >
- {t('onboarding.verifyInstallation.perfectDesc')}
- </Text>
- </div>
- ) : (
- <div className='mx-auto mt-8 max-w-md rounded-lg border border-gray-200 bg-gray-50 p-5 dark:border-slate-700/60 dark:bg-slate-800/50'>
- <div className='flex items-center gap-3'>
- <div className='flex size-11 items-center justify-center rounded-lg bg-white dark:bg-slate-700'>
- <PulsatingCircle type='big' />
+ <Textarea
+ classes={{
+ container: 'font-mono text-xs',
+ textarea:
+ 'bg-white dark:bg-slate-900 ring-1 ring-gray-200 dark:ring-slate-700',
+ }}
+ value={getSnippet(project.id)}
+ rows={12}
+ readOnly
+ />
+
+ <Text
+ as='p'
+ size='xs'
+ colour='muted'
+ className='mt-4'
+ >
+ <Trans
+ t={t}
+ i18nKey='onboarding.installTracking.weAlsoSupport'
+ components={{
+ url: (
+ <a
+ href={DOCS_URL}
+ target='_blank'
+ rel='noopener noreferrer'
+ className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'
+ />
+ ),
+ }}
+ />
+ </Text>
+ </div>
+
+ {isWaitingForEvents && (
+ <div className='mt-6 rounded-xl border border-indigo-200 bg-indigo-50 p-4 dark:border-indigo-800 dark:bg-indigo-900/20'>
+ <div className='flex items-center gap-3'>
+ <PulsatingCircle type='big' />
+ <div>
+ <Text as='h3' size='sm' weight='semibold'>
+ {t(
+ 'onboarding.verifyInstallation.waitingForEvents',
+ )}
+ </Text>
+ <Text as='p' size='xs' colour='muted'>
+ {t(
+ 'onboarding.verifyInstallation.waitingForAnEvent',
+ )}
+ </Text>
+ </div>
+ </div>
+ </div>
+ )}
+
+ {hasEvents && (
+ <div className='mt-6 rounded-xl border border-emerald-200 bg-emerald-50 p-4 dark:border-emerald-800 dark:bg-emerald-900/20'>
+ <div className='flex items-center gap-3'>
+ <CheckCircleIcon className='size-6 text-emerald-600 dark:text-emerald-400' />
+ <div>
+ <Text
+ as='h3'
+ size='sm'
+ weight='semibold'
+ className='text-emerald-700 dark:text-emerald-300'
+ >
+ {t('onboarding.verifyInstallation.perfect')}
+ </Text>
+ <Text
+ as='p'
+ size='xs'
+ className='text-emerald-600 dark:text-emerald-400'
+ >
+ {t(
+ 'onboarding.verifyInstallation.eventReceived',
+ )}
+ </Text>
+ </div>
+ </div>
+ </div>
+ )}
</div>
+ )}
+
+ {currentStep === 'verify_email' && (
<div>
- <Text as='h3' size='sm' weight='semibold'>
- {t('onboarding.verifyInstallation.waitingForEvents')}
+ <div className='mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-linear-to-br from-indigo-100 to-purple-100 dark:from-indigo-500/20 dark:to-purple-500/20'>
+ <EnvelopeIcon className='size-8 text-indigo-600 dark:text-indigo-400' />
+ </div>
+ <Text
+ as='h1'
+ size='3xl'
+ weight='bold'
+ tracking='tight'
+ className='mb-2 text-center'
+ >
+ {t('onboarding.confirm.title')}
</Text>
- <Text as='p' size='xs' colour='muted'>
- {project?.name
- ? t('onboarding.verifyInstallation.onTheXProject', {
- project: project.name,
- })
- : t('onboarding.verifyInstallation.onYourProject')}
+ <Text
+ as='p'
+ colour='secondary'
+ className='mx-auto max-w-md text-center'
+ >
+ {t('onboarding.confirm.linkSent', {
+ email: user?.email,
+ })}
+ </Text>
+
+ <div className='mx-auto mt-8 max-w-sm rounded-xl bg-indigo-50 p-4 dark:bg-indigo-900/20'>
+ <div className='flex items-start gap-3'>
+ <EnvelopeIcon className='mt-0.5 size-5 shrink-0 text-indigo-600 dark:text-indigo-400' />
+ <div>
+ <Text as='h3' size='sm' weight='semibold'>
+ {t('onboarding.confirm.verifyTitle')}
+ </Text>
+ <Text as='p' size='sm' colour='secondary'>
+ {t('onboarding.confirm.spam')}
+ </Text>
+ </div>
+ </div>
+ </div>
+
+ <Text
+ as='p'
+ size='sm'
+ colour='muted'
+ className='mt-6 text-center'
+ >
+ <Trans
+ t={t}
+ i18nKey='onboarding.confirm.wrongEmail'
+ components={{
+ url: (
+ <button
+ type='button'
+ className='cursor-pointer rounded font-medium text-indigo-600 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 dark:text-indigo-400'
+ onClick={handleDeleteAccount}
+ />
+ ),
+ }}
+ />
</Text>
</div>
- </div>
- <Text as='p' size='sm' colour='secondary' className='mt-4'>
- {t('onboarding.verifyInstallation.waitingForAnEvent')}
- </Text>
-
- <div className='mt-4 space-y-2 border-t border-gray-200 pt-4 dark:border-slate-700'>
- <Text as='p' size='xs' colour='muted'>
- <Trans
- t={t}
- i18nKey='onboarding.verifyInstallation.needInstructionsAgain'
- components={{
- btn: (
- <button
- type='button'
- onClick={() => {
- setCurrentStep(2)
- setIsWaitingForEvents(false)
- }}
- className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'
- />
- ),
- }}
- />
- </Text>
- <Text as='p' size='xs' colour='muted'>
- <Trans
- t={t}
- i18nKey='onboarding.verifyInstallation.orContactUs'
- components={{
- url: (
- <Link
- to={
- isSelfhosted ? CONTACT_US_URL : routes.contact
- }
- target='_blank'
- rel='noopener noreferrer'
- className='font-medium text-indigo-600 hover:underline dark:text-indigo-400'
- />
- ),
- }}
- />
- </Text>
- </div>
- </div>
- )}
-
- <div className='mt-8 flex justify-center gap-3'>
- {!hasEvents ? (
+ )}
+ </motion.div>
+ </AnimatePresence>
+ </div>
+
+ <div className='shrink-0 border-t border-gray-200 px-6 py-4 dark:border-slate-700'>
+ <div className='flex items-center justify-end gap-3'>
+ {currentStepIndex > 0 && currentStep !== 'verify_email' && (
+ <Button onClick={goBack} secondary large>
+ {t('common.back')}
+ </Button>
+ )}
+ {currentStep === 'setup_tracking' && (
+ <Button onClick={handleSkipTracking} secondary large>
+ {t('common.skip')}
+ </Button>
+ )}
+ {currentStep === 'language' && (
+ <Button onClick={handleLanguageConfirm} primary large>
+ {t('common.next')}
+ </Button>
+ )}
+ {(currentStep === 'welcome' ||
+ currentStep === 'feature_traffic' ||
+ currentStep === 'feature_errors' ||
+ currentStep === 'feature_sessions') && (
+ <Button onClick={goNext} primary large>
+ {t('common.next')}
+ </Button>
+ )}
+ {currentStep === 'create_project' && (
+ <Button
+ onClick={() => handleCreateProject()}
+ loading={isLoading}
+ primary
+ large
+ >
+ {t('common.continue')}
+ </Button>
+ )}
+ {currentStep === 'setup_tracking' && (
+ <Button
+ onClick={() => {
+ setIsWaitingForEvents(true)
+ if (isSelfhosted) {
+ handleCompleteOnboarding(false)
+ } else {
+ goNext()
+ }
+ }}
+ primary
+ large
+ >
+ {t('common.continue')}
+ </Button>
+ )}
+ {currentStep === 'verify_email' && (
<Button
onClick={async () => {
- await updateUserStep('setup_tracking')
- setCurrentStep(2)
- setIsWaitingForEvents(false)
+ setIsCheckingVerification(true)
+ try {
+ await loadUser()
+ handleCompleteOnboarding(false)
+ } finally {
+ setIsCheckingVerification(false)
+ }
}}
- secondary
+ loading={isCheckingVerification}
+ primary
large
>
- {t('common.goBack')}
+ {t('onboarding.finishOnboarding')}
</Button>
- ) : null}
- <Button
- onClick={() => handleCompleteOnboarding(false)}
- primary
- large
- >
- {t('onboarding.finishOnboarding')}
- </Button>
+ )}
</div>
</div>
- ) : null}
+ </div>
</div>
</div>
</div>
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 071c24db3..ea4c65be9 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -112,6 +112,9 @@
"notConnected": "Not connected",
"connected": "Connected",
"goBack": "Go back",
+ "back": "Back",
+ "next": "Next",
+ "skip": "Skip",
"accept": "Accept",
"reject": "Reject",
"delete": "Delete",
@@ -2073,19 +2076,50 @@
"title": "Get started",
"skipOnboarding": "Skip onboarding",
"finishOnboarding": "Finish onboarding",
+ "selectLanguage": {
+ "title": "Select your language",
+ "subtitle": "What is your preferred language?"
+ },
+ "welcomeScreen": {
+ "title": "Welcome to Swetrix!",
+ "subtitle": "Privacy-first, cookieless analytics that give you the insights you need without compromising your users' privacy.",
+ "featureTitle": "A studio for your data",
+ "featureDesc": "A place to understand your traffic, track errors, and make data-driven decisions."
+ },
+ "features": {
+ "feature": "Feature",
+ "traffic": {
+ "title": "Traffic Analytics",
+ "desc": "Understand your website traffic with real-time analytics. See where your visitors come from, what pages they view, and how they interact with your site.",
+ "tip": "Track visitors from 200+ countries with no cookies required."
+ },
+ "errors": {
+ "title": "Error Tracking",
+ "desc": "Catch and fix bugs before your users notice them. Get detailed error reports with stack traces, browser info, and user context.",
+ "tip": "Receive instant alerts when new errors occur."
+ },
+ "sessions": {
+ "title": "User Sessions",
+ "desc": "See exactly how users navigate through your site. Understand user journeys, identify drop-off points, and optimise the experience.",
+ "tip": "View real-time sessions as they happen."
+ }
+ },
"confirm": {
"navTitle": "Confirm your email",
"navDesc": "Check your inbox and click the confirmation link.",
"title": "Check your inbox",
"linkSent": "We've sent an account confirmation link to {{email}}, please click the link to confirm your email address.",
"spam": "Can't see the email? Please check your spam folder.",
- "wrongEmail": "Wrong email? <url>Create a new account.</url>"
+ "wrongEmail": "Wrong email? <url>Create a new account.</url>",
+ "verifyTitle": "Please verify your email address",
+ "checkVerification": "I've verified my email"
},
"createProject": {
"navTitle": "Create a project",
"navDesc": "Add a website to start tracking analytics.",
"title": "Let's set up your first project",
- "desc": "Create a project to start tracking your website's analytics. Enter a name for it to continue."
+ "desc": "Create a project to start tracking your website's analytics. Enter a name for it to continue.",
+ "placeholder": "My awesome website"
},
"installTracking": {
"navTitle": "Install tracking script",
@@ -2106,9 +2140,9 @@
"onTheXProject": "On the {{project}} project",
"onYourProject": "On your project",
"perfect": "Perfect!",
- "perfectDesc": "We're receiving data 🎉",
+ "perfectDesc": "We're receiving data!",
"waitingForAnEvent": "We're waiting for your first event! If your integration is set up correctly, you should see it within 1 minute.",
- "eventReceived": "We've received your first event! Your integration works correctly. Welcome to Swetrix :)"
+ "eventReceived": "We've received your first event! Your integration works correctly. Welcome to Swetrix!"
}
},
"titles": {