Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(license-v2): introduce breakdown scope handling for usage metrics

Victor Hugo dos Santos20fa00a0eba0
diff --git a/backend/src/ee/routes/v1/license-v2-router.ts b/backend/src/ee/routes/v1/license-v2-router.ts
index 72d32dd90b..7057019e12 100644
--- a/backend/src/ee/routes/v1/license-v2-router.ts
+++ b/backend/src/ee/routes/v1/license-v2-router.ts
@@ -1,7 +1,7 @@
import { FastifyRequest } from "fastify";
import { z } from "zod";
-import { BillingV2BreakdownDimension } from "@app/ee/services/license-v2/license-v2-types";
+import { BillingV2BreakdownDimension, BillingV2BreakdownScopeKind } from "@app/ee/services/license-v2/license-v2-types";
import { readLimit, writeLimit } from "@app/server/config/rateLimiter";
import { isUserSessionAuth } from "@app/server/plugins/auth/inject-identity";
import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
@@ -337,6 +337,14 @@ export const registerLicenseV2Router = async (server: FastifyZodProvider) => {
organizationId: z.string().trim().uuid(),
dimensionKey: z.nativeEnum(BillingV2BreakdownDimension).describe("The metered dimension to break down.")
}),
+ querystring: z.object({
+ scope: z
+ .nativeEnum(BillingV2BreakdownScopeKind)
+ .default(BillingV2BreakdownScopeKind.Organization)
+ .describe(
+ "'instance' explains usage across the entire self-hosted licence; 'organization' explains one root organization's share of it."
+ )
+ }),
response: {
200: z.object({ breakdown: BillingV2UsageBreakdownSchema })
}
@@ -347,7 +355,8 @@ export const registerLicenseV2Router = async (server: FastifyZodProvider) => {
orgId: req.params.organizationId,
dimensionKey: req.params.dimensionKey,
actor: buildActor(req.permission),
- isInstanceAdmin: isSuperAdmin(req.auth)
+ isInstanceAdmin: isSuperAdmin(req.auth),
+ scope: req.query.scope
});
}
});
diff --git a/backend/src/ee/services/license-v2/license-v2-breakdown-dal.ts b/backend/src/ee/services/license-v2/license-v2-breakdown-dal.ts
index 594bf26620..9315639efc 100644
--- a/backend/src/ee/services/license-v2/license-v2-breakdown-dal.ts
+++ b/backend/src/ee/services/license-v2/license-v2-breakdown-dal.ts
@@ -26,6 +26,23 @@ export const licenseV2BreakdownDALFactory = (db: TDbClient) => {
}
};
+ // Every organization on the instance, for the instance-wide breakdown. On self-hosted the meters
+ // count the whole database rather than one tree (usage-counters passes no org when !isCloud), so a
+ // tree-scoped roster would leave the parts short of the figure the customer is billed on.
+ const findAllOrgNames = async (): Promise<TScopeOrgRow[]> => {
+ try {
+ const rows = (await db.replicaNode()(TableName.Organization).select("id", "name", "rootOrgId")) as {
+ id: string;
+ name: string;
+ rootOrgId: string | null;
+ }[];
+
+ return rows.map((row) => ({ id: row.id, name: row.name, isRoot: !row.rootOrgId }));
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Find all org names for usage breakdown" });
+ }
+ };
+
const findProjectNames = async (projectIds: string[]): Promise<TScopeProjectRow[]> => {
if (!projectIds.length) {
return [];
@@ -64,5 +81,5 @@ export const licenseV2BreakdownDALFactory = (db: TDbClient) => {
}
};
- return { findOrgTreeNames, findProjectNames, findAllRootOrgs };
+ return { findOrgTreeNames, findAllOrgNames, findProjectNames, findAllRootOrgs };
};
diff --git a/backend/src/ee/services/license-v2/license-v2-service.ts b/backend/src/ee/services/license-v2/license-v2-service.ts
index fa376d97ae..60a677cc93 100644
--- a/backend/src/ee/services/license-v2/license-v2-service.ts
+++ b/backend/src/ee/services/license-v2/license-v2-service.ts
@@ -2,7 +2,7 @@ import { ForbiddenError } from "@casl/ability";
import { OrganizationActionScope, ProjectType } from "@app/db/schemas";
import { TEnvConfig } from "@app/lib/config/env";
-import { BadRequestError, InternalServerError, NotFoundError } from "@app/lib/errors";
+import { BadRequestError, ForbiddenRequestError, InternalServerError, NotFoundError } from "@app/lib/errors";
import { logger } from "@app/lib/logger";
import { isScopeNarrowedRequest } from "@app/lib/request-context/oauth-delegation";
import { TLicenseClientFactory } from "@app/services/license-client";
@@ -25,6 +25,7 @@ import {
BillingV2BreakdownDimension,
BillingV2BreakdownProject,
BillingV2BreakdownScope,
+ BillingV2BreakdownScopeKind,
BillingV2CatalogProduct,
BillingV2CompareRow,
BillingV2Deprecation,
@@ -917,16 +918,32 @@ export const licenseV2ServiceFactory = ({
.sort((a, b) => Number(b.isRoot) - Number(a.isRoot) || b.count - a.count || a.name.localeCompare(b.name));
};
- const getUsageBreakdown = async ({ orgId, actor, dimensionKey, isInstanceAdmin }: TGetBillingV2UsageBreakdownDTO) => {
+ const getUsageBreakdown = async ({
+ orgId,
+ actor,
+ dimensionKey,
+ isInstanceAdmin,
+ scope: scopeKind = BillingV2BreakdownScopeKind.Organization
+ }: TGetBillingV2UsageBreakdownDTO) => {
await ensureBillingRead(orgId, actor, isInstanceAdmin);
+ const isInstanceScope = scopeKind === BillingV2BreakdownScopeKind.Instance;
+ if (isInstanceScope && !canReadAcrossOrgs(isInstanceAdmin)) {
+ throw new ForbiddenRequestError({
+ message: "Instance-wide usage can only be read by an instance admin on a self-hosted instance."
+ });
+ }
+
const organization = await orgDAL.findById(orgId);
if (!organization) {
throw new NotFoundError({ message: `Organization with ID '${orgId}' not found` });
}
- const rootOrgId = await usageCounterDAL.resolveRootOrgId(orgId);
- const orgs = await breakdownDAL.findOrgTreeNames(rootOrgId);
+ const rootOrgId = isInstanceScope ? null : await usageCounterDAL.resolveRootOrgId(orgId);
+ const scopeOrgId = rootOrgId ?? undefined;
+ const orgs = isInstanceScope
+ ? await breakdownDAL.findAllOrgNames()
+ : await breakdownDAL.findOrgTreeNames(rootOrgId as string);
const buildIdentityBreakdown = async (
counts: { users: number; identities: number },
@@ -976,8 +993,8 @@ export const licenseV2ServiceFactory = ({
const projectType =
dimensionKey === BillingV2BreakdownDimension.SecretIdentities ? ProjectType.SecretManager : ProjectType.PAM;
const [counts, rows] = await Promise.all([
- usageCounterDAL.countProjectIdentitiesByKindFor(projectType, rootOrgId),
- usageCounterDAL.getProjectIdentityBreakdown(projectType, rootOrgId)
+ usageCounterDAL.countProjectIdentitiesByKindFor(projectType, scopeOrgId),
+ usageCounterDAL.getProjectIdentityBreakdown(projectType, scopeOrgId)
]);
return {
breakdown: await buildIdentityBreakdown(
@@ -1002,12 +1019,12 @@ export const licenseV2ServiceFactory = ({
};
}
case BillingV2BreakdownDimension.InternalCas: {
- const rows = await usageCounterDAL.getInternalCaOrgBreakdown(rootOrgId);
+ const rows = await usageCounterDAL.getInternalCaOrgBreakdown(scopeOrgId);
return { breakdown: buildOrgOnlyBreakdown(rows, "internal CA") };
}
case BillingV2BreakdownDimension.ActiveCerts:
case BillingV2BreakdownDimension.WildcardCerts: {
- const rows = await usageCounterDAL.getActiveCertificateOrgBreakdown(rootOrgId);
+ const rows = await usageCounterDAL.getActiveCertificateOrgBreakdown(scopeOrgId);
const isWildcard = dimensionKey === BillingV2BreakdownDimension.WildcardCerts;
return {
breakdown: buildOrgOnlyBreakdown(
diff --git a/backend/src/ee/services/license-v2/license-v2-types.ts b/backend/src/ee/services/license-v2/license-v2-types.ts
index 9ddbddc967..f2abdd82e2 100644
--- a/backend/src/ee/services/license-v2/license-v2-types.ts
+++ b/backend/src/ee/services/license-v2/license-v2-types.ts
@@ -391,9 +391,15 @@ export type BillingV2UsageBreakdown = {
scopes: BillingV2BreakdownScope[];
};
+export enum BillingV2BreakdownScopeKind {
+ Instance = "instance",
+ Organization = "organization"
+}
+
export type TGetBillingV2UsageBreakdownDTO = {
orgId: string;
actor: OrgServiceActor;
dimensionKey: TBillingV2BreakdownDimension;
isInstanceAdmin?: boolean;
+ scope?: BillingV2BreakdownScopeKind;
};
diff --git a/backend/src/ee/services/license/license-dal.ts b/backend/src/ee/services/license/license-dal.ts
index 4e0bea6d62..2190c949d4 100644
--- a/backend/src/ee/services/license/license-dal.ts
+++ b/backend/src/ee/services/license/license-dal.ts
@@ -191,8 +191,9 @@ export const licenseDALFactory = (db: TDbClient) => {
// created. Seats are held by membership (an identity can sit in many projects), so grouping on
// membership would count one identity several times; identities.projectId is a single column, so
// grouping on ownership partitions the billed total exactly once across the tree.
+ // orgId null means the whole instance, matching countBillableOrgActors and the meter it feeds.
const getBillableIdentityOwnershipBreakdown = async (
- orgId: string,
+ orgId: string | null,
tx?: Knex
): Promise<TBillableIdentityOwnershipRow[]> => {
try {
diff --git a/backend/src/services/license-client/usage/usage-counter-dal.ts b/backend/src/services/license-client/usage/usage-counter-dal.ts
index 0baaf358da..9ee4b09f28 100644
--- a/backend/src/services/license-client/usage/usage-counter-dal.ts
+++ b/backend/src/services/license-client/usage/usage-counter-dal.ts
@@ -282,7 +282,7 @@ export const usageCounterDALFactory = (db: TDbClient) => {
// identities.projectId is a single column and partitions the metered total exactly once.
const getProjectIdentityOwnershipBreakdown = async (
projectType: ProjectType,
- orgId: string
+ orgId?: string
): Promise<TIdentityOwnershipRow[]> => {
const rows = (await db
.replicaNode()({ i: TableName.Identity })
@@ -317,7 +317,7 @@ export const usageCounterDALFactory = (db: TDbClient) => {
}
};
- const countProjectIdentitiesByKindFor = async (projectType: ProjectType, orgId: string) => {
+ const countProjectIdentitiesByKindFor = async (projectType: ProjectType, orgId?: string) => {
try {
return await countProjectIdentitiesByKind(projectType, orgId);
} catch (error) {
@@ -325,7 +325,7 @@ export const usageCounterDALFactory = (db: TDbClient) => {
}
};
- const getProjectIdentityBreakdown = async (projectType: ProjectType, orgId: string) => {
+ const getProjectIdentityBreakdown = async (projectType: ProjectType, orgId?: string) => {
try {
return await getProjectIdentityOwnershipBreakdown(projectType, orgId);
} catch (error) {
@@ -333,7 +333,7 @@ export const usageCounterDALFactory = (db: TDbClient) => {
}
};
- const getInternalCaOrgBreakdown = async (orgId: string): Promise<TOrgUnitCountRow[]> => {
+ const getInternalCaOrgBreakdown = async (orgId?: string): Promise<TOrgUnitCountRow[]> => {
try {
const rows = (await $internalCas(orgId)
.groupBy(`${TableName.Project}.orgId`)
@@ -353,7 +353,7 @@ export const usageCounterDALFactory = (db: TDbClient) => {
// orgs is a single billable unit. Splitting that by org therefore needs each quotaKey attributed to
// exactly one of them, else the parts sum past the billed total. The earliest issuance wins (org id
// breaks a tie) so the attribution is stable between reads rather than shifting with row order.
- const getActiveCertificateOrgBreakdown = async (orgId: string): Promise<TCertificateOrgUnitRow[]> => {
+ const getActiveCertificateOrgBreakdown = async (orgId?: string): Promise<TCertificateOrgUnitRow[]> => {
try {
const attributed = $activeQuotaCertificates(orgId)
.whereNotNull(`${TableName.Certificate}.quotaKey`)
diff --git a/frontend/src/components/v3/generic/Combobox/Combobox.tsx b/frontend/src/components/v3/generic/Combobox/Combobox.tsx
index e3a842da45..0a7cfb95a8 100644
--- a/frontend/src/components/v3/generic/Combobox/Combobox.tsx
+++ b/frontend/src/components/v3/generic/Combobox/Combobox.tsx
@@ -228,10 +228,19 @@ const ComboboxList = <TOption,>({
>
{getOptionGroup
? (group: ComboboxGroup<TOption>) => (
- <ComboboxPrimitive.Group key={group.value} items={group.items}>
- <ComboboxPrimitive.GroupLabel className="px-2 py-1.5 text-xs font-medium text-muted">
- {group.value}
- </ComboboxPrimitive.GroupLabel>
+ <ComboboxPrimitive.Group
+ key={group.value}
+ items={group.items}
+ className={cn(
+ group.value === "" && "border-b border-border pb-1",
+ group.value === "" && "mb-1"
+ )}
+ >
+ {group.value !== "" && (
+ <ComboboxPrimitive.GroupLabel className="px-2 py-1.5 text-xs font-medium text-muted">
+ {group.value}
+ </ComboboxPrimitive.GroupLabel>
+ )}
<ComboboxPrimitive.Collection>{renderItem}</ComboboxPrimitive.Collection>
</ComboboxPrimitive.Group>
)
diff --git a/frontend/src/hooks/api/billingV2/index.tsx b/frontend/src/hooks/api/billingV2/index.tsx
index 82cbd71b02..4db58a26d8 100644
--- a/frontend/src/hooks/api/billingV2/index.tsx
+++ b/frontend/src/hooks/api/billingV2/index.tsx
@@ -22,6 +22,7 @@ export {
export type {
BillingV2BreakdownProject,
BillingV2BreakdownScope,
+ BillingV2BreakdownScopeKind,
BillingV2Cadence,
BillingV2CatalogProduct,
BillingV2CommitmentChange,
diff --git a/frontend/src/hooks/api/billingV2/queries.tsx b/frontend/src/hooks/api/billingV2/queries.tsx
index cb850477eb..6c4ad6c929 100644
--- a/frontend/src/hooks/api/billingV2/queries.tsx
+++ b/frontend/src/hooks/api/billingV2/queries.tsx
@@ -3,6 +3,7 @@ import { keepPreviousData, useQuery } from "@tanstack/react-query";
import { apiRequest } from "@app/config/request";
import {
+ BillingV2BreakdownScopeKind,
BillingV2CatalogProduct,
BillingV2OrganizationsPage,
BillingV2Overview,
@@ -14,8 +15,8 @@ type BillingV2OrganizationsParams = { search?: string; limit?: number; offset?:
export const billingV2Keys = {
overview: (orgId: string) => [{ orgId }, "billing-v2-overview"] as const,
catalog: (orgId: string) => [{ orgId }, "billing-v2-catalog"] as const,
- usageBreakdown: (orgId: string, dimensionKey: string) =>
- [{ orgId, dimensionKey }, "billing-v2-usage-breakdown"] as const,
+ usageBreakdown: (orgId: string, dimensionKey: string, scope: BillingV2BreakdownScopeKind) =>
+ [{ orgId, dimensionKey, scope }, "billing-v2-usage-breakdown"] as const,
organizations: (orgId: string, { search, ...rest }: BillingV2OrganizationsParams) =>
[{ orgId, search: search || undefined, ...rest }, "billing-v2-organizations"] as const
};
@@ -52,14 +53,19 @@ export const useGetBillingV2Catalog = (orgId: string) => {
});
};
-export const useGetBillingV2UsageBreakdown = (orgId: string, dimensionKey: string | null) => {
+export const useGetBillingV2UsageBreakdown = (
+ orgId: string,
+ dimensionKey: string | null,
+ scope: BillingV2BreakdownScopeKind = "organization"
+) => {
return useQuery({
- queryKey: billingV2Keys.usageBreakdown(orgId, dimensionKey ?? ""),
+ queryKey: billingV2Keys.usageBreakdown(orgId, dimensionKey ?? "", scope),
queryFn: async () => {
const {
data: { breakdown }
} = await apiRequest.get<{ breakdown: BillingV2UsageBreakdown }>(
- `/api/v1/organizations/${orgId}/billing/v2/breakdowns/${dimensionKey}`
+ `/api/v1/organizations/${orgId}/billing/v2/breakdowns/${dimensionKey}`,
+ { params: { scope } }
);
return breakdown;
diff --git a/frontend/src/hooks/api/billingV2/types.ts b/frontend/src/hooks/api/billingV2/types.ts
index 7c399319b8..c04632a88f 100644
--- a/frontend/src/hooks/api/billingV2/types.ts
+++ b/frontend/src/hooks/api/billingV2/types.ts
@@ -394,6 +394,8 @@ export type BillingV2UsageBreakdown = {
scopes: BillingV2BreakdownScope[];
};
+export type BillingV2BreakdownScopeKind = "instance" | "organization";
+
export type BillingV2Organization = {
id: string;
name: string;
diff --git a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx
index 447f733a3b..bcdc6b6b64 100644
--- a/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/BillingV2Page.tsx
@@ -13,6 +13,7 @@ import {
} from "@app/context";
import { useDebounce } from "@app/hooks";
import {
+ BillingV2BreakdownScopeKind,
useAddBillingV2PaymentMethod,
useCreateBillingV2PortalSession,
useGetBillingV2Catalog,
@@ -23,6 +24,7 @@ import {
import { Overview } from "./components/Overview";
import { ProductSheet } from "./components/ProductSheet";
import { RemoveProductModal } from "./components/RemoveProductModal";
+import { ALL_ORGS_VALUE } from "./components/RootOrgFilter";
import { UsageBreakdownSheet } from "./components/UsageBreakdownSheet";
import { catalogById } from "./billing-v2-format";
// LOCAL PREVIEW ONLY — DO NOT COMMIT (see billing-v2-local-preview.ts).
@@ -56,11 +58,13 @@ export const BillingV2Page = () => {
OrgPermissionSubjects.Billing
);
+ const [breakdownScope, setBreakdownScope] = useState<BillingV2BreakdownScopeKind>("instance");
const [selectedOrgId, setSelectedOrgId] = useState(orgId);
const [lastOrgId, setLastOrgId] = useState(orgId);
if (orgId !== lastOrgId) {
setLastOrgId(orgId);
setSelectedOrgId(orgId);
+ setBreakdownScope("instance");
}
// The picker searches server-side: the instance's root organizations are listed a page at a time,
// so an organization past the page is reachable only by name. Short enough that the popup does not
@@ -254,8 +258,15 @@ export const BillingV2Page = () => {
rootOrgs={pickerOrgs}
rootOrgCount={rootOrgCount}
isRootOrgsLoading={isRootOrgsFetching}
- selectedOrgId={selectedOrgId}
- onSelectOrg={setSelectedOrgId}
+ selectedOrgId={breakdownScope === "instance" ? ALL_ORGS_VALUE : selectedOrgId}
+ onSelectOrg={(nextId) => {
+ if (nextId === ALL_ORGS_VALUE) {
+ setBreakdownScope("instance");
+ return;
+ }
+ setBreakdownScope("organization");
+ setSelectedOrgId(nextId);
+ }}
onSearchOrgs={setOrgSearch}
showOrgFilter={showOrgFilter}
onUpdatePayment={onUpdatePayment}
@@ -290,6 +301,7 @@ export const BillingV2Page = () => {
{flow?.type === "breakdown" && catalogById(catalog, flow.prodId) && (
<UsageBreakdownSheet
orgId={selectedOrgId}
+ scope={showOrgFilter ? breakdownScope : "organization"}
prod={catalogById(catalog, flow.prodId)!}
entitlement={overview?.entitlements[flow.prodId]}
onClose={close}
diff --git a/frontend/src/pages/organization/BillingV2Page/components/RootOrgFilter.tsx b/frontend/src/pages/organization/BillingV2Page/components/RootOrgFilter.tsx
index 579aa6b463..676bcc684c 100644
--- a/frontend/src/pages/organization/BillingV2Page/components/RootOrgFilter.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/RootOrgFilter.tsx
@@ -11,6 +11,10 @@ import {
} from "@app/components/v3";
import { BillingV2Organization } from "@app/hooks/api";
+// The pinned row's id. Not a real organization, so it never collides with one and the page keys its
+// scope off it rather than off a parallel boolean the picker could drift from.
+export const ALL_ORGS_VALUE = "__all__";
+
type RootOrgFilterProps = {
orgs: BillingV2Organization[];
value: string;
@@ -31,8 +35,11 @@ export const RootOrgFilter = ({
totalCount,
isLoading
}: RootOrgFilterProps) => {
+ const allOrgsOption: BillingV2Organization = { id: ALL_ORGS_VALUE, name: "All organizations" };
+ const options = [allOrgsOption, ...orgs];
+
const [lastSelected, setLastSelected] = useState<BillingV2Organization | null>(null);
- const orgInPage = orgs.find((org) => org.id === value) ?? null;
+ const orgInPage = options.find((org) => org.id === value) ?? null;
if (orgInPage && orgInPage.id !== lastSelected?.id) {
setLastSelected(orgInPage);
}
@@ -57,8 +64,9 @@ export const RootOrgFilter = ({
searchPlaceholder="Search organizations..."
searchAriaLabel="Search root organizations"
isLoading={isLoading}
- options={orgs}
+ options={options}
value={selectedOrg}
+ getOptionGroup={(option) => (option.id === ALL_ORGS_VALUE ? "" : "Organizations")}
onValueChange={(option) => onChange(option.id)}
onSearchChange={onSearchChange}
getOptionValue={(option) => option.id}
diff --git a/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsx b/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsx
index e5e4415670..d35d995fab 100644
--- a/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/UsageBreakdownSheet.tsx
@@ -30,6 +30,7 @@ import { cn } from "@app/components/v3/utils";
import {
BillingV2BreakdownDimension,
BillingV2BreakdownScope,
+ BillingV2BreakdownScopeKind,
BillingV2CatalogProduct,
BillingV2Entitlement,
BillingV2UsageBreakdown,
@@ -182,13 +183,21 @@ const BreakdownSkeleton = () => (
</div>
);
-const BreakdownBody = ({ breakdown }: { breakdown: BillingV2UsageBreakdown }) => {
+const BreakdownBody = ({
+ breakdown,
+ scopeKind
+}: {
+ breakdown: BillingV2UsageBreakdown;
+ scopeKind: BillingV2BreakdownScopeKind;
+}) => {
const [query, setQuery] = useState("");
const [sort, setSort] = useState<SortOrder>("count");
const { total, userCount, scopedCount, unit, hasProjectDetail, scopes } = breakdown;
const unitLabel = pluralizeUnit(unit);
- const totalLabel = userCount > 0 ? "unique identities" : unitLabel;
+ const isInstanceScope = scopeKind === "instance";
+ const totalNoun = userCount > 0 ? "unique identities" : unitLabel;
+ const totalLabel = isInstanceScope ? totalNoun : `${totalNoun} from this organization`;
const rootScope = scopes.find((scope) => scope.isRoot);
const subOrgScopes = useMemo(() => scopes.filter((scope) => !scope.isRoot), [scopes]);
const subOrgCount = subOrgScopes.reduce((sum, scope) => sum + scope.count, 0);
@@ -367,6 +376,7 @@ const BreakdownBody = ({ breakdown }: { breakdown: BillingV2UsageBreakdown }) =>
type UsageBreakdownSheetProps = {
orgId: string;
+ scope: BillingV2BreakdownScopeKind;
prod: BillingV2CatalogProduct;
entitlement?: BillingV2Entitlement;
onClose: () => void;
@@ -374,6 +384,7 @@ type UsageBreakdownSheetProps = {
export const UsageBreakdownSheet = ({
orgId,
+ scope,
prod,
entitlement,
onClose
@@ -386,7 +397,7 @@ export const UsageBreakdownSheet = ({
data: breakdown,
isPending,
isError
- } = useGetBillingV2UsageBreakdown(orgId, activeDim?.key ?? null);
+ } = useGetBillingV2UsageBreakdown(orgId, activeDim?.key ?? null, scope);
return (
<Sheet open onOpenChange={(open) => !open && onClose()}>
@@ -426,7 +437,7 @@ export const UsageBreakdownSheet = ({
</Empty>
)}
- {breakdown && !isError && <BreakdownBody breakdown={breakdown} />}
+ {breakdown && !isError && <BreakdownBody breakdown={breakdown} scopeKind={scope} />}
</div>
<SheetFooter className="flex-row items-center justify-end border-t">