Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Signup refactor (#491)

Bill Yange4a08742609e
diff --git a/client/package-lock.json b/client/package-lock.json
index 8a4cf0206..563d03096 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -9,6 +9,7 @@
"version": "1.5.1",
"dependencies": {
"@hookform/resolvers": "5.0.1",
+ "@icons-pack/react-simple-icons": "^13.6.0",
"@nivo/bar": "0.96.0",
"@nivo/calendar": "0.96.0",
"@nivo/line": "0.96.0",
@@ -1009,6 +1010,15 @@
"react-hook-form": "^7.55.0"
}
},
+ "node_modules/@icons-pack/react-simple-icons": {
+ "version": "13.6.0",
+ "resolved": "https://registry.npmjs.org/@icons-pack/react-simple-icons/-/react-simple-icons-13.6.0.tgz",
+ "integrity": "sha512-q4FySfJfM3Mv8jdF+Pq9zUmsiJe1IP4zbwFjsTK7uirqS+yeroadd40mAXphiQq90f5NHLFTfFkRiJDCLZS8/A==",
+ "license": "MIT",
+ "peerDependencies": {
+ "react": "^16.13 || ^17 || ^18 || ^19"
+ }
+ },
"node_modules/@img/sharp-darwin-arm64": {
"version": "0.34.1",
"resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.1.tgz",
diff --git a/client/package.json b/client/package.json
index 287cd66d9..c74fd80bd 100644
--- a/client/package.json
+++ b/client/package.json
@@ -11,6 +11,7 @@
},
"dependencies": {
"@hookform/resolvers": "5.0.1",
+ "@icons-pack/react-simple-icons": "^13.6.0",
"@nivo/bar": "0.96.0",
"@nivo/calendar": "0.96.0",
"@nivo/line": "0.96.0",
diff --git a/client/src/app/[site]/components/Header/NoData.tsx b/client/src/app/[site]/components/Header/NoData.tsx
index 8e48bfcb6..412fd162c 100644
--- a/client/src/app/[site]/components/Header/NoData.tsx
+++ b/client/src/app/[site]/components/Header/NoData.tsx
@@ -1,47 +1,236 @@
+import {
+ SiAngular,
+ SiAstro,
+ SiDocusaurus,
+ SiDrupal,
+ SiFramer,
+ SiGatsby,
+ SiGoogletagmanager,
+ SiHugo,
+ SiJekyll,
+ SiLaravel,
+ SiNextdotjs,
+ SiNuxt,
+ SiReact,
+ SiRemix,
+ SiShopify,
+ SiSquarespace,
+ SiSvelte,
+ SiVuedotjs,
+ SiWebflow,
+ SiWix,
+ SiWoocommerce,
+ SiWordpress,
+} from "@icons-pack/react-simple-icons";
+import React from "react";
import { useGetSite, useSiteHasData } from "../../../../api/admin/sites";
import { CodeSnippet } from "../../../../components/CodeSnippet";
import { Alert } from "../../../../components/ui/alert";
import { useStore } from "../../../../lib/store";
+// Custom Card Component
+interface CardProps {
+ icon: React.ReactNode;
+ title: string;
+ description: string;
+ href: string;
+}
+
+function Card({ icon, title, description, href }: CardProps) {
+ return (
+ <a
+ href={href}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="group flex flex-col py-2 px-3 rounded-lg bg-neutral-850 border border-neutral-750 hover:bg-neutral-900 transition-all duration-200 hover:shadow-lg"
+ >
+ <div className="flex items-center gap-2">
+ <div className="text-neutral-300 group-hover:text-emerald-400 transition-colors">{icon}</div>
+ <h3 className="font-medium text-xs text-neutral-900 dark:text-neutral-100">{title}</h3>
+ </div>
+ {description && <p className="text-sm text-neutral-600 dark:text-neutral-400 mt-2">{description}</p>}
+ </a>
+ );
+}
+
export function NoData() {
const { site } = useStore();
const { data: siteHasData, isLoading } = useSiteHasData(site);
- const { data: siteMetadata, isLoading: isLoadingSiteMetadata } =
- useGetSite(site);
+ const { data: siteMetadata, isLoading: isLoadingSiteMetadata } = useGetSite(site);
if (!siteHasData && !isLoading && !isLoadingSiteMetadata) {
return (
- <Alert className="mt-4 p-4 bg-yellow-50 border-yellow-200 dark:bg-yellow-900/20 dark:border-yellow-800">
- <div className="flex flex-col gap-3">
- <div className="flex items-center gap-3">
- <span className="relative flex h-3 w-3">
- <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"></span>
- <span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
+ <>
+ <Alert className="mt-4 p-4 dark:bg-neutral-900 dark:border-amber-600/80">
+ <div className="flex flex-col gap-3">
+ <div className="flex items-center gap-3">
+ <span className="relative flex h-3 w-3">
+ <span className="absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"></span>
+ <span className="relative inline-flex h-3 w-3 rounded-full bg-green-500"></span>
+ </span>
+ <div className="font-medium">Waiting for analytics from {siteMetadata?.domain}...</div>
+ </div>
+ <div className="text-xs text-muted-foreground">Place this snippet in the &lt;head&gt; of your website:</div>
+ <CodeSnippet
+ language="HTML"
+ code={`<script\n src="${globalThis.location.origin}/api/script.js"\n data-site-id="${siteMetadata?.siteId}"\n defer\n></script>`}
+ className="text-xs"
+ />
+ <span className="text-xs text-muted-foreground">
+ See our{" "}
+ <a href="https://rybbit.io/docs/script" className="text-blue-500 hover:underline">
+ docs
+ </a>{" "}
+ for more information.
</span>
- <div className="font-medium">
- Waiting for analytics from {siteMetadata?.domain}...
+ {/* Framework Guide Cards */}
+ <div className="">
+ <h2 className="text-sm font-medium mb-4">Platform Guides</h2>
+ <div className="flex flex-wrap gap-2">
+ <Card
+ icon={<SiGoogletagmanager className="w-5 h-5" />}
+ title="Google Tag Manager"
+ description=""
+ href="https://rybbit.io/docs/guides/google-tag-manager"
+ />
+ <Card
+ icon={<SiReact className="w-5 h-5" />}
+ title="React"
+ description=""
+ href="https://rybbit.io/docs/guides/react/vite-cra"
+ />
+ <Card
+ icon={<SiNextdotjs className="w-5 h-5" />}
+ title="Next.js"
+ description=""
+ href="https://rybbit.io/docs/guides/react/next-js"
+ />
+ <Card
+ icon={<SiAngular className="w-5 h-5" />}
+ title="Angular"
+ description=""
+ href="https://rybbit.io/docs/guides/angular"
+ />
+ <Card
+ icon={<SiVuedotjs className="w-5 h-5" />}
+ title="Vue"
+ description=""
+ href="https://rybbit.io/docs/guides/vue/vite"
+ />
+ <Card
+ icon={<SiNuxt className="w-5 h-5" />}
+ title="Nuxt"
+ description=""
+ href="https://rybbit.io/docs/guides/vue/nuxt"
+ />
+ <Card
+ icon={<SiSvelte className="w-5 h-5" />}
+ title="Svelte"
+ description=""
+ href="https://rybbit.io/docs/guides/svelte/vite"
+ />
+ <Card
+ icon={<SiSvelte className="w-5 h-5" />}
+ title="SvelteKit"
+ description=""
+ href="https://rybbit.io/docs/guides/svelte/sveltekit"
+ />
+ <Card
+ icon={<SiAstro className="w-5 h-5" />}
+ title="Astro"
+ description=""
+ href="https://rybbit.io/docs/guides/astro"
+ />
+ <Card
+ icon={<SiGatsby className="w-5 h-5" />}
+ title="Gatsby"
+ description=""
+ href="https://rybbit.io/docs/guides/react/gatsby"
+ />
+ <Card
+ icon={<SiRemix className="w-5 h-5" />}
+ title="Remix"
+ description=""
+ href="https://rybbit.io/docs/guides/react/remix"
+ />
+ <Card
+ icon={<SiDocusaurus className="w-5 h-5" />}
+ title="Docusaurus"
+ description=""
+ href="https://rybbit.io/docs/guides/docusaurus"
+ />
+ <Card
+ icon={<SiDrupal className="w-5 h-5" />}
+ title="Drupal"
+ description=""
+ href="https://rybbit.io/docs/guides/drupal"
+ />
+ <Card
+ icon={<SiFramer className="w-5 h-5" />}
+ title="Framer"
+ description=""
+ href="https://rybbit.io/docs/guides/framer"
+ />
+
+ <Card
+ icon={<SiHugo className="w-5 h-5" />}
+ title="Hugo"
+ description=""
+ href="https://rybbit.io/docs/guides/hugo"
+ />
+ <Card
+ icon={<SiJekyll className="w-5 h-5" />}
+ title="Jekyll"
+ description=""
+ href="https://rybbit.io/docs/guides/jekyll"
+ />
+ <Card
+ icon={<SiLaravel className="w-5 h-5" />}
+ title="Laravel"
+ description=""
+ href="https://rybbit.io/docs/guides/laravel"
+ />
+ <Card
+ icon={<SiShopify className="w-5 h-5" />}
+ title="Shopify"
+ description=""
+ href="https://rybbit.io/docs/guides/shopify"
+ />
+ <Card
+ icon={<SiSquarespace className="w-5 h-5" />}
+ title="Squarespace"
+ description=""
+ href="https://rybbit.io/docs/guides/squarespace"
+ />
+ <Card
+ icon={<SiWordpress className="w-5 h-5" />}
+ title="WordPress"
+ description=""
+ href="https://rybbit.io/docs/guides/wordpress"
+ />
+ <Card
+ icon={<SiWebflow className="w-5 h-5" />}
+ title="Webflow"
+ description=""
+ href="https://rybbit.io/docs/guides/webflow"
+ />
+ <Card
+ icon={<SiWix className="w-5 h-5" />}
+ title="Wix"
+ description=""
+ href="https://rybbit.io/docs/guides/wix"
+ />
+ <Card
+ icon={<SiWoocommerce className="w-5 h-5" />}
+ title="WooCommerce"
+ description=""
+ href="https://rybbit.io/docs/guides/woocommerce"
+ />
+ </div>
</div>
</div>
- <div className="text-xs text-muted-foreground">
- Place this snippet in the &lt;head&gt; of your website:
- </div>
- <CodeSnippet
- language="HTML"
- code={`<script\n src="${globalThis.location.origin}/api/script.js"\n data-site-id="${siteMetadata?.siteId}"\n defer\n></script>`}
- className="text-xs"
- />
- <span className="text-xs text-muted-foreground">
- See our{" "}
- <a
- href="https://rybbit.io/docs/script"
- className="text-blue-500 hover:underline"
- >
- docs
- </a>{" "}
- for more information.
- </span>
- </div>
- </Alert>
+ </Alert>
+ </>
);
}
diff --git a/client/src/app/components/AddSite.tsx b/client/src/app/components/AddSite.tsx
index a7d7deaba..eb6509e4e 100644
--- a/client/src/app/components/AddSite.tsx
+++ b/client/src/app/components/AddSite.tsx
@@ -16,37 +16,15 @@ import {
import { Input } from "../../components/ui/input";
import { Label } from "../../components/ui/label";
import { Switch } from "../../components/ui/switch";
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "../../components/ui/tooltip";
+import { Tooltip, TooltipContent, TooltipTrigger } from "../../components/ui/tooltip";
import { authClient } from "../../lib/auth";
import { IS_CLOUD } from "../../lib/const";
import { useStripeSubscription } from "../../lib/subscription/useStripeSubscription";
import { resetStore, useStore } from "../../lib/store";
import { useRouter } from "next/navigation";
-import { normalizeDomain } from "../../lib/utils";
-
-/**
- * A simple domain validation function:
- * - Ensures at least one dot separator
- * - Allows subdomains (e.g. sub.example.com)
- * - Requires the TLD to be alphabetical (e.g. .com)
- */
-function isValidDomain(domain: string): boolean {
- const domainRegex =
- /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
- return domainRegex.test(domain);
-}
+import { isValidDomain, normalizeDomain } from "../../lib/utils";
-export function AddSite({
- trigger,
- disabled,
-}: {
- trigger?: React.ReactNode;
- disabled?: boolean;
-}) {
+export function AddSite({ trigger, disabled }: { trigger?: React.ReactNode; disabled?: boolean }) {
const { setSite } = useStore();
const router = useRouter();
@@ -55,10 +33,7 @@ export function AddSite({
const { data: subscription } = useStripeSubscription();
// Disable if user is on free plan and has 3+ sites
- const isDisabledDueToLimit =
- subscription?.status !== "active" &&
- (sites?.sites?.length || 0) >= 3 &&
- IS_CLOUD;
+ const isDisabledDueToLimit = subscription?.status !== "active" && (sites?.sites?.length || 0) >= 3 && IS_CLOUD;
const finalDisabled = disabled || isDisabledDueToLimit;
const [open, setOpen] = useState(false);
@@ -77,23 +52,16 @@ export function AddSite({
// Validate before attempting to add
if (!isValidDomain(domain)) {
- setError(
- "Invalid domain format. Must be a valid domain like example.com or sub.example.com"
- );
+ setError("Invalid domain format. Must be a valid domain like example.com or sub.example.com");
return;
}
try {
const normalizedDomain = normalizeDomain(domain);
- const site = await addSite(
- normalizedDomain,
- normalizedDomain,
- activeOrganization.id,
- {
- isPublic,
- saltUserIds,
- }
- );
+ const site = await addSite(normalizedDomain, normalizedDomain, activeOrganization.id, {
+ isPublic,
+ saltUserIds,
+ });
resetStore();
setSite(site.siteId.toString());
@@ -156,17 +124,12 @@ export function AddSite({
<AppWindow className="h-6 w-6" />
Add Website
</DialogTitle>
- <DialogDescription>
- Track analytics for a new website in your organization
- </DialogDescription>
+ <DialogDescription>Track analytics for a new website in your organization</DialogDescription>
</DialogHeader>
<div className="grid gap-4 py-2">
<div className="grid w-full items-center gap-1.5">
- <Label
- htmlFor="domain"
- className="text-sm font-medium text-white"
- >
+ <Label htmlFor="domain" className="text-sm font-medium text-white">
Domain
</Label>
<Input
@@ -179,41 +142,27 @@ export function AddSite({
{/* Public Analytics Setting */}
<div className="flex items-center justify-between">
<div>
- <Label
- htmlFor="isPublic"
- className="text-sm font-medium text-white"
- >
+ <Label htmlFor="isPublic" className="text-sm font-medium text-white">
Public Analytics
</Label>
<p className="text-xs text-muted-foreground mt-1">
When enabled, anyone can view analytics without logging in
</p>
</div>
- <Switch
- id="isPublic"
- checked={isPublic}
- onCheckedChange={setIsPublic}
- />
+ <Switch id="isPublic" checked={isPublic} onCheckedChange={setIsPublic} />
</div>
{/* User ID Salting Setting */}
<div className="flex items-center justify-between">
<div>
- <Label
- htmlFor="saltUserIds"
- className="text-sm font-medium text-white"
- >
+ <Label htmlFor="saltUserIds" className="text-sm font-medium text-white">
Enable User ID Salting
</Label>
<p className="text-xs text-muted-foreground mt-1">
Enhance privacy with daily rotating salts for user IDs
</p>
</div>
- <Switch
- id="saltUserIds"
- checked={saltUserIds}
- onCheckedChange={setSaltUserIds}
- />
+ <Switch id="saltUserIds" checked={saltUserIds} onCheckedChange={setSaltUserIds} />
</div>
</div>
@@ -225,19 +174,10 @@ export function AddSite({
</Alert>
)}
<DialogFooter>
- <Button
- type="button"
- onClick={() => setOpen(false)}
- variant="outline"
- >
+ <Button type="button" onClick={() => setOpen(false)} variant="outline">
Cancel
</Button>
- <Button
- type="submit"
- variant={"success"}
- onClick={handleSubmit}
- disabled={!domain}
- >
+ <Button type="submit" variant={"success"} onClick={handleSubmit} disabled={!domain}>
Add
</Button>
</DialogFooter>
diff --git a/client/src/app/signup/page.tsx b/client/src/app/signup/page.tsx
index 5e76472e5..0f1aea9e4 100644
--- a/client/src/app/signup/page.tsx
+++ b/client/src/app/signup/page.tsx
@@ -9,19 +9,18 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { motion } from "framer-motion";
-import { AppWindow, ArrowLeft, ArrowRight, Building2, Check, Code, Sparkles, User } from "lucide-react";
+import { ArrowRight, Check } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
import { useRouter, useSearchParams } from "next/navigation";
-import { Suspense, useEffect, useState } from "react";
+import React, { Suspense, useEffect, useState } from "react";
import { addSite } from "../../api/admin/sites";
-import { CodeSnippet } from "../../components/CodeSnippet";
import { useSetPageTitle } from "../../hooks/useSetPageTitle";
import { authClient } from "../../lib/auth";
import { useConfigs } from "../../lib/configs";
import { IS_CLOUD } from "../../lib/const";
import { userStore } from "../../lib/userStore";
-import { cn, normalizeDomain } from "../../lib/utils";
+import { cn, isValidDomain, normalizeDomain } from "../../lib/utils";
// Animation variants for step transitions
const contentVariants = {
@@ -64,9 +63,6 @@ export default function SignupPage() {
const [organizationId, setOrganizationId] = useState("");
const [domain, setDomain] = useState("");
- // Step 4: Data for tracking code
- const [siteId, setSiteId] = useState<number>();
-
// Handle organization name change and generate slug
const handleOrgNameChange = (value: string) => {
setOrgName(value);
@@ -79,12 +75,6 @@ export default function SignupPage() {
}
};
- // Validate domain
- const isValidDomain = (domain: string): boolean => {
- const domainRegex = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
- return domainRegex.test(domain);
- };
-
// Step 1: Account creation submission
const handleAccountSubmit = async () => {
setIsLoading(true);
@@ -165,8 +155,8 @@ export default function SignupPage() {
try {
const normalizedDomain = normalizeDomain(domain);
const response = await addSite(normalizedDomain, normalizedDomain, organizationId);
- setSiteId(response.siteId);
- setCurrentStep(4);
+ // Navigate directly to dashboard after adding website
+ router.push(`/${response.siteId}`);
} catch (error) {
setError(String(error));
}
@@ -177,29 +167,13 @@ export default function SignupPage() {
}
};
- // Get step icon based on step number
- const getStepIcon = (step: number) => {
- switch (step) {
- case 1:
- return <User className="h-4 w-4" />;
- case 2:
- return <Building2 className="h-4 w-4" />;
- case 3:
- return <AppWindow className="h-4 w-4" />;
- case 4:
- return <Sparkles className="h-4 w-4" />;
- default:
- return null;
- }
- };
-
// Render the content based on current step
const renderStepContent = () => {
switch (currentStep) {
case 1:
return (
<motion.div initial="hidden" animate="visible" variants={contentVariants}>
- <h2 className="text-2xl font-semibold mb-6">Create your account</h2>
+ <h2 className="text-2xl font-semibold mb-4">Signup</h2>
<div className="space-y-4">
<AuthInput
id="email"
@@ -250,18 +224,13 @@ export default function SignupPage() {
Log in
</Link>
</div>
-
- <AuthError error={error} />
</div>
</motion.div>
);
case 2:
return (
<motion.div initial="hidden" animate="visible" variants={contentVariants}>
- <h2 className="text-2xl font-semibold mb-6 flex items-center gap-2">
- <Building2 className="h-6 w-6 text-emerald-500" />
- Create your organization
- </h2>
+ <h2 className="text-2xl font-semibold mb-4">Create your organization</h2>
<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="orgName">Organization Name</Label>
@@ -296,7 +265,7 @@ export default function SignupPage() {
/>
</div> */}
- <div className="flex flex-col gap-4 pt-4">
+ <div className="flex flex-col gap-4">
<Button
className="w-full transition-all duration-300 h-11 bg-emerald-600 hover:bg-emerald-500 text-white"
onClick={handleOrganizationSubmit}
@@ -316,10 +285,7 @@ export default function SignupPage() {
case 3:
return (
<motion.div initial="hidden" animate="visible" variants={contentVariants}>
- <h2 className="text-2xl font-semibold mb-6 flex items-center gap-2">
- <AppWindow className="h-6 w-6 text-emerald-500" />
- Add your first website
- </h2>
+ <h2 className="text-2xl font-semibold mb-4">Add your site</h2>
<div className="space-y-4">
<div className="space-y-2">
<Label htmlFor="domain">Website Domain</Label>
@@ -335,11 +301,11 @@ export default function SignupPage() {
<p className="text-xs text-muted-foreground">Enter the domain of the website you want to track</p>
</div>
- <div className="flex justify-between pt-4">
+ <div className="flex justify-between">
<Button
className="w-full transition-all duration-300 h-11 bg-emerald-600 hover:bg-emerald-500 text-white"
onClick={handleWebsiteSubmit}
- disabled={isLoading || !domain}
+ disabled={isLoading || !domain || !isValidDomain(domain)}
variant="success"
>
Continue
@@ -349,72 +315,11 @@ export default function SignupPage() {
</div>
</motion.div>
);
- case 4:
- return (
- <motion.div initial="hidden" animate="visible" variants={contentVariants}>
- <h2 className="text-2xl font-semibold mb-6 flex items-center gap-2">
- <Code className="h-6 w-6 text-emerald-500" />
- Add tracking code to your website
- </h2>
- <div className="space-y-6">
- <div className="rounded-lg bg-muted p-5 border border-neutral-700 backdrop-blur-sm bg-neutral-800/20">
- <div className="flex items-center gap-3 mb-2">
- <div className="flex items-center justify-center w-8 h-8 rounded-full bg-emerald-600 text-primary-foreground">
- <Check className="h-4 w-4" />
- </div>
- <p className="text-base font-medium">Your account is ready!</p>
- </div>
- <p className="text-sm text-muted-foreground ml-11">
- To start collecting analytics data, add this tracking code to your website.
- </p>
- </div>
-
- <div className="flex flex-col gap-2">
- <Label>Place this snippet in the &lt;head&gt; of your website</Label>
- <div className="border border-neutral-700 rounded-lg overflow-hidden">
- <CodeSnippet
- language="HTML"
- code={`<script\n src="${globalThis.location.origin}/api/script.js"\n data-site-id="${siteId}"\n defer\n></script>`}
- />
- </div>
- </div>
-
- <div className="rounded-lg bg-muted p-4 border border-neutral-700 backdrop-blur-sm bg-neutral-800/20">
- <p className="text-sm text-muted-foreground">
- Once you've added the tracking code, it may take a few minutes for data to appear in your dashboard.
- </p>
- </div>
-
- <div className="flex justify-between pt-4 gap-4">
- <Button
- type="button"
- variant="outline"
- onClick={() => setCurrentStep(3)}
- className="transition-all duration-300 h-11 bg-neutral-800/50 border-neutral-700"
- >
- <ArrowLeft className="mr-2 h-4 w-4" />
- Back
- </Button>
- <Button
- onClick={() => router.push(`/${siteId}`)}
- variant="success"
- className="flex-1 transition-all duration-300 h-11 bg-emerald-600 hover:bg-emerald-500 text-white"
- >
- Go to Dashboard
- <Check className="ml-2 h-4 w-4" />
- </Button>
- </div>
- </div>
- </motion.div>
- );
default:
return null;
}
};
- // Calculate progress percentage
- const progressPercentage = ((currentStep - 1) / 3) * 100;
-
if (isLoadingConfigs) {
return null;
}
@@ -444,91 +349,78 @@ export default function SignupPage() {
}
return (
- <div className="flex flex-col justify-between items-center min-h-screen bg-background p-4 relative overflow-hidden">
- {/* Suspense boundary for the URL parameter handler */}
- <Suspense fallback={null}>
- <StepHandler onSetStep={setCurrentStep} />
- </Suspense>
-
- {/* Background gradients similar to docs page */}
- <div className="absolute top-0 left-0 w-[550px] h-[550px] bg-emerald-500/40 rounded-full blur-[80px] opacity-40"></div>
- <div className="absolute top-20 left-20 w-[400px] h-[400px] bg-emerald-600/30 rounded-full blur-[70px] opacity-30"></div>
-
- <div className="absolute bottom-0 right-0 w-[500px] h-[500px] bg-blue-500/40 rounded-full blur-[80px] opacity-30"></div>
- <div className="absolute bottom-40 right-20 w-[350px] h-[350px] bg-indigo-500/30 rounded-full blur-[75px] opacity-30"></div>
-
- <div className="absolute top-1/4 right-0 w-[320px] h-[320px] bg-purple-500/40 rounded-full blur-[70px] opacity-20"></div>
-
- <div></div>
- <Card className="w-full max-w-4xl p-0 overflow-hidden shadow-2xl border-neutral-700/50 backdrop-blur-sm bg-neutral-800/20 relative z-10">
- <div className="flex flex-col md:flex-row h-full">
- {/* Left sidebar with steps */}
- <div className="md:w-80 p-6 relative overflow-hidden border-r border-neutral-700/50 backdrop-blur-sm bg-neutral-800/30">
- <div className="absolute top-0 left-0 right-0 h-1 bg-muted-foreground/20 overflow-hidden">
- <div
- className="h-full bg-emerald-500 transition-all duration-500 ease-out"
- style={{ width: `${progressPercentage}%` }}
- />
- </div>
- <div className="relative z-10 flex flex-col space-y-4">
- <a href="https://rybbit.io" target="_blank">
- <Image src="/rybbit-text.svg" alt="Rybbit" width={120} height={27} />
- </a>
+ <div className="flex justify-center items-center h-screen w-full p-4 ">
+ <div className="flex flex-col items-center bg-background relative">
+ {/* Suspense boundary for the URL parameter handler */}
+ <Suspense fallback={null}>
+ <StepHandler onSetStep={setCurrentStep} />
+ </Suspense>
+
+ {/* Background gradients similar to docs page */}
+ <div className="absolute top-0 left-0 w-[550px] h-[550px] bg-emerald-500/40 rounded-full blur-[80px] opacity-40"></div>
+ <div className="absolute top-20 left-20 w-[400px] h-[400px] bg-emerald-600/30 rounded-full blur-[70px] opacity-30"></div>
+
+ <div className="absolute bottom-0 right-0 w-[500px] h-[500px] bg-blue-500/40 rounded-full blur-[80px] opacity-30"></div>
+ <div className="absolute bottom-40 right-20 w-[350px] h-[350px] bg-indigo-500/30 rounded-full blur-[75px] opacity-30"></div>
+
+ <div className="absolute top-1/4 right-0 w-[320px] h-[320px] bg-purple-500/40 rounded-full blur-[70px] opacity-20"></div>
+
+ {/* Logo and title above the card */}
+ <div className="relative z-10 mb-6 text-center">
+ <a href="https://rybbit.io" target="_blank" className="inline-block mb-2">
+ <Image src="/rybbit-text.svg" alt="Rybbit" width={150} height={34} />
+ </a>
+ <h1 className="text-lg text-neutral-300">Get started with Rybbit</h1>
+ </div>
- {[1, 2, 3, 4].map((step) => (
+ <Card className="w-full md:w-[500px] p-0 overflow-hidden shadow-2xl border-neutral-700/50 backdrop-blur-sm bg-neutral-800/20 z-10 p-8">
+ {/* Horizontal step indicator */}
+ <div className="flex items-center w-full mb-4">
+ {[1, 2, 3].map((step, index) => (
+ <React.Fragment key={step}>
<div
- key={step}
className={cn(
- "flex items-center space-x-3 py-3",
+ "flex items-center justify-center w-10 h-10 rounded-full text-sm font-semibold transition-all duration-300",
currentStep === step
- ? "text-emerald-400 font-medium"
+ ? "bg-emerald-600 text-primary-foreground"
: currentStep > step
- ? "text-muted-foreground"
- : "text-muted-foreground/60"
+ ? "bg-emerald-600/20 text-emerald-400 border-2 border-emerald-600/40"
+ : "bg-muted-foreground/20 text-muted-foreground border-2 border-muted-foreground/40"
)}
>
+ {currentStep > step ? <Check className="h-5 w-5" /> : step}
+ </div>
+ {index < 2 && (
<div
className={cn(
- "flex items-center justify-center w-8 h-8 rounded-full transition-all duration-300",
- currentStep === step
- ? "bg-emerald-600 text-primary-foreground"
- : currentStep > step
- ? "bg-emerald-600/20 text-emerald-400"
- : "bg-muted-foreground/20 text-muted-foreground"
+ "flex-1 h-0.5 transition-all duration-300",
+ currentStep > step ? "bg-emerald-600" : "bg-muted-foreground/40"
)}
- >
- {currentStep > step ? <Check className="h-4 w-4" /> : getStepIcon(step)}
- </div>
- <span>
- {step === 1 && "Create account"}
- {step === 2 && "Create organization"}
- {step === 3 && "Add website"}
- {step === 4 && "Track your first pageview"}
- </span>
- </div>
- ))}
- </div>
+ />
+ )}
+ </React.Fragment>
+ ))}
</div>
- {/* Right content area */}
- <div className="p-6 md:p-8 flex-1 h-[600px] flex flex-col backdrop-blur-sm bg-neutral-900/50">
- {error && <AuthError error={error} />}
+ {/* Content area */}
+ <div className="flex flex-col gap-4">
+ {renderStepContent()}
+ <AuthError error={error} />
+ </div>
+ </Card>
- <div className="flex-1 flex flex-col justify-between">
- <div className="min-h-[400px]">{renderStepContent()}</div>
- </div>
+ {!IS_CLOUD && (
+ <div className="text-xs text-muted-foreground relative z-10 mt-8">
+ <a
+ href="https://rybbit.io"
+ target="_blank"
+ rel="noopener"
+ title="Rybbit - Open Source Privacy-Focused Web Analytics"
+ >
+ Open source web analytics powered by Rybbit
+ </a>
</div>
- </div>
- </Card>
- <div className="text-xs text-muted-foreground relative z-10 mt-4">
- <a
- href="https://rybbit.io"
- target="_blank"
- rel="noopener"
- title="Rybbit - Open Source Privacy-Focused Web Analytics"
- >
- Open source web analytics powered by Rybbit
- </a>
+ )}
</div>
</div>
);
diff --git a/client/src/lib/utils.ts b/client/src/lib/utils.ts
index 34b3a73e3..5973fd363 100644
--- a/client/src/lib/utils.ts
+++ b/client/src/lib/utils.ts
@@ -27,8 +27,7 @@ export function formatSecondsAsMinutesAndSeconds(value: number) {
}
}
-export const sleep = (ms: number) =>
- new Promise((resolve) => setTimeout(resolve, ms));
+export const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
export const getCountryName = (countryCode: string) => {
return countries[countryCode as keyof typeof countries]?.name;
@@ -61,20 +60,31 @@ export const getLanguageName = (languageCode: string) => {
export function normalizeDomain(domain: string): string {
if (!domain) return domain;
-
+
let normalized = domain.trim();
-
+
// Remove protocol (http:// or https://)
- normalized = normalized.replace(/^https?:\/\//, '');
-
+ normalized = normalized.replace(/^https?:\/\//, "");
+
// Remove www. prefix
- normalized = normalized.replace(/^www\./, '');
-
+ normalized = normalized.replace(/^www\./, "");
+
// Remove trailing slash and any path
- normalized = normalized.split('/')[0];
-
+ normalized = normalized.split("/")[0];
+
// Remove trailing dots
- normalized = normalized.replace(/\.+$/, '');
-
+ normalized = normalized.replace(/\.+$/, "");
+
return normalized;
}
+
+/**
+ * A simple domain validation function:
+ * - Ensures at least one dot separator
+ * - Allows subdomains (e.g. sub.example.com)
+ * - Requires the TLD to be alphabetical (e.g. .com)
+ */
+export function isValidDomain(domain: string): boolean {
+ const domainRegex = /^(?:https?:\/\/)?(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
+ return domainRegex.test(domain);
+}
diff --git a/docs/src/content/index.mdx b/docs/src/content/index.mdx
index 421e3c376..97f32c7d5 100644
--- a/docs/src/content/index.mdx
+++ b/docs/src/content/index.mdx
@@ -176,3 +176,4 @@ Rybbit is open sourced under the AGPL-3.0 license. You can find the code on [Git
## Community
Join our [Discord server](https://discord.gg/DEhGb4hYBj) or talk to me on [X](https://x.com/yang_frog). I'm always looking for feedback and ideas to make Rybbit as awesome as possible.
+