Skip to content

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

feat: wire frontend components to insights routes

adilsona8261b1300ff
diff --git a/frontend/src/hooks/api/secretInsights/index.ts b/frontend/src/hooks/api/secretInsights/index.ts
index f1f04afb8b..85c1251752 100644
--- a/frontend/src/hooks/api/secretInsights/index.ts
+++ b/frontend/src/hooks/api/secretInsights/index.ts
@@ -3,6 +3,12 @@ export {
useGetAuthMethodDistribution,
useGetCalendarInsights,
useGetInsightsSummary,
+ useGetOrgAuthMethodDistribution,
+ useGetOrgSecretsAccessVolume,
+ useGetOrgSecretsCounts,
+ useGetOrgSecretsProjects,
+ useGetOrgSecretsSummary,
+ useGetOrgStaticSecretsUsage,
// useGetSecretAccessLocations,
useGetSecretAccessVolume,
useGetSecretBlindIndexStatus,
@@ -19,12 +25,21 @@ export type {
TGetAuthMethodDistributionResponse,
TGetCalendarInsightsDTO,
TGetCalendarInsightsResponse,
+ TGetOrgSecretsProjectsDTO,
TGetSecretAccessLocationsDTO,
TGetSecretAccessLocationsResponse,
TGetSecretAccessVolumeDTO,
TGetSecretAccessVolumeResponse,
TGetSecretsDuplicationDTO,
TGetSecretsDuplicationResponse,
+ TOrgAuthMethodUsage,
+ TOrgProjectInsight,
+ TOrgProjectInsightWarnings,
+ TOrgProjectsInsights,
+ TOrgSecretAccessVolume,
+ TOrgSecretsCounts,
+ TOrgSecretsSummary,
+ TOrgStaticSecretUsage,
TSecretAccessVolumeActor,
TSecretAccessVolumeDay
} from "./types";
diff --git a/frontend/src/hooks/api/secretInsights/queries.tsx b/frontend/src/hooks/api/secretInsights/queries.tsx
index 5eeaec33c2..1bb66bc559 100644
--- a/frontend/src/hooks/api/secretInsights/queries.tsx
+++ b/frontend/src/hooks/api/secretInsights/queries.tsx
@@ -11,6 +11,7 @@ import {
TGetInsightsCountsResponse,
TGetInsightsSummaryDTO,
TGetInsightsSummaryResponse,
+ TGetOrgSecretsProjectsDTO,
// TGetSecretAccessLocationsDTO,
// TGetSecretAccessLocationsResponse,
TGetSecretAccessVolumeDTO,
@@ -18,7 +19,13 @@ import {
TGetSecretBlindIndexStatusDTO,
TGetSecretBlindIndexStatusResponse,
TGetSecretsDuplicationDTO,
- TGetSecretsDuplicationResponse
+ TGetSecretsDuplicationResponse,
+ TOrgAuthMethodUsage,
+ TOrgProjectsInsights,
+ TOrgSecretAccessVolume,
+ TOrgSecretsCounts,
+ TOrgSecretsSummary,
+ TOrgStaticSecretUsage
} from "./types";
export const secretInsightsKeys = {
@@ -38,7 +45,21 @@ export const secretInsightsKeys = {
secretsDuplication: (params: TGetSecretsDuplicationDTO) =>
[...secretInsightsKeys.all(), "secrets-duplication", params] as const,
blindIndexStatus: (params: TGetSecretBlindIndexStatusDTO) =>
- [...secretInsightsKeys.all(), "blind-index-status", params] as const
+ [...secretInsightsKeys.all(), "blind-index-status", params] as const,
+ // Org-scoped keys. The endpoints derive the org from the auth token, so orgId is only
+ // here to isolate the cache when the user switches organizations.
+ orgSecretsSummary: (orgId: string) =>
+ [...secretInsightsKeys.all(), "org-secrets-summary", { orgId }] as const,
+ orgSecretsProjects: (orgId: string, params: TGetOrgSecretsProjectsDTO) =>
+ [...secretInsightsKeys.all(), "org-secrets-projects", { orgId, ...params }] as const,
+ orgAuthMethodDistribution: (orgId: string) =>
+ [...secretInsightsKeys.all(), "org-auth-method-distribution", { orgId }] as const,
+ orgStaticSecretsUsage: (orgId: string) =>
+ [...secretInsightsKeys.all(), "org-static-secrets-usage", { orgId }] as const,
+ orgAccessVolume: (orgId: string) =>
+ [...secretInsightsKeys.all(), "org-access-volume", { orgId }] as const,
+ orgSecretsCounts: (orgId: string) =>
+ [...secretInsightsKeys.all(), "org-secrets-counts", { orgId }] as const
};
const INSIGHTS_STALE_TIME = 5 * 60 * 1000; // 5 minutes
@@ -95,33 +116,6 @@ export const useGetSecretAccessVolume = (
});
};
-// export const useGetSecretAccessLocations = (
-// params: TGetSecretAccessLocationsDTO,
-// options?: Omit<
-// UseQueryOptions<
-// TGetSecretAccessLocationsResponse,
-// unknown,
-// TGetSecretAccessLocationsResponse,
-// ReturnType<typeof secretInsightsKeys.accessLocations>
-// >,
-// "queryKey" | "queryFn"
-// >
-// ) => {
-// return useQuery({
-// queryKey: secretInsightsKeys.accessLocations(params),
-// queryFn: async () => {
-// const { projectId, ...query } = params;
-// const { data } = await apiRequest.get<TGetSecretAccessLocationsResponse>(
-// `/api/v1/insights/${projectId}/secrets/access-locations`,
-// { params: query }
-// );
-// return data;
-// },
-// staleTime: INSIGHTS_STALE_TIME,
-// ...options
-// });
-// };
-
export const useGetAuthMethodDistribution = (
params: TGetAuthMethodDistributionDTO,
options?: Omit<
@@ -251,3 +245,92 @@ export const useGetSecretBlindIndexStatus = (
...options
});
};
+
+// Org-scoped insights hooks. The endpoints have no :projectId — the backend resolves the
+// org from the auth token, so the hooks only take orgId to key the cache.
+
+export const useGetOrgSecretsSummary = (orgId: string) => {
+ return useQuery({
+ queryKey: secretInsightsKeys.orgSecretsSummary(orgId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ usageInsights: TOrgSecretsSummary }>(
+ "/api/v1/insights/secrets/summary"
+ );
+ return data.usageInsights;
+ },
+ enabled: Boolean(orgId),
+ staleTime: INSIGHTS_STALE_TIME
+ });
+};
+
+export const useGetOrgSecretsProjects = (orgId: string, params: TGetOrgSecretsProjectsDTO = {}) => {
+ return useQuery({
+ queryKey: secretInsightsKeys.orgSecretsProjects(orgId, params),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ projectWarnings: TOrgProjectsInsights }>(
+ "/api/v1/insights/secrets/projects",
+ { params }
+ );
+ return data.projectWarnings;
+ },
+ enabled: Boolean(orgId),
+ staleTime: INSIGHTS_STALE_TIME,
+ placeholderData: (prev) => prev
+ });
+};
+
+export const useGetOrgAuthMethodDistribution = (orgId: string) => {
+ return useQuery({
+ queryKey: secretInsightsKeys.orgAuthMethodDistribution(orgId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ authMethodDistribution: TOrgAuthMethodUsage }>(
+ "/api/v1/insights/secrets/usage/auth-methods"
+ );
+ return data.authMethodDistribution;
+ },
+ enabled: Boolean(orgId),
+ staleTime: INSIGHTS_STALE_TIME
+ });
+};
+
+export const useGetOrgStaticSecretsUsage = (orgId: string) => {
+ return useQuery({
+ queryKey: secretInsightsKeys.orgStaticSecretsUsage(orgId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ staticSecretUsage: TOrgStaticSecretUsage }>(
+ "/api/v1/insights/secrets/usage/static-secrets"
+ );
+ return data.staticSecretUsage;
+ },
+ enabled: Boolean(orgId),
+ staleTime: INSIGHTS_STALE_TIME
+ });
+};
+
+export const useGetOrgSecretsAccessVolume = (orgId: string) => {
+ return useQuery({
+ queryKey: secretInsightsKeys.orgAccessVolume(orgId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ accessVolume: TOrgSecretAccessVolume }>(
+ "/api/v1/insights/secrets/access-volume"
+ );
+ return data.accessVolume;
+ },
+ enabled: Boolean(orgId),
+ staleTime: INSIGHTS_STALE_TIME
+ });
+};
+
+export const useGetOrgSecretsCounts = (orgId: string) => {
+ return useQuery({
+ queryKey: secretInsightsKeys.orgSecretsCounts(orgId),
+ queryFn: async () => {
+ const { data } = await apiRequest.get<{ counts: TOrgSecretsCounts }>(
+ "/api/v1/insights/secrets/counts"
+ );
+ return data.counts;
+ },
+ enabled: Boolean(orgId),
+ staleTime: INSIGHTS_STALE_TIME
+ });
+};
diff --git a/frontend/src/hooks/api/secretInsights/types.ts b/frontend/src/hooks/api/secretInsights/types.ts
index 65ca709b37..fcdae7bd0e 100644
--- a/frontend/src/hooks/api/secretInsights/types.ts
+++ b/frontend/src/hooks/api/secretInsights/types.ts
@@ -1,3 +1,5 @@
+import { IdentityAuthMethod } from "../identities/enums";
+
export type TCalendarRotation = {
id: string;
name: string;
@@ -164,3 +166,68 @@ export type TGetInsightsCountsResponse = {
secretRotationCount: number;
honeyTokenCount: number | null;
};
+
+// Org-scoped insights (endpoints without :projectId — the org comes from the auth token).
+// Shapes mirror backend/src/ee/services/insights/insights-schemas.ts.
+
+export type TOrgSecretsSummary = {
+ activeLeases: number;
+ users: number;
+ identities: number;
+};
+
+export type TOrgProjectInsightWarnings = {
+ // null means unknown (e.g. secret blind index disabled), which is different from zero
+ duplicatedSecrets: number | null;
+ staleSecrets: number;
+ failedRotations: number;
+ failedSyncs: number;
+ orphanedLeases: number;
+};
+
+export type TOrgProjectInsight = {
+ projectId: string;
+ projectName: string;
+ projectSlug: string;
+ totalSecrets: number;
+ severityScore: number;
+ warnings: TOrgProjectInsightWarnings;
+};
+
+export type TOrgProjectsInsights = {
+ projects: TOrgProjectInsight[];
+ totalProjects: number;
+ projectsWithIssues: number;
+ offset: number;
+ limit: number;
+};
+
+export type TGetOrgSecretsProjectsDTO = {
+ offset?: number;
+ limit?: number;
+};
+
+export type TOrgAuthMethodUsage = {
+ isSupported: boolean;
+ totalFetches: number;
+ unknownCount: number;
+ methods: { authMethod: IdentityAuthMethod; count: number }[];
+};
+
+export type TOrgStaticSecretUsage = {
+ // Secrets created during each of the last twelve UTC calendar weeks, oldest first.
+ // totalSecrets is a per-week count, not a running total.
+ weeks: { weekStart: string; totalSecrets: number; isPartial: boolean }[];
+};
+
+export type TOrgSecretAccessVolume = {
+ isSupported: boolean;
+ days: { date: string; total: number }[];
+};
+
+export type TOrgSecretsCounts = {
+ projects: number;
+ secrets: number;
+ environments: number;
+ rotations: number;
+};
diff --git a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx
index ada74ee4b7..d39841fdfe 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx
@@ -3,9 +3,18 @@ import { Helmet } from "react-helmet";
import { BoxIcon, KeyIcon, LayersIcon, RefreshCwIcon } from "lucide-react";
import { PageHeader } from "@app/components/v2";
-import { OrgPermissionSubjects } from "@app/context";
+import { Skeleton } from "@app/components/v3";
+import { OrgPermissionSubjects, useOrganization } from "@app/context";
import { OrgPermissionSecretsManagementInsightsActions } from "@app/context/OrgPermissionContext/types";
import { withPermission } from "@app/hoc";
+import {
+ useGetOrgAuthMethodDistribution,
+ useGetOrgSecretsAccessVolume,
+ useGetOrgSecretsCounts,
+ useGetOrgSecretsProjects,
+ useGetOrgSecretsSummary,
+ useGetOrgStaticSecretsUsage
+} from "@app/hooks/api";
import { ProjectType } from "@app/hooks/api/projects/types";
import {
@@ -15,49 +24,56 @@ import {
StaticSecretPresenceCard,
SummaryCard
} from "./components";
-import {
- MOCK_ACCESS_VOLUME,
- MOCK_AUTH_METHOD_USAGE,
- MOCK_ORG_COUNTS,
- MOCK_PROJECTS_INSIGHTS,
- MOCK_SECRETS_SUMMARY,
- MOCK_STATIC_SECRET_USAGE
-} from "./mockData";
export const SecretInsightsPage = withPermission(
() => {
- // TODO: replace the mock constants with the org insights query hooks once the cards are
- // wired. isSupported comes from the endpoints and decides whether the audit-log-backed
- // cards render at all (e.g. self-hosted instances without ClickHouse).
- const summary = MOCK_SECRETS_SUMMARY;
- const projectsInsights = MOCK_PROJECTS_INSIGHTS;
- const authMethodUsage = MOCK_AUTH_METHOD_USAGE;
- const staticSecretUsage = MOCK_STATIC_SECRET_USAGE;
- const accessVolume = MOCK_ACCESS_VOLUME;
- const counts = MOCK_ORG_COUNTS;
+ const { currentOrg } = useOrganization();
+
+ const { data: summary, isPending: isSummaryPending } = useGetOrgSecretsSummary(currentOrg.id);
+ // limit 100 is the endpoint maximum; orgs with more projects need real pagination later
+ const { data: projectsInsights, isPending: isProjectsPending } = useGetOrgSecretsProjects(
+ currentOrg.id,
+ { limit: 100 }
+ );
+ const { data: authMethodUsage, isPending: isAuthMethodsPending } =
+ useGetOrgAuthMethodDistribution(currentOrg.id);
+ const { data: staticSecretUsage, isPending: isStaticSecretsPending } =
+ useGetOrgStaticSecretsUsage(currentOrg.id);
+ const { data: accessVolume, isPending: isAccessVolumePending } = useGetOrgSecretsAccessVolume(
+ currentOrg.id
+ );
+
+ const { data: counts } = useGetOrgSecretsCounts(currentOrg.id);
+
+ // isSupported decides whether the audit-log-backed cards render at all
+ // (e.g. self-hosted instances without ClickHouse). While the auth methods query is
+ // pending we keep its grid slot so the row doesn't reflow when the card appears.
+ const showAuthMethodsSlot = isAuthMethodsPending || Boolean(authMethodUsage?.isSupported);
- const headerStats: { label: string; value: number; icon: ReactNode }[] = [
- {
- label: "projects",
- value: counts.projects,
- icon: <BoxIcon className="size-3.5 text-accent" />
- },
- {
- label: "secrets",
- value: counts.secrets,
- icon: <KeyIcon className="size-3.5 text-accent" />
- },
- {
- label: "environments",
- value: counts.environments,
- icon: <LayersIcon className="size-3.5 text-accent" />
- },
- {
- label: "rotations",
- value: counts.rotations,
- icon: <RefreshCwIcon className="size-3.5 text-secret-rotation" />
- }
- ];
+ const headerStats: { label: string; value: number; icon: ReactNode }[] = counts
+ ? [
+ {
+ label: "projects",
+ value: counts.projects,
+ icon: <BoxIcon className="size-3.5 text-accent" />
+ },
+ {
+ label: "secrets",
+ value: counts.secrets,
+ icon: <KeyIcon className="size-3.5 text-accent" />
+ },
+ {
+ label: "environments",
+ value: counts.environments,
+ icon: <LayersIcon className="size-3.5 text-accent" />
+ },
+ {
+ label: "rotations",
+ value: counts.rotations,
+ icon: <RefreshCwIcon className="size-3.5 text-secret-rotation" />
+ }
+ ]
+ : [];
const renderStatStrip = (className: string) => (
<div className={`flex-wrap items-center gap-x-2 gap-y-1 text-xs text-accent ${className}`}>
@@ -94,19 +110,36 @@ export const SecretInsightsPage = withPermission(
</PageHeader>
{renderStatStrip("mb-6 flex justify-start dashboard:hidden")}
<div className="flex flex-col gap-4 pb-8">
- <SummaryCard summary={summary} />
- <NeedsAttentionCard data={projectsInsights} />
+ {isSummaryPending && (
+ <div className="grid gap-4 md:grid-cols-3">
+ <Skeleton className="h-[150px]" />
+ <Skeleton className="h-[150px]" />
+ <Skeleton className="h-[150px]" />
+ </div>
+ )}
+ {!isSummaryPending && summary && <SummaryCard summary={summary} />}
+ {isProjectsPending && <Skeleton className="h-[320px]" />}
+ {!isProjectsPending && projectsInsights && (
+ <NeedsAttentionCard data={projectsInsights} />
+ )}
<div
className={
- authMethodUsage.isSupported
- ? "grid gap-4 xl:grid-cols-[1.35fr_1fr]"
- : "grid gap-4"
+ showAuthMethodsSlot ? "grid gap-4 xl:grid-cols-[1.35fr_1fr]" : "grid gap-4"
}
>
- {authMethodUsage.isSupported && <AuthMethodsCard data={authMethodUsage} />}
- <StaticSecretPresenceCard data={staticSecretUsage} />
+ {isAuthMethodsPending && <Skeleton className="h-[320px]" />}
+ {!isAuthMethodsPending && authMethodUsage?.isSupported && (
+ <AuthMethodsCard data={authMethodUsage} />
+ )}
+ {isStaticSecretsPending && <Skeleton className="h-[320px]" />}
+ {!isStaticSecretsPending && staticSecretUsage && (
+ <StaticSecretPresenceCard data={staticSecretUsage} />
+ )}
</div>
- {accessVolume.isSupported && <SecretAccessVolumeCard data={accessVolume} />}
+ {isAccessVolumePending && <Skeleton className="h-[300px]" />}
+ {!isAccessVolumePending && accessVolume?.isSupported && (
+ <SecretAccessVolumeCard data={accessVolume} />
+ )}
</div>
</div>
</div>
diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/AuthMethodsCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/AuthMethodsCard.tsx
index 596e0a1ff6..b5ca896b99 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/components/AuthMethodsCard.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/components/AuthMethodsCard.tsx
@@ -16,9 +16,8 @@ import {
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
-import { IdentityAuthMethod, identityAuthToNameMap } from "@app/hooks/api";
+import { IdentityAuthMethod, identityAuthToNameMap, TOrgAuthMethodUsage } from "@app/hooks/api";
-import { TAuthMethodUsage } from "../types";
import { CHART_COLORS, UNKNOWN_SERIES_COLOR } from "./chartColors";
type Segment = {
@@ -37,7 +36,7 @@ const humanizeAuthMethod = (authMethod: string) =>
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(" ");
-export const AuthMethodsCard = ({ data }: { data: TAuthMethodUsage }) => {
+export const AuthMethodsCard = ({ data }: { data: TOrgAuthMethodUsage }) => {
const segments = useMemo<Segment[]>(() => {
if (data.totalFetches === 0) return [];
diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx
index d1c2ac5df1..7da1bf0457 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/components/NeedsAttentionCard.tsx
@@ -33,8 +33,7 @@ import {
TBadgeProps
} from "@app/components/v3";
import { useOrganization } from "@app/context";
-
-import { TProjectInsightWarnings, TProjectsInsights } from "../types";
+import { TOrgProjectInsightWarnings, TOrgProjectsInsights } from "@app/hooks/api";
const COLLAPSED_ROW_COUNT = 4;
@@ -45,7 +44,7 @@ const pluralize = (count: number, noun: string, plural = `${noun}s`) =>
`${count.toLocaleString()} ${count === 1 ? noun : plural}`;
const WARNING_CHIPS: {
- key: keyof TProjectInsightWarnings;
+ key: keyof TOrgProjectInsightWarnings;
variant: TBadgeProps["variant"];
label: (count: number) => string;
}[] = [
@@ -56,7 +55,7 @@ const WARNING_CHIPS: {
{ key: "duplicatedSecrets", variant: "neutral", label: (c) => `${c.toLocaleString()} duplicated` }
];
-const WarningBadges = ({ warnings }: { warnings: TProjectInsightWarnings }) => (
+const WarningBadges = ({ warnings }: { warnings: TOrgProjectInsightWarnings }) => (
<div className="flex flex-wrap gap-1">
{WARNING_CHIPS.map(({ key, variant, label }) => {
const count = warnings[key];
@@ -71,10 +70,10 @@ const WarningBadges = ({ warnings }: { warnings: TProjectInsightWarnings }) => (
</div>
);
-const hasIssues = (warnings: TProjectInsightWarnings) =>
+const hasIssues = (warnings: TOrgProjectInsightWarnings) =>
WARNING_CHIPS.some(({ key }) => (warnings[key] ?? 0) > 0);
-export const NeedsAttentionCard = ({ data }: { data: TProjectsInsights }) => {
+export const NeedsAttentionCard = ({ data }: { data: TOrgProjectsInsights }) => {
const navigate = useNavigate();
const { currentOrg } = useOrganization();
const [search, setSearch] = useState("");
diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/SecretAccessVolumeCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/SecretAccessVolumeCard.tsx
index 303a194279..aca29e44a8 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/components/SecretAccessVolumeCard.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/components/SecretAccessVolumeCard.tsx
@@ -11,11 +11,10 @@ import {
EmptyHeader,
EmptyTitle
} from "@app/components/v3";
+import { TOrgSecretAccessVolume } from "@app/hooks/api";
import { LineChart } from "@app/pages/secret-manager/InsightsPage/components/LineChart";
-import { TSecretAccessVolume } from "../types";
-
-export const SecretAccessVolumeCard = ({ data }: { data: TSecretAccessVolume }) => {
+export const SecretAccessVolumeCard = ({ data }: { data: TOrgSecretAccessVolume }) => {
const chartData = useMemo(
() =>
data.days.map((day) => ({
diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/StaticSecretPresenceCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/StaticSecretPresenceCard.tsx
index 1cfc49ccad..2c2eeb2a04 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/components/StaticSecretPresenceCard.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/components/StaticSecretPresenceCard.tsx
@@ -25,8 +25,7 @@ import {
EmptyTitle,
TBadgeProps
} from "@app/components/v3";
-
-import { TStaticSecretUsage } from "../types";
+import { TOrgStaticSecretUsage } from "@app/hooks/api";
const BAR_GRADIENT_ID = "org-static-secrets-bar";
@@ -39,7 +38,7 @@ type WeekPoint = {
isPartial: boolean;
};
-const getCreationTrend = (weeks: TStaticSecretUsage["weeks"]): TrendBadge | null => {
+const getCreationTrend = (weeks: TOrgStaticSecretUsage["weeks"]): TrendBadge | null => {
if (weeks.length < 3) return null;
const [a, b, c] = weeks.slice(-3).map((week) => week.totalSecrets);
if (a < b && b < c) return { label: "Increasing", variant: "warning" };
@@ -67,7 +66,7 @@ const ChartTooltip = ({
);
};
-export const StaticSecretPresenceCard = ({ data }: { data: TStaticSecretUsage }) => {
+export const StaticSecretPresenceCard = ({ data }: { data: TOrgStaticSecretUsage }) => {
const weeks = useMemo<WeekPoint[]>(
() =>
data.weeks.map((week) => ({
diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/SummaryCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/SummaryCard.tsx
index 97419b686a..7b7f9166f4 100644
--- a/frontend/src/pages/organization/SecretInsightsPage/components/SummaryCard.tsx
+++ b/frontend/src/pages/organization/SecretInsightsPage/components/SummaryCard.tsx
@@ -2,8 +2,7 @@ import { BotIcon, ClockIcon, UsersIcon } from "lucide-react";
import { Card, CardAction, CardContent, CardHeader, CardTitle } from "@app/components/v3";
import { cn } from "@app/components/v3/utils";
-
-import { TSecretsSummary } from "../types";
+import { TOrgSecretsSummary } from "@app/hooks/api";
type StatCardProps = {
title: string;
@@ -41,7 +40,7 @@ const StatCard = ({ title, icon, iconVariant, value, suffix, caption }: StatCard
</Card>
);
-export const SummaryCard = ({ summary }: { summary: TSecretsSummary }) => (
+export const SummaryCard = ({ summary }: { summary: TOrgSecretsSummary }) => (
<div className="grid gap-4 md:grid-cols-3">
<StatCard
title="Dynamic Secrets in Use"
diff --git a/frontend/src/pages/organization/SecretInsightsPage/mockData.ts b/frontend/src/pages/organization/SecretInsightsPage/mockData.ts
deleted file mode 100644
index 7fd4ab197f..0000000000
--- a/frontend/src/pages/organization/SecretInsightsPage/mockData.ts
+++ /dev/null
@@ -1,202 +0,0 @@
-import { IdentityAuthMethod } from "@app/hooks/api";
-
-import {
- TAuthMethodUsage,
- TOrgCounts,
- TProjectsInsights,
- TSecretAccessVolume,
- TSecretsSummary,
- TStaticSecretUsage
-} from "./types";
-
-// Placeholder data until the cards are wired to the org insights endpoints.
-
-export const MOCK_ORG_COUNTS: TOrgCounts = {
- projects: 35,
- secrets: 1284,
- environments: 96,
- rotations: 57
-};
-
-export const MOCK_SECRETS_SUMMARY: TSecretsSummary = {
- activeLeases: 342,
- users: 128,
- identities: 416
-};
-
-export const MOCK_PROJECTS_INSIGHTS: TProjectsInsights = {
- totalProjects: 35,
- projectsWithIssues: 9,
- projects: [
- {
- projectId: "00000000-0000-0000-0000-000000000001",
- projectName: "payments-api",
- projectSlug: "payments-api",
- totalSecrets: 86,
- severityScore: 96,
- warnings: {
- duplicatedSecrets: 4,
- staleSecrets: 23,
- failedRotations: 2,
- failedSyncs: 1,
- orphanedLeases: 3
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000002",
- projectName: "auth-service",
- projectSlug: "auth-service",
- totalSecrets: 112,
- severityScore: 74,
- warnings: {
- duplicatedSecrets: 6,
- staleSecrets: 18,
- failedRotations: 0,
- failedSyncs: 3,
- orphanedLeases: 0
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000003",
- projectName: "data-pipeline",
- projectSlug: "data-pipeline",
- totalSecrets: 64,
- severityScore: 68,
- warnings: {
- duplicatedSecrets: null,
- staleSecrets: 12,
- failedRotations: 1,
- failedSyncs: 0,
- orphanedLeases: 7
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000004",
- projectName: "infra-core",
- projectSlug: "infra-core",
- totalSecrets: 203,
- severityScore: 55,
- warnings: {
- duplicatedSecrets: 9,
- staleSecrets: 6,
- failedRotations: 0,
- failedSyncs: 2,
- orphanedLeases: 0
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000005",
- projectName: "billing-service",
- projectSlug: "billing-service",
- totalSecrets: 57,
- severityScore: 44,
- warnings: {
- duplicatedSecrets: 0,
- staleSecrets: 31,
- failedRotations: 0,
- failedSyncs: 0,
- orphanedLeases: 0
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000006",
- projectName: "ml-inference",
- projectSlug: "ml-inference",
- totalSecrets: 71,
- severityScore: 32,
- warnings: {
- duplicatedSecrets: 0,
- staleSecrets: 8,
- failedRotations: 0,
- failedSyncs: 1,
- orphanedLeases: 0
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000007",
- projectName: "staging-sandbox",
- projectSlug: "staging-sandbox",
- totalSecrets: 132,
- severityScore: 27,
- warnings: {
- duplicatedSecrets: 0,
- staleSecrets: 17,
- failedRotations: 0,
- failedSyncs: 0,
- orphanedLeases: 0
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000008",
- projectName: "web-frontend",
- projectSlug: "web-frontend",
- totalSecrets: 44,
- severityScore: 21,
- warnings: {
- duplicatedSecrets: 3,
- staleSecrets: 14,
- failedRotations: 0,
- failedSyncs: 0,
- orphanedLeases: 0
- }
- },
- {
- projectId: "00000000-0000-0000-0000-000000000009",
- projectName: "edge-gateway",
- projectSlug: "edge-gateway",
- totalSecrets: 92,
- severityScore: 12,
- warnings: {
- duplicatedSecrets: 12,
- staleSecrets: 0,
- failedRotations: 0,
- failedSyncs: 0,
- orphanedLeases: 1
- }
- }
- ]
-};
-
-export const MOCK_AUTH_METHOD_USAGE: TAuthMethodUsage = {
- isSupported: true,
- totalFetches: 48470,
- unknownCount: 1150,
- methods: [
- { authMethod: IdentityAuthMethod.UNIVERSAL_AUTH, count: 19400 },
- { authMethod: IdentityAuthMethod.KUBERNETES_AUTH, count: 10400 },
- { authMethod: IdentityAuthMethod.AWS_AUTH, count: 6630 },
- { authMethod: IdentityAuthMethod.OIDC_AUTH, count: 4260 },
- { authMethod: IdentityAuthMethod.GCP_AUTH, count: 3790 },
- { authMethod: IdentityAuthMethod.TOKEN_AUTH, count: 2840 }
- ]
-};
-
-export const MOCK_STATIC_SECRET_USAGE: TStaticSecretUsage = {
- weeks: [
- { weekStart: "2026-05-18", totalSecrets: 24, isPartial: false },
- { weekStart: "2026-05-25", totalSecrets: 31, isPartial: false },
- { weekStart: "2026-06-01", totalSecrets: 18, isPartial: false },
- { weekStart: "2026-06-08", totalSecrets: 42, isPartial: false },
- { weekStart: "2026-06-15", totalSecrets: 37, isPartial: false },
- { weekStart: "2026-06-22", totalSecrets: 29, isPartial: false },
- { weekStart: "2026-06-29", totalSecrets: 46, isPartial: false },
- { weekStart: "2026-07-06", totalSecrets: 51, isPartial: false },
- { weekStart: "2026-07-13", totalSecrets: 34, isPartial: false },
- { weekStart: "2026-07-20", totalSecrets: 58, isPartial: false },
- { weekStart: "2026-07-27", totalSecrets: 63, isPartial: false },
- { weekStart: "2026-08-03", totalSecrets: 21, isPartial: true }
- ]
-};
-
-export const MOCK_ACCESS_VOLUME: TSecretAccessVolume = {
- isSupported: true,
- days: [
- { date: "2026-07-31", total: 2380 },
- { date: "2026-08-01", total: 1420 },
- { date: "2026-08-02", total: 1180 },
- { date: "2026-08-03", total: 3620 },
- { date: "2026-08-04", total: 3300 },
- { date: "2026-08-05", total: 4213 },
- { date: "2026-08-06", total: 3980 }
- ]
-};
diff --git a/frontend/src/pages/organization/SecretInsightsPage/types.ts b/frontend/src/pages/organization/SecretInsightsPage/types.ts
deleted file mode 100644
index de322a1a7a..0000000000
--- a/frontend/src/pages/organization/SecretInsightsPage/types.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { IdentityAuthMethod } from "@app/hooks/api";
-
-// These types mirror the org insights endpoint schemas in
-// backend/src/ee/services/insights/insights-schemas.ts. The cards are not wired to the
-// backend yet; keeping the shapes identical means wiring later is only a data-source swap.
-
-// Header stat strip counts. No org endpoint returns these yet — flag to backend when wiring.
-export type TOrgCounts = {
- projects: number;
- secrets: number;
- environments: number;
- rotations: number;
-};
-
-export type TSecretsSummary = {
- activeLeases: number;
- users: number;
- identities: number;
-};
-
-export type TProjectInsightWarnings = {
- // null means unknown (e.g. secret blind index disabled), which is different from zero
- duplicatedSecrets: number | null;
- staleSecrets: number;
- failedRotations: number;
- failedSyncs: number;
- orphanedLeases: number;
-};
-
-export type TProjectInsight = {
- projectId: string;
- projectName: string;
- projectSlug: string;
- totalSecrets: number;
- severityScore: number;
- warnings: TProjectInsightWarnings;
-};
-
-export type TProjectsInsights = {
- projects: TProjectInsight[];
- totalProjects: number;
- projectsWithIssues: number;
-};
-
-export type TAuthMethodUsage = {
- isSupported: boolean;
- totalFetches: number;
- unknownCount: number;
- methods: { authMethod: IdentityAuthMethod; count: number }[];
-};
-
-export type TStaticSecretUsage = {
- // Secrets created during each of the last twelve UTC calendar weeks, oldest first.
- // totalSecrets is a per-week count, not a running total.
- weeks: { weekStart: string; totalSecrets: number; isPartial: boolean }[];
-};
-
-export type TSecretAccessVolume = {
- isSupported: boolean;
- days: { date: string; total: number }[];
-};