Skip to content

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

standardize limit (#249)

Bill Yang2bdf18d7ffeb
diff --git a/server/src/api/sites/getSites.ts b/server/src/api/sites/getSites.ts
index d4e286134..af9180de4 100644
--- a/server/src/api/sites/getSites.ts
+++ b/server/src/api/sites/getSites.ts
@@ -4,10 +4,7 @@ import { db } from "../../db/postgres/postgres.js";
import { member } from "../../db/postgres/schema.js";
import { getSitesUserHasAccessTo } from "../../lib/auth-utils.js";
import { getSubscriptionInner } from "../stripe/getSubscription.js";
-import { IS_CLOUD } from "../../lib/const.js";
-
-// Default event limit for users without an active subscription
-const DEFAULT_EVENT_LIMIT = 1_000_000;
+import { IS_CLOUD, TRIAL_EVENT_LIMIT } from "../../lib/const.js";
export async function getSites(req: FastifyRequest, reply: FastifyReply) {
try {
@@ -50,7 +47,7 @@ export async function getSites(req: FastifyRequest, reply: FastifyReply) {
const subscription = await getSubscriptionInner(ownerId);
const monthlyEventCount = subscription?.monthlyEventCount || 0;
- const eventLimit = subscription?.eventLimit || DEFAULT_EVENT_LIMIT;
+ const eventLimit = subscription?.eventLimit || TRIAL_EVENT_LIMIT;
return {
...site,
diff --git a/server/src/cron/monthly-usage-checker.ts b/server/src/cron/monthly-usage-checker.ts
index 388501f6c..f598e6aee 100644
--- a/server/src/cron/monthly-usage-checker.ts
+++ b/server/src/cron/monthly-usage-checker.ts
@@ -5,14 +5,16 @@ import { processResults } from "../api/analytics/utils.js";
import { clickhouse } from "../db/clickhouse/clickhouse.js";
import { db } from "../db/postgres/postgres.js";
import { member, sites, user } from "../db/postgres/schema.js";
-import { getStripePrices, StripePlan } from "../lib/const.js";
+import {
+ getStripePrices,
+ StripePlan,
+ TRIAL_EVENT_LIMIT,
+} from "../lib/const.js";
import { stripe } from "../lib/stripe.js";
// Default event limit for users without an active subscription
const DEFAULT_EVENT_LIMIT = 0;
-const TRIAL_EVENT_LIMIT = 1_000_000;
-
// Global set to track site IDs that have exceeded their monthly limits
export const sitesOverLimit = new Set<number>();
diff --git a/server/src/lib/const.ts b/server/src/lib/const.ts
index 79c7b9e73..3389ef770 100644
--- a/server/src/lib/const.ts
+++ b/server/src/lib/const.ts
@@ -7,7 +7,7 @@ export const DISABLE_SIGNUP = process.env.DISABLE_SIGNUP === "true";
// Trial constants
export const TRIAL_DURATION_DAYS = 14;
-export const TRIAL_EVENT_LIMIT = 100000;
+export const TRIAL_EVENT_LIMIT = 1_000_000;
// Define a type for the plan objects
export interface StripePlan {