Skip to content

Commit 5c2d2e7

Browse files
committed
Update migration instructions and enhance usage banners
- Changed the server address in migration instructions from 'user@new-server' to 'root@clickhouse'. - Updated the docker command syntax from 'docker-compose' to 'docker compose' for consistency. - Refactored the UsageBanners component to improve the display of event limit messages, including clearer messaging for exceeding and approaching limits. - Added current month name to the UsageBanners for better context. - Enhanced the PaidPlan component to display event limit alongside the formatted price.
1 parent 4d844d3 commit 5c2d2e7

File tree

3 files changed

+54
-75
lines changed

3 files changed

+54
-75
lines changed

clickhouse/MIGRATION.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ docker run --rm \
1111

1212
# 2. Copy to your local machine or transfer directly to new server
1313

14-
scp /tmp/clickhouse-data.tar.gz user@new-server:/tmp/
14+
scp /tmp/clickhouse-data.tar.gz root@clickhouse:/tmp/
1515

1616
On New Server:
1717

18-
# 1. Upload the docker-compose file and create .env
18+
# 1. Upload the docker compose file and create .env
1919

2020
# Create .env file with your settings:
2121

@@ -36,7 +36,7 @@ docker run --rm \
3636

3737
# 3. Start ClickHouse
3838

39-
docker-compose -f docker-compose.clickhouse.yml up -d
39+
docker compose -f docker compose.clickhouse.yml up -d
4040

4141
# 4. Verify data
4242

@@ -47,13 +47,12 @@ docker exec clickhouse clickhouse-client --password=frog --query="SELECT count()
4747

4848
1. ClickHouse stores everything in /var/lib/clickhouse
4949

50-
51-
- Table definitions
52-
- Data files (compressed)
53-
- Metadata
50+
- Table definitions
51+
- Data files (compressed)
52+
- Metadata
5453

5554
2. Same ClickHouse version (25.4.2) - compatible format
56-
3. Same configurations - copied from your cloud docker-compose
55+
3. Same configurations - copied from your cloud docker compose
5756

5857
Quick Test Locally First:
5958

@@ -63,7 +62,7 @@ cd /Users/bill/Desktop/rybbit/server/src/db/clickhouse
6362

6463
# Start the standalone ClickHouse
6564

66-
docker-compose -f docker-compose.clickhouse.yml up -d
65+
docker compose -f docker compose.clickhouse.yml up -d
6766

6867
# Test connection
6968

client/src/app/[site]/components/Header/UsageBanners.tsx

Lines changed: 41 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { AlertTriangle, ArrowRight } from "lucide-react";
22
import Link from "next/link";
33
import { useCurrentSite } from "../../../../api/admin/sites";
4-
import { Alert, AlertDescription, AlertTitle } from "../../../../components/ui/alert";
54
import { Button } from "../../../../components/ui/button";
65

76
export function UsageBanners() {
@@ -14,88 +13,67 @@ export function UsageBanners() {
1413
return num.toLocaleString();
1514
};
1615

16+
// Get current month name
17+
const currentMonth = new Date().toLocaleString("en-US", { month: "long" });
18+
1719
// Calculate usage percentage
1820
const getUsagePercentage = () => {
1921
if (!subscription?.eventLimit || !subscription.monthlyEventCount) return 0;
2022
return (subscription.monthlyEventCount / subscription.eventLimit) * 100;
2123
};
2224

2325
const usagePercentage = getUsagePercentage();
24-
const isNearLimit = usagePercentage >= 90 && !subscription?.overMonthlyLimit;
2526

2627
if (
2728
subscription?.monthlyEventCount &&
2829
subscription?.eventLimit &&
2930
subscription.monthlyEventCount > subscription.eventLimit
3031
) {
3132
return (
32-
<Alert variant="destructive" className="p-4 mt-4">
33-
<div className="flex items-start space-x-3">
34-
<AlertTriangle className="h-5 w-5 mt-0.5" />
35-
<div className="flex-1">
36-
<AlertTitle className="text-base font-semibold mb-1">Event Limit Exceeded</AlertTitle>
37-
<div className="mb-2 text-sm">
38-
<strong>{formatNumber(subscription.monthlyEventCount || 0)}</strong> events used of{" "}
39-
<strong>{formatNumber(subscription.eventLimit)}</strong>
40-
</div>
41-
42-
{site.isOwner ? (
43-
<div className="flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-2 items-start sm:items-center">
44-
<AlertDescription className="text-sm">
45-
Upgrade your plan to continue collecting analytics.
46-
</AlertDescription>
47-
<Button variant="success" asChild size="sm">
48-
<Link href="/subscribe">
49-
Upgrade Plan <ArrowRight className="ml-1 h-3 w-3" />
50-
</Link>
51-
</Button>
52-
</div>
53-
) : (
54-
<AlertDescription className="text-sm">
55-
This site has exceeded its monthly event limit. Please contact your organization owner to upgrade the
56-
plan.
57-
</AlertDescription>
58-
)}
59-
</div>
33+
<div className="mt-4 px-4 py-3 rounded-lg border border-red-200 dark:border-red-400/30 bg-red-50/80 dark:bg-red-900/20 text-sm flex gap-4 items-center">
34+
<AlertTriangle className="h-5 w-5 text-red-600 dark:text-red-400 flex-shrink-0" />
35+
<div className="flex-1">
36+
<span className="text-red-700 dark:text-red-300 font-medium">
37+
Monthly event limit exceeded: <strong>{formatNumber(subscription.monthlyEventCount || 0)}</strong> of{" "}
38+
<strong>{formatNumber(subscription.eventLimit)}</strong> events used.{" "}
39+
{site.isOwner
40+
? "Upgrade your plan to continue collecting analytics."
41+
: "Please contact your organization owner to upgrade."}
42+
</span>
6043
</div>
61-
</Alert>
44+
{site.isOwner && (
45+
<Button variant="success" size="sm" asChild>
46+
<Link href="/settings/organization/subscription">
47+
Upgrade <ArrowRight className="ml-1 h-3 w-3" />
48+
</Link>
49+
</Button>
50+
)}
51+
</div>
6252
);
6353
}
6454

65-
// If approaching limit (>90%), show warning banner
66-
if (isNearLimit) {
55+
// Approaching limit (90-100%)
56+
if (usagePercentage <= 90) {
6757
return (
68-
<Alert className="mt-4 p-4 bg-amber-50 border-amber-200 dark:bg-amber-900/20 dark:border-amber-800">
69-
<div className="flex items-start space-x-3">
70-
<AlertTriangle className="h-5 w-5 mt-0.5 text-amber-500" />
71-
<div className="flex-1">
72-
<AlertTitle className="text-base font-semibold mb-1 text-amber-700 dark:text-amber-400">
73-
Approaching Event Limit
74-
</AlertTitle>
75-
<div className="mb-2 text-sm text-amber-700 dark:text-amber-400">
76-
<strong>{formatNumber(subscription?.monthlyEventCount || 0)}</strong> events used of{" "}
77-
<strong>{formatNumber(subscription?.eventLimit || 0)}</strong>
78-
</div>
79-
80-
{site.isOwner ? (
81-
<div className="flex flex-col space-y-2 sm:flex-row sm:space-y-0 sm:space-x-2 items-start sm:items-center">
82-
<AlertDescription className="text-sm text-amber-700 dark:text-amber-400">
83-
Consider upgrading your plan to avoid interruptions.
84-
</AlertDescription>
85-
<Button asChild variant="success" size="sm">
86-
<Link href="/subscribe">
87-
Upgrade Plan <ArrowRight className="ml-1 h-3 w-3" />
88-
</Link>
89-
</Button>
90-
</div>
91-
) : (
92-
<AlertDescription className="text-sm text-amber-700 dark:text-amber-400">
93-
This site is approaching its monthly event limit. You may want to notify your organization owner.
94-
</AlertDescription>
95-
)}
96-
</div>
58+
<div className="mt-4 px-4 py-3 rounded-lg border border-amber-200 dark:border-amber-400/30 bg-amber-50/80 dark:bg-amber-900/20 text-sm flex gap-4 items-center">
59+
<AlertTriangle className="h-5 w-5 text-amber-600 dark:text-amber-400 flex-shrink-0" />
60+
<div className="flex-1">
61+
<span className="text-amber-700 dark:text-amber-300 font-medium">
62+
Approaching monthly event limit: <strong>{formatNumber(subscription?.monthlyEventCount || 0)}</strong> of{" "}
63+
<strong>{formatNumber(subscription?.eventLimit || 0)}</strong> events used.{" "}
64+
{site.isOwner
65+
? "Consider upgrading to avoid interruptions."
66+
: "You may want to notify your organization owner."}
67+
</span>
9768
</div>
98-
</Alert>
69+
{site.isOwner && (
70+
<Button variant="success" size="sm" asChild>
71+
<Link href="/settings/organization/subscription">
72+
Upgrade <ArrowRight className="ml-1 h-3 w-3" />
73+
</Link>
74+
</Button>
75+
)}
76+
</div>
9977
);
10078
}
10179

client/src/components/subscription/PaidPlain/PaidPlan.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ export function PaidPlan() {
144144
<div className="space-y-6 mt-3 p-2">
145145
<div className="flex justify-between items-start">
146146
<div className="space-y-1">
147-
<p className="text-3xl font-bold">{currentPlanDetails?.name || activeSubscription.planName}</p>
148-
<p className="text text-gray-300">{getFormattedPrice()}</p>
147+
<p className="text-3xl font-bold">{currentPlanDetails?.name || activeSubscription.planName} </p>
148+
<p className="text text-gray-300">
149+
{getFormattedPrice()}{activeSubscription.eventLimit.toLocaleString()} events
150+
</p>
149151
{isAnnualPlan && (
150152
<div className="mt-2 text-sm text-emerald-400">
151153
<p>You save by paying annually (2 months free)</p>
@@ -164,7 +166,7 @@ export function PaidPlan() {
164166
</div>
165167

166168
<div className="space-y-2">
167-
<h3 className="font-medium mb-2">Usage</h3>
169+
<h3 className="font-medium mb-2">Usage this month</h3>
168170
<div className="space-y-4">
169171
<div>
170172
<div className="flex justify-between mb-1">

0 commit comments

Comments
 (0)