Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
improvement(insights): show a blurred preview when Insights is not on the plan (#8703)
Andrew Huanga92ebb145cbf
diff --git a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsxindex 1b3c716d54..4526d9c008 100644--- a/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx+++ b/frontend/src/pages/organization/SecretInsightsPage/SecretInsightsPage.tsx@@ -1,8 +1,7 @@-import { useCallback, useEffect, useMemo } from "react";+import { useCallback, useMemo } from "react";import { Helmet } from "react-helmet";-import { Link } from "@tanstack/react-router";import { format } from "date-fns";-import { FileTextIcon, LockIcon } from "lucide-react";+import { FileTextIcon } from "lucide-react";import {SecretAccessInsightsUpgradeIntent,@@ -10,9 +9,6 @@ import {} from "@app/components/license/UpgradeGate";import { OrgPermissionCan } from "@app/components/permissions";import {- Alert,- AlertDescription,- AlertTitle,Button,Skeleton,Tooltip,@@ -32,11 +28,6 @@ import { withPermission } from "@app/hoc";import { usePopUp } from "@app/hooks";import {AuditReportStatus,- TOrgAuthMethodUsage,- TOrgProjectsInsights,- TOrgSecretAccessVolume,- TOrgSecretsSummary,- TOrgStaticSecretUsage,useGetOrgAuditReports,useGetOrgAuthMethodDistribution,useGetOrgSecretsAccessVolume,@@ -50,6 +41,7 @@ import {AuthMethodsCard,DuplicatedSecretsCard,InsightsCard,+ InsightsUpgradePreview,RequestOrgAuditReportModal,SecretAccessVolumeCard,StaticSecretPresenceCard,@@ -59,21 +51,6 @@ import {const SENT_REPORT_STATUSES = [AuditReportStatus.Completed, AuditReportStatus.Partial];const IN_FLIGHT_REPORT_STATUSES = [AuditReportStatus.Pending, AuditReportStatus.Processing];-// Every insights endpoint is gated on the same entitlement, so without it there is nothing to-// fetch. The cards render from these zeroed payloads and fall back to their own empty states, so-// the page keeps its shape behind the upgrade prompt instead of collapsing to a blank screen.-const PLAN_LOCKED_SUMMARY: TOrgSecretsSummary = { activeLeases: 0, users: 0, identities: 0 };-const PLAN_LOCKED_PROJECTS: TOrgProjectsInsights = {- projects: [],- totalProjects: 0,- projectsWithIssues: 0,- offset: 0,- limit: 0-};-const PLAN_LOCKED_AUTH_METHODS: TOrgAuthMethodUsage = { totalFetches: 0, methods: [] };-const PLAN_LOCKED_STATIC_SECRETS: TOrgStaticSecretUsage = { weeks: [] };-const PLAN_LOCKED_ACCESS_VOLUME: TOrgSecretAccessVolume = { days: [] };-export const SecretInsightsPage = withPermission(() => {const { currentOrg } = useOrganization();@@ -146,26 +123,14 @@ export const SecretInsightsPage = withPermission(});}, [openUpgradeGate]);- useEffect(() => {- if (subscription && !subscription.secretAccessInsights) {- handleUpgrade();- }- }, [handleUpgrade, subscription]);-const isSummaryLoading = hasInsightsPlan && isSummaryPending;const isProjectsLoading = hasInsightsPlan && isProjectsPending;const isStaticSecretsLoading = hasInsightsPlan && isStaticSecretsPending;const isAuthMethodsLoading = isClickhouseEnabled && hasInsightsPlan && isAuthMethodsPending;const isAccessVolumeLoading = isClickhouseEnabled && hasInsightsPlan && isAccessVolumePending;- const summaryData = hasInsightsPlan ? summary : PLAN_LOCKED_SUMMARY;- const projectsData = hasInsightsPlan ? projectsInsights : PLAN_LOCKED_PROJECTS;- const staticSecretData = hasInsightsPlan ? staticSecretUsage : PLAN_LOCKED_STATIC_SECRETS;- const authMethodData = hasInsightsPlan ? authMethodUsage : PLAN_LOCKED_AUTH_METHODS;- const accessVolumeData = hasInsightsPlan ? accessVolume : PLAN_LOCKED_ACCESS_VOLUME;-const showAuthMethodsSlot =- isAuthMethodsLoading || (isClickhouseEnabled && Boolean(authMethodData));+ isAuthMethodsLoading || (isClickhouseEnabled && Boolean(authMethodUsage));return (<>@@ -226,65 +191,48 @@ export const SecretInsightsPage = withPermission(</OrgPermissionCan></div></PageHeader>- <div className="flex flex-col gap-4 pb-8">- {!hasInsightsPlan && (- <Alert variant="info">- <LockIcon />- <AlertTitle>Insights Is Not Included in Your Current Plan</AlertTitle>- <AlertDescription>- <p>- Secret health, access volume, and authentication data stay empty until you- upgrade. Go to{" "}- <Link- to="/organizations/$orgId/billing"- params={{ orgId: currentOrg.id }}- className="inline underline hover:opacity-80"- >- Billing- </Link>{" "}- to change your plan.- </p>- </AlertDescription>- </Alert>- )}- {isSummaryLoading && (- <div className="grid gap-4 md:grid-cols-3">- <Skeleton className="h-[150px]" />- <Skeleton className="h-[150px]" />- <Skeleton className="h-[150px]" />- </div>- )}- {!isSummaryLoading && summaryData && <SummaryCard summary={summaryData} />}- {isProjectsLoading && <Skeleton className="h-[320px]" />}- {!isProjectsLoading && projectsData && (- <InsightsCard- data={projectsData}- hasMore={hasMoreProjects}- onLoadMore={fetchMoreProjects}- isLoadingMore={isFetchingMoreProjects}- isPlanRestricted={!hasInsightsPlan}- />- )}- <DuplicatedSecretsCard isPlanRestricted={!hasInsightsPlan} />- <div- className={- showAuthMethodsSlot ? "grid gap-4 xl:grid-cols-[1fr_1.35fr]" : "grid gap-4"- }- >- {isAuthMethodsLoading && <Skeleton className="h-[320px]" />}- {!isAuthMethodsLoading && isClickhouseEnabled && authMethodData && (- <AuthMethodsCard data={authMethodData} />+ {hasInsightsPlan ? (+ <div className="flex flex-col gap-4 pb-8">+ {isSummaryLoading && (+ <div className="grid gap-4 md:grid-cols-3">+ <Skeleton className="h-[150px]" />+ <Skeleton className="h-[150px]" />+ <Skeleton className="h-[150px]" />+ </div>+ )}+ {!isSummaryLoading && summary && <SummaryCard summary={summary} />}+ {isProjectsLoading && <Skeleton className="h-[320px]" />}+ {!isProjectsLoading && projectsInsights && (+ <InsightsCard+ data={projectsInsights}+ hasMore={hasMoreProjects}+ onLoadMore={fetchMoreProjects}+ isLoadingMore={isFetchingMoreProjects}+ />)}- {isStaticSecretsLoading && <Skeleton className="h-[320px]" />}- {!isStaticSecretsLoading && staticSecretData && (- <StaticSecretPresenceCard data={staticSecretData} />+ <DuplicatedSecretsCard />+ <div+ className={+ showAuthMethodsSlot ? "grid gap-4 xl:grid-cols-[1fr_1.35fr]" : "grid gap-4"+ }+ >+ {isAuthMethodsLoading && <Skeleton className="h-[320px]" />}+ {!isAuthMethodsLoading && isClickhouseEnabled && authMethodUsage && (+ <AuthMethodsCard data={authMethodUsage} />+ )}+ {isStaticSecretsLoading && <Skeleton className="h-[320px]" />}+ {!isStaticSecretsLoading && staticSecretUsage && (+ <StaticSecretPresenceCard data={staticSecretUsage} />+ )}+ </div>+ {isAccessVolumeLoading && <Skeleton className="h-[300px]" />}+ {!isAccessVolumeLoading && isClickhouseEnabled && accessVolume && (+ <SecretAccessVolumeCard data={accessVolume} />)}</div>- {isAccessVolumeLoading && <Skeleton className="h-[300px]" />}- {!isAccessVolumeLoading && isClickhouseEnabled && accessVolumeData && (- <SecretAccessVolumeCard data={accessVolumeData} />- )}- </div>+ ) : (+ <InsightsUpgradePreview onUpgrade={handleUpgrade} />+ )}</div></div><RequestOrgAuditReportModaldiff --git a/frontend/src/pages/organization/SecretInsightsPage/components/DuplicatedSecretsCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/DuplicatedSecretsCard.tsxindex 75b54b07d0..ff4453cba1 100644--- a/frontend/src/pages/organization/SecretInsightsPage/components/DuplicatedSecretsCard.tsx+++ b/frontend/src/pages/organization/SecretInsightsPage/components/DuplicatedSecretsCard.tsx@@ -24,11 +24,7 @@ import { useGetOrgSecretsDuplication } from "@app/hooks/api/secretInsights";import { DuplicateGroupList } from "./DuplicateGroupList";-type Props = {- isPlanRestricted: boolean;-};--export const DuplicatedSecretsCard = ({ isPlanRestricted }: Props) => {+export const DuplicatedSecretsCard = () => {const { currentOrg } = useOrganization();const orgId = currentOrg.id;const { permission } = useOrgPermission();@@ -37,31 +33,14 @@ export const DuplicatedSecretsCard = ({ isPlanRestricted }: Props) => {OrgPermissionSecretsManagementInsightsActions.SearchAllSecretValues,OrgPermissionSubjects.SecretsManagementInsights);- const canQuery = canSearchAllValues && !isPlanRestricted;- const tracking = useOrgSecretValueTracking({ orgId, enabled: canQuery });+ const tracking = useOrgSecretValueTracking({ orgId, enabled: canSearchAllValues });const { data, isPending, isError } = useGetOrgSecretsDuplication(orgId, {- enabled: canQuery && tracking.isTrackingOn+ enabled: canSearchAllValues && tracking.isTrackingOn});const renderBody = () => {- if (isPlanRestricted) {- return (- <Empty className="border">- <EmptyHeader>- <EmptyMedia variant="icon">- <LockIcon />- </EmptyMedia>- <EmptyTitle>Duplicate detection is not on your current plan</EmptyTitle>- <EmptyDescription>- Upgrade to locate secrets that share a value across every project in the organization.- </EmptyDescription>- </EmptyHeader>- </Empty>- );- }-if (!canSearchAllValues) {return (<Empty className="border">@@ -119,7 +98,7 @@ export const DuplicatedSecretsCard = ({ isPlanRestricted }: Props) => {};const remainingMinutes =- canQuery && data?.remainingTtl != null && data.remainingTtl >= 0+ canSearchAllValues && data?.remainingTtl != null && data.remainingTtl >= 0? Math.max(1, Math.ceil(data.remainingTtl / 60)): null;diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/InsightsCard.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/InsightsCard.tsxindex dfa23d2146..48ee78e193 100644--- a/frontend/src/pages/organization/SecretInsightsPage/components/InsightsCard.tsx+++ b/frontend/src/pages/organization/SecretInsightsPage/components/InsightsCard.tsx@@ -6,7 +6,6 @@ import {ChevronRightIcon,ChevronUpIcon,FolderIcon,- LockIcon,SearchIcon,SearchXIcon} from "lucide-react";@@ -93,16 +92,12 @@ export const InsightsCard = ({data,hasMore,onLoadMore,- isLoadingMore,- isPlanRestricted = false+ isLoadingMore}: {data: TOrgProjectsInsights;hasMore: boolean;onLoadMore: () => void;isLoadingMore: boolean;- // Without the insights entitlement the row set is empty because nothing was fetched, so the card- // must not report the org as healthy- isPlanRestricted?: boolean;}) => {const navigate = useNavigate();const { currentOrg } = useOrganization();@@ -142,7 +137,6 @@ export const InsightsCard = ({const visible = showAll || isSearching ? filtered : filtered.slice(0, COLLAPSED_ROW_COUNT);const getDescription = () => {- if (isPlanRestricted) return "Upgrade your plan to see project-level issues.";if (isHealthy) return "No projects have outstanding issues right now.";return `${data.projectsWithIssues} of ${data.totalProjects} projects have outstanding issues, ordered by severity.`;};@@ -156,15 +150,6 @@ export const InsightsCard = ({};}- if (isPlanRestricted) {- return {- icon: <LockIcon />,- title: "Project insights are not on your current plan",- description:- "Upgrade to see failed rotations, failed syncs, stale secrets, and duplicated secrets for every project."- };- }-if (data.totalProjects === 0) {return {icon: <FolderIcon />,diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/InsightsUpgradePreview.tsx b/frontend/src/pages/organization/SecretInsightsPage/components/InsightsUpgradePreview.tsxnew file mode 100644index 0000000000..fdfff05221--- /dev/null+++ b/frontend/src/pages/organization/SecretInsightsPage/components/InsightsUpgradePreview.tsx@@ -0,0 +1,171 @@+import { useEffect, useId } from "react";+import { LockIcon } from "lucide-react";++import {+ Button,+ Empty,+ EmptyContent,+ EmptyDescription,+ EmptyHeader,+ EmptyMedia,+ EmptyTitle+} from "@app/components/v3";+import { IdentityAuthMethod } from "@app/hooks/api/identities/enums";+import {+ TOrgAuthMethodUsage,+ TOrgProjectsInsights,+ TOrgSecretAccessVolume,+ TOrgSecretsSummary,+ TOrgStaticSecretUsage+} from "@app/hooks/api/secretInsights/types";++import { AuthMethodsCard } from "./AuthMethodsCard";+import { InsightsCard } from "./InsightsCard";+import { SecretAccessVolumeCard } from "./SecretAccessVolumeCard";+import { StaticSecretPresenceCard } from "./StaticSecretPresenceCard";+import { SummaryCard } from "./SummaryCard";++const DAY_MS = 24 * 60 * 60 * 1000;++const SAMPLE_SUMMARY: TOrgSecretsSummary = { activeLeases: 42, users: 128, identities: 57 };++const sampleProject = (+ index: number,+ projectName: string,+ severityScore: number,+ warnings: Partial<TOrgProjectsInsights["projects"][number]["warnings"]>+) => ({+ projectId: `sample-project-${index}`,+ projectName,+ projectSlug: projectName.toLowerCase().replace(/\s+/g, "-"),+ totalSecrets: 120 + index * 37,+ severityScore,+ warnings: {+ duplicatedSecrets: 0,+ staleSecrets: 0,+ failedRotations: 0,+ failedSyncs: 0,+ orphanedLeases: 0,+ ...warnings+ }+});++const SAMPLE_PROJECTS: TOrgProjectsInsights = {+ projects: [+ sampleProject(1, "Payments API", 9, { failedRotations: 2, staleSecrets: 14 }),+ sampleProject(2, "Checkout Web", 7, { failedSyncs: 3, duplicatedSecrets: 6 }),+ sampleProject(3, "Data Pipeline", 5, { staleSecrets: 21 }),+ sampleProject(4, "Mobile Backend", 3, { duplicatedSecrets: 4, orphanedLeases: 1 }),+ sampleProject(5, "Internal Tools", 2, { staleSecrets: 5 })+ ],+ totalProjects: 18,+ projectsWithIssues: 5,+ offset: 0,+ limit: 100+};++const SAMPLE_AUTH_METHODS: TOrgAuthMethodUsage = {+ totalFetches: 48210,+ methods: [+ { authMethod: IdentityAuthMethod.UNIVERSAL_AUTH, count: 21450 },+ { authMethod: IdentityAuthMethod.KUBERNETES_AUTH, count: 14320 },+ { authMethod: IdentityAuthMethod.AWS_AUTH, count: 8240 },+ { authMethod: IdentityAuthMethod.OIDC_AUTH, count: 4200 }+ ]+};++const SAMPLE_WEEKLY_SECRETS = [34, 41, 28, 52, 47, 63, 38, 55, 71, 49, 66, 24];+const SAMPLE_DAILY_READS = [3120, 3480, 2910, 4020, 4410, 2380, 2150];++const buildSampleData = () => {+ const now = Date.now();+ const staticSecretUsage: TOrgStaticSecretUsage = {+ weeks: SAMPLE_WEEKLY_SECRETS.map((totalSecrets, index) => ({+ weekStart: new Date(now - (SAMPLE_WEEKLY_SECRETS.length - 1 - index) * 7 * DAY_MS)+ .toISOString()+ .slice(0, 10),+ totalSecrets,+ isPartial: index === SAMPLE_WEEKLY_SECRETS.length - 1+ }))+ };+ const accessVolume: TOrgSecretAccessVolume = {+ days: SAMPLE_DAILY_READS.map((total, index) => ({+ date: new Date(now - (SAMPLE_DAILY_READS.length - 1 - index) * DAY_MS)+ .toISOString()+ .slice(0, 10),+ total+ }))+ };+ return { staticSecretUsage, accessVolume };+};++// React 18 does not type the inert attribute yet.+const INERT_PROPS: { inert?: "" } = { inert: "" };++type Props = {+ onUpgrade: () => void;+};++// Shown in place of Insights when the plan lacks the entitlement. The backdrop is the real+// Insights cards fed sample data, blurred and made inert, so the viewer sees what they would get+// without any request being made against the gated endpoints.+export const InsightsUpgradePreview = ({ onUpgrade }: Props) => {+ const titleId = useId();+ const { staticSecretUsage, accessVolume } = buildSampleData();++ // The upgrade gate refreshes the cached subscription when it mounts on a billing return, so open+ // it automatically then; otherwise the page would keep showing this preview after an upgrade.+ useEffect(() => {+ const search = new URLSearchParams(window.location.search);+ if (search.get("checkout") === "success" || search.get("card") === "setup_success") {+ onUpgrade();+ }+ }, [onUpgrade]);++ return (+ <div className="grid w-full pb-8">+ <div+ aria-hidden+ {...INERT_PROPS}+ className="pointer-events-none col-start-1 row-start-1 flex flex-col gap-4 [mask-image:linear-gradient(to_bottom,black_55%,transparent_100%)] blur-[3px] select-none"+ >+ <SummaryCard summary={SAMPLE_SUMMARY} />+ <InsightsCard+ data={SAMPLE_PROJECTS}+ hasMore={false}+ onLoadMore={() => {}}+ isLoadingMore={false}+ />+ <div className="grid gap-4 xl:grid-cols-[1fr_1.35fr]">+ <AuthMethodsCard data={SAMPLE_AUTH_METHODS} />+ <StaticSecretPresenceCard data={staticSecretUsage} />+ </div>+ <SecretAccessVolumeCard data={accessVolume} />+ </div>+ <div className="relative col-start-1 row-start-1 flex items-start justify-center p-4 pt-40">+ <section+ aria-labelledby={titleId}+ className="w-full max-w-lg animate-in rounded-lg border border-border bg-popover p-8 shadow-lg duration-200 fade-in-0 zoom-in-95"+ >+ <Empty variant="unstyled">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <LockIcon />+ </EmptyMedia>+ <EmptyTitle id={titleId}>Insights Is Not Included in Your Current Plan</EmptyTitle>+ <EmptyDescription>+ Upgrade to see secret health, access volume, and authentication trends across your+ projects.+ </EmptyDescription>+ </EmptyHeader>+ <EmptyContent>+ <Button variant="project" onClick={onUpgrade}>+ Upgrade Plan+ </Button>+ </EmptyContent>+ </Empty>+ </section>+ </div>+ </div>+ );+};diff --git a/frontend/src/pages/organization/SecretInsightsPage/components/index.ts b/frontend/src/pages/organization/SecretInsightsPage/components/index.tsindex 4df415cd8a..95b9a3b37f 100644--- a/frontend/src/pages/organization/SecretInsightsPage/components/index.ts+++ b/frontend/src/pages/organization/SecretInsightsPage/components/index.ts@@ -1,6 +1,7 @@export { AuthMethodsCard } from "./AuthMethodsCard";export { DuplicatedSecretsCard } from "./DuplicatedSecretsCard";export { InsightsCard } from "./InsightsCard";+export { InsightsUpgradePreview } from "./InsightsUpgradePreview";export { RequestOrgAuditReportModal } from "./RequestOrgAuditReportModal";export { SecretAccessVolumeCard } from "./SecretAccessVolumeCard";export { StaticSecretPresenceCard } from "./StaticSecretPresenceCard";diff --git a/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsx b/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsxindex 1c70245edd..e5236550d1 100644--- a/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsx+++ b/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsx@@ -1,4 +1,4 @@-import { Fragment, ReactNode, useEffect } from "react";+import { Fragment, ReactNode, useCallback } from "react";import { Helmet } from "react-helmet";import {FingerprintIcon,@@ -25,6 +25,7 @@ import { ProjectPermissionHoneyTokenActions } from "@app/context/ProjectPermissiimport { withProjectPermission } from "@app/hoc";import { ProjectType } from "@app/hooks/api/projects/types";import { useGetInsightsCounts } from "@app/hooks/api/secretInsights/queries";+import { InsightsUpgradePreview } from "@app/pages/organization/SecretInsightsPage/components";import {AuditReportsCard,@@ -42,19 +43,16 @@ export const InsightsPage = withProjectPermission(const { permission } = useProjectPermission();const { openUpgradeGate, upgradeGate } = useUpgradeGate();- const { data: counts } = useGetInsightsCounts(- { projectId },- { enabled: Boolean(subscription?.secretAccessInsights) }- );+ const hasInsightsPlan = Boolean(subscription?.secretAccessInsights);++ const { data: counts } = useGetInsightsCounts({ projectId }, { enabled: hasInsightsPlan });- useEffect(() => {- if (subscription && !subscription.secretAccessInsights) {- openUpgradeGate({- intent: SecretAccessInsightsUpgradeIntent,- paywallKey: "secret-manager.insights"- });- }- }, [openUpgradeGate, subscription]);+ const handleUpgrade = useCallback(() => {+ openUpgradeGate({+ intent: SecretAccessInsightsUpgradeIntent,+ paywallKey: "secret-manager.insights"+ });+ }, [openUpgradeGate]);const canReadHoneyTokens = permission.can(ProjectPermissionHoneyTokenActions.Read,@@ -131,20 +129,26 @@ export const InsightsPage = withProjectPermission({headerStats.length > 0 && renderStatStrip("hidden justify-end dashboard:flex")}</PageHeader>{headerStats.length > 0 && renderStatStrip("mb-6 flex justify-start dashboard:hidden")}- <InsightsSummaryCards />- <div className="mt-6">- <AuditReportsCard />- </div>- <div className="mt-6 grid items-start gap-6 xl:grid-cols-[1.3fr_1fr]">- <div className="flex flex-col gap-6">- <DuplicatedSecretsCard />- <CalendarCard />- </div>- <div className="flex flex-col gap-6">- <SecretAccessChart />- <AuthMethodChart />- </div>- </div>+ {hasInsightsPlan ? (+ <>+ <InsightsSummaryCards />+ <div className="mt-6">+ <AuditReportsCard />+ </div>+ <div className="mt-6 grid items-start gap-6 xl:grid-cols-[1.3fr_1fr]">+ <div className="flex flex-col gap-6">+ <DuplicatedSecretsCard />+ <CalendarCard />+ </div>+ <div className="flex flex-col gap-6">+ <SecretAccessChart />+ <AuthMethodChart />+ </div>+ </div>+ </>+ ) : (+ <InsightsUpgradePreview onUpgrade={handleUpgrade} />+ )}{upgradeGate}</>);