feat: Add security center and warning for exceeding bounce/complaint rates

This commit is contained in:
Dries Augustyns
2025-12-11 18:34:30 +01:00
parent 0ecd82d62e
commit fbd303801f
9 changed files with 475 additions and 27 deletions
@@ -0,0 +1,28 @@
import useSWR from 'swr';
import type {ProjectSecurityMetrics} from '@plunk/types';
export interface ProjectSecurityResponse {
success: boolean;
data: ProjectSecurityMetrics;
}
/**
* Hook to fetch project security metrics
* Auto-refreshes every 2 minutes to keep data current
*/
export function useProjectSecurity(projectId: string | undefined) {
const {data, error, isLoading, mutate} = useSWR<ProjectSecurityResponse>(
projectId ? `/projects/${projectId}/security` : null,
{
refreshInterval: 120000, // 2 minutes
revalidateOnFocus: false,
},
);
return {
securityMetrics: data?.data,
isLoading,
error,
mutate,
};
}