Skip to content

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

Implement NoData component and enhance layout structure

Bill Yang46b7e85488b0
diff --git a/client/src/app/[site]/components/Header/Header.tsx b/client/src/app/[site]/components/Header/Header.tsx
index 5b4c5f6ce..04f9a39b6 100644
--- a/client/src/app/[site]/components/Header/Header.tsx
+++ b/client/src/app/[site]/components/Header/Header.tsx
@@ -2,6 +2,7 @@
import { FreeTrialBanner } from "../../../../components/FreeTrialBanner";
import { userStore } from "../../../../lib/userStore";
+import { NoData } from "./NoData";
import { UsageBanners } from "./UsageBanners";
export function Header() {
@@ -13,6 +14,7 @@ export function Header() {
<>
<FreeTrialBanner />
<UsageBanners />
+ <NoData />
</>
)}
</div>
diff --git a/client/src/app/[site]/components/Header/NoData.tsx b/client/src/app/[site]/components/Header/NoData.tsx
new file mode 100644
index 000000000..f4710e8fc
--- /dev/null
+++ b/client/src/app/[site]/components/Header/NoData.tsx
@@ -0,0 +1,42 @@
+import { useGetSite, useSiteHasData } from "../../../../api/admin/sites";
+import { Alert } from "../../../../components/ui/alert";
+import { useStore } from "../../../../lib/store";
+import { CodeSnippet } from "../../../../components/CodeSnippet";
+import { BACKEND_URL } from "../../../../lib/const";
+
+export function NoData() {
+ const { site } = useStore();
+ const { data: siteHasData, isLoading } = useSiteHasData(site);
+ const { data: siteMetadata, isLoading: isLoadingSiteMetadata } =
+ useGetSite(site);
+
+ if (!siteHasData && !isLoading && !isLoadingSiteMetadata) {
+ return (
+ <div className="m-4 mb-0">
+ <Alert className="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>
+ </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="${BACKEND_URL}/script.js"\n site-id="${siteMetadata?.siteId}"\n defer\n/>`}
+ className="text-xs"
+ />
+ </div>
+ </Alert>
+ </div>
+ );
+ }
+
+ return null;
+}
diff --git a/client/src/app/[site]/events/components/EventList.tsx b/client/src/app/[site]/events/components/EventList.tsx
index 74a21638f..5841caa03 100644
--- a/client/src/app/[site]/events/components/EventList.tsx
+++ b/client/src/app/[site]/events/components/EventList.tsx
@@ -6,6 +6,7 @@ import { memo, useState } from "react";
import { EventName } from "../../../../api/analytics/useGetEventNames";
import { useGetEventProperties } from "../../../../api/analytics/useGetEventProperties";
import { EventProperties } from "./EventProperties";
+import { NothingFound } from "../../../../components/NothingFound";
// Skeleton component for EventList
const EventListSkeleton = memo(
@@ -105,10 +106,10 @@ export function EventList({
if (!events || events.length === 0) {
return (
- <div className="text-neutral-300 w-full text-center mt-6 flex flex-row gap-2 items-center justify-center">
- <Info className="w-5 h-5" />
- No custom events found
- </div>
+ <NothingFound
+ title={"No custom events found"}
+ description={"Try a different date range or filter"}
+ />
);
}
diff --git a/client/src/app/[site]/events/components/EventLog.tsx b/client/src/app/[site]/events/components/EventLog.tsx
index 189a43ae5..000919791 100644
--- a/client/src/app/[site]/events/components/EventLog.tsx
+++ b/client/src/app/[site]/events/components/EventLog.tsx
@@ -4,6 +4,7 @@ import { useCallback, useEffect, useRef } from "react";
import { useGetEventsInfinite } from "../../../../api/analytics/useGetEvents";
import { formatter } from "../../../../lib/utils";
import { EventLogItem, EventLogItemSkeleton } from "./EventLogItem";
+import { NothingFound } from "../../../../components/NothingFound";
export function EventLog() {
const containerRef = useRef<HTMLDivElement>(null);
@@ -79,9 +80,10 @@ export function EventLog() {
if (allEvents.length === 0) {
return (
- <div className="text-center py-8 text-neutral-400">
- No events found in the selected time period.
- </div>
+ <NothingFound
+ title={"No events found"}
+ description={"Try a different date range or filter"}
+ />
);
}
diff --git a/client/src/app/[site]/funnels/page.tsx b/client/src/app/[site]/funnels/page.tsx
index 6a59b3924..e1ec68fa6 100644
--- a/client/src/app/[site]/funnels/page.tsx
+++ b/client/src/app/[site]/funnels/page.tsx
@@ -3,17 +3,11 @@
import { SavedFunnel, useGetFunnels } from "@/api/analytics/useGetFunnels";
import { Skeleton } from "@/components/ui/skeleton";
import { useStore } from "@/lib/store";
-import { PlusCircle } from "lucide-react";
+import { ArrowRight, FilterIcon } from "lucide-react";
import { MobileSidebar } from "../../../components/MobileSidebar";
+import { NothingFound } from "../../../components/NothingFound";
import { CreateFunnelDialog } from "./components/CreateFunnel";
import { FunnelRow } from "./components/FunnelRow";
-import {
- ArrowRight,
- ChevronDown,
- FileText,
- FilterIcon,
- MousePointerClick,
-} from "lucide-react";
// Skeleton for the funnel row component
const FunnelRowSkeleton = () => (
@@ -105,17 +99,13 @@ export default function FunnelsPage() {
))}
</div>
) : (
- <div className="flex flex-col items-center justify-center py-10 text-center">
- <div className="bg-neutral-100 dark:bg-neutral-800 rounded-full p-3 mb-4">
- <PlusCircle className="h-6 w-6" />
- </div>
- <h3 className="text-lg font-medium mb-2">No funnels yet</h3>
- <p className="text-neutral-500 max-w-md mb-6">
- Create your first funnel to track conversions through your site's
- user journey
- </p>
- <CreateFunnelDialog />
- </div>
+ <NothingFound
+ title={"No funnels yet"}
+ description={
+ "Create your first funnel to track conversions through your site's user journey"
+ }
+ action={<CreateFunnelDialog />}
+ />
)}
</div>
);
diff --git a/client/src/app/[site]/goals/page.tsx b/client/src/app/[site]/goals/page.tsx
index 4f903ceaa..f6d4a58cf 100644
--- a/client/src/app/[site]/goals/page.tsx
+++ b/client/src/app/[site]/goals/page.tsx
@@ -3,6 +3,7 @@
import { useState } from "react";
import { useGetGoals } from "../../../api/analytics/useGetGoals";
import { getStartAndEndDate } from "../../../api/utils";
+import { NothingFound } from "../../../components/NothingFound";
import { GOALS_PAGE_FILTERS, useStore } from "../../../lib/store";
import { SubHeader } from "../components/SubHeader/SubHeader";
import CreateGoalButton from "./components/CreateGoalButton";
@@ -93,13 +94,13 @@ export default function GoalsPage() {
))}
</div>
) : !goalsData || goalsData.data.length === 0 ? (
- <div className="py-10 text-center">
- <h3 className="text-lg font-medium">No goals configured yet</h3>
- <p className="text-sm text-gray-500 mt-2">
- Create your first conversion goal to start tracking important user
- actions.
- </p>
- </div>
+ <NothingFound
+ title={"No goals found"}
+ description={
+ "Create your first conversion goal to start tracking important user actions."
+ }
+ action={<CreateGoalButton siteId={Number(site)} />}
+ />
) : (
<GoalsList
goals={goalsData.data}
diff --git a/client/src/app/[site]/journeys/page.tsx b/client/src/app/[site]/journeys/page.tsx
index 20cf79061..2800edaf1 100644
--- a/client/src/app/[site]/journeys/page.tsx
+++ b/client/src/app/[site]/journeys/page.tsx
@@ -462,11 +462,11 @@ export default function JourneysPage() {
</Alert>
)}
- {data?.journeys?.length && data?.journeys?.length > 0 && (
+ {data?.journeys?.length && data?.journeys?.length > 0 ? (
<div className="overflow-x-auto">
<svg ref={svgRef} className="w-full h-[1000px]" />
</div>
- )}
+ ) : null}
</CardContent>
</Card>
</div>
diff --git a/client/src/app/[site]/layout.tsx b/client/src/app/[site]/layout.tsx
index 603c8bf52..811975f67 100644
--- a/client/src/app/[site]/layout.tsx
+++ b/client/src/app/[site]/layout.tsx
@@ -41,14 +41,15 @@ export default function SiteLayout({
return null;
}
- if (!siteHasData && !isLoading && !isLoadingSiteMetadata) {
- return <NoData siteMetadata={siteMetadata} />;
- }
+ // if (!siteHasData && !isLoading && !isLoadingSiteMetadata) {
+ // return <NoData siteMetadata={siteMetadata} />;
+ // }
if (width && width < 768) {
return (
<div className="">
<TopBar />
+ <Header />
<div>{children}</div>
</div>
// <div className="flex flex-col h-screen relative">
diff --git a/client/src/app/[site]/realtime/RealtimeChart/RealtimeChart.tsx b/client/src/app/[site]/realtime/RealtimeChart/RealtimeChart.tsx
index 9079d7edf..a803e6ad4 100644
--- a/client/src/app/[site]/realtime/RealtimeChart/RealtimeChart.tsx
+++ b/client/src/app/[site]/realtime/RealtimeChart/RealtimeChart.tsx
@@ -33,18 +33,7 @@ export function RealtimeChart() {
}
if (!chartData || chartData.length === 0) {
- return (
- <div
- style={{
- height: 300,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- }}
- >
- No data available for this period.
- </div>
- );
+ return null;
}
return (
diff --git a/client/src/app/[site]/retention/page.tsx b/client/src/app/[site]/retention/page.tsx
index ec1fbd936..d284cdb19 100644
--- a/client/src/app/[site]/retention/page.tsx
+++ b/client/src/app/[site]/retention/page.tsx
@@ -23,6 +23,7 @@ import {
} from "../../../components/ui/select";
import { Tabs, TabsList, TabsTrigger } from "../../../components/ui/tabs";
import { RetentionChart } from "./RetentionChart";
+import { NothingFound } from "../../../components/NothingFound";
// Available time range options (in days)
const RANGE_OPTIONS = [
@@ -196,20 +197,13 @@ export default function RetentionPage() {
// Render empty state
if (data && (!data.cohorts || cohortKeys.length === 0)) {
return (
- <div className="pt-4">
- <Card>
- <CardContent>
- <div className="p-8 text-center">
- <div className="text-neutral-300 mb-2 font-medium">
- No retention data available
- </div>
- <p className="text-neutral-500 text-sm">
- Try selecting a different time range or make sure you have
- tracking data in the system.
- </p>
- </div>
- </CardContent>
- </Card>
+ <div className="p-2 md:p-4 max-w-[1300px] mx-auto flex flex-col gap-3">
+ <NothingFound
+ title={"No retention data available"}
+ description={
+ "Try selecting a different time range or make sure you have tracking data in the system."
+ }
+ />
</div>
);
}
diff --git a/client/src/components/NothingFound.tsx b/client/src/components/NothingFound.tsx
new file mode 100644
index 000000000..72927c903
--- /dev/null
+++ b/client/src/components/NothingFound.tsx
@@ -0,0 +1,28 @@
+import { PlusCircle } from "lucide-react";
+
+export function NothingFound({
+ title,
+ description,
+ action,
+ icon,
+}: {
+ title: string;
+ description?: string;
+ action?: React.ReactNode;
+ icon?: React.ReactNode;
+}) {
+ return (
+ <div className="flex flex-col items-center justify-center py-10 text-center">
+ {icon && (
+ <div className="bg-neutral-100 dark:bg-neutral-800 rounded-full p-3 mb-4">
+ {icon}
+ </div>
+ )}
+ <h3 className="text-lg font-medium mb-2">{title}</h3>
+ {description && (
+ <p className="text-neutral-500 max-w-md mb-6">{description}</p>
+ )}
+ {action && action}
+ </div>
+ );
+}
diff --git a/client/src/components/Sessions/SessionsList.tsx b/client/src/components/Sessions/SessionsList.tsx
index f7fe34e12..bf2cfa143 100644
--- a/client/src/components/Sessions/SessionsList.tsx
+++ b/client/src/components/Sessions/SessionsList.tsx
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef } from "react";
import { useGetSessionsInfinite } from "../../api/analytics/userSessions";
import { SessionCard, SessionCardSkeleton } from "./SessionCard";
import { Button } from "../ui/button";
+import { NothingFound } from "../NothingFound";
export default function SessionsList({ userId }: { userId?: string }) {
// Get sessions data with infinite loading
@@ -34,9 +35,10 @@ export default function SessionsList({ userId }: { userId?: string }) {
// Show skeleton cards while loading
<SessionCardSkeleton />
) : flattenedData.length === 0 ? (
- <div className="flex justify-center py-8 text-gray-400">
- No sessions found
- </div>
+ <NothingFound
+ title={"No sessions found"}
+ description={"Try a different date range or filter"}
+ />
) : (
// Render session cards with more robust key generation
flattenedData.map((session, index) => (
diff --git a/client/src/components/SiteSettings/ScriptBuilder.tsx b/client/src/components/SiteSettings/ScriptBuilder.tsx
index 689aab69e..6f21c400c 100644
--- a/client/src/components/SiteSettings/ScriptBuilder.tsx
+++ b/client/src/components/SiteSettings/ScriptBuilder.tsx
@@ -185,7 +185,7 @@ export function ScriptBuilder({ siteId }: ScriptBuilderProps) {
</div>
{/* Track Outbound Links Option */}
- <div className="space-y-2">
+ {/* <div className="space-y-2">
<div className="flex items-center justify-between">
<div>
<Label
@@ -204,7 +204,7 @@ export function ScriptBuilder({ siteId }: ScriptBuilderProps) {
onCheckedChange={setTrackOutbound}
/>
</div>
- </div>
+ </div> */}
{/* Skip Patterns Option */}
<div className="space-y-2">
diff --git a/docs/src/app/layout.jsx b/docs/src/app/layout.jsx
index 7d1ae2700..0f8fc9327 100644
--- a/docs/src/app/layout.jsx
+++ b/docs/src/app/layout.jsx
@@ -21,7 +21,8 @@ export const metadata = {
title: {
template: '%s - Rybbit'
},
- description: 'Next-gen, open source, lightweight, cookieless web & product analytics for everyone — GDPR/CCPA compliant.',
+ description: 'Next-gen, open source, lightweight, cookieless web & product analytics for everyone.',
+ // description: 'Next-gen, open source, lightweight, cookieless web & product analytics for everyone — GDPR/CCPA compliant.',
applicationName: 'Rybbit',
generator: 'Next.js',
appleWebApp: {
diff --git a/docs/src/app/page.jsx b/docs/src/app/page.jsx
index 43b15b210..c799119d7 100644
--- a/docs/src/app/page.jsx
+++ b/docs/src/app/page.jsx
@@ -29,7 +29,7 @@ export default function IndexPage() {
<div className="flex flex-col items-center justify-center overflow-x-hidden">
<h1 className={`text-4xl md:text-5xl lg:text-7xl font-semibold pt-16 md:pt-24 px-4 tracking-tight max-w-3xl text-center text-transparent bg-clip-text bg-gradient-to-b from-white via-gray-100 to-gray-400 ${tilt_wrap.className}`}>The Modern Google Analytics Alternative</h1>
- <h2 className="text-lg md:text-2xl pt-4 md:pt-6 px-4 tracking-tight max-w-3xl text-center text-neutral-300">Next-gen, open source, lightweight, cookieless web & product analytics for everyone — GDPR/CCPA compliant.</h2>
+ <h2 className="text-lg md:text-2xl pt-4 md:pt-6 px-4 tracking-tight max-w-3xl text-center text-neutral-300">Next-gen, open source, lightweight, cookieless web & product analytics for everyone.</h2>
<div className="flex flex-col sm:flex-row my-8 md:my-10 items-center justify-center gap-4 md:gap-6 text-base md:text-lg px-4">
<Link href="https://app.rybbit.io/signup" className="w-full sm:w-auto">
diff --git a/docs/src/content/track-events.mdx b/docs/src/content/track-events.mdx
index e6fa68686..2766a9cde 100644
--- a/docs/src/content/track-events.mdx
+++ b/docs/src/content/track-events.mdx
@@ -50,7 +50,7 @@ A convenience function for tracking custom events. Equivalent to `window.rybbit.
```javascript
window.rybbit.event("Video Played", { videoId: "xyz789" });
```
-
+{/*
### `window.rybbit.trackOutbound(url, text, target)`
A convenience function for manually tracking outbound link clicks. Useful for programmatic navigation or custom link handling.
@@ -62,7 +62,7 @@ A convenience function for manually tracking outbound link clicks. Useful for pr
```javascript
// Track a programmatic navigation to an external site
window.rybbit.trackOutbound("https://example.com", "Example Site", "_blank");
-```
+``` */}
## Typescript Support
diff --git a/docs/src/content/tracker.mdx b/docs/src/content/tracker.mdx
index 5328825d0..0b2d29b0c 100644
--- a/docs/src/content/tracker.mdx
+++ b/docs/src/content/tracker.mdx
@@ -29,12 +29,12 @@ Set to `"false"` to disable tracking of URL query strings. This enhances privacy
- **Default:** `"true"`
- **Example:** `data-track-query="false"`
-### `data-track-outbound`
+{/* ### `data-track-outbound`
Set to `"false"` to disable automatic tracking of outbound link clicks. When enabled, the script automatically detects when a user clicks on a link to an external domain and tracks it with an event type of "outbound".
- **Default:** `"true"`
-- **Example:** `data-track-outbound="false"`
+- **Example:** `data-track-outbound="false"` */}
### `data-skip-patterns`