This allows you to automatically delete traces that are older than a defined retention period, which helps in managing storage efficiently and maintaining privacy by not retaining data longer than necessary.
Ensure to apply the new Prisma migration to have the ProjectRetentionPolicy table available.
Use the command:
Copy
npx prisma migrate deploy
Enable/Disable Trace Retention:
Navigate to your project’s settings under the “General” tab and locate the “Project Traces” section. Use the toggle switch to enable or disable automatic trace cleanup. Input the number of days you wish to retain traces. Only traces older than this age will be deleted.
Cron Job:
Enable authentication for the cron job API calls by setting the CRON_API_KEY environment variable.
Set up a cron job to periodically call the GET /api/cron/cleanup-traces endpoint with the cron-api-key header value matching the one defined in the CRON_API_KEY environment variable.
Copy
curl -X GET http://localhost:3000/api/cron/cleanup-traces -H "cron-api-key: YOUR_CRON_API_KEY"