Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: audit log entitlement (#40242)

Ignacio Dobronicha39b429e0d61
diff --git a/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx b/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
index cd8e2dd3df8..69b50dc194c 100644
--- a/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
+++ b/apps/studio/components/interfaces/Organization/AuditLogs/AuditLogs.tsx
@@ -32,6 +32,7 @@ import {
Button,
WarningIcon,
} from 'ui'
+import { useCheckEntitlements } from 'hooks/misc/useCheckEntitlements'
const logsUpgradeError = 'upgrade to Team or Enterprise Plan to access audit logs.'
@@ -64,6 +65,9 @@ export const AuditLogs = () => {
'notifications'
)
+ const { hasAccess: hasAccessToAuditLogs, isLoading: isLoadingEntitlements } =
+ useCheckEntitlements('security.audit_logs_days')
+
const { data, error, isLoading, isSuccess, isError, isRefetching, refetch } =
useOrganizationAuditLogsQuery(
{
@@ -79,7 +83,8 @@ export const AuditLogs = () => {
},
}
)
- const isLogsNotAvailableBasedOnPlan = isError && error.message.endsWith(logsUpgradeError)
+
+ const isLogsNotAvailableBasedOnPlan = isError && !hasAccessToAuditLogs
const isRangeExceededError = isError && error.message.includes('range exceeded')
const showFilters = !isLoading && !isLogsNotAvailableBasedOnPlan
@@ -127,10 +132,10 @@ export const AuditLogs = () => {
}
})
- // This feature depends on the subscription tier of the user. Free user can view logs up to 1 day
- // in the past. The API limits the logs to maximum of 1 day and 5 minutes so when the page is
+ // This feature depends on the subscription tier of the user.
+ // The API limits the logs to maximum of 62 days and 5 minutes so when the page is
// viewed for more than 5 minutes, the call parameters needs to be updated. This also works with
- // higher tiers (7 days of logs).The user will see a loading shimmer.
+ // higher tiers.The user will see a loading shimmer.
useEffect(() => {
const duration = dayjs(dateRange.from).diff(dayjs(dateRange.to))
const interval = setInterval(() => {
@@ -160,7 +165,7 @@ export const AuditLogs = () => {
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_ className="flex flex-row justify-between gap-3">
<p>
- Upgrade to Team or Enterprise to view up to 28 days of Audit Logs for your
+ Upgrade to Team or Enterprise to view up to 62 days of Audit Logs for your
organization.
</p>
</AlertDescription_Shadcn_>
@@ -261,7 +266,7 @@ export const AuditLogs = () => {
</div>
)}
- {isLoading || isLoadingPermissions ? (
+ {isLoading || isLoadingPermissions || isLoadingEntitlements ? (
<div className="space-y-2">
<ShimmeringLoader />
<ShimmeringLoader className="w-3/4" />