Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore(billing): remove usage-tracker component (#9641)

Michael Fröhliche8efbb5e8f04
diff --git a/web/src/components/nav/app-sidebar.tsx b/web/src/components/nav/app-sidebar.tsx
index 4ad0dd74d8..c2d952eb86 100644
--- a/web/src/components/nav/app-sidebar.tsx
+++ b/web/src/components/nav/app-sidebar.tsx
@@ -24,11 +24,9 @@ import { useRouter } from "next/router";
import Link from "next/link";
import { LangfuseLogo } from "@/src/components/LangfuseLogo";
import { SidebarNotifications } from "@/src/components/nav/sidebar-notifications";
-import { UsageTracker } from "@/src/ee/features/billing/components/UsageTracker";
import { type RouteGroup } from "@/src/components/layouts/routes";
import { ExternalLink, Grid2X2 } from "lucide-react";
import { useLangfuseCloudRegion } from "@/src/features/organizations/hooks";
-import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";
type AppSidebarProps = {
navItems: {
@@ -48,7 +46,6 @@ export function AppSidebar({
userNavProps,
...props
}: AppSidebarProps) {
- const isCloudBillingAvailable = useIsCloudBillingAvailable();
return (
<Sidebar collapsible="icon" variant="sidebar" {...props}>
<SidebarHeader>
@@ -62,7 +59,6 @@ export function AppSidebar({
<NavMain items={navItems} />
<div className="flex-1" />
<div className="flex flex-col gap-2 p-2">
- {isCloudBillingAvailable && <UsageTracker />}
<SidebarNotifications />
</div>
<NavMain items={secondaryNavItems} />
diff --git a/web/src/ee/features/billing/components/UsageTracker.tsx b/web/src/ee/features/billing/components/UsageTracker.tsx
deleted file mode 100644
index a88e83ac2a..0000000000
--- a/web/src/ee/features/billing/components/UsageTracker.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-import { api } from "@/src/utils/api";
-import { useQueryProjectOrOrganization } from "@/src/features/projects/hooks";
-import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";
-import { MAX_EVENTS_FREE_PLAN } from "@/src/ee/features/billing/constants";
-import { useHasEntitlement, usePlan } from "@/src/features/entitlements/hooks";
-import {
- Card,
- CardContent,
- CardDescription,
- CardHeader,
- CardTitle,
-} from "@/src/components/ui/card";
-import { ActionButton } from "@/src/components/ActionButton";
-import { cn } from "@/src/utils/tailwind";
-import { AlertTriangle } from "lucide-react";
-import { useSidebar } from "@/src/components/ui/sidebar";
-import { useIsCloudBillingAvailable } from "@/src/ee/features/billing/utils/isCloudBilling";
-
-export const UsageTracker = () => {
- const { organization } = useQueryProjectOrOrganization();
- const hasEntitlement = useHasEntitlement("cloud-billing");
- const plan = usePlan();
- const hasAccess = useHasOrganizationAccess({
- organizationId: organization?.id,
- scope: "langfuseCloudBilling:CRUD",
- });
- const { setOpen } = useSidebar();
- const isCloudBillingAvailable = useIsCloudBillingAvailable();
-
- const usageQuery = api.cloudBilling.getUsage.useQuery(
- {
- orgId: organization?.id!,
- },
- {
- enabled:
- !!organization &&
- hasAccess &&
- hasEntitlement &&
- isCloudBillingAvailable,
- refetchOnMount: false,
- refetchOnReconnect: false,
- refetchOnWindowFocus: false,
- staleTime: 60 * 60 * 1000,
- },
- );
-
- // Don't show usage tracker if cloud billing is not available
- if (!isCloudBillingAvailable) {
- return null;
- }
-
- if (
- usageQuery.isPending ||
- !usageQuery.data ||
- !hasEntitlement ||
- plan !== "cloud:hobby"
- ) {
- return null;
- }
-
- const usage = usageQuery.data.usageCount || 0;
- const usageType = usageQuery.data.usageType;
- const percentage = (usage / MAX_EVENTS_FREE_PLAN) * 100;
-
- if (percentage < 90) {
- return null;
- }
-
- const isCritical = percentage > 200;
-
- return (
- <>
- {/* icon when critical and sidebar is collapsed */}
- {isCritical && (
- <AlertTriangle
- className="hidden h-4 w-4 cursor-pointer self-center text-destructive group-data-[collapsible=icon]:inline-block"
- onClick={() => setOpen(true)}
- />
- )}
- {/* card when sidebar is not collapsed */}
- <Card
- className={cn(
- "relative max-h-48 overflow-hidden rounded-md bg-opacity-50 shadow-none group-data-[collapsible=icon]:hidden",
- isCritical && "border-destructive",
- )}
- >
- <CardHeader className="p-4 pb-0">
- <CardTitle className="flex items-center gap-2 text-sm">
- {isCritical && (
- <AlertTriangle className="inline-block h-4 w-4 text-destructive" />
- )}
- Plan Usage Limit
- </CardTitle>
- <CardDescription>
- {`${usage.toLocaleString()} / ${MAX_EVENTS_FREE_PLAN.toLocaleString()} (${percentage.toFixed(0)}%) ${usageType} in last 30 days. Please upgrade your plan to avoid interruptions.`}
- </CardDescription>
- </CardHeader>
- <CardContent className="p-4 pt-2">
- <ActionButton
- variant={isCritical ? "default" : "secondary"}
- size="sm"
- href={`/organization/${organization?.id}/settings/billing`}
- hasAccess={hasAccess}
- >
- Upgrade plan
- </ActionButton>
- </CardContent>
- </Card>
- </>
- );
-};