feat: granular file access audit logging (viewed/opened/downloaded)
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Some checks failed
Build and Push Docker Image / build (push) Has been cancelled
Replace single FILE_DOWNLOADED action with three granular actions: - FILE_VIEWED: inline preview loaded in the UI - FILE_OPENED: file opened in a new browser tab - FILE_DOWNLOADED: explicit download button clicked Add 'purpose' field to getDownloadUrl input (preview/open/download). All client callers updated to pass the appropriate purpose. Audit page updated with new filter options and color mappings. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -77,6 +77,8 @@ const ACTION_TYPES = [
|
||||
'ROUND_ARCHIVED',
|
||||
'UPLOAD_FILE',
|
||||
'DELETE_FILE',
|
||||
'FILE_VIEWED',
|
||||
'FILE_OPENED',
|
||||
'FILE_DOWNLOADED',
|
||||
'BULK_CREATE',
|
||||
'BULK_UPDATE_STATUS',
|
||||
@@ -171,6 +173,8 @@ const actionColors: Record<string, 'default' | 'destructive' | 'secondary' | 'ou
|
||||
ROUND_ACTIVATED: 'default',
|
||||
ROUND_CLOSED: 'secondary',
|
||||
ROUND_ARCHIVED: 'secondary',
|
||||
FILE_VIEWED: 'outline',
|
||||
FILE_OPENED: 'outline',
|
||||
FILE_DOWNLOADED: 'outline',
|
||||
ROLE_CHANGED: 'secondary',
|
||||
PASSWORD_SET: 'outline',
|
||||
|
||||
@@ -146,7 +146,7 @@ export default function BulkUploadPage() {
|
||||
const handleViewFile = useCallback(
|
||||
async (bucket: string, objectKey: string) => {
|
||||
try {
|
||||
const { url } = await utils.file.getDownloadUrl.fetch({ bucket, objectKey })
|
||||
const { url } = await utils.file.getDownloadUrl.fetch({ bucket, objectKey, purpose: 'open' as const })
|
||||
window.open(url, '_blank')
|
||||
} catch {
|
||||
toast.error('Failed to open file. It may have been deleted from storage.')
|
||||
|
||||
@@ -46,11 +46,11 @@ const fileTypeLabels: Record<string, string> = {
|
||||
|
||||
function FileActionButtons({ bucket, objectKey, fileName }: { bucket: string; objectKey: string; fileName: string }) {
|
||||
const { data: viewData } = trpc.file.getDownloadUrl.useQuery(
|
||||
{ bucket, objectKey, forDownload: false },
|
||||
{ bucket, objectKey, forDownload: false, purpose: 'open' as const },
|
||||
{ staleTime: 10 * 60 * 1000 }
|
||||
)
|
||||
const { data: dlData } = trpc.file.getDownloadUrl.useQuery(
|
||||
{ bucket, objectKey, forDownload: true, fileName },
|
||||
{ bucket, objectKey, forDownload: true, fileName, purpose: 'download' as const },
|
||||
{ staleTime: 10 * 60 * 1000 }
|
||||
)
|
||||
const viewUrl = typeof viewData === 'string' ? viewData : viewData?.url
|
||||
|
||||
Reference in New Issue
Block a user