punimtag/scripts/cleanup-click-logs.sh
tanyar09 d0dd5c82ea
Some checks failed
CI / skip-ci-check (pull_request) Successful in 8s
CI / lint-and-type-check (pull_request) Successful in 54s
CI / test-backend (pull_request) Has been cancelled
CI / build (pull_request) Has been cancelled
CI / secret-scanning (pull_request) Has been cancelled
CI / dependency-scan (pull_request) Has been cancelled
CI / sast-scan (pull_request) Has been cancelled
CI / workflow-summary (pull_request) Has been cancelled
CI / python-lint (pull_request) Has been cancelled
feat: add click logging for admin frontend
- Add backend click logging utility with file rotation and retention
- Add POST /api/v1/log/click endpoint for logging click events
- Add frontend click logger service with batching and context extraction
- Add global click handler in App.tsx for authenticated users
- Add log cleanup script for old log files
- Update QUICK_LOG_REFERENCE.md with click log documentation

Logs are written to /opt/punimtag/logs/admin-clicks.log with:
- Auto-rotation at 10MB (keeps 5 backups)
- 30-day retention
- Format: timestamp | username | page | element_type | element_id | element_text | context
2026-02-05 17:50:15 +00:00

23 lines
504 B
Bash
Executable File

#!/bin/bash
# Cleanup old click log files (older than retention period)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
LOG_DIR="$PROJECT_ROOT/logs"
if [ ! -d "$LOG_DIR" ]; then
echo "Log directory does not exist: $LOG_DIR"
exit 0
fi
# Run Python cleanup function
cd "$PROJECT_ROOT"
python3 -c "
from backend.utils.click_logger import cleanup_old_logs
cleanup_old_logs()
print('✅ Old click logs cleaned up')
" 2>&1